From 2a12a97a98810ba2265002f866fa469bb61f10e5 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Mon, 11 Dec 2023 16:15:33 +0800 Subject: [PATCH] all: fix typo and comments --- accounts/abi/bind/backends/simulated.go | 2 +- eth/catalyst/simulated_beacon.go | 18 +++++++++--------- ethclient/simulated/backend.go | 4 ++-- ethclient/simulated/backend_test.go | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 867e79e426..9271566692 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -36,7 +36,7 @@ func (b *SimulatedBackend) Fork(ctx context.Context, parentHash common.Hash) err return b.Backend.Fork(parentHash) } -// New creates a new binding backend using a simulated blockchain +// NewSimulatedBackend creates a new binding backend using a simulated blockchain // for testing purposes. // // A simulated backend always uses chainID 1337. diff --git a/eth/catalyst/simulated_beacon.go b/eth/catalyst/simulated_beacon.go index 84ebffc80a..5c7971f42a 100644 --- a/eth/catalyst/simulated_beacon.go +++ b/eth/catalyst/simulated_beacon.go @@ -86,9 +86,10 @@ type SimulatedBeacon struct { // NewSimulatedBeacon constructs a new simulated beacon chain. // Period sets the period in which blocks should be produced. -// If period is set to 0, a block is produced on every transaction. -// If period is set to math.MaxUint64, blocks can only be produced -// via Commit, Fork and AdjustTime. +// +// - If period is set to 0, a block is produced on every transaction. +// - If period is set to math.MaxUint64, blocks can only be produced +// via Commit, Fork and AdjustTime. func NewSimulatedBeacon(period uint64, eth *eth.Ethereum) (*SimulatedBeacon, error) { block := eth.BlockChain().CurrentBlock() current := engine.ForkchoiceStateV1{ @@ -127,9 +128,8 @@ func (c *SimulatedBeacon) Start() error { go c.loopOnDemand() } else if c.period == math.MaxUint64 { // if period is set to MaxUint, do not mine at all - // this is used in the simulated backend - // where blocks are explicitly mined via - // Commit, AdjustTime and Fork + // this is used in the simulated backend where blocks + // are explicitly mined via Commit, AdjustTime and Fork } else { go c.loop() } @@ -195,6 +195,7 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal, tstamp uint return err } c.setCurrentState(payload.BlockHash, finalizedHash) + // Mark the block containing the payload as canonical if _, err = c.engineAPI.ForkchoiceUpdatedV2(c.curForkchoiceState, nil); err != nil { return err @@ -247,8 +248,8 @@ func (c *SimulatedBeacon) loop() { } } -// finalizedBlockHash returns the block hash of the finalized block corresponding to the given number -// or nil if doesn't exist in the chain. +// finalizedBlockHash returns the block hash of the finalized block corresponding +// to the given number or nil if doesn't exist in the chain. func (c *SimulatedBeacon) finalizedBlockHash(number uint64) *common.Hash { var finalizedNumber uint64 if number%devEpochLength == 0 { @@ -256,7 +257,6 @@ func (c *SimulatedBeacon) finalizedBlockHash(number uint64) *common.Hash { } else { finalizedNumber = (number - 1) / devEpochLength * devEpochLength } - if finalizedBlock := c.eth.BlockChain().GetBlockByNumber(finalizedNumber); finalizedBlock != nil { fh := finalizedBlock.Hash() return &fh diff --git a/ethclient/simulated/backend.go b/ethclient/simulated/backend.go index 0a8e846ce3..d87e2f89f1 100644 --- a/ethclient/simulated/backend.go +++ b/ethclient/simulated/backend.go @@ -43,8 +43,8 @@ type Backend struct { client simClient } -// simClient wraps ethclient. This exists to prevent extracting ethclient.Client from the -// Client interface returned by Backend. +// simClient wraps ethclient. This exists to prevent extracting ethclient.Client +// from the Client interface returned by Backend. type simClient struct { *ethclient.Client } diff --git a/ethclient/simulated/backend_test.go b/ethclient/simulated/backend_test.go index d40e2fb98d..16a2acdf4f 100644 --- a/ethclient/simulated/backend_test.go +++ b/ethclient/simulated/backend_test.go @@ -67,7 +67,6 @@ func newTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error) { Gas: 21000, To: &addr, }) - return types.SignTx(tx, types.LatestSignerForChainID(chainid), key) }