diff --git a/core/tx_pool.go b/core/tx_pool.go index 698cef4d5e..16ce925292 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -621,7 +621,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { // Ensure the transaction doesn't exceed the current block limit gas. var reservedGas uint64 = 0 if pool.chainconfig.Consortium != nil { - reservedGas = params.ReservedGasForSystemTransactions + if pool.chain.CurrentBlock().NumberU64()%pool.chainconfig.Consortium.EpochV2 == pool.chainconfig.Consortium.EpochV2-1 { + reservedGas = params.ReservedGasForCheckpointSystemTransactions + } else { + reservedGas = params.ReservedGasForNormalSystemTransactions + } } if pool.currentMaxGas-reservedGas < tx.Gas() { return ErrGasLimit diff --git a/miner/worker.go b/miner/worker.go index 9799a11089..82598d5eda 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -872,17 +872,25 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin return true } + var reservedGas uint64 = 0 + if w.chainConfig.Consortium != nil { + if w.current.header.Number.Uint64()%w.chainConfig.Consortium.EpochV2 == w.chainConfig.Consortium.EpochV2-1 { + reservedGas = params.ReservedGasForCheckpointSystemTransactions + } else { + reservedGas = params.ReservedGasForNormalSystemTransactions + } + } gasLimit := w.current.header.GasLimit if w.current.gasPool == nil { w.current.gasPool = new(core.GasPool).AddGas(gasLimit) // If the gas pool is newly created, reserve some gas for system transactions if w.chainConfig.Consortium != nil { - if err := w.current.gasPool.SubGas(params.ReservedGasForSystemTransactions); err != nil { + if err := w.current.gasPool.SubGas(reservedGas); err != nil { log.Error( "Failed to reserve gas for system transactions", "pool", w.current.gasPool, - "reserve", params.ReservedGasForSystemTransactions, + "reserve", reservedGas, "error", err, ) return true diff --git a/params/protocol_params.go b/params/protocol_params.go index 5ca54c3db6..0ead6ad377 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -19,7 +19,8 @@ package params import "math/big" const ( - ReservedGasForSystemTransactions uint64 = 10_000_000 // The reserved gas for system transactions in each block. + ReservedGasForCheckpointSystemTransactions uint64 = 10_000_000 // The reserved gas for system transactions in checkpoint blocks. + ReservedGasForNormalSystemTransactions uint64 = 2_000_000 // The reserved gas for system transactions in normal blocks. GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. ConsortiumGasLimitBoundDivisor uint64 = 256