internal/ethapi: remove double map-clone (#30788)

`ActivePrecompiledContracts()` clones the precompiled contract map, thus
its callsite does not need to clone it
This commit is contained in:
Hyunsoo Shin (Lake) 2024-11-22 16:21:20 +09:00 committed by GitHub
parent a25be32fa9
commit 2cd25fdd23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,7 +21,6 @@ import (
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"maps"
gomath "math" gomath "math"
"math/big" "math/big"
"strings" "strings"
@ -254,7 +253,7 @@ func (api *TxPoolAPI) Inspect() map[string]map[string]map[string]string {
pending, queue := api.b.TxPoolContent() pending, queue := api.b.TxPoolContent()
// Define a formatter to flatten a transaction into a string // Define a formatter to flatten a transaction into a string
var format = func(tx *types.Transaction) string { format := func(tx *types.Transaction) string {
if to := tx.To(); to != nil { if to := tx.To(); to != nil {
return fmt.Sprintf("%s: %v wei + %v gas × %v wei", tx.To().Hex(), tx.Value(), tx.Gas(), tx.GasPrice()) return fmt.Sprintf("%s: %v wei + %v gas × %v wei", tx.To().Hex(), tx.Value(), tx.Gas(), tx.GasPrice())
} }
@ -825,7 +824,7 @@ func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.S
blockOverrides.Apply(&blockCtx) blockOverrides.Apply(&blockCtx)
} }
rules := b.ChainConfig().Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time) rules := b.ChainConfig().Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time)
precompiles := maps.Clone(vm.ActivePrecompiledContracts(rules)) precompiles := vm.ActivePrecompiledContracts(rules)
if err := overrides.Apply(state, precompiles); err != nil { if err := overrides.Apply(state, precompiles); err != nil {
return nil, err return nil, err
} }
@ -1762,11 +1761,11 @@ func (api *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs,
matchTx := sendArgs.ToTransaction(types.LegacyTxType) matchTx := sendArgs.ToTransaction(types.LegacyTxType)
// Before replacing the old transaction, ensure the _new_ transaction fee is reasonable. // Before replacing the old transaction, ensure the _new_ transaction fee is reasonable.
var price = matchTx.GasPrice() price := matchTx.GasPrice()
if gasPrice != nil { if gasPrice != nil {
price = gasPrice.ToInt() price = gasPrice.ToInt()
} }
var gas = matchTx.Gas() gas := matchTx.Gas()
if gasLimit != nil { if gasLimit != nil {
gas = uint64(*gasLimit) gas = uint64(*gasLimit)
} }