From 2dd0c39e0f4edb43f0ee6b5e529b90e4271ca7a3 Mon Sep 17 00:00:00 2001 From: 0xferrous <0xferrous@proton.me> Date: Mon, 12 Jan 2026 10:02:22 +0000 Subject: [PATCH 1/2] fix: impl Tx for the BlobTransactionSidecarVariant recently introduced upstream --- src/fill/alloy.rs | 70 ++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/src/fill/alloy.rs b/src/fill/alloy.rs index 355c2fa..0413d8d 100644 --- a/src/fill/alloy.rs +++ b/src/fill/alloy.rs @@ -2,8 +2,8 @@ use crate::{Block, Tx}; use alloy::{ consensus::{ transaction::{Recovered, SignerRecoverable}, - BlobTransactionSidecar, EthereumTxEnvelope, Signed, TxEip4844, TxEip4844WithSidecar, - TxEnvelope, TxType, + BlobTransactionSidecar, BlobTransactionSidecarVariant, EthereumTxEnvelope, Signed, + TxEip4844, TxEip4844WithSidecar, TxEnvelope, TxType, }, eips::eip7594::BlobTransactionSidecarEip7594, primitives::U256, @@ -47,6 +47,7 @@ delegate_alloy_txs!(alloy::consensus::TxEip1559); delegate_alloy_txs!(alloy::consensus::TxEip4844); delegate_alloy_txs!(alloy::consensus::TxEip4844WithSidecar); delegate_alloy_txs!(alloy::consensus::TxEip4844WithSidecar); +delegate_alloy_txs!(alloy::consensus::TxEip4844WithSidecar); delegate_alloy_txs!(alloy::consensus::TxEip4844Variant); delegate_alloy_txs!(alloy::consensus::TxEip7702); @@ -56,6 +57,9 @@ delegate_alloy_txs!(@envelope EthereumTxEnvelope> ); +delegate_alloy_txs!( + @envelope EthereumTxEnvelope> +); impl Tx for Recovered<&alloy::consensus::TxLegacy> { fn fill_tx_env(&self, tx_env: &mut TxEnv) { @@ -197,42 +201,10 @@ impl Tx for Recovered<&alloy::consensus::TxEip4844> { } } -impl Tx for Recovered<&alloy::consensus::TxEip4844WithSidecar> { - fn fill_tx_env(&self, tx_env: &mut TxEnv) { - let TxEnv { - tx_type, - caller, - gas_limit, - gas_price, - kind, - value, - data, - nonce, - chain_id, - access_list, - gas_priority_fee, - blob_hashes, - max_fee_per_blob_gas, - authorization_list, - } = tx_env; - *tx_type = TxType::Eip4844 as u8; - *caller = self.signer(); - *gas_limit = self.inner().tx.gas_limit; - *gas_price = self.inner().tx.max_fee_per_gas; - *kind = self.inner().tx.to.into(); - *value = self.inner().tx.value; - *data = self.inner().tx.input.clone(); - *nonce = self.inner().tx.nonce; - *chain_id = Some(self.inner().tx.chain_id); - access_list.clone_from(&self.inner().tx.access_list); - *gas_priority_fee = Some(self.inner().tx.max_priority_fee_per_gas); - blob_hashes.clone_from(&self.inner().tx.blob_versioned_hashes); - *max_fee_per_blob_gas = self.inner().tx.max_fee_per_blob_gas; - authorization_list.clear(); - } -} - -impl Tx for Recovered<&alloy::consensus::TxEip4844WithSidecar> { +impl Tx for Recovered<&alloy::consensus::TxEip4844WithSidecar> +where + T: Send + Sync, +{ fn fill_tx_env(&self, tx_env: &mut TxEnv) { let TxEnv { tx_type, @@ -407,6 +379,28 @@ impl Tx for Recovered<&EthereumTxEnvelope>> { + fn fill_tx_env(&self, tx_env: &mut TxEnv) { + match self.inner() { + EthereumTxEnvelope::Legacy(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + EthereumTxEnvelope::Eip2930(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + EthereumTxEnvelope::Eip1559(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + EthereumTxEnvelope::Eip4844(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + EthereumTxEnvelope::Eip7702(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + } + } +} + impl Block for alloy::consensus::Header { fn fill_block_env(&self, block_env: &mut BlockEnv) { let BlockEnv { From 0e43d74fddde461217557d32a4914903022209dd Mon Sep 17 00:00:00 2001 From: 0xferrous <0xferrous@proton.me> Date: Mon, 12 Jan 2026 13:24:45 +0000 Subject: [PATCH 2/2] chore: macro for duplicate impl generation for sidecar types --- Cargo.toml | 2 +- src/fill/alloy.rs | 163 +++++++++++++++++++--------------------------- 2 files changed, 67 insertions(+), 98 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b63730e..bebc8f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ name = "fork_ref_transact" required-features = ["alloy-db"] [dependencies] -alloy = { version = "1.0.35", default-features = false, features = [ +alloy = { version = "1.4.0", default-features = false, features = [ "consensus", "rpc-types-mev", "eips", diff --git a/src/fill/alloy.rs b/src/fill/alloy.rs index 0413d8d..0857313 100644 --- a/src/fill/alloy.rs +++ b/src/fill/alloy.rs @@ -201,44 +201,49 @@ impl Tx for Recovered<&alloy::consensus::TxEip4844> { } } -impl Tx for Recovered<&alloy::consensus::TxEip4844WithSidecar> -where - T: Send + Sync, -{ - fn fill_tx_env(&self, tx_env: &mut TxEnv) { - let TxEnv { - tx_type, - caller, - gas_limit, - gas_price, - kind, - value, - data, - nonce, - chain_id, - access_list, - gas_priority_fee, - blob_hashes, - max_fee_per_blob_gas, - authorization_list, - } = tx_env; - *tx_type = TxType::Eip4844 as u8; - *caller = self.signer(); - *gas_limit = self.inner().tx.gas_limit; - *gas_price = self.inner().tx.max_fee_per_gas; - *kind = self.inner().tx.to.into(); - *value = self.inner().tx.value; - *data = self.inner().tx.input.clone(); - *nonce = self.inner().tx.nonce; - *chain_id = Some(self.inner().tx.chain_id); - access_list.clone_from(&self.inner().tx.access_list); - *gas_priority_fee = Some(self.inner().tx.max_priority_fee_per_gas); - blob_hashes.clone_from(&self.inner().tx.blob_versioned_hashes); - *max_fee_per_blob_gas = self.inner().tx.max_fee_per_blob_gas; - authorization_list.clear(); - } +macro_rules! impl_tx_eip4844_with_sidecar { + ($target:ty) => { + impl Tx for Recovered<&alloy::consensus::TxEip4844WithSidecar<$target>> { + fn fill_tx_env(&self, tx_env: &mut TxEnv) { + let TxEnv { + tx_type, + caller, + gas_limit, + gas_price, + kind, + value, + data, + nonce, + chain_id, + access_list, + gas_priority_fee, + blob_hashes, + max_fee_per_blob_gas, + authorization_list, + } = tx_env; + *tx_type = TxType::Eip4844 as u8; + *caller = self.signer(); + *gas_limit = self.inner().tx.gas_limit; + *gas_price = self.inner().tx.max_fee_per_gas; + *kind = self.inner().tx.to.into(); + *value = self.inner().tx.value; + *data = self.inner().tx.input.clone(); + *nonce = self.inner().tx.nonce; + *chain_id = Some(self.inner().tx.chain_id); + access_list.clone_from(&self.inner().tx.access_list); + *gas_priority_fee = Some(self.inner().tx.max_priority_fee_per_gas); + blob_hashes.clone_from(&self.inner().tx.blob_versioned_hashes); + *max_fee_per_blob_gas = self.inner().tx.max_fee_per_blob_gas; + authorization_list.clear(); + } + } + }; } +impl_tx_eip4844_with_sidecar!(BlobTransactionSidecar); +impl_tx_eip4844_with_sidecar!(BlobTransactionSidecarEip7594); +impl_tx_eip4844_with_sidecar!(BlobTransactionSidecarVariant); + impl Tx for Recovered<&alloy::consensus::TxEip4844Variant> { fn fill_tx_env(&self, tx_env: &mut TxEnv) { match self.inner() { @@ -335,71 +340,35 @@ impl Tx for Recovered<&EthereumTxEnvelope> { } } -impl Tx for Recovered<&EthereumTxEnvelope>> { - fn fill_tx_env(&self, tx_env: &mut TxEnv) { - match self.inner() { - EthereumTxEnvelope::Legacy(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip2930(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip1559(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip4844(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip7702(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - } - } -} - -impl Tx for Recovered<&EthereumTxEnvelope>> { - fn fill_tx_env(&self, tx_env: &mut TxEnv) { - match self.inner() { - EthereumTxEnvelope::Legacy(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip2930(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip1559(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip4844(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip7702(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) +macro_rules! impl_tx_eip4744_envelope_with_sidecar { + ($target:ty) => { + impl Tx for Recovered<&EthereumTxEnvelope>> { + fn fill_tx_env(&self, tx_env: &mut TxEnv) { + match self.inner() { + EthereumTxEnvelope::Legacy(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + EthereumTxEnvelope::Eip2930(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + EthereumTxEnvelope::Eip1559(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + EthereumTxEnvelope::Eip4844(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + EthereumTxEnvelope::Eip7702(t) => { + Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) + } + } } } - } + }; } -impl Tx for Recovered<&EthereumTxEnvelope>> { - fn fill_tx_env(&self, tx_env: &mut TxEnv) { - match self.inner() { - EthereumTxEnvelope::Legacy(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip2930(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip1559(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip4844(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - EthereumTxEnvelope::Eip7702(t) => { - Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) - } - } - } -} +impl_tx_eip4744_envelope_with_sidecar!(BlobTransactionSidecar); +impl_tx_eip4744_envelope_with_sidecar!(BlobTransactionSidecarEip7594); +impl_tx_eip4744_envelope_with_sidecar!(BlobTransactionSidecarVariant); impl Block for alloy::consensus::Header { fn fill_block_env(&self, block_env: &mut BlockEnv) {