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

Support storing voting snapshots in the database #63

Open
jwasinger opened this issue Mar 13, 2019 · 12 comments
Open

Support storing voting snapshots in the database #63

jwasinger opened this issue Mar 13, 2019 · 12 comments

Comments

@jwasinger
Copy link
Member

Otherwise, we have to trace back through the chain and rebuild the voting snapshot on startup (which can be very slow depending on where we are in the epoch).

@jleni
Copy link
Member

jleni commented Mar 13, 2019

I am not sure about the context of what you've been discussing.
Are you referring to an internal class for Snapshots matching Geth snapshots?

To match the types in the API, I have to create this:
https://github.com/goerli/parity-goerli/pull/58/files#diff-c08ee81f30b2cc1b9b605a93a4267708R47

But having this tracked internally instead would be useful

@jwasinger
Copy link
Member Author

jwasinger commented Mar 13, 2019

I'm referring to the way voting snapshot state is constructed. Right now, when the client starts up we must traverse the chain backwards to the last epoch in order rebuild the voting snapshot state:

https://github.com/goerli/parity-goerli/blob/master/ethcore/src/engines/clique/mod.rs#L266-L299

Geth stores voting snapshots on disk to avoid this. We can do the same.

@jleni
Copy link
Member

jleni commented Mar 13, 2019

yes, this is a problem for the REST API, because I need to access them by index or hash

@jleni
Copy link
Member

jleni commented Mar 13, 2019

if this is refactored, it would be amazing if:

  • storage allows for fast access via index or hash
  • the data structures match Geth.

Otherwise, searching/wrapping/converting on each REST call will be inefficient.
We can get the types/tests from that file in the PR that I linked earlier.

@jwasinger
Copy link
Member Author

The voting snapshot is only restored during client startup so there should be no overhead for the RPC API AFAIK

@jwasinger
Copy link
Member Author

I haven't had time to review the RPC API changes yet so I could be wrong.

@jleni
Copy link
Member

jleni commented Mar 13, 2019

Yes, I have just started. I will be working on this in the next few days. It is much better now that things got merged and are a bit more stable.

I assume then that snapshots are accessible here:

block_state_by_hash: RwLock<LruCache<H256, CliqueBlockState>>,

I may need a way to get them by index. I need to review the code a bit more.

@jwasinger
Copy link
Member Author

Cool. Looking forward to seeing what you come up with :)

@jwasinger
Copy link
Member Author

My inclination is that this issue is nice to have but the implementation should be merged separately from the main clique PR in order to avoid more review overhead from the Parity side.

@jleni
Copy link
Member

jleni commented Mar 13, 2019

would it be possible to make this public?

fn state(&self, header: &Header) -> Result<CliqueBlockState, Error> {

@jwasinger
Copy link
Member Author

Yes. I think so.

@jwasinger
Copy link
Member Author

Hey @jleni looks like this might be easy to add via the "block metadata feature" (see the related comment on the PR above). I'm going to look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants