From 6dc9cdf15b2eb2044eb204c78579fcfb5c6e113d Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 25 Aug 2023 15:59:40 +0200 Subject: [PATCH] core: support null balance in genesis (#28005) --- core/genesis.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index 47a8ea8c7..8b5932727 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -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 { @@ -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 {