Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only checkpoint required blocks for voting contracts #65

Open
ethanfrey opened this issue Feb 2, 2022 · 0 comments
Open

Only checkpoint required blocks for voting contracts #65

ethanfrey opened this issue Feb 2, 2022 · 0 comments

Comments

@ethanfrey
Copy link
Contributor

In SnapshotMap, we provide:

pub enum Strategy {
    EveryBlock,
    Never,
    /// Only writes for linked blocks - does a few more reads to save some writes.
    /// Probably uses more gas, but less total disk usage.
    ///
    /// Note that you need a trusted source (eg. own contract) to set/remove checkpoints.
    /// Useful when the checkpoint setting happens in the same contract as the snapshotting.
    Selected,
}

For the generic design, it was very unclear how to handle auth, so we just used EveryBlock, which is always correct even if less efficient.

As we have many voting contracts and sets in tgrade, it would make sense to looking into optimizing this. What do we need to use selected?

There are two functions add_checkpoint and remove_checkpoint which need to be exposed with some auth control. The voting contract should always call add_checkpoint at the current height when opening a vote. The voting_contract may also call remove_checkpoint when executing/closing a proposal... if no other proposals are on the same height (some sort of rc).

As we get a large space savings even if we never cleanup checkpoints (and even more if we do), we can look at registering the voting contract on the respective groups somehow on init. And later just all AddCheckpoint on proposal creation. That would be a good first step and verifying everything works (fuzzing it?) in odd conditions (multiple proposals on block, multiple closing in one transaction, etc)

@ethanfrey ethanfrey changed the title Only snapshot needed blocks for voting contracts Only checkpoint required blocks for voting contracts Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant