From 8ef781a41e857c6cd14932d952ce71401e76d5e3 Mon Sep 17 00:00:00 2001 From: buddho Date: Mon, 11 Mar 2024 18:56:19 +0800 Subject: [PATCH] upstream: more code review fix (#35) --- cmd/geth/pruneblock_test.go | 2 +- core/eip3529tests/eip3529_test_util.go | 2 +- core/vote/vote_pool_test.go | 2 +- eth/protocols/trust/handler_test.go | 2 +- miner/worker.go | 22 +++++++++++----------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/geth/pruneblock_test.go b/cmd/geth/pruneblock_test.go index 87fae5d38e52..1d8f068a9de3 100644 --- a/cmd/geth/pruneblock_test.go +++ b/cmd/geth/pruneblock_test.go @@ -51,7 +51,7 @@ var ( key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") address = crypto.PubkeyToAddress(key.PublicKey) balance = big.NewInt(100000000000000000) - gspec = &core.Genesis{Config: params.TestChainConfig, Alloc: core.GenesisAlloc{address: {Balance: balance}}, BaseFee: big.NewInt(params.InitialBaseFee)} + gspec = &core.Genesis{Config: params.TestChainConfig, Alloc: types.GenesisAlloc{address: {Balance: balance}}, BaseFee: big.NewInt(params.InitialBaseFee)} signer = types.LatestSigner(gspec.Config) config = &core.CacheConfig{ TrieCleanLimit: 256, diff --git a/core/eip3529tests/eip3529_test_util.go b/core/eip3529tests/eip3529_test_util.go index b562877d1ed1..d2448bb332bd 100644 --- a/core/eip3529tests/eip3529_test_util.go +++ b/core/eip3529tests/eip3529_test_util.go @@ -33,7 +33,7 @@ func TestGasUsage(t *testing.T, config *params.ChainConfig, engine consensus.Eng balanceBefore = big.NewInt(1000000000000000) gspec = &core.Genesis{ Config: config, - Alloc: core.GenesisAlloc{ + Alloc: types.GenesisAlloc{ address: {Balance: balanceBefore}, aa: { Code: bytecode, diff --git a/core/vote/vote_pool_test.go b/core/vote/vote_pool_test.go index 5a7a7e889bb5..ed905e0f3ada 100644 --- a/core/vote/vote_pool_test.go +++ b/core/vote/vote_pool_test.go @@ -146,7 +146,7 @@ func testVotePool(t *testing.T, isValidRules bool) { genesis := &core.Genesis{ Config: params.TestChainConfig, - Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(1000000)}}, + Alloc: types.GenesisAlloc{testAddr: {Balance: big.NewInt(1000000)}}, } mux := new(event.TypeMux) diff --git a/eth/protocols/trust/handler_test.go b/eth/protocols/trust/handler_test.go index 131aa118cdf4..187b29c93244 100644 --- a/eth/protocols/trust/handler_test.go +++ b/eth/protocols/trust/handler_test.go @@ -50,7 +50,7 @@ func newTestBackendWithGenerator(blocks int) *testBackend { genspec := &core.Genesis{ Config: params.AllCliqueProtocolChanges, ExtraData: make([]byte, 32+common.AddressLength+65), - Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(100000000000000000)}}, + Alloc: types.GenesisAlloc{testAddr: {Balance: big.NewInt(100000000000000000)}}, BaseFee: big.NewInt(0), } copy(genspec.ExtraData[32:], testAddr[:]) diff --git a/miner/worker.go b/miner/worker.go index 61b89a204aee..ba5afdf41f3c 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -819,6 +819,17 @@ LOOP: signal = commitInterruptOutOfGas break } + if stopTimer != nil { + select { + case <-stopTimer.C: + log.Info("Not enough time for further transactions", "txs", len(env.txs)) + stopTimer.Reset(0) // re-active the timer, in case it will be used later. + signal = commitInterruptTimeout + break LOOP + default: + } + } + // If we don't have enough blob space for any further blob transactions, // skip that list altogether if !blobTxs.Empty() && env.blobs*params.BlobTxBlobGasPerBlob >= params.MaxBlobGasPerBlock { @@ -850,17 +861,6 @@ LOOP: break } - if stopTimer != nil { - select { - case <-stopTimer.C: - log.Info("Not enough time for further transactions", "txs", len(env.txs)) - stopTimer.Reset(0) // re-active the timer, in case it will be used later. - signal = commitInterruptTimeout - break LOOP - default: - } - } - // If we don't have enough space for the next transaction, skip the account. if env.gasPool.Gas() < ltx.Gas { log.Trace("Not enough gas left for transaction", "hash", ltx.Hash, "left", env.gasPool.Gas(), "needed", ltx.Gas)