Skip to content

Commit

Permalink
core: ensure a broken trie invariant crashes genesis creation (ethere…
Browse files Browse the repository at this point in the history
…um#22780)

* Ensure state could be created in ToBlock

* Fix rebase errors

* use a panic instead
  • Loading branch information
gballet authored May 11, 2021
1 parent f34f749 commit a2c456a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
if db == nil {
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 {
statedb.AddBalance(addr, account.Balance)
statedb.SetCode(addr, account.Code)
Expand Down

0 comments on commit a2c456a

Please sign in to comment.