Skip to content

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Aug 26, 2025

Motivation

Closes: #11348

Solution

Enforcing of tx gas limit is disabled by default as this is what users would expect, allow users to enforce the tx gas limit imposed by Osaka (EIP-7825). If there are further changes that change this tx gas limit we can make expand this to be EVM version specific.

Adds clarifying alias to block_gas_limit / disable_block_gas_limit to be block specific, retaining original alias for backwards compatibility

Breaking changes

Renamed TransactionExecutionOutcome::Exhausted => TransactionExecutionOutcome::BlockGasExhausted for clarity, expecting this to have no impact on regular users

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@zerosnacks zerosnacks changed the title chore: make enabling of tx_gas limit as enforced in Osaka possible feat(forge): loosen tx gas limit restrictions ahead of Osaka + make enforceable w/ --enable-tx-gas-limit Aug 26, 2025
@@ -265,6 +265,7 @@ impl CallArgs {

// modify settings that usually set in eth_call
env.evm_env.cfg_env.disable_block_gas_limit = true;
env.evm_env.cfg_env.tx_gas_limit_cap = Some(u64::MAX);
Copy link
Member Author

@zerosnacks zerosnacks Aug 26, 2025

Choose a reason for hiding this comment

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

this makes sense to me, do not enforce tx gas limit when simulating the behavior of an eth_call

@@ -1558,6 +1559,7 @@ impl Backend {
// we want to disable this in eth_call, since this is common practice used by other node
// impls and providers <https://github.com/foundry-rs/foundry/issues/4388>
env.evm_env.cfg_env.disable_block_gas_limit = true;
env.evm_env.cfg_env.tx_gas_limit_cap = Some(u64::MAX);
Copy link
Member Author

@zerosnacks zerosnacks Aug 26, 2025

Choose a reason for hiding this comment

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

same here, makes sense to avoid enforcing a tx gas limit cap here (and not introduce an option to configure it)

}

// check that we comply with the transaction's gas limit as imposed by Osaka (EIP-7825)
if env.evm_env.cfg_env.tx_gas_limit_cap.is_none()
Copy link
Member Author

Choose a reason for hiding this comment

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

spec's before Osaka have this set to Some(U64::max) by default

https://github.com/bluealloy/revm/blob/784d30d141beae3aa9f042f3bd3d1faa54ae7cc1/crates/context/src/cfg.rs#L254-L262

https://github.com/bluealloy/revm/blob/784d30d141beae3aa9f042f3bd3d1faa54ae7cc1/crates/handler/src/validation.rs#L117

it is debatable if it is really necessary to catch it here but could give user a richer error

@zerosnacks zerosnacks marked this pull request as ready for review September 8, 2025 08:08
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

do you see any issue if we infer / enable tx gas limit automatically if osaka evm version instead adding yet another enable_tx_gas_limit arg?

@zerosnacks
Copy link
Member Author

zerosnacks commented Sep 10, 2025

So by default REVM enables the tx gas limit with Osaka. This causes problems for users that have specified a high gas limit in their foundry.toml (say 100M gas) whose transactions will fail as it exceeds ~16M or if they have extremely large transactions in their tests / scripts. So in Foundry we need to always disable this behavior REVM enables by default. If users do want to accurately simulate the tx gas limit their gas set this flag.

@grandizzy
Copy link
Collaborator

So by default REVM enables the tx gas limit with Osaka.

Ah, I see, makes sense then

@grandizzy grandizzy self-requested a review September 10, 2025 13:04
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

lgtm! pending one more reviewer before merge

Copy link
Contributor

@0xrusowsky 0xrusowsky left a comment

Choose a reason for hiding this comment

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

the changes make sense to me!

@zerosnacks zerosnacks merged commit d244cd0 into master Sep 11, 2025
23 checks passed
@zerosnacks zerosnacks deleted the zerosnacks/chore-make-tx-gas-limit-cap-configurable branch September 11, 2025 10:29
@github-project-automation github-project-automation bot moved this to Done in Foundry Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

feat(forge): loosen tx gas limit restrictions ahead of Osaka + make enforceable w/ --enable-tx-gas-limit
3 participants