Skip to content

Commit 303afb8

Browse files
authored
fix: force 4844 txtype in blobhashes setter (#11355)
* test: add blobhashes repro * fix: force 4844 tx type
1 parent 5b221fe commit 303afb8

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

crates/cheatcodes/src/evm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{
88
use alloy_consensus::TxEnvelope;
99
use alloy_dyn_abi::{DynSolType, DynSolValue};
1010
use alloy_genesis::{Genesis, GenesisAccount};
11+
use alloy_network::eip2718::EIP4844_TX_TYPE_ID;
1112
use alloy_primitives::{Address, B256, U256, hex, map::HashMap};
1213
use alloy_rlp::Decodable;
1314
use alloy_sol_types::SolValue;
@@ -542,6 +543,8 @@ impl Cheatcode for blobhashesCall {
542543
see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844"
543544
);
544545
ccx.ecx.tx.blob_hashes.clone_from(hashes);
546+
// force this as 4844 txtype
547+
ccx.ecx.tx.tx_type = EIP4844_TX_TYPE_ID;
545548
Ok(Default::default())
546549
}
547550
}

crates/forge/tests/it/repros.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,6 @@ test_repro!(10586);
416416

417417
// https://github.com/foundry-rs/foundry/issues/10957
418418
test_repro!(10957);
419+
420+
// https://github.com/foundry-rs/foundry/issues/11353
421+
test_repro!(11353);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
pragma solidity ^0.8.18;
3+
4+
import "ds-test/test.sol";
5+
import "cheats/Vm.sol";
6+
7+
contract Blobhash {
8+
function getIndices(uint256[] calldata blobIndices) public view returns (bytes32[] memory) {
9+
bytes32[] memory blobHashes = new bytes32[](blobIndices.length);
10+
for (uint256 i = 0; i < blobIndices.length; i++) {
11+
uint256 blobIndex = blobIndices[i];
12+
bytes32 blobHash = blobhash(blobIndex);
13+
require(blobHash != 0, "blob not found");
14+
blobHashes[i] = blobHash;
15+
}
16+
return blobHashes;
17+
}
18+
}
19+
20+
// https://github.com/foundry-rs/foundry/issues/11353
21+
contract Issue11353Test is DSTest {
22+
Vm constant vm = Vm(HEVM_ADDRESS);
23+
24+
Blobhash public blobhashContract;
25+
26+
function setUp() public {
27+
blobhashContract = new Blobhash();
28+
}
29+
30+
function test_blobhashes() public {
31+
uint256[] memory blobIndices = new uint256[](1);
32+
blobIndices[0] = 0;
33+
34+
bytes32[] memory blobHashes = new bytes32[](1);
35+
blobHashes[0] = keccak256(abi.encode(0));
36+
vm.blobhashes(blobHashes);
37+
38+
vm.assertEq(blobhashContract.getIndices(blobIndices), blobHashes);
39+
}
40+
}

0 commit comments

Comments
 (0)