core: ensure a broken trie invariant crashes genesis creation (#22780)

* Ensure state could be created in ToBlock

* Fix rebase errors

* use a panic instead
This commit is contained in:
Guillaume Ballet 2021-05-11 17:12:10 +02:00 committed by GitHub
parent f34f749e81
commit a2c456a526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -259,7 +259,10 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
if db == nil { if db == nil {
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
} }
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db), nil) statedb, err := state.New(common.Hash{}, state.NewDatabase(db), nil)
if err != nil {
panic(err)
}
for addr, account := range g.Alloc { for addr, account := range g.Alloc {
statedb.AddBalance(addr, account.Balance) statedb.AddBalance(addr, account.Balance)
statedb.SetCode(addr, account.Code) statedb.SetCode(addr, account.Code)