Skip to content

EIP-7825: Transaction gas limit cap #8700

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

Merged
merged 12 commits into from
Jun 4, 2025
Merged

Conversation

fab-10
Copy link
Contributor

@fab-10 fab-10 commented May 27, 2025

PR description

Built on top of #8736

Implement EIP-7825: Transaction gas limit cap
The gas limit cap is driven by the protocol schedule, and at Osaka fork will be 30M, while before Osaka it is Long.MAX_VALUE that is a safe assumption, since no transactions have every or will reach that value before Osaka activation.
The 30M value is currently hard coded, but a future development can make it configurable, in case there is a need for that feature.

The transaction gas limit cap is also supported during simulations, with the following behavior:

  • when estimating gas, the limit is enforced, following the fact that we already enforce the gas limit accordingly to the block gas limit or the sender balance
  • instead for eth_call related calls, the limit is not enforced, since there it is already possible to specify a higher limit that the block gas limit, and the max depends on the configuration option rpc_gas_cap

Fixed Issue(s)

fixes #8604

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

@fab-10 fab-10 force-pushed the tx-gas-limit-cap branch from 94f0e0e to da1d2cb Compare May 27, 2025 10:02
@Gabriel-Trintinalia Gabriel-Trintinalia added the Osaka Osaka fork related - part of Fusaka label May 29, 2025
@Gabriel-Trintinalia Gabriel-Trintinalia moved this to In Progress in Osaka May 29, 2025
@fab-10 fab-10 force-pushed the tx-gas-limit-cap branch from da1d2cb to ffef57b Compare May 30, 2025 11:28
@fab-10 fab-10 marked this pull request as ready for review May 30, 2025 13:17
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;

public class OsakaTargetingGasLimitCalculator extends CancunTargetingGasLimitCalculator {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really understand this class name, and it seems more like a transaction validator than a gas calculator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking at the interface GasLimitCalculator from which all the specify forks derive, probably is clearer what is the scope, probably since this hierarchy of classes has evolved and changed since its inception, could be time to rename? Do you have any suggestion?

Copy link
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia Jun 1, 2025

Choose a reason for hiding this comment

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

It's not a transaction validator per se, but it computes parameters that are used by the MainnetTransactionValidator and block header validation rules, such as the next gas limit and the next blob gas target. In this context, the current name makes sense. Maybe we could drop either target or limit from the name but I think it is out of the scope of this PR.

Copy link
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia left a comment

Choose a reason for hiding this comment

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

The PR looks good to me overall, but we need to change the TransactionSimulator as well. If no gasLimit is provided in the call object, it defaults to the block's gas limit—which is always greater than 30M. I suggest updating TransactionSimulator.calculateSimulationGasCap to use min(transactionGasLimit, blockGasLimit) when no initial gas cap is explicitly provided.

fab-10 added 3 commits June 3, 2025 11:28
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10
Copy link
Contributor Author

fab-10 commented Jun 3, 2025

The PR looks good to me overall, but we need to change the TransactionSimulator as well. If no gasLimit is provided in the call object, it defaults to the block's gas limit—which is always greater than 30M. I suggest updating TransactionSimulator.calculateSimulationGasCap to use min(transactionGasLimit, blockGasLimit) when no initial gas cap is explicitly provided.

Good point, I missed that part, and I think in a future PR we also need to evaluate if and how that can impact the rpc-gas-cap option (https://besu.hyperledger.org/public-networks/reference/cli/options#rpc-gas-cap)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 force-pushed the tx-gas-limit-cap branch from d1f4b34 to 205c4bb Compare June 3, 2025 12:24
fab-10 added 3 commits June 3, 2025 14:59
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
# Conflicts:
#	ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
#	ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 force-pushed the tx-gas-limit-cap branch 2 times, most recently from 2c4dde7 to 79424b6 Compare June 3, 2025 16:35
@fab-10 fab-10 force-pushed the tx-gas-limit-cap branch from 79424b6 to 4c654a8 Compare June 3, 2025 17:01
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 force-pushed the tx-gas-limit-cap branch from 4c654a8 to eefc131 Compare June 3, 2025 17:09
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
…rict

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
fab-10 added 2 commits June 4, 2025 09:41
# Conflicts:
#	ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
#	ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java
@fab-10 fab-10 enabled auto-merge (squash) June 4, 2025 07:53
@fab-10 fab-10 merged commit 23c5e46 into hyperledger:main Jun 4, 2025
48 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Osaka Jun 4, 2025
@fab-10 fab-10 deleted the tx-gas-limit-cap branch June 4, 2025 08:43
Gabriel-Trintinalia added a commit that referenced this pull request Jun 6, 2025
* EIP-7825: Transaction gas limit cap (#8700)

* EIP-7825: Transaction gas limit cap

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Support transaction gas limit cap when simulating a tx

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Do not allow isAllowExceedingGasLimit for when block simulation is strict

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

---------

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Co-authored-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

* EIP-7823 - Modexp upper bounds (#8632)

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>

* Change Maven artifactIds to avoid possible collisions with other libs (#8589)

* Improve Maven artifacts naming to avoid possible collisions with other libs

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Rename besu subproject to app (#8746)

* Rename `besu` module to `app`

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Implement percentiles array size limit for eth_feeHistory (#8748)

* implement percentiles array size limit for eth_feeHistory

Signed-off-by: garyschulte <garyschulte@gmail.com>

* Revert "feat: remove chain head check if peer supports eth/69 (#8725)" (#8753)

This reverts commit ed1086d.

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

---------

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Simon Dudley <simon.dudley@consensys.net>
Co-authored-by: garyschulte <garyschulte@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Osaka Osaka fork related - part of Fusaka
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

EIP-7825 Transaction Gas Limit Cap
3 participants