-
Notifications
You must be signed in to change notification settings - Fork 12
Add a new field 'next validator set hash' in the header #153
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
Conversation
373487a
to
bd50f18
Compare
types/src/header.rs
Outdated
@@ -50,6 +51,8 @@ pub struct Header { | |||
transactions_root: H256, | |||
/// State root. | |||
state_root: H256, | |||
/// Validator set root. Note that this is for the next block. | |||
validator_set_root: H256, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you choose the term "root"?
Is the validator set is stored in a tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding the "next_" prefix to the field name?
When I first read the "validator_set_root", it seems that it is the current block's validator set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then I'll rename it as next_validator_set_hash
after your overall review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's squash the copyright commit to the parent commit.
It is hard to know the commit actually update the needed files.
@@ -21,7 +21,7 @@ use crate::consensus::CodeChainEngine; | |||
use crate::error::Error; | |||
use ctypes::{CommonParams, Header}; | |||
|
|||
/// A canonial verifier -- this does full verification. | |||
/// A canonical verifier -- this does full verification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a new commit for the typo.
A commit should change code only for one purpose.
|
||
// It will be hashed in the header. | ||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct CompactValidatorSet(pub Vec<(Public, u64)>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this structure?
Why now implementing hash function instead of create_compact_validator_set for NextValidator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested to Junha to add this struct in the "types/src" directory.
If someone wants to know what is the "validator_set_root" in the header, reading this struct will help them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it will be also passed to the light client for verification. Light client only needs that compact data of the validator set. @sgkim126
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check how tests code in Foundry are using random?
core/src/block.rs
Outdated
@@ -232,6 +233,12 @@ impl<'x> OpenBlock<'x> { | |||
e | |||
})?; | |||
self.block.header.set_state_root(state_root); | |||
|
|||
// Note : Does state always hold validator set? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this to "FIXME" like the below description?
NextValidators do not exist in the static validator set.
This code does not work expected when using the static validator set.
Since we will change Foundry to use only the dynamic validator set, we don't add code that handles the static validator set.
After changing Foundry to use only the dynamic validator set, we should remove this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it doesn't cause an error even for now, since we use unwrap_or_default()
in load_from_state()
.
So just simple comment will be ok.
NextValidators
entry doesn't exit in the state during static-validator-set-mode.
It doesn't cause a direct error since we useunwrap_or_default()
here, but should be aware of such problem
Remove this comment after we completely omit static-validator-set-mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@majecty updated.
8d04728
to
cabe823
Compare
core/src/block.rs
Outdated
@@ -232,6 +233,16 @@ impl<'x> OpenBlock<'x> { | |||
e | |||
})?; | |||
self.block.header.set_state_root(state_root); | |||
|
|||
/* | |||
FIXME: NextValidators entry doesn't exit in the state during static-validator-set-mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit- > exist?
Please review English grammar before updating PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@majecty typo fixed
@sgkim126 I want to merge this PR. |
I will add unit/e2e tests after #130 and reviews