Skip to content

eth/gasestimator: check ErrGasLimitTooHigh conditions #32268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a7efdcb
p2p/rlpx: optimize XOR operation using bitutil.XORBytes (#32217)
reallesee Jul 22, 2025
3b67602
eth/gasestimator: fix potential overflow (#32255)
gzeoneth Jul 23, 2025
16117eb
triedb/pathdb: fix an deadlock in history indexer (#32260)
jsvisa Jul 23, 2025
b369a85
eth/protocols/snap: add healing and syncing metrics (#32258)
MariusVanDerWijden Jul 24, 2025
29eebb5
core: replace the empty fmt.Errorf with errors.New (#32274)
nthumann Jul 28, 2025
0fe1bc0
eth/catalyst: fix error message in ExecuteStatelessPayloadV4 (#32269)
Galoretka Jul 28, 2025
a7aed7b
cmd, eth, internal: introduce debug_sync (#32177)
rjl493456442 Jul 28, 2025
32d537c
all: replace fmt.Errorf with errors.New (#32286)
ericxtheodore Jul 28, 2025
b64a500
downloader: fix typos, grammar and formatting (#32288)
tomasandroil Jul 28, 2025
eb7aef4
ethclient/simulated: Fix flaky rollback test (#32280)
kashitaka Jul 28, 2025
a56558d
core/state: preallocate capacity for logs list (#32291)
mask-pp Jul 29, 2025
d14d4d2
core/state: improve PrettyPrint function (#32293)
ericxtheodore Jul 30, 2025
2d95ba7
core/types: expose sigHash as Hash for SetCodeAuthorization (#32298)
dkatzan Jul 31, 2025
0814d99
common/hexutil: replace customized bit sizer with bit.Uintsize (#32304)
cuiweixie Jul 31, 2025
4d9d728
accounts/abi: precompile regex (#32301)
cuiweixie Jul 31, 2025
d4a3bf1
cmd/devp2p/internal/v4test: add test for ENRRequest (#32303)
fjl Jul 31, 2025
23da91f
trie: reduce the memory allocation in trie hashing (#31902)
rjl493456442 Aug 1, 2025
17d65e9
core/vm: add configurable jumpdest analysis cache (#32143)
lmittmann Aug 1, 2025
9c58810
eth: fix typos and outdated comments (#32324)
tomasandroil Aug 1, 2025
4d1264f
Allow ErrGasLimitTooHigh errors when executing transactions for gas l…
mininny Jul 24, 2025
db12f63
Use params.MaxTxGas for RPCGasCap
mininny Jul 28, 2025
a7857cd
Cap maximum gas allowance to EIP-7825 in gas estimates only for osaka
mininny Jul 31, 2025
5ef01bb
core/vm, internal/ethapi: fix lint
rjl493456442 Aug 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion accounts/abi/abigen/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import (
"github.com/ethereum/go-ethereum/log"
)

var (
intRegex = regexp.MustCompile(`(u)?int([0-9]*)`)
)

func isKeyWord(arg string) bool {
switch arg {
case "break":
Expand Down Expand Up @@ -299,7 +303,7 @@ func bindBasicType(kind abi.Type) string {
case abi.AddressTy:
return "common.Address"
case abi.IntTy, abi.UintTy:
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(kind.String())
parts := intRegex.FindStringSubmatch(kind.String())
switch parts[2] {
case "8", "16", "32", "64":
return fmt.Sprintf("%sint%s", parts[1], parts[2])
Expand Down
2 changes: 1 addition & 1 deletion cmd/devp2p/internal/ethtest/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (c *Conn) Write(proto Proto, code uint64, msg any) error {
return err
}

var errDisc error = fmt.Errorf("disconnect")
var errDisc error = errors.New("disconnect")

// ReadEth reads an Eth sub-protocol wire message.
func (c *Conn) ReadEth() (any, error) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/devp2p/internal/ethtest/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package ethtest
import (
"context"
"crypto/rand"
"errors"
"fmt"
"reflect"
"sync"
Expand Down Expand Up @@ -1092,7 +1093,7 @@ func (s *Suite) testBadBlobTx(t *utesting.T, tx *types.Transaction, badTx *types
return
}
if !readUntilDisconnect(conn) {
errc <- fmt.Errorf("expected bad peer to be disconnected")
errc <- errors.New("expected bad peer to be disconnected")
return
}
stage3.Done()
Expand Down Expand Up @@ -1139,7 +1140,7 @@ func (s *Suite) testBadBlobTx(t *utesting.T, tx *types.Transaction, badTx *types
}

if req.GetPooledTransactionsRequest[0] != tx.Hash() {
errc <- fmt.Errorf("requested unknown tx hash")
errc <- errors.New("requested unknown tx hash")
return
}

Expand All @@ -1149,7 +1150,7 @@ func (s *Suite) testBadBlobTx(t *utesting.T, tx *types.Transaction, badTx *types
return
}
if readUntilDisconnect(conn) {
errc <- fmt.Errorf("unexpected disconnect")
errc <- errors.New("unexpected disconnect")
return
}
close(errc)
Expand Down
32 changes: 32 additions & 0 deletions cmd/devp2p/internal/v4test/discv4tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/utesting"
"github.com/ethereum/go-ethereum/p2p/discover/v4wire"
"github.com/ethereum/go-ethereum/p2p/enode"
)

const (
Expand Down Expand Up @@ -501,6 +502,36 @@ func FindnodeAmplificationWrongIP(t *utesting.T) {
}
}

func ENRRequest(t *utesting.T) {
t.Log(`This test sends an ENRRequest packet and expects a response containing a valid ENR.`)

te := newTestEnv(Remote, Listen1, Listen2)
defer te.close()
bond(t, te)

req := &v4wire.ENRRequest{Expiration: futureExpiration()}
hash := te.send(te.l1, req)

response, _, err := te.read(te.l1)
if err != nil {
t.Fatal("read error:", err)
}
enrResp, ok := response.(*v4wire.ENRResponse)
if !ok {
t.Fatalf("expected ENRResponse packet, got %T", response)
}
if !bytes.Equal(enrResp.ReplyTok, hash) {
t.Errorf("wrong hash in response packet: got %x, want %x", enrResp.ReplyTok, hash)
}
node, err := enode.New(enode.ValidSchemes, &enrResp.Record)
if err != nil {
t.Errorf("invalid record in response: %v", err)
}
if node.ID() != te.remote.ID() {
t.Errorf("wrong node ID in response: got %v, want %v", node.ID(), te.remote.ID())
}
}

var AllTests = []utesting.Test{
{Name: "Ping/Basic", Fn: BasicPing},
{Name: "Ping/WrongTo", Fn: PingWrongTo},
Expand All @@ -510,6 +541,7 @@ var AllTests = []utesting.Test{
{Name: "Ping/PastExpiration", Fn: PingPastExpiration},
{Name: "Ping/WrongPacketType", Fn: WrongPacketType},
{Name: "Ping/BondThenPingWithWrongFrom", Fn: BondThenPingWithWrongFrom},
{Name: "ENRRequest", Fn: ENRRequest},
{Name: "Findnode/WithoutEndpointProof", Fn: FindnodeWithoutEndpointProof},
{Name: "Findnode/BasicFindnode", Fn: BasicFindnode},
{Name: "Findnode/UnsolicitedNeighbors", Fn: UnsolicitedNeighbors},
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ func downloadEra(ctx *cli.Context) error {
case ctx.IsSet(utils.SepoliaFlag.Name):
network = "sepolia"
default:
return fmt.Errorf("unsupported network, no known era1 checksums")
return errors.New("unsupported network, no known era1 checksums")
}
}

Expand Down
6 changes: 4 additions & 2 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,16 @@ func makeFullNode(ctx *cli.Context) *node.Node {
if cfg.Ethstats.URL != "" {
utils.RegisterEthStatsService(stack, backend, cfg.Ethstats.URL)
}
// Configure full-sync tester service if requested
// Configure synchronization override service
var synctarget common.Hash
if ctx.IsSet(utils.SyncTargetFlag.Name) {
hex := hexutil.MustDecode(ctx.String(utils.SyncTargetFlag.Name))
if len(hex) != common.HashLength {
utils.Fatalf("invalid sync target length: have %d, want %d", len(hex), common.HashLength)
}
utils.RegisterFullSyncTester(stack, eth, common.BytesToHash(hex), ctx.Bool(utils.ExitWhenSyncedFlag.Name))
synctarget = common.BytesToHash(hex)
}
utils.RegisterSyncOverrideService(stack, eth, synctarget, ctx.Bool(utils.ExitWhenSyncedFlag.Name))

if ctx.IsSet(utils.DeveloperFlag.Name) {
// Start dev mode.
Expand Down
14 changes: 9 additions & 5 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/catalyst"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/eth/gasprice"
"github.com/ethereum/go-ethereum/eth/syncer"
"github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb/remotedb"
Expand Down Expand Up @@ -1997,10 +1997,14 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
return filterSystem
}

// RegisterFullSyncTester adds the full-sync tester service into node.
func RegisterFullSyncTester(stack *node.Node, eth *eth.Ethereum, target common.Hash, exitWhenSynced bool) {
catalyst.RegisterFullSyncTester(stack, eth, target, exitWhenSynced)
log.Info("Registered full-sync tester", "hash", target, "exitWhenSynced", exitWhenSynced)
// RegisterSyncOverrideService adds the synchronization override service into node.
func RegisterSyncOverrideService(stack *node.Node, eth *eth.Ethereum, target common.Hash, exitWhenSynced bool) {
if target != (common.Hash{}) {
log.Info("Registered sync override service", "hash", target, "exitWhenSynced", exitWhenSynced)
} else {
log.Info("Registered sync override service")
}
syncer.Register(stack, eth, target, exitWhenSynced)
}

// SetupMetrics configures the metrics system.
Expand Down
6 changes: 3 additions & 3 deletions cmd/workload/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package main

import (
"embed"
"fmt"
"errors"
"io/fs"
"os"

Expand Down Expand Up @@ -97,7 +97,7 @@ type testConfig struct {
traceTestFile string
}

var errPrunedHistory = fmt.Errorf("attempt to access pruned history")
var errPrunedHistory = errors.New("attempt to access pruned history")

// validateHistoryPruneErr checks whether the given error is caused by access
// to history before the pruning threshold block (it is an rpc.Error with code 4444).
Expand All @@ -109,7 +109,7 @@ func validateHistoryPruneErr(err error, blockNum uint64, historyPruneBlock *uint
if err != nil {
if rpcErr, ok := err.(rpc.Error); ok && rpcErr.ErrorCode() == 4444 {
if historyPruneBlock != nil && blockNum > *historyPruneBlock {
return fmt.Errorf("pruned history error returned after pruning threshold")
return errors.New("pruned history error returned after pruning threshold")
}
return errPrunedHistory
}
Expand Down
5 changes: 2 additions & 3 deletions common/hexutil/hexutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ import (
"encoding/hex"
"fmt"
"math/big"
"math/bits"
"strconv"
)

const uintBits = 32 << (uint64(^uint(0)) >> 63)

// Errors
var (
ErrEmptyString = &decError{"empty hex string"}
Expand All @@ -48,7 +47,7 @@ var (
ErrEmptyNumber = &decError{"hex string \"0x\""}
ErrLeadingZero = &decError{"hex number with leading zero digits"}
ErrUint64Range = &decError{"hex number > 64 bits"}
ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", uintBits)}
ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", bits.UintSize)}
ErrBig256Range = &decError{"hex number > 256 bits"}
)

Expand Down
3 changes: 2 additions & 1 deletion common/hexutil/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/json"
"errors"
"math/big"
"math/bits"
"testing"

"github.com/holiman/uint256"
Expand Down Expand Up @@ -384,7 +385,7 @@ func TestUnmarshalUint(t *testing.T) {
for _, test := range unmarshalUintTests {
var v Uint
err := json.Unmarshal([]byte(test.input), &v)
if uintBits == 32 && test.wantErr32bit != nil {
if bits.UintSize == 32 && test.wantErr32bit != nil {
checkError(t, test.input, err, test.wantErr32bit)
continue
}
Expand Down
8 changes: 4 additions & 4 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()]
if predefinedPoint == nil || freezerTail != predefinedPoint.BlockNumber {
log.Error("Chain history database is pruned with unknown configuration", "tail", freezerTail)
return fmt.Errorf("unexpected database tail")
return errors.New("unexpected database tail")
}
bc.historyPrunePoint.Store(predefinedPoint)
return nil
Expand All @@ -695,15 +695,15 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
// action to happen. So just tell them how to do it.
log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is not pruned.", bc.cfg.ChainHistoryMode.String()))
log.Error(fmt.Sprintf("Run 'geth prune-history' to prune pre-merge history."))
return fmt.Errorf("history pruning requested via configuration")
return errors.New("history pruning requested via configuration")
}
predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()]
if predefinedPoint == nil {
log.Error("Chain history pruning is not supported for this network", "genesis", bc.genesisBlock.Hash())
return fmt.Errorf("history pruning requested for unknown network")
return errors.New("history pruning requested for unknown network")
} else if freezerTail > 0 && freezerTail != predefinedPoint.BlockNumber {
log.Error("Chain history database is pruned to unknown block", "tail", freezerTail)
return fmt.Errorf("unexpected database tail")
return errors.New("unexpected database tail")
}
bc.historyPrunePoint.Store(predefinedPoint)
return nil
Expand Down
5 changes: 1 addition & 4 deletions core/state/access_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ func (al *accessList) Equal(other *accessList) bool {
// PrettyPrint prints the contents of the access list in a human-readable form
func (al *accessList) PrettyPrint() string {
out := new(strings.Builder)
var sortedAddrs []common.Address
for addr := range al.addresses {
sortedAddrs = append(sortedAddrs, addr)
}
sortedAddrs := slices.Collect(maps.Keys(al.addresses))
slices.SortFunc(sortedAddrs, common.Address.Cmp)
for _, addr := range sortedAddrs {
idx := al.addresses[addr]
Expand Down
2 changes: 1 addition & 1 deletion core/state/snapshot/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func iterateJournal(db ethdb.KeyValueReader, callback journalCallback) error {
}
if len(destructs) > 0 {
log.Warn("Incompatible legacy journal detected", "version", journalV0)
return fmt.Errorf("incompatible legacy journal detected")
return errors.New("incompatible legacy journal detected")
}
}
if err := r.Decode(&accounts); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (s *StateDB) GetLogs(hash common.Hash, blockNumber uint64, blockHash common
}

func (s *StateDB) Logs() []*types.Log {
var logs []*types.Log
logs := make([]*types.Log, 0, s.logSize)
for _, lgs := range s.logs {
logs = append(logs, lgs...)
}
Expand Down
13 changes: 4 additions & 9 deletions core/state/transient_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package state

import (
"fmt"
"maps"
"slices"
"strings"

Expand Down Expand Up @@ -70,19 +71,13 @@ func (t transientStorage) Copy() transientStorage {
// PrettyPrint prints the contents of the access list in a human-readable form
func (t transientStorage) PrettyPrint() string {
out := new(strings.Builder)
var sortedAddrs []common.Address
for addr := range t {
sortedAddrs = append(sortedAddrs, addr)
slices.SortFunc(sortedAddrs, common.Address.Cmp)
}
sortedAddrs := slices.Collect(maps.Keys(t))
slices.SortFunc(sortedAddrs, common.Address.Cmp)

for _, addr := range sortedAddrs {
fmt.Fprintf(out, "%#x:", addr)
var sortedKeys []common.Hash
storage := t[addr]
for key := range storage {
sortedKeys = append(sortedKeys, key)
}
sortedKeys := slices.Collect(maps.Keys(storage))
slices.SortFunc(sortedKeys, common.Hash.Cmp)
for _, key := range sortedKeys {
fmt.Fprintf(out, " %X : %X\n", key, storage[key])
Expand Down
6 changes: 3 additions & 3 deletions core/tracing/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package tracing

import (
"fmt"
"errors"
"math/big"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -39,14 +39,14 @@ type entry interface {
// WrapWithJournal wraps the given tracer with a journaling layer.
func WrapWithJournal(hooks *Hooks) (*Hooks, error) {
if hooks == nil {
return nil, fmt.Errorf("wrapping nil tracer")
return nil, errors.New("wrapping nil tracer")
}
// No state change to journal, return the wrapped hooks as is
if hooks.OnBalanceChange == nil && hooks.OnNonceChange == nil && hooks.OnNonceChangeV2 == nil && hooks.OnCodeChange == nil && hooks.OnStorageChange == nil {
return hooks, nil
}
if hooks.OnNonceChange != nil && hooks.OnNonceChangeV2 != nil {
return nil, fmt.Errorf("cannot have both OnNonceChange and OnNonceChangeV2")
return nil, errors.New("cannot have both OnNonceChange and OnNonceChangeV2")
}

// Create a new Hooks instance and copy all hooks
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
}
if tx.Type() == types.SetCodeTxType {
if len(tx.SetCodeAuthorizations()) == 0 {
return fmt.Errorf("set code tx must have at least one authorization tuple")
return errors.New("set code tx must have at least one authorization tuple")
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion core/types/bal/bal_encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (e *AccountAccess) validate() error {
// Convert code change
if len(e.Code) == 1 {
if len(e.Code[0].Code) > params.MaxCodeSize {
return fmt.Errorf("code change contained oversized code")
return errors.New("code change contained oversized code")
}
}
return nil
Expand Down
Loading