-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
mismatch between genesis state PUT and GET operations (dumpgenesis failure) #26746
Comments
Ah, so this is a bit weird. We write the geneiss spec here: https://github.com/ethereum/go-ethereum/blob/master/core/genesis.go#L169 root, err := statedb.Commit(false)
if err != nil {
return err
}
// Commit newly generated states into disk if it's not empty.
if root != types.EmptyRootHash {
if err := triedb.Commit(root, true); err != nil {
return err
}
}
// Marshal the genesis state specification and persist.
blob, err := json.Marshal(ga)
if err != nil {
return err
}
rawdb.WriteGenesisStateSpec(db, root, blob) That is, the we use the But func ReadGenesis(db ethdb.Database) (*Genesis, error) {
var genesis Genesis
stored := rawdb.ReadCanonicalHash(db, 0)
if (stored == common.Hash{}) {
return nil, fmt.Errorf("invalid genesis hash in database: %x", stored)
}
blob := rawdb.ReadGenesisStateSpec(db, stored) And, even worse, in blockchain, under certain conditions, we try to look up the genesis state, by blockhash, not if beyondRoot || newHeadBlock.NumberU64() == 0 {
if newHeadBlock.NumberU64() == 0 {
// Recommit the genesis state into disk in case the rewinding destination
// is genesis block and the relevant state is gone. In the future this
// rewinding destination can be the earliest block stored in the chain
// if the historical chain pruning is enabled. In that case the logic
// needs to be improved here.
if !bc.HasState(bc.genesisBlock.Root()) {
if err := CommitGenesisState(bc.db, bc.triedb, bc.genesisBlock.Hash()); err != nil {
log.Crit("Failed to commit genesis state", "err", err)
} |
We need to decide what key to use (blockhash or root hash), and be consistent about it. |
Wanted to check/repro #21881 , and found that something is wonky with custom genesis and/or custom datadirs:
The text was updated successfully, but these errors were encountered: