eth/tracers, internal/ethapi: remove unnecessary map pointer in state override #30094 (#1483)

This commit is contained in:
Daniel Liu 2025-09-13 10:41:51 +08:00 committed by GitHub
parent a00d95bf1a
commit ea239d5b15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View file

@ -740,9 +740,9 @@ func newAccounts(n int) (accounts []Account) {
return accounts
}
func newRPCBalance(balance *big.Int) **hexutil.Big {
func newRPCBalance(balance *big.Int) *hexutil.Big {
rpcBalance := (*hexutil.Big)(balance)
return &rpcBalance
return rpcBalance
}
func newRPCBytes(bytes []byte) *hexutil.Bytes {
@ -750,7 +750,7 @@ func newRPCBytes(bytes []byte) *hexutil.Bytes {
return &rpcBytes
}
func newStates(keys []common.Hash, vals []common.Hash) *map[common.Hash]common.Hash {
func newStates(keys []common.Hash, vals []common.Hash) map[common.Hash]common.Hash {
if len(keys) != len(vals) {
panic("invalid input")
}
@ -758,7 +758,7 @@ func newStates(keys []common.Hash, vals []common.Hash) *map[common.Hash]common.H
for i := 0; i < len(keys); i++ {
m[keys[i]] = vals[i]
}
return &m
return m
}
func TestTraceChain(t *testing.T) {

View file

@ -532,11 +532,11 @@ func (s *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.
// if statDiff is set, all diff will be applied first and then execute the call
// message.
type OverrideAccount struct {
Nonce *hexutil.Uint64 `json:"nonce"`
Code *hexutil.Bytes `json:"code"`
Balance **hexutil.Big `json:"balance"`
State *map[common.Hash]common.Hash `json:"state"`
StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
Nonce *hexutil.Uint64 `json:"nonce"`
Code *hexutil.Bytes `json:"code"`
Balance *hexutil.Big `json:"balance"`
State map[common.Hash]common.Hash `json:"state"`
StateDiff map[common.Hash]common.Hash `json:"stateDiff"`
}
// StateOverride is the collection of overridden accounts.
@ -558,18 +558,18 @@ func (diff *StateOverride) Apply(statedb *state.StateDB) error {
}
// Override account balance.
if account.Balance != nil {
statedb.SetBalance(addr, (*big.Int)(*account.Balance), tracing.BalanceChangeUnspecified)
statedb.SetBalance(addr, (*big.Int)(account.Balance), tracing.BalanceChangeUnspecified)
}
if account.State != nil && account.StateDiff != nil {
return fmt.Errorf("account %s has both 'state' and 'stateDiff'", addr.Hex())
}
// Replace entire state if caller requires.
if account.State != nil {
statedb.SetStorage(addr, *account.State)
statedb.SetStorage(addr, account.State)
}
// Apply state diff into specified accounts.
if account.StateDiff != nil {
for key, value := range *account.StateDiff {
for key, value := range account.StateDiff {
statedb.SetState(addr, key, value)
}
}