From 872c1248f3e6986ba8b22f7b14d5426cdcf2e35c Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Fri, 6 Feb 2026 17:14:54 +0800 Subject: [PATCH] test(params): move params.V2TestsGasLimit to engine_v2_tests package (#2028) - V2TestsGasLimit should be changed to const - V2TestsGasLimit is only used by engine_v2_tests package --- consensus/tests/engine_v2_tests/helper.go | 4 +++- consensus/tests/engine_v2_tests/mine_test.go | 10 ++++---- .../tests/engine_v2_tests/penalty_test.go | 2 +- params/protocol_params.go | 23 ++++++++----------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/consensus/tests/engine_v2_tests/helper.go b/consensus/tests/engine_v2_tests/helper.go index d92807e177..9dd6d7c006 100644 --- a/consensus/tests/engine_v2_tests/helper.go +++ b/consensus/tests/engine_v2_tests/helper.go @@ -37,6 +37,8 @@ type signersList map[string]bool const GAP = int(450) +const testGasLimit uint64 = 1200000000 // The gas limit used in the v2 consensus tests + var ( acc1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") acc2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee") @@ -872,7 +874,7 @@ func createBlockFromHeader(bc *core.BlockChain, customHeader *types.Header, txs Coinbase: customHeader.Coinbase, Difficulty: difficulty, Number: customHeader.Number, - GasLimit: params.V2TestsGasLimit, + GasLimit: testGasLimit, Time: uint64(time.Now().Unix() - 1000000 + int64(customHeader.Number.Uint64()*10)), Extra: customHeader.Extra, Validator: customHeader.Validator, diff --git a/consensus/tests/engine_v2_tests/mine_test.go b/consensus/tests/engine_v2_tests/mine_test.go index 286f7ef88c..2cc06639e9 100644 --- a/consensus/tests/engine_v2_tests/mine_test.go +++ b/consensus/tests/engine_v2_tests/mine_test.go @@ -150,7 +150,7 @@ func TestPrepareFail(t *testing.T) { notReadyToProposeHeader := &types.Header{ ParentHash: currentBlock.Hash(), Number: big.NewInt(int64(901)), - GasLimit: params.V2TestsGasLimit, + GasLimit: testGasLimit, Time: tstamp, Coinbase: signer, } @@ -161,7 +161,7 @@ func TestPrepareFail(t *testing.T) { notReadyToMine := &types.Header{ ParentHash: currentBlock.Hash(), Number: big.NewInt(int64(901)), - GasLimit: params.V2TestsGasLimit, + GasLimit: testGasLimit, Time: tstamp, Coinbase: signer, } @@ -175,7 +175,7 @@ func TestPrepareFail(t *testing.T) { header901WithoutCoinbase := &types.Header{ ParentHash: currentBlock.Hash(), Number: big.NewInt(int64(901)), - GasLimit: params.V2TestsGasLimit, + GasLimit: testGasLimit, Time: tstamp, } @@ -196,7 +196,7 @@ func TestPrepareHappyPath(t *testing.T) { header901 := &types.Header{ ParentHash: currentBlock.Hash(), Number: big.NewInt(int64(901)), - GasLimit: params.V2TestsGasLimit, + GasLimit: testGasLimit, Time: tstamp, Coinbase: signer, } @@ -276,7 +276,7 @@ func TestUpdateMultipleMasterNodes(t *testing.T) { header1800 := &types.Header{ ParentHash: parentBlock.Hash(), Number: big.NewInt(int64(1800)), - GasLimit: params.V2TestsGasLimit, + GasLimit: testGasLimit, Time: tstamp, Coinbase: voterAddr, } diff --git a/consensus/tests/engine_v2_tests/penalty_test.go b/consensus/tests/engine_v2_tests/penalty_test.go index 0fa80f2036..dddb375cc7 100644 --- a/consensus/tests/engine_v2_tests/penalty_test.go +++ b/consensus/tests/engine_v2_tests/penalty_test.go @@ -49,7 +49,7 @@ func TestHookPenaltyV2Mining(t *testing.T) { headerMining := &types.Header{ ParentHash: header2100.ParentHash, Number: header2100.Number, - GasLimit: params.V2TestsGasLimit, + GasLimit: testGasLimit, Time: header2100.Time, Coinbase: acc1Addr, } diff --git a/params/protocol_params.go b/params/protocol_params.go index 39797d8e8e..687b02ed64 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -18,11 +18,6 @@ package params import "math/big" -var ( - TargetGasLimit uint64 = XDCGenesisGasLimit // The artificial target - V2TestsGasLimit uint64 = 1200000000 // The gas limit used in the v2 consensus tests -) - const ( GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. MinGasLimit uint64 = 5000 // Minimum the gas limit may ever be. @@ -97,16 +92,7 @@ const ( // up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529 RefundQuotient uint64 = 2 RefundQuotientEIP3529 uint64 = 5 -) -var ( - DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. - GenesisDifficulty = big.NewInt(131072) // Difficulty of the Genesis block. - MinimumDifficulty = big.NewInt(131072) // The minimum that the difficulty may ever be. - DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. -) - -const ( NetSstoreNoopGas uint64 = 200 // Once per SSTORE operation if the value doesn't change. NetSstoreInitGas uint64 = 20000 // Once per SSTORE operation from clean zero. NetSstoreCleanGas uint64 = 5000 // Once per SSTORE operation from clean non-zero. @@ -175,3 +161,12 @@ const ( Bn256PairingPerPointGasByzantium uint64 = 80000 // Byzantium per-point price for an elliptic curve pairing check Bn256PairingPerPointGasIstanbul uint64 = 34000 // Per-point price for an elliptic curve pairing check ) + +var ( + DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. + GenesisDifficulty = big.NewInt(131072) // Difficulty of the Genesis block. + MinimumDifficulty = big.NewInt(131072) // The minimum that the difficulty may ever be. + DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + + TargetGasLimit uint64 = XDCGenesisGasLimit // The artificial target +)