Skip to content

Commit

Permalink
chore(executor): Use Upstreamed op-alloy Methods (#651)
Browse files Browse the repository at this point in the history
* chore(executor): use upstream system transaction method

* fix: update deps and remove utils

* fix rebase

* fixes
  • Loading branch information
refcell authored Oct 9, 2024
1 parent 54b531b commit 98f9337
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 171 deletions.
52 changes: 26 additions & 26 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 @@ -133,7 +133,7 @@ alloy-node-bindings = { version = "0.4.2", default-features = false }
alloy-transport-http = { version = "0.4.2", default-features = false }

# OP Alloy
op-alloy-consensus = { version = "0.3.3", default-features = false }
op-alloy-protocol = { version = "0.3.3", default-features = false }
op-alloy-genesis = { version = "0.3.3", default-features = false }
op-alloy-rpc-types-engine = { version = "0.3.3", default-features = false }
op-alloy-consensus = { version = "0.4.0", default-features = false }
op-alloy-protocol = { version = "0.4.0", default-features = false }
op-alloy-genesis = { version = "0.4.0", default-features = false }
op-alloy-rpc-types-engine = { version = "0.4.0", default-features = false }
17 changes: 8 additions & 9 deletions bin/client/src/l1/driver.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Contains the [DerivationDriver] struct, which handles the [OptimismPayloadAttributes] derivation
//! Contains the [DerivationDriver] struct, which handles the [OpPayloadAttributes] derivation
//! process.
//!
//! [OptimismPayloadAttributes]: op_alloy_rpc_types_engine::OptimismPayloadAttributes
//! [OpPayloadAttributes]: op_alloy_rpc_types_engine::OpPayloadAttributes
use super::OracleL1ChainProvider;
use crate::{l2::OracleL2ChainProvider, BootInfo, HintType};
Expand All @@ -28,7 +28,7 @@ use kona_providers::{ChainProvider, L2ChainProvider};
use op_alloy_consensus::OpTxType;
use op_alloy_genesis::RollupConfig;
use op_alloy_protocol::{BlockInfo, L2BlockInfo};
use op_alloy_rpc_types_engine::OptimismAttributesWithParent;
use op_alloy_rpc_types_engine::OpAttributesWithParent;
use tracing::{error, info, warn};

/// An oracle-backed derivation pipeline.
Expand Down Expand Up @@ -59,13 +59,13 @@ pub type OracleAttributesQueue<DAP, O> = AttributesQueue<
OracleAttributesBuilder<O>,
>;

/// The [DerivationDriver] struct is responsible for handling the [OptimismPayloadAttributes]
/// The [DerivationDriver] struct is responsible for handling the [OpPayloadAttributes]
/// derivation process.
///
/// It contains an inner [OraclePipeline] that is used to derive the attributes, backed by
/// oracle-based data sources.
///
/// [OptimismPayloadAttributes]: op_alloy_rpc_types_engine::OptimismPayloadAttributes
/// [OpPayloadAttributes]: op_alloy_rpc_types_engine::OpPayloadAttributes
#[derive(Debug)]
pub struct DerivationDriver<O, B>
where
Expand Down Expand Up @@ -183,8 +183,7 @@ where
H: TrieHinter + Send + Sync + Clone,
{
loop {
let OptimismAttributesWithParent { mut attributes, .. } =
self.produce_payload().await?;
let OpAttributesWithParent { mut attributes, .. } = self.produce_payload().await?;

let mut executor = self.new_executor(cfg, provider, hinter, handle_register);
let number = match executor.execute_payload(attributes.clone()) {
Expand Down Expand Up @@ -233,9 +232,9 @@ where
}
}

/// Produces the disputed [OptimismAttributesWithParent] payload, directly after the starting L2
/// Produces the disputed [OpAttributesWithParent] payload, directly after the starting L2
/// output root passed through the [BootInfo].
async fn produce_payload(&mut self) -> Result<OptimismAttributesWithParent> {
async fn produce_payload(&mut self) -> Result<OpAttributesWithParent> {
// As we start the safe head at the disputed block's parent, we step the pipeline until the
// first attributes are produced. All batches at and before the safe head will be
// dropped, so the first payload will always be the disputed one.
Expand Down
14 changes: 7 additions & 7 deletions crates/derive/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use kona_providers::{ChainProvider, L2ChainProvider};
use op_alloy_consensus::Hardforks;
use op_alloy_genesis::{RollupConfig, SystemConfig};
use op_alloy_protocol::{decode_deposit, L1BlockInfoTx, L2BlockInfo, DEPOSIT_EVENT_ABI_HASH};
use op_alloy_rpc_types_engine::OptimismPayloadAttributes;
use op_alloy_rpc_types_engine::OpPayloadAttributes;

/// The sequencer fee vault address.
pub const SEQUENCER_FEE_VAULT_ADDRESS: Address =
Expand Down Expand Up @@ -59,7 +59,7 @@ where
&mut self,
l2_parent: L2BlockInfo,
epoch: BlockNumHash,
) -> PipelineResult<OptimismPayloadAttributes> {
) -> PipelineResult<OpPayloadAttributes> {
let l1_header;
let deposit_transactions: Vec<Bytes>;

Expand Down Expand Up @@ -183,7 +183,7 @@ where
parent_beacon_root = Some(l1_header.parent_beacon_block_root.unwrap_or_default());
}

Ok(OptimismPayloadAttributes {
Ok(OpPayloadAttributes {
payload_attributes: PayloadAttributes {
timestamp: next_l2_time,
prev_randao: l1_header.mix_hash,
Expand Down Expand Up @@ -547,7 +547,7 @@ mod tests {
};
let next_l2_time = l2_parent.block_info.timestamp + block_time;
let payload = builder.prepare_payload_attributes(l2_parent, epoch).await.unwrap();
let expected = OptimismPayloadAttributes {
let expected = OpPayloadAttributes {
payload_attributes: PayloadAttributes {
timestamp: next_l2_time,
prev_randao,
Expand Down Expand Up @@ -593,7 +593,7 @@ mod tests {
};
let next_l2_time = l2_parent.block_info.timestamp + block_time;
let payload = builder.prepare_payload_attributes(l2_parent, epoch).await.unwrap();
let expected = OptimismPayloadAttributes {
let expected = OpPayloadAttributes {
payload_attributes: PayloadAttributes {
timestamp: next_l2_time,
prev_randao,
Expand Down Expand Up @@ -641,7 +641,7 @@ mod tests {
};
let next_l2_time = l2_parent.block_info.timestamp + block_time;
let payload = builder.prepare_payload_attributes(l2_parent, epoch).await.unwrap();
let expected = OptimismPayloadAttributes {
let expected = OpPayloadAttributes {
payload_attributes: PayloadAttributes {
timestamp: next_l2_time,
prev_randao,
Expand Down Expand Up @@ -688,7 +688,7 @@ mod tests {
};
let next_l2_time = l2_parent.block_info.timestamp + block_time;
let payload = builder.prepare_payload_attributes(l2_parent, epoch).await.unwrap();
let expected = OptimismPayloadAttributes {
let expected = OpPayloadAttributes {
payload_attributes: PayloadAttributes {
timestamp: next_l2_time,
prev_randao,
Expand Down
20 changes: 10 additions & 10 deletions crates/derive/src/pipeline/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::fmt::Debug;
use kona_providers::L2ChainProvider;
use op_alloy_genesis::RollupConfig;
use op_alloy_protocol::{BlockInfo, L2BlockInfo};
use op_alloy_rpc_types_engine::OptimismAttributesWithParent;
use op_alloy_rpc_types_engine::OpAttributesWithParent;
use tracing::{error, trace, warn};

/// The derivation pipeline is responsible for deriving L2 inputs from L1 data.
Expand All @@ -33,9 +33,9 @@ where
/// A handle to the next attributes.
pub attributes: S,
/// Reset provider for the pipeline.
/// A list of prepared [OptimismAttributesWithParent] to be used by the derivation pipeline
/// A list of prepared [OpAttributesWithParent] to be used by the derivation pipeline
/// consumer.
pub prepared: VecDeque<OptimismAttributesWithParent>,
pub prepared: VecDeque<OpAttributesWithParent>,
/// The rollup config.
pub rollup_config: Arc<RollupConfig>,
/// The L2 Chain Provider used to fetch the system config on reset.
Expand Down Expand Up @@ -91,7 +91,7 @@ where
+ Sync,
P: L2ChainProvider + Send + Sync + Debug,
{
type Item = OptimismAttributesWithParent;
type Item = OpAttributesWithParent;

fn next(&mut self) -> Option<Self::Item> {
self.prepared.pop_front()
Expand All @@ -111,8 +111,8 @@ where
+ Sync,
P: L2ChainProvider + Send + Sync + Debug,
{
/// Peeks at the next prepared [OptimismAttributesWithParent] from the pipeline.
fn peek(&self) -> Option<&OptimismAttributesWithParent> {
/// Peeks at the next prepared [OpAttributesWithParent] from the pipeline.
fn peek(&self) -> Option<&OpAttributesWithParent> {
self.prepared.front()
}

Expand Down Expand Up @@ -208,11 +208,11 @@ mod tests {
use kona_providers::test_utils::TestL2ChainProvider;
use op_alloy_genesis::{RollupConfig, SystemConfig};
use op_alloy_protocol::{BlockInfo, L2BlockInfo};
use op_alloy_rpc_types_engine::{OptimismAttributesWithParent, OptimismPayloadAttributes};
use op_alloy_rpc_types_engine::{OpAttributesWithParent, OpPayloadAttributes};

fn default_test_payload_attributes() -> OptimismAttributesWithParent {
OptimismAttributesWithParent {
attributes: OptimismPayloadAttributes {
fn default_test_payload_attributes() -> OpAttributesWithParent {
OpAttributesWithParent {
attributes: OpPayloadAttributes {
payload_attributes: PayloadAttributes {
timestamp: 0,
prev_randao: Default::default(),
Expand Down
Loading

0 comments on commit 98f9337

Please sign in to comment.