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

Added writing of genesis.Alloc on bootstrap #15

Merged

Conversation

maoueh
Copy link

@maoueh maoueh commented Jul 27, 2023

No description provided.

@@ -406,6 +406,34 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
}
}

if bc.logger != nil && bc.CurrentBlock().Number.Uint64() == 0 {
Copy link
Owner

Choose a reason for hiding this comment

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

Hm, so we want to only emit this event on the first sync? Asking because you have the currentBlock == 0 check

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure we have the state that tells us if it's a first sync or not. I would like to have OnGenesisBlock called only once indeed!

@maoueh maoueh force-pushed the sf/feature/genesis-alloc-on-init branch from 24e52d7 to 0856f27 Compare August 4, 2023 15:14
@maoueh
Copy link
Author

maoueh commented Aug 4, 2023

Updated with the fact that genesis state spec is already written, only modified geth init now to also write the state spec if not present in the database

core/genesis.go Outdated
alloc = genesis.Alloc
} else {
return errors.New("not found")
return nil, true, err
Copy link
Owner

Choose a reason for hiding this comment

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

Do we really need found? a nil alloc could mean not found

Copy link
Author

Choose a reason for hiding this comment

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

Yes we can do that.

core/genesis.go Outdated
}

if !found {
return nil
Copy link
Owner

Choose a reason for hiding this comment

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

We used to return errors.New("not found") in this case. What's the reason for this behavior change?

Copy link
Author

Choose a reason for hiding this comment

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

That's was a mistake indeed, I'll revert this

@maoueh maoueh changed the title Added writing of genesis.Alloc on bootstrap, geth init also fills the missing value Added writing of genesis.Alloc on bootstrap Aug 23, 2023
Copy link
Owner

@s1na s1na left a comment

Choose a reason for hiding this comment

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

LGTM

@s1na s1na merged commit 216a4b0 into s1na:extended-tracer Aug 30, 2023
@maoueh maoueh deleted the sf/feature/genesis-alloc-on-init branch September 1, 2023 13:06
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