From 2c40021f710ebaf445654709d8f696564f70cf25 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Fri, 14 Nov 2025 18:58:18 +0800 Subject: [PATCH] core/state, internal/ethapi: GetAccountInfo handle error properly, close XFN-79 (#1663) --- core/state/statedb.go | 8 ++++++-- internal/ethapi/api.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 790963c19d..d8869a2d4d 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -314,14 +314,18 @@ func (s *StateDB) GetAccountInfo(addr common.Address) *AccountInfo { stateObject := s.getStateObject(addr) if stateObject == nil { - result.Balance = common.Big0 + result.Balance = new(big.Int) return &result } if stateObject.code != nil { result.CodeSize = len(stateObject.code) } else { - result.CodeSize, _ = s.db.ContractCodeSize(stateObject.addrHash, common.BytesToHash(stateObject.CodeHash())) + size, err := s.db.ContractCodeSize(stateObject.addrHash, common.BytesToHash(stateObject.CodeHash())) + if err != nil { + s.setError(err) + } + result.CodeSize = size } result.Nonce = stateObject.Nonce() result.Balance = stateObject.Balance() diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index e76ca05054..f4a66e1642 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -509,7 +509,7 @@ func (api *BlockChainAPI) GetAccountInfo(ctx context.Context, address common.Add "nonce": info.Nonce, "storageHash": info.StorageHash, } - return result, nil + return result, state.Error() } // GetStorageAt returns the storage from the state at the given address, key and