Skip to content

Commit 595480f

Browse files
authored
Merge branch 'ethereum:master' into yzang/expose-readerlimit
2 parents 12c7693 + a56558d commit 595480f

File tree

31 files changed

+281
-198
lines changed

31 files changed

+281
-198
lines changed

cmd/devp2p/internal/ethtest/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (c *Conn) Write(proto Proto, code uint64, msg any) error {
129129
return err
130130
}
131131

132-
var errDisc error = fmt.Errorf("disconnect")
132+
var errDisc error = errors.New("disconnect")
133133

134134
// ReadEth reads an Eth sub-protocol wire message.
135135
func (c *Conn) ReadEth() (any, error) {

cmd/devp2p/internal/ethtest/suite.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package ethtest
1919
import (
2020
"context"
2121
"crypto/rand"
22+
"errors"
2223
"fmt"
2324
"reflect"
2425
"sync"
@@ -1092,7 +1093,7 @@ func (s *Suite) testBadBlobTx(t *utesting.T, tx *types.Transaction, badTx *types
10921093
return
10931094
}
10941095
if !readUntilDisconnect(conn) {
1095-
errc <- fmt.Errorf("expected bad peer to be disconnected")
1096+
errc <- errors.New("expected bad peer to be disconnected")
10961097
return
10971098
}
10981099
stage3.Done()
@@ -1139,7 +1140,7 @@ func (s *Suite) testBadBlobTx(t *utesting.T, tx *types.Transaction, badTx *types
11391140
}
11401141

11411142
if req.GetPooledTransactionsRequest[0] != tx.Hash() {
1142-
errc <- fmt.Errorf("requested unknown tx hash")
1143+
errc <- errors.New("requested unknown tx hash")
11431144
return
11441145
}
11451146

@@ -1149,7 +1150,7 @@ func (s *Suite) testBadBlobTx(t *utesting.T, tx *types.Transaction, badTx *types
11491150
return
11501151
}
11511152
if readUntilDisconnect(conn) {
1152-
errc <- fmt.Errorf("unexpected disconnect")
1153+
errc <- errors.New("unexpected disconnect")
11531154
return
11541155
}
11551156
close(errc)

cmd/geth/chaincmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ func downloadEra(ctx *cli.Context) error {
716716
case ctx.IsSet(utils.SepoliaFlag.Name):
717717
network = "sepolia"
718718
default:
719-
return fmt.Errorf("unsupported network, no known era1 checksums")
719+
return errors.New("unsupported network, no known era1 checksums")
720720
}
721721
}
722722

cmd/geth/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,16 @@ func makeFullNode(ctx *cli.Context) *node.Node {
262262
if cfg.Ethstats.URL != "" {
263263
utils.RegisterEthStatsService(stack, backend, cfg.Ethstats.URL)
264264
}
265-
// Configure full-sync tester service if requested
265+
// Configure synchronization override service
266+
var synctarget common.Hash
266267
if ctx.IsSet(utils.SyncTargetFlag.Name) {
267268
hex := hexutil.MustDecode(ctx.String(utils.SyncTargetFlag.Name))
268269
if len(hex) != common.HashLength {
269270
utils.Fatalf("invalid sync target length: have %d, want %d", len(hex), common.HashLength)
270271
}
271-
utils.RegisterFullSyncTester(stack, eth, common.BytesToHash(hex), ctx.Bool(utils.ExitWhenSyncedFlag.Name))
272+
synctarget = common.BytesToHash(hex)
272273
}
274+
utils.RegisterSyncOverrideService(stack, eth, synctarget, ctx.Bool(utils.ExitWhenSyncedFlag.Name))
273275

274276
if ctx.IsSet(utils.DeveloperFlag.Name) {
275277
// Start dev mode.

cmd/utils/flags.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ import (
4949
"github.com/ethereum/go-ethereum/crypto"
5050
"github.com/ethereum/go-ethereum/crypto/kzg4844"
5151
"github.com/ethereum/go-ethereum/eth"
52-
"github.com/ethereum/go-ethereum/eth/catalyst"
5352
"github.com/ethereum/go-ethereum/eth/ethconfig"
5453
"github.com/ethereum/go-ethereum/eth/filters"
5554
"github.com/ethereum/go-ethereum/eth/gasprice"
55+
"github.com/ethereum/go-ethereum/eth/syncer"
5656
"github.com/ethereum/go-ethereum/eth/tracers"
5757
"github.com/ethereum/go-ethereum/ethdb"
5858
"github.com/ethereum/go-ethereum/ethdb/remotedb"
@@ -1997,10 +1997,14 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
19971997
return filterSystem
19981998
}
19991999

2000-
// RegisterFullSyncTester adds the full-sync tester service into node.
2001-
func RegisterFullSyncTester(stack *node.Node, eth *eth.Ethereum, target common.Hash, exitWhenSynced bool) {
2002-
catalyst.RegisterFullSyncTester(stack, eth, target, exitWhenSynced)
2003-
log.Info("Registered full-sync tester", "hash", target, "exitWhenSynced", exitWhenSynced)
2000+
// RegisterSyncOverrideService adds the synchronization override service into node.
2001+
func RegisterSyncOverrideService(stack *node.Node, eth *eth.Ethereum, target common.Hash, exitWhenSynced bool) {
2002+
if target != (common.Hash{}) {
2003+
log.Info("Registered sync override service", "hash", target, "exitWhenSynced", exitWhenSynced)
2004+
} else {
2005+
log.Info("Registered sync override service")
2006+
}
2007+
syncer.Register(stack, eth, target, exitWhenSynced)
20042008
}
20052009

20062010
// SetupMetrics configures the metrics system.

cmd/workload/testsuite.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package main
1818

1919
import (
2020
"embed"
21-
"fmt"
21+
"errors"
2222
"io/fs"
2323
"os"
2424

@@ -97,7 +97,7 @@ type testConfig struct {
9797
traceTestFile string
9898
}
9999

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

102102
// validateHistoryPruneErr checks whether the given error is caused by access
103103
// to history before the pruning threshold block (it is an rpc.Error with code 4444).
@@ -109,7 +109,7 @@ func validateHistoryPruneErr(err error, blockNum uint64, historyPruneBlock *uint
109109
if err != nil {
110110
if rpcErr, ok := err.(rpc.Error); ok && rpcErr.ErrorCode() == 4444 {
111111
if historyPruneBlock != nil && blockNum > *historyPruneBlock {
112-
return fmt.Errorf("pruned history error returned after pruning threshold")
112+
return errors.New("pruned history error returned after pruning threshold")
113113
}
114114
return errPrunedHistory
115115
}

core/blockchain.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
682682
predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()]
683683
if predefinedPoint == nil || freezerTail != predefinedPoint.BlockNumber {
684684
log.Error("Chain history database is pruned with unknown configuration", "tail", freezerTail)
685-
return fmt.Errorf("unexpected database tail")
685+
return errors.New("unexpected database tail")
686686
}
687687
bc.historyPrunePoint.Store(predefinedPoint)
688688
return nil
@@ -695,15 +695,15 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
695695
// action to happen. So just tell them how to do it.
696696
log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is not pruned.", bc.cfg.ChainHistoryMode.String()))
697697
log.Error(fmt.Sprintf("Run 'geth prune-history' to prune pre-merge history."))
698-
return fmt.Errorf("history pruning requested via configuration")
698+
return errors.New("history pruning requested via configuration")
699699
}
700700
predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()]
701701
if predefinedPoint == nil {
702702
log.Error("Chain history pruning is not supported for this network", "genesis", bc.genesisBlock.Hash())
703-
return fmt.Errorf("history pruning requested for unknown network")
703+
return errors.New("history pruning requested for unknown network")
704704
} else if freezerTail > 0 && freezerTail != predefinedPoint.BlockNumber {
705705
log.Error("Chain history database is pruned to unknown block", "tail", freezerTail)
706-
return fmt.Errorf("unexpected database tail")
706+
return errors.New("unexpected database tail")
707707
}
708708
bc.historyPrunePoint.Store(predefinedPoint)
709709
return nil

core/state/snapshot/journal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func iterateJournal(db ethdb.KeyValueReader, callback journalCallback) error {
350350
}
351351
if len(destructs) > 0 {
352352
log.Warn("Incompatible legacy journal detected", "version", journalV0)
353-
return fmt.Errorf("incompatible legacy journal detected")
353+
return errors.New("incompatible legacy journal detected")
354354
}
355355
}
356356
if err := r.Decode(&accounts); err != nil {

core/state/statedb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (s *StateDB) GetLogs(hash common.Hash, blockNumber uint64, blockHash common
258258
}
259259

260260
func (s *StateDB) Logs() []*types.Log {
261-
var logs []*types.Log
261+
logs := make([]*types.Log, 0, s.logSize)
262262
for _, lgs := range s.logs {
263263
logs = append(logs, lgs...)
264264
}

core/tracing/journal.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package tracing
1818

1919
import (
20-
"fmt"
20+
"errors"
2121
"math/big"
2222

2323
"github.com/ethereum/go-ethereum/common"
@@ -39,14 +39,14 @@ type entry interface {
3939
// WrapWithJournal wraps the given tracer with a journaling layer.
4040
func WrapWithJournal(hooks *Hooks) (*Hooks, error) {
4141
if hooks == nil {
42-
return nil, fmt.Errorf("wrapping nil tracer")
42+
return nil, errors.New("wrapping nil tracer")
4343
}
4444
// No state change to journal, return the wrapped hooks as is
4545
if hooks.OnBalanceChange == nil && hooks.OnNonceChange == nil && hooks.OnNonceChangeV2 == nil && hooks.OnCodeChange == nil && hooks.OnStorageChange == nil {
4646
return hooks, nil
4747
}
4848
if hooks.OnNonceChange != nil && hooks.OnNonceChangeV2 != nil {
49-
return nil, fmt.Errorf("cannot have both OnNonceChange and OnNonceChangeV2")
49+
return nil, errors.New("cannot have both OnNonceChange and OnNonceChangeV2")
5050
}
5151

5252
// Create a new Hooks instance and copy all hooks

0 commit comments

Comments
 (0)