Skip to content

Commit ec0df6f

Browse files
calberamask-ppjsvisarjl493456442reallesee
authored
Update with latest main (#42)
* core/types: minimize this invalid intermediate state (ethereum#32241) * core/rawdb: downgrade log level in chain freezer (ethereum#32253) * triedb/pathdb: use binary.append to eliminate the tmp scratch slice (ethereum#32250) `binary.AppendUvarint` offers better performance than using append directly, because it avoids unnecessary memory allocation and copying. In our case, it can increase the performance by +35.8% for the `blockWriter.append` function: ``` benchmark old ns/op new ns/op delta BenchmarkBlockWriterAppend-8 5.97 3.83 -35.80% ``` --------- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Gary Rong <garyrong0905@gmail.com> * p2p/rlpx: optimize XOR operation using bitutil.XORBytes (ethereum#32217) Replace manual byte-by-byte XOR implementation with the optimized bitutil.XORBytes function. This improves performance by using word-sized operations on supported architectures while maintaining the same functionality. The optimized version processes data in bulk rather than one byte at a time --------- Co-authored-by: Felix Lange <fjl@twurst.com> * eth/gasestimator: fix potential overflow (ethereum#32255) Improve binary search, preventing the potential overflow in certain L2 cases * triedb/pathdb: fix an deadlock in history indexer (ethereum#32260) Seems the `signal.result` was not sent back in shorten case, this will cause a deadlock. --------- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Gary Rong <garyrong0905@gmail.com> * eth/protocols/snap: add healing and syncing metrics (ethereum#32258) Adds the heal time and snap sync time to grafana --------- Co-authored-by: Gary Rong <garyrong0905@gmail.com> * core: replace the empty fmt.Errorf with errors.New (ethereum#32274) The `errors.new` function does not require string formatting, so its performance is better than that of `fmt.Errorf`. * eth/catalyst: fix error message in ExecuteStatelessPayloadV4 (ethereum#32269) Correct the error message in the ExecuteStatelessPayloadV4 function to reference newPayloadV4 and the Prague fork, instead of incorrectly referencing newPayloadV3 and Cancun. This improves clarity during debugging and aligns the error message with the actual function and fork being validated. No logic is changed. --------- Co-authored-by: rjl493456442 <garyrong0905@gmail.com> * cmd, eth, internal: introduce debug_sync (ethereum#32177) Alternative implementation of ethereum#32159 * all: replace fmt.Errorf with errors.New (ethereum#32286) The errors.new function does not require string formatting, so its performance is better than that of fmt.Errorf. * downloader: fix typos, grammar and formatting (ethereum#32288) * ethclient/simulated: Fix flaky rollback test (ethereum#32280) This PR addresses a flakiness in the rollback test discussed in ethereum#32252 I found `nonce` collision caused transactions occasionally fail to send. I tried to change error message in the failed test like: ``` if err = client.SendTransaction(ctx, signedTx); err != nil { t.Fatalf("failed to send transaction: %v, nonce: %d", err, signedTx.Nonce()) } ``` and I occasionally got test failure with this message: ``` === CONT TestFlakyFunction/Run_#100 rollback_test.go:44: failed to send transaction: already known, nonce: 0 --- FAIL: TestFlakyFunction/Run_#100 (0.07s) ``` Although `nonces` are obtained via `PendingNonceAt`, we observed that, in rare cases (approximately 1 in 1000), two transactions from the same sender end up with the same nonce. This likely happens because `tx0` has not yet propagated to the transaction pool before `tx1` requests its nonce. When the test succeeds, `tx0` and `tx1` have nonces `0` and `1`, respectively. However, in rare failures, both transactions end up with nonce `0`. We modified the test to explicitly assign nonces to each transaction. By controlling the nonce values manually, we eliminated the race condition and ensured consistent behavior. After several thousand runs, the flakiness was no longer reproducible in my local environment. Reduced internal polling interval in `pendingStateHasTx()` to speed up test execution without impacting stability. It reduces test time for `TestTransactionRollbackBehavior` from about 7 seconds to 2 seconds. * core/state: preallocate capacity for logs list (ethereum#32291) Improvement: preallocate capacity for `logs` at first to avoid reallocating multi times. * core/state: improve PrettyPrint function (ethereum#32293) --------- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: maskpp <maskpp266@gmail.com> Co-authored-by: Delweng <delweng@gmail.com> Co-authored-by: Gary Rong <garyrong0905@gmail.com> Co-authored-by: Micke <155267459+reallesee@users.noreply.github.com> Co-authored-by: Felix Lange <fjl@twurst.com> Co-authored-by: gzeon <h@arry.io> Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: nthumann <nthumanna@gmail.com> Co-authored-by: Galoretka <galoretochka@gmail.com> Co-authored-by: ericxtheodore <ericxtheodore@outlook.com> Co-authored-by: Tomás Andróil <tomasandroil@gmail.com> Co-authored-by: kashitaka <takao.w9st.kashima@xica.net>
2 parents 88d9d20 + 006ada2 commit ec0df6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+415
-251
lines changed

cmd/bera-geth/chaincmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ func downloadEra(ctx *cli.Context) error {
724724
case ctx.IsSet(utils.BepoliaFlag.Name):
725725
network = "bepolia"
726726
default:
727-
return fmt.Errorf("unsupported network, no known era1 checksums")
727+
return errors.New("unsupported network, no known era1 checksums")
728728
}
729729
}
730730

cmd/bera-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/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/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"
@@ -2008,10 +2008,14 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
20082008
return filterSystem
20092009
}
20102010

