Skip to content

Commit

Permalink
fix(fork): set block blob_excess_gas_and_price only if `excess_blob_g…
Browse files Browse the repository at this point in the history
…as header` is Some (#9298)

fix(fork): set block blob_excess_gas_and_price only if excess_blob_gas header is Some
  • Loading branch information
grandizzy authored Nov 11, 2024
1 parent f8d9234 commit 4817280
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/evm/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1922,8 +1922,9 @@ fn update_env_block<T>(env: &mut Env, block: &Block<T>) {
env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default());
env.block.gas_limit = U256::from(block.header.gas_limit);
env.block.number = U256::from(block.header.number);
env.block.blob_excess_gas_and_price =
block.header.excess_blob_gas.map(BlobExcessGasAndPrice::new);
if let Some(excess_blob_gas) = block.header.excess_blob_gas {
env.block.blob_excess_gas_and_price = Some(BlobExcessGasAndPrice::new(excess_blob_gas));
}
}

/// Executes the given transaction and commits state changes to the database _and_ the journaled
Expand Down
23 changes: 23 additions & 0 deletions crates/forge/tests/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2616,3 +2616,26 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| {

cmd.forge_fuse().args(["test", "--mc", "GetBroadcastTest", "-vvv"]).assert_success();
});

// See <https://github.com/foundry-rs/foundry/issues/9297>
forgetest_init!(test_roll_scroll_fork_with_cancun, |prj, cmd| {
prj.add_test(
"ScrollForkTest.t.sol",
r#"
import {Test} from "forge-std/Test.sol";
contract ScrollForkTest is Test {
function test_roll_scroll_fork_to_tx() public {
vm.createSelectFork("https://scroll-mainnet.chainstacklabs.com/");
bytes32 targetTxHash = 0xf94774a1f69bba76892141190293ffe85dd8d9ac90a0a2e2b114b8c65764014c;
vm.rollFork(targetTxHash);
}
}
"#,
)
.unwrap();

cmd.args(["test", "--mt", "test_roll_scroll_fork_to_tx", "--evm-version", "cancun"])
.assert_success();
});

0 comments on commit 4817280

Please sign in to comment.