Skip to content

Commit

Permalink
chore: bump op-alloy (paradigmxyz#11617)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored and ebo committed Oct 14, 2024
1 parent b48be36 commit 1f9405a
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 70 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@ alloy-transport-ipc = { version = "0.4.2", default-features = false }
alloy-transport-ws = { version = "0.4.2", default-features = false }

# op
op-alloy-rpc-types = "0.3.2"
op-alloy-rpc-types-engine = "0.3.2"
op-alloy-network = "0.3.2"
op-alloy-consensus = "0.3.2"
op-alloy-rpc-types = "0.4"
op-alloy-rpc-types-engine = "0.4"
op-alloy-network = "0.4"
op-alloy-consensus = "0.4"

# misc
aquamarine = "0.5"
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e-test-utils/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use op_alloy_rpc_types_engine::OptimismExecutionPayloadEnvelopeV3;
use op_alloy_rpc_types_engine::OpExecutionPayloadEnvelopeV3;
use reth::rpc::types::engine::{ExecutionPayloadEnvelopeV3, ExecutionPayloadV3};

/// The execution payload envelope type.
Expand All @@ -7,7 +7,7 @@ pub trait PayloadEnvelopeExt: Send + Sync + std::fmt::Debug {
fn execution_payload(&self) -> ExecutionPayloadV3;
}

impl PayloadEnvelopeExt for OptimismExecutionPayloadEnvelopeV3 {
impl PayloadEnvelopeExt for OpExecutionPayloadEnvelopeV3 {
fn execution_payload(&self) -> ExecutionPayloadV3 {
self.execution_payload.clone()
}
Expand Down
10 changes: 5 additions & 5 deletions crates/optimism/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ impl From<Genesis> for OpChainSpec {

#[derive(Default, Debug)]
struct OptimismGenesisInfo {
optimism_chain_info: op_alloy_rpc_types::genesis::OptimismChainInfo,
optimism_chain_info: op_alloy_rpc_types::genesis::OpChainInfo,
base_fee_params: BaseFeeParamsKind,
}

impl OptimismGenesisInfo {
fn extract_from(genesis: &Genesis) -> Self {
let mut info = Self {
optimism_chain_info: op_alloy_rpc_types::genesis::OptimismChainInfo::extract_from(
optimism_chain_info: op_alloy_rpc_types::genesis::OpChainInfo::extract_from(
&genesis.config.extra_fields,
)
.unwrap_or_default(),
Expand Down Expand Up @@ -622,7 +622,7 @@ mod tests {

#[test]
fn parse_genesis_optimism_with_variable_base_fee_params() {
use op_alloy_rpc_types::genesis::OptimismBaseFeeInfo;
use op_alloy_rpc_types::genesis::OpBaseFeeInfo;

let geth_genesis = r#"
{
Expand Down Expand Up @@ -673,11 +673,11 @@ mod tests {

let optimism_object = genesis.config.extra_fields.get("optimism").unwrap();
let optimism_base_fee_info =
serde_json::from_value::<OptimismBaseFeeInfo>(optimism_object.clone()).unwrap();
serde_json::from_value::<OpBaseFeeInfo>(optimism_object.clone()).unwrap();

assert_eq!(
optimism_base_fee_info,
OptimismBaseFeeInfo {
OpBaseFeeInfo {
eip1559_elasticity: Some(6),
eip1559_denominator: Some(50),
eip1559_denominator_canyon: None,
Expand Down
19 changes: 9 additions & 10 deletions crates/optimism/node/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::sync::Arc;

use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1};
use op_alloy_rpc_types_engine::{
OptimismExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV4,
OptimismPayloadAttributes,
OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4, OpPayloadAttributes,
};
use reth_chainspec::ChainSpec;
use reth_node_api::{
Expand Down Expand Up @@ -35,13 +34,13 @@ impl<T: PayloadTypes> EngineTypes for OptimismEngineTypes<T>
where
T::BuiltPayload: TryInto<ExecutionPayloadV1>
+ TryInto<ExecutionPayloadEnvelopeV2>
+ TryInto<OptimismExecutionPayloadEnvelopeV3>
+ TryInto<OptimismExecutionPayloadEnvelopeV4>,
+ TryInto<OpExecutionPayloadEnvelopeV3>
+ TryInto<OpExecutionPayloadEnvelopeV4>,
{
type ExecutionPayloadV1 = ExecutionPayloadV1;
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
type ExecutionPayloadV3 = OptimismExecutionPayloadEnvelopeV3;
type ExecutionPayloadV4 = OptimismExecutionPayloadEnvelopeV4;
type ExecutionPayloadV3 = OpExecutionPayloadEnvelopeV3;
type ExecutionPayloadV4 = OpExecutionPayloadEnvelopeV4;
}

/// A default payload type for [`OptimismEngineTypes`]
Expand All @@ -51,7 +50,7 @@ pub struct OptimismPayloadTypes;

impl PayloadTypes for OptimismPayloadTypes {
type BuiltPayload = OptimismBuiltPayload;
type PayloadAttributes = OptimismPayloadAttributes;
type PayloadAttributes = OpPayloadAttributes;
type PayloadBuilderAttributes = OptimismPayloadBuilderAttributes;
}

Expand Down Expand Up @@ -112,12 +111,12 @@ pub fn validate_withdrawals_presence(

impl<Types> EngineValidator<Types> for OptimismEngineValidator
where
Types: EngineTypes<PayloadAttributes = OptimismPayloadAttributes>,
Types: EngineTypes<PayloadAttributes = OpPayloadAttributes>,
{
fn validate_version_specific_fields(
&self,
version: EngineApiMessageVersion,
payload_or_attrs: PayloadOrAttributes<'_, OptimismPayloadAttributes>,
payload_or_attrs: PayloadOrAttributes<'_, OpPayloadAttributes>,
) -> Result<(), EngineObjectValidationError> {
validate_withdrawals_presence(
&self.chain_spec,
Expand All @@ -138,7 +137,7 @@ where
fn ensure_well_formed_attributes(
&self,
version: EngineApiMessageVersion,
attributes: &OptimismPayloadAttributes,
attributes: &OpPayloadAttributes,
) -> Result<(), EngineObjectValidationError> {
validate_version_specific_fields(&self.chain_spec, version, attributes.into())?;

Expand Down
4 changes: 1 addition & 3 deletions crates/optimism/payload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ pub mod builder;
pub use builder::OptimismPayloadBuilder;
pub mod error;
pub mod payload;
pub use payload::{
OptimismBuiltPayload, OptimismPayloadAttributes, OptimismPayloadBuilderAttributes,
};
pub use payload::{OpPayloadAttributes, OptimismBuiltPayload, OptimismPayloadBuilderAttributes};
21 changes: 8 additions & 13 deletions crates/optimism/payload/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use alloy_primitives::{Address, B256, U256};
use alloy_rlp::Encodable;
use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId};
/// Re-export for use in downstream arguments.
pub use op_alloy_rpc_types_engine::OptimismPayloadAttributes;
use op_alloy_rpc_types_engine::{
OptimismExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV4,
};
pub use op_alloy_rpc_types_engine::OpPayloadAttributes;
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4};
use reth_chain_state::ExecutedBlock;
use reth_chainspec::EthereumHardforks;
use reth_optimism_chainspec::OpChainSpec;
Expand Down Expand Up @@ -40,13 +38,13 @@ pub struct OptimismPayloadBuilderAttributes {
}

impl PayloadBuilderAttributes for OptimismPayloadBuilderAttributes {
type RpcPayloadAttributes = OptimismPayloadAttributes;
type RpcPayloadAttributes = OpPayloadAttributes;
type Error = alloy_rlp::Error;

/// Creates a new payload builder for the given parent block and the attributes.
///
/// Derives the unique [`PayloadId`] for the given parent and attributes
fn try_new(parent: B256, attributes: OptimismPayloadAttributes) -> Result<Self, Self::Error> {
fn try_new(parent: B256, attributes: OpPayloadAttributes) -> Result<Self, Self::Error> {
let id = payload_id_optimism(&parent, &attributes);

let transactions = attributes
Expand Down Expand Up @@ -213,7 +211,7 @@ impl From<OptimismBuiltPayload> for ExecutionPayloadEnvelopeV2 {
}
}

impl From<OptimismBuiltPayload> for OptimismExecutionPayloadEnvelopeV3 {
impl From<OptimismBuiltPayload> for OpExecutionPayloadEnvelopeV3 {
fn from(value: OptimismBuiltPayload) -> Self {
let OptimismBuiltPayload { block, fees, sidecars, chain_spec, attributes, .. } = value;

Expand All @@ -240,7 +238,7 @@ impl From<OptimismBuiltPayload> for OptimismExecutionPayloadEnvelopeV3 {
}
}
}
impl From<OptimismBuiltPayload> for OptimismExecutionPayloadEnvelopeV4 {
impl From<OptimismBuiltPayload> for OpExecutionPayloadEnvelopeV4 {
fn from(value: OptimismBuiltPayload) -> Self {
let OptimismBuiltPayload { block, fees, sidecars, chain_spec, attributes, .. } = value;

Expand Down Expand Up @@ -268,13 +266,10 @@ impl From<OptimismBuiltPayload> for OptimismExecutionPayloadEnvelopeV4 {
}
}

/// Generates the payload id for the configured payload from the [`OptimismPayloadAttributes`].
/// Generates the payload id for the configured payload from the [`OpPayloadAttributes`].
///
/// Returns an 8-byte identifier by hashing the payload components with sha256 hash.
pub(crate) fn payload_id_optimism(
parent: &B256,
attributes: &OptimismPayloadAttributes,
) -> PayloadId {
pub(crate) fn payload_id_optimism(parent: &B256, attributes: &OpPayloadAttributes) -> PayloadId {
use sha2::Digest;
let mut hasher = sha2::Sha256::new();
hasher.update(parent.as_slice());
Expand Down
32 changes: 14 additions & 18 deletions crates/optimism/rpc/src/eth/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
use alloy_eips::eip2718::Encodable2718;
use alloy_rpc_types::{AnyReceiptEnvelope, Log, TransactionReceipt};
use op_alloy_consensus::{OpDepositReceipt, OpDepositReceiptWithBloom, OpReceiptEnvelope};
use op_alloy_rpc_types::{
receipt::L1BlockInfo, OpTransactionReceipt, OptimismTransactionReceiptFields,
};
use op_alloy_rpc_types::{receipt::L1BlockInfo, OpTransactionReceipt, OpTransactionReceiptFields};
use reth_chainspec::ChainSpec;
use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_optimism_chainspec::OpChainSpec;
Expand Down Expand Up @@ -68,7 +66,7 @@ where
tx: &TransactionSigned,
l1_block_info: revm::L1BlockInfo,
receipt: &Receipt,
) -> Result<OptimismTransactionReceiptFields, OpEthApiError> {
) -> Result<OpTransactionReceiptFields, OpEthApiError> {
Ok(OpReceiptFieldsBuilder::default()
.l1_block_info(&self.inner.provider().chain_spec(), tx, l1_block_info)?
.deposit_nonce(receipt.deposit_nonce)
Expand Down Expand Up @@ -162,8 +160,8 @@ impl OpReceiptFieldsBuilder {
self
}

/// Builds the [`OptimismTransactionReceiptFields`] object.
pub const fn build(self) -> OptimismTransactionReceiptFields {
/// Builds the [`OpTransactionReceiptFields`] object.
pub const fn build(self) -> OpTransactionReceiptFields {
let Self {
l1_block_timestamp: _, // used to compute other fields
l1_fee,
Expand All @@ -177,7 +175,7 @@ impl OpReceiptFieldsBuilder {
l1_blob_base_fee_scalar,
} = self;

OptimismTransactionReceiptFields {
OpTransactionReceiptFields {
l1_block_info: L1BlockInfo {
l1_gas_price,
l1_gas_used,
Expand All @@ -201,7 +199,7 @@ pub struct OpReceiptBuilder {
/// Transaction type.
pub tx_type: TxType,
/// Additional OP receipt fields.
pub op_receipt_fields: OptimismTransactionReceiptFields,
pub op_receipt_fields: OpTransactionReceiptFields,
}

impl OpReceiptBuilder {
Expand Down Expand Up @@ -234,11 +232,8 @@ impl OpReceiptBuilder {
pub fn build(self) -> OpTransactionReceipt {
let Self { core_receipt, tx_type, op_receipt_fields } = self;

let OptimismTransactionReceiptFields {
l1_block_info,
deposit_nonce,
deposit_receipt_version,
} = op_receipt_fields;
let OpTransactionReceiptFields { l1_block_info, deposit_nonce, deposit_receipt_version } =
op_receipt_fields;

let TransactionReceipt {
inner: AnyReceiptEnvelope { inner: receipt_with_bloom, .. },
Expand All @@ -261,10 +256,11 @@ impl OpReceiptBuilder {
TxType::Legacy => OpReceiptEnvelope::<Log>::Legacy(receipt_with_bloom),
TxType::Eip2930 => OpReceiptEnvelope::<Log>::Eip2930(receipt_with_bloom),
TxType::Eip1559 => OpReceiptEnvelope::<Log>::Eip1559(receipt_with_bloom),
TxType::Eip4844 => OpReceiptEnvelope::<Log>::Eip4844(receipt_with_bloom),
TxType::Eip7702 => {
unimplemented!("not implemented yet for OpReceiptEnvelope")
TxType::Eip4844 => {
// TODO: unreachable
OpReceiptEnvelope::<Log>::Eip1559(receipt_with_bloom)
}
TxType::Eip7702 => OpReceiptEnvelope::<Log>::Eip7702(receipt_with_bloom),
TxType::Deposit => {
OpReceiptEnvelope::<Log>::Deposit(OpDepositReceiptWithBloom::<Log> {
receipt: OpDepositReceipt::<Log> {
Expand Down Expand Up @@ -325,8 +321,8 @@ mod test {
/// L1 block info for transaction at index 1 in block 124665056.
///
/// <https://optimistic.etherscan.io/tx/0x1059e8004daff32caa1f1b1ef97fe3a07a8cf40508f5b835b66d9420d87c4a4a>
const TX_META_TX_1_OP_MAINNET_BLOCK_124665056: OptimismTransactionReceiptFields =
OptimismTransactionReceiptFields {
const TX_META_TX_1_OP_MAINNET_BLOCK_124665056: OpTransactionReceiptFields =
OpTransactionReceiptFields {
l1_block_info: L1BlockInfo {
l1_gas_price: Some(1055991687), // since bedrock l1 base fee
l1_gas_used: Some(4471),
Expand Down
4 changes: 2 additions & 2 deletions crates/payload/primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy_rpc_types::{
engine::{PayloadAttributes as EthPayloadAttributes, PayloadId},
Withdrawal,
};
use op_alloy_rpc_types_engine::OptimismPayloadAttributes;
use op_alloy_rpc_types_engine::OpPayloadAttributes;
use reth_chain_state::ExecutedBlock;
use reth_primitives::{SealedBlock, Withdrawals};
use std::{future::Future, pin::Pin};
Expand Down Expand Up @@ -145,7 +145,7 @@ impl PayloadAttributes for EthPayloadAttributes {
}
}

impl PayloadAttributes for OptimismPayloadAttributes {
impl PayloadAttributes for OpPayloadAttributes {
fn timestamp(&self) -> u64 {
self.payload_attributes.timestamp
}
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/alloy_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl TryFrom<WithOtherFields<alloy_rpc_types::Transaction>> for Transaction {
#[cfg(feature = "optimism")]
Some(TxType::Deposit) => {
let fields = other
.deserialize_into::<op_alloy_rpc_types::OptimismTransactionFields>()
.deserialize_into::<op_alloy_rpc_types::OpTransactionFields>()
.map_err(|e| ConversionError::Custom(e.to_string()))?;
Ok(Self::Deposit(op_alloy_consensus::TxDeposit {
source_hash: fields
Expand Down

0 comments on commit 1f9405a

Please sign in to comment.