Skip to content

Commit

Permalink
core: support null balance in genesis (#28005)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl authored Aug 25, 2023
1 parent 56d2366 commit 6dc9cdf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ func (ga *GenesisAlloc) deriveHash() (common.Hash, error) {
return common.Hash{}, err
}
for addr, account := range *ga {
statedb.AddBalance(addr, account.Balance)
if account.Balance != nil {
statedb.AddBalance(addr, account.Balance)
}
statedb.SetCode(addr, account.Code)
statedb.SetNonce(addr, account.Nonce)
for key, value := range account.Storage {
Expand All @@ -149,7 +151,9 @@ func (ga *GenesisAlloc) flush(db ethdb.Database, triedb *trie.Database, blockhas
return err
}
for addr, account := range *ga {
statedb.AddBalance(addr, account.Balance)
if account.Balance != nil {
statedb.AddBalance(addr, account.Balance)
}
statedb.SetCode(addr, account.Code)
statedb.SetNonce(addr, account.Nonce)
for key, value := range account.Storage {
Expand Down

0 comments on commit 6dc9cdf

Please sign in to comment.