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

cmd/{geth,utils}: read genesis block from db in chain import #30869

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gballet
Copy link
Member

@gballet gballet commented Dec 6, 2024

I discovered that importing blocks from a non "official" chain is broken.

This is because the import function will call MakeGenesis, which doesn't try to load any block from the db, and falls back on the hardcoded ones. If none of these hardcoded genesis blocks work, it YOLOs it by returning a nil genesis. This doesn't go well: at some point, the genesis is filled with default values, whose hash never matches that of the genesis block that was stored with geth init.

Somehow, the genesis block should be passed to MakeChain. So this PR introduces MakeChainWithGenesisBlockAndChain so that this info can be recovered from the DB.

I'm not a big fan of it, and I think we should remove MakeChain altogether. But I'm putting this out there to gather input on the approach, which is perfectible imo.

Ultimately, this is coming down to SetupGenesisWithOverrides doing too much, that should be refactored. Happy to have the discussion here.

@rjl493456442 rjl493456442 self-assigned this Dec 7, 2024
@holiman
Copy link
Contributor

holiman commented Dec 9, 2024

Do you have an example genesis + chain to repro / test with?

@gballet
Copy link
Member Author

gballet commented Dec 11, 2024

Do you have an example genesis + chain to repro / test with?

same as in this issue #30878

@gballet
Copy link
Member Author

gballet commented Dec 13, 2024

Probably fixed by #30907, but let's confirm when it's merged.

@MariusVanDerWijden
Copy link
Member

@gballet could you confirm that this was fixed by #30907 ?

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.

4 participants