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
This commit is contained in:
Daniel Liu 2026-02-06 17:14:54 +08:00 committed by GitHub
parent 2e2d12304e
commit 872c1248f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 21 deletions

View file

@ -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,

View file

@ -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,
}

View file

@ -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,
}

View file

@ -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
)