2011-
// RegisterFullSyncTester adds the full-sync tester service into node.
2012-
func RegisterFullSyncTester(stack *node.Node, eth *eth.Ethereum, target common.Hash, exitWhenSynced bool) {
2013-
catalyst.RegisterFullSyncTester(stack, eth, target, exitWhenSynced)
2014-
log.Info("Registered full-sync tester", "hash", target, "exitWhenSynced", exitWhenSynced)
2011+
// RegisterSyncOverrideService adds the synchronization override service into node.
2012+
func RegisterSyncOverrideService(stack *node.Node, eth *eth.Ethereum, target common.Hash, exitWhenSynced bool) {
2013+
if target != (common.Hash{}) {
2014+
log.Info("Registered sync override service", "hash", target, "exitWhenSynced", exitWhenSynced)
2015+
} else {
2016+
log.Info("Registered sync override service")
2017+
}
2018+
syncer.Register(stack, eth, target, exitWhenSynced)
20152019
}
20162020

20172021
// 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

@@ -107,7 +107,7 @@ type testConfig struct {
107107
traceTestFile string
108108
}
109109

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

112112
// validateHistoryPruneErr checks whether the given error is caused by access
113113
// to history before the pruning threshold block (it is an rpc.Error with code 4444).
@@ -119,7 +119,7 @@ func validateHistoryPruneErr(err error, blockNum uint64, historyPruneBlock *uint
119119
if err != nil {
120120
if rpcErr, ok := err.(rpc.Error); ok && rpcErr.ErrorCode() == 4444 {
121121
if historyPruneBlock != nil && blockNum > *historyPruneBlock {
122-
return fmt.Errorf("pruned history error returned after pruning threshold")
122+
return errors.New("pruned history error returned after pruning threshold")
123123
}
124124
return errPrunedHistory
125125
}

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/rawdb/chain_freezer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (f *chainFreezer) Close() error {
104104
func (f *chainFreezer) readHeadNumber(db ethdb.KeyValueReader) uint64 {
105105
hash := ReadHeadBlockHash(db)
106106
if hash == (common.Hash{}) {
107-
log.Error("Head block is not reachable")
107+
log.Warn("Head block is not reachable")
108108
return 0
109109
}
110110
number, ok := ReadHeaderNumber(db, hash)

core/state/access_list.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,7 @@ func (al *accessList) Equal(other *accessList) bool {
145145
// PrettyPrint prints the contents of the access list in a human-readable form
146146
func (al *accessList) PrettyPrint() string {
147147
out := new(strings.Builder)
148-
var sortedAddrs []common.Address
149-
for addr := range al.addresses {
150-
sortedAddrs = append(sortedAddrs, addr)
151-
}
148+
sortedAddrs := slices.Collect(maps.Keys(al.addresses))
152149
slices.SortFunc(sortedAddrs, common.Address.Cmp)
153150
for _, addr := range sortedAddrs {
154151
idx := al.addresses[addr]

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 {

0 commit comments

Comments
 (0)