Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

core: adjust reserved gas for system transactions in non-checkpoint block #414

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

andicrypt
Copy link
Contributor

@andicrypt andicrypt commented Mar 11, 2024

Currently, reserved gas for system transaction is hardcoded as 10M gas. (

ronin/miner/worker.go

Lines 879 to 890 in 95e3707

// 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 {
log.Error(
"Failed to reserve gas for system transactions",
"pool", w.current.gasPool,
"reserve", params.ReservedGasForSystemTransactions,
"error", err,
)
return true
}
}
). However, only the checkpoint block - 1 (the block at the end of epoch) needs to reserve that much (because wrap up epoch transaction requires a lot of gas), it is necessary to adjust the logic to reserve lower gas in normal block or higher gas in checkpoint block.

Copy link
Collaborator

@minh-bq minh-bq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the prefix in commit title to follow the convention

miner/worker.go Outdated
@@ -872,17 +872,23 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin
return true
}

var reservedGas uint64 = 0
if w.current.header.Number.Uint64()%w.chainConfig.Consortium.EpochV2 == w.chainConfig.Consortium.EpochV2-1 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add check for pool.chainconfig.Consortium != nil to avoid crash on unit test

@andicrypt andicrypt changed the title fix: adjust reserved gas for system transactions in non-checkpoint block core/params: adjust reserved gas for system transactions in non-checkpoint block Mar 11, 2024
@andicrypt andicrypt changed the title core/params: adjust reserved gas for system transactions in non-checkpoint block core/tx_pool: adjust reserved gas for system transactions in non-checkpoint block Mar 11, 2024
@andicrypt andicrypt changed the title core/tx_pool: adjust reserved gas for system transactions in non-checkpoint block core: adjust reserved gas for system transactions in non-checkpoint block Mar 11, 2024
@minh-bq minh-bq merged commit 88a7a3c into master Mar 12, 2024
1 check passed
@minh-bq minh-bq deleted the feat/reserved-gas branch March 12, 2024 03:54
Francesco4203 pushed a commit to Francesco4203/ronin that referenced this pull request Jun 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants