chore: bump revm and op-alloy (#16429)

Co-authored-by: Ishika Choudhury <117741714+Rimeeeeee@users.noreply.github.com>
This commit is contained in:
Matthias Seitz
2025-05-23 13:22:18 +02:00
committed by GitHub
parent b76d4f6617
commit ecbdf45654
9 changed files with 198 additions and 244 deletions

View File

@@ -17,7 +17,7 @@
extern crate alloc;
use alloc::{borrow::Cow, sync::Arc, vec::Vec};
use alloc::{borrow::Cow, sync::Arc};
use alloy_consensus::{BlockHeader, Header};
pub use alloy_evm::EthEvm;
use alloy_evm::{
@@ -101,19 +101,6 @@ impl<EvmFactory> EthEvmConfig<EvmFactory> {
self.executor_factory.spec()
}
/// Returns blob params by hard fork as specified in chain spec.
/// Blob params are in format `(spec id, target blob count, max blob count)`.
pub fn blob_max_and_target_count_by_hardfork(&self) -> Vec<(SpecId, u64, u64)> {
let cancun = self.chain_spec().blob_params.cancun();
let prague = self.chain_spec().blob_params.prague();
let osaka = self.chain_spec().blob_params.osaka();
Vec::from([
(SpecId::CANCUN, cancun.target_blob_count, cancun.max_blob_count),
(SpecId::PRAGUE, prague.target_blob_count, prague.max_blob_count),
(SpecId::OSAKA, osaka.target_blob_count, osaka.max_blob_count),
])
}
/// Sets the extra data for the block assembler.
pub fn with_extra_data(mut self, extra_data: Bytes) -> Self {
self.block_assembler.extra_data = extra_data;
@@ -151,20 +138,21 @@ where
}
fn evm_env(&self, header: &Header) -> EvmEnv {
let blob_params = self.chain_spec().blob_params_at_timestamp(header.timestamp);
let spec = config::revm_spec(self.chain_spec(), header);
// configure evm env based on parent block
let cfg_env = CfgEnv::new()
.with_chain_id(self.chain_spec().chain().id())
.with_spec(spec)
.with_blob_max_and_target_count(self.blob_max_and_target_count_by_hardfork());
let mut cfg_env =
CfgEnv::new().with_chain_id(self.chain_spec().chain().id()).with_spec(spec);
if let Some(blob_params) = &blob_params {
cfg_env.set_blob_max_count(blob_params.max_blob_count);
}
// derive the EIP-4844 blob fees from the header's `excess_blob_gas` and the current
// blobparams
let blob_excess_gas_and_price = header
.excess_blob_gas
.zip(self.chain_spec().blob_params_at_timestamp(header.timestamp))
.map(|(excess_blob_gas, params)| {
let blob_excess_gas_and_price =
header.excess_blob_gas.zip(blob_params).map(|(excess_blob_gas, params)| {
let blob_gasprice = params.calc_blob_fee(excess_blob_gas);
BlobExcessGasAndPrice { excess_blob_gas, blob_gasprice }
});
@@ -189,19 +177,22 @@ where
attributes: &NextBlockEnvAttributes,
) -> Result<EvmEnv, Self::Error> {
// ensure we're not missing any timestamp based hardforks
let chain_spec = self.chain_spec();
let blob_params = chain_spec.blob_params_at_timestamp(attributes.timestamp);
let spec_id = revm_spec_by_timestamp_and_block_number(
self.chain_spec(),
chain_spec,
attributes.timestamp,
parent.number() + 1,
);
// configure evm env based on parent block
let cfg = CfgEnv::new()
.with_chain_id(self.chain_spec().chain().id())
.with_spec(spec_id)
.with_blob_max_and_target_count(self.blob_max_and_target_count_by_hardfork());
let mut cfg =
CfgEnv::new().with_chain_id(self.chain_spec().chain().id()).with_spec(spec_id);
if let Some(blob_params) = &blob_params {
cfg.set_blob_max_count(blob_params.max_blob_count);
}
let blob_params = self.chain_spec().blob_params_at_timestamp(attributes.timestamp);
// if the parent block did not have excess blob gas (i.e. it was pre-cancun), but it is
// cancun now, we need to set the excess blob gas to the default value(0)
let blob_excess_gas_and_price = parent

View File

@@ -70,7 +70,7 @@ where
cancun::ensure_well_formed_header_and_sidecar_fields(
&sealed_block,
sidecar.canyon(),
sidecar.ecotone(),
self.is_cancun_active_at_timestamp(sealed_block.timestamp),
)?;

View File

@@ -505,15 +505,6 @@ impl<'a> arbitrary::Arbitrary<'a> for OpTransactionSigned {
)
.unwrap();
// Both `Some(0)` and `None` values are encoded as empty string byte. This introduces
// ambiguity in roundtrip tests. Patch the mint value of deposit transaction here, so that
// it's `None` if zero.
if let OpTypedTransaction::Deposit(ref mut tx_deposit) = transaction {
if tx_deposit.mint == Some(0) {
tx_deposit.mint = None;
}
}
let signature = if transaction.is_deposit() { TxDeposit::signature() } else { signature };
Ok(Self::new_unhashed(transaction, signature))

View File

@@ -113,11 +113,7 @@ where
}
});
// For consistency with op-geth, we always return `0x0` for mint if it is
// missing This is because op-geth does not distinguish
// between null and 0, because this value is decoded from RLP where null is
// represented as 0
tx.inner_mut().mint = Some(tx.mint.unwrap_or_default());
tx.inner_mut().mint = tx.mint;
}
let TransactionInfo {

View File

@@ -337,7 +337,7 @@ mod tests {
source_hash: Default::default(),
from: signer,
to: TxKind::Create,
mint: None,
mint: 0,
value: U256::ZERO,
gas_limit: 0,
is_system_transaction: false,

View File

@@ -116,7 +116,6 @@ where
TransferKind::Create => OperationType::OpCreate,
TransferKind::Create2 => OperationType::OpCreate2,
TransferKind::SelfDestruct => OperationType::OpSelfDestruct,
TransferKind::EofCreate => OperationType::OpEofCreate,
},
})
.collect::<Vec<_>>()

View File

@@ -53,7 +53,10 @@ impl Compact for AlloyTxDeposit {
source_hash: self.source_hash,
from: self.from,
to: self.to,
mint: self.mint,
mint: match self.mint {
0 => None,
v => Some(v),
},
value: self.value,
gas_limit: self.gas_limit,
is_system_transaction: self.is_system_transaction,
@@ -68,7 +71,7 @@ impl Compact for AlloyTxDeposit {
source_hash: tx.source_hash,
from: tx.from,
to: tx.to,
mint: tx.mint,
mint: tx.mint.unwrap_or_default(),
value: tx.value,
gas_limit: tx.gas_limit,
is_system_transaction: tx.is_system_transaction,