cmd/{geth,utils}: read genesis block from db in chain import #30869
+11
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 anil
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 withgeth init
.Somehow, the genesis block should be passed to
MakeChain
. So this PR introducesMakeChainWithGenesisBlockAndChain
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.