Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txpool: apply miner's gasceil to txpool #2680

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

zzzckck
Copy link
Collaborator

@zzzckck zzzckck commented Sep 4, 2024

Description

Apply Eth.Miner.GasCeil to TxPool even the node did not enable --mine option. Otherwise, there could be accmulated pending transactions in txpool.
Take an example:

  • Currently, BSC testnet's block gaslimit is 70M, as 20M gas is reserved for
    SystemTxs, the maximum acceptable GasLimit for transaction is 50M.
  • TxPool recevied a transaction with GasLimit 60M, it would be accepted in TxPool but it
    will never be accepted by validators. Such kinds of transactions will be kept in txpool
    and gradually make the txpool overflowed

Here is part of the TxPool status dumped from one mainnet p2p node(current mainnet block gaslimit 140M): transactions with GasLimit(133000000) will always in pending state and it also blocks its following transactions

{
  pending: {
    0x00C78eaA93150De50E863FD4DEe38E4Ed76388Cd: {
      53: "0x490e6c5C8bc4a6Da41A2EEaAD628886930Cc90D0: 0 wei + 133000000 gas × 1000000000 wei"
    },
    0x033780B652a585BeF8e37b0E3FADa67a211e6700: {
      102: "0xB48200eD722e7e86a78D04245bF743D047289E95: 0 wei + 133000000 gas × 1000000000 wei"
    },
    0x0449F629DCc0a0a7F209939e12DAd63e8049671c: {
      19: "0xfB1389f2e7917388BeE2221EaE9B9Cf161C6D4Dd: 0 wei + 133000000 gas × 3000000000 wei",
      20: "0x55d398326f99059fF775485246999027B3197955: 0 wei + 51627 gas × 3000000000 wei",
      21: "0x55d398326f99059fF775485246999027B3197955: 0 wei + 51627 gas × 3000000000 wei"
    },
    0x051a352876192c60673E7554b77A184352a64D5c: {
      19: "0xe9428B8acaA6b9d7C3314D093975c291Ec59A009: 0 wei + 132478448 gas × 1000000000 wei"
    },
    0x05C1A4cBd48c2F30549FD55A90F76943b9ca7c83: {
      48: "0x5350265d385F9CE98b939E1121b328B88f2d90A3: 0 wei + 133000000 gas × 1000000000 wei"
    },
    0x07fA136d3882dF1395c4B9bDE4e51C1B6ebBd352: {
      60: "0x07fA136d3882dF1395c4B9bDE4e51C1B6ebBd352: 0 wei + 131960955 gas × 6000000000 wei",
      61: "0xBDf5bAfEE1291EEc45Ae3aadAc89BE8152D4E673: 0 wei + 133000000 gas × 3000000000 wei"
    },
    0x080FdeBDf2d6bA1F1645A90972c96cB91511D47B: {
      383: "0x080FdeBDf2d6bA1F1645A90972c96cB91511D47B: 0 wei + 133000000 gas × 1100000000 wei",
      384: "0xE58C3A44B74362048e202cb7C8036D4b0B28Af50: 0 wei + 56549 gas × 1000000000 wei",
      385: "0xE58C3A44B74362048e202cb7C8036D4b0B28Af50: 0 wei + 56549 gas × 1000000000 wei",
      386: "0xE58C3A44B74362048e202cb7C8036D4b0B28Af50: 0 wei + 56549 gas × 1000000000 wei",
      387: "0xE58C3A44B74362048e202cb7C8036D4b0B28Af50: 0 wei + 56549 gas × 1000000000 wei",
      388: "0xE58C3A44B74362048e202cb7C8036D4b0B28Af50: 0 wei + 56549 gas × 1000000000 wei",
      389: "0xE58C3A44B74362048e202cb7C8036D4b0B28Af50: 0 wei + 56549 gas × 1000000000 wei",
      390: "0x080FdeBDf2d6bA1F1645A90972c96cB91511D47B: 0 wei + 96893 gas × 13200000000 wei",
      391: "0x080FdeBDf2d6bA1F1645A90972c96cB91511D47B: 0 wei + 96893 gas × 1100000000 wei",
      392: "0x080FdeBDf2d6bA1F1645A90972c96cB91511D47B: 0 wei + 96893 gas × 1100000000 wei"
    },
   ...

Rationale

NA

Example

NA

Changes

Pls check your config.toml:

  • if you have setEth.Miner.GasCeil, make sure it is correct, for current mainnet it is 140000000
  • if you haven't set Eth.Miner.GasCeil, it is ok, but you may face the issue mentioned in this PR, your TxPool could be full.
[Eth.Miner]
GasCeil = 140000000

To clarify how GasCeil will be calculated:

  • case 1: no [Eth.Miner] in config.toml, GasCeill will be set to the default value(currently it 30M)
  • case 2: has [Eth.Miner] in config.toml, but no GasCeil, then it will be set to 0, TxPool will have no limitation on Tx gas limit.
[Eth.Miner]
GasPrice = 3000000000
Recommit = 10000000000
  • case 3: has [Eth.Miner] in config.toml, but set GasCeil to less then 20M, then it is invalid, TxPool will have no limitation on Tx gas limit.
[Eth.Miner]
GasCeil = 10000000
GasPrice = 3000000000
Recommit = 10000000000
  • case 4: has [Eth.Miner] in config.toml, and GasCeil > 20M, then it is valid, TxPool will have the limitation on Tx size, only accept tx with GasLimit less then (GasCeil - 20000000).
[Eth.Miner]
GasCeil = 140000000
GasPrice = 3000000000
Recommit = 10000000000

apply `Eth.Miner.GasCeil` to TxPool even the node did not enable `--mine` option
Otherwise, there could be accmulated pending transactions in txpool.
Take an example:
- Currently, BSC testnet's block gaslimit is 70M, as 20M gas is reserved for
  SystemTxs, the maximum acceptable GasLimit for transaction is 50M.
- TxPool recevied a transaction with GasLimit 60M, it would be accepted in TxPool but it
  will never be accepted by validators. Such kinds of transactions will be kept in txpool
  and gradually make the txpool overflowed
@zzzckck zzzckck changed the title Txpool gasceil txpool: apply miner's gasceil to txpool Sep 4, 2024
Copy link
Contributor

@MatusKysel MatusKysel left a comment

Choose a reason for hiding this comment

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

👍

@zzzckck zzzckck merged commit 0dab664 into bnb-chain:develop Sep 4, 2024
7 checks passed
zzzckck added a commit to zzzckck/bsc that referenced this pull request Sep 5, 2024
This PR tries to improve bnb-chain#2680
If the node did not set `Eth.Miner` in config.toml, the default GasCeil
will be 30000000, it is not an accurate number for both BSC mainnet and testnet.
Set it to 0 means disable the transaction GasLimit check, i.e. the TxPool will
accept transactions with any GasLimit size.
zzzckck added a commit that referenced this pull request Sep 5, 2024
This PR tries to improve #2680
If the node did not set `Eth.Miner` in config.toml, the default GasCeil
will be 30000000, it is not an accurate number for both BSC mainnet and testnet.
Set it to 0 means disable the transaction GasLimit check, i.e. the TxPool will
accept transactions with any GasLimit size.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants