Skip to content

Commit 46f2d89

Browse files
mablrmattsse
andauthored
feat(cheatcodes): support both 4844/7594 formats in attachBlob (#13054)
Co-authored-by: Matthias Seitz <[email protected]>
1 parent 78ff58f commit 46f2d89

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

crates/cheatcodes/src/inspector.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use crate::{
2020
},
2121
utils::IgnoredTraces,
2222
};
23-
use alloy_consensus::BlobTransactionSidecar;
23+
use alloy_consensus::BlobTransactionSidecarVariant;
2424
use alloy_evm::eth::EthEvmContext;
25-
use alloy_network::TransactionBuilder4844;
25+
use alloy_network::{TransactionBuilder4844, TransactionBuilder7594};
2626
use alloy_primitives::{
2727
Address, B256, Bytes, Log, TxKind, U256, hex,
2828
map::{AddressHashMap, HashMap, HashSet},
@@ -392,7 +392,7 @@ pub struct Cheatcodes {
392392
pub active_delegations: Vec<SignedAuthorization>,
393393

394394
/// The active EIP-4844 blob that will be attached to the next call.
395-
pub active_blob_sidecar: Option<BlobTransactionSidecar>,
395+
pub active_blob_sidecar: Option<BlobTransactionSidecarVariant>,
396396

397397
/// The gas price.
398398
///
@@ -938,7 +938,11 @@ impl Cheatcodes {
938938
precompile_call_logs: vec![],
939939
});
940940
}
941-
tx_req.set_blob_sidecar(blob_sidecar);
941+
if blob_sidecar.is_eip4844() {
942+
tx_req.set_blob_sidecar(blob_sidecar.into_eip4844().unwrap());
943+
} else if blob_sidecar.is_eip7594() {
944+
tx_req.set_blob_sidecar_7594(blob_sidecar.into_eip7594().unwrap());
945+
}
942946
}
943947

944948
// Apply active EIP-7702 delegations, if any.

crates/cheatcodes/src/script.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,12 @@ impl Cheatcode for attachBlobCall {
228228
see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844"
229229
);
230230
let sidecar: SidecarBuilder<SimpleCoder> = SidecarBuilder::from_slice(blob);
231-
let sidecar = sidecar.build().map_err(|e| format!("{e}"))?;
232-
ccx.state.active_blob_sidecar = Some(sidecar);
231+
let sidecar_variant = if ccx.ecx.cfg.spec < SpecId::OSAKA {
232+
sidecar.build_4844().map_err(|e| format!("{e}"))?.into()
233+
} else {
234+
sidecar.build_7594().map_err(|e| format!("{e}"))?.into()
235+
};
236+
ccx.state.active_blob_sidecar = Some(sidecar_variant);
233237
Ok(Default::default())
234238
}
235239
}

0 commit comments

Comments
 (0)