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

Initialize the DB with the GenesisState if the node is bootstrapping for the first time #1124

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

charithabandi
Copy link
Contributor

No description provided.

Copy link
Member

@jchappelow jchappelow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one thing I think should change, otherwise just some thought.

Comment on lines +98 to +102
binary.Write(hasher, binary.BigEndian, gc.MaxBlockSize)
binary.Write(hasher, binary.BigEndian, gc.JoinExpiry)
binary.Write(hasher, binary.BigEndian, gc.VoteExpiry)
binary.Write(hasher, binary.BigEndian, gc.DisabledGasCosts)
binary.Write(hasher, binary.BigEndian, gc.MaxVotesPerTx)
Copy link
Member

@jchappelow jchappelow Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One point about these, but not necessarily needing change: these are almost too convenient in that we can casually change the type of these and this code will not break, but the result will change, which is a consensus breaker. It's a lot more cumbersome to use the functions like binary.BigEndian.Append/PutUint64 etc, so let's go ahead with what you have now since we will certainly be changing gc a lot before release, but at some point I think we should harden this code.

func (ce *ConsensusEngine) doBlockSync(ctx context.Context) error {
if ce.role.Load() == types.RoleLeader {
if len(ce.validators.GetValidators()) == 1 {
// TODO: which validator set we should use here? whatever we have in the state?
// what if the current validators are not the same as the ones in the state?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I understand the difference between "current validators" and "the ones in the state".

@@ -313,6 +316,8 @@ func New(cfg *Config) *ConsensusEngine {
return ce
}

var initialHeight int64 = 0 // TODO: get it from genesis?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point. Yeah we should add this to the genesis config struct. Can do later though.

@jchappelow jchappelow merged commit afe9326 into main Dec 6, 2024
2 checks passed
@jchappelow jchappelow deleted the genesis-state branch December 6, 2024 21:34
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

Successfully merging this pull request may close these issues.

2 participants