Skip to content

Commit

Permalink
feat(primitives): Remove Attributes (#529)
Browse files Browse the repository at this point in the history
* feat: remove attributes

* fixes
  • Loading branch information
refcell committed Sep 17, 2024
1 parent f639744 commit f79724c
Show file tree
Hide file tree
Showing 22 changed files with 394 additions and 332 deletions.
58 changes: 46 additions & 12 deletions Cargo.lock

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

13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ lto = "fat"
op-alloy-protocol = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }
op-alloy-consensus = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }
op-alloy-genesis = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }
op-alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }

[workspace.dependencies]
# Workspace
Expand Down Expand Up @@ -97,7 +98,7 @@ serde_json = { version = "1.0.125", default-features = false }
unsigned-varint = "0.8.0"
revm = { version = "14.0", default-features = false }

# Superchain
# Optimism
superchain = { version = "0.5", default-features = false }

# K/V database
Expand All @@ -106,15 +107,19 @@ rocksdb = { version = "0.22", default-features = false, features = ["snappy"] }
# Alloy
alloy-rlp = { version = "0.3.8", default-features = false }
alloy-trie = { version = "0.5", default-features = false }
alloy-eips = { version = "0.3.5", default-features = false }
alloy-provider = { version = "0.3.5", default-features = false }
alloy-primitives = { version = "0.8", default-features = false }
alloy-rpc-types = { version = "0.3.5", default-features = false }
alloy-consensus = { version = "0.3.5", default-features = false }
alloy-transport = { version = "0.3.5", default-features = false }
alloy-transport-http = { version = "0.3.5", default-features = false }
alloy-eips = { version = "0.3.5", default-features = false }
alloy-rpc-types = { version = "0.3.5", default-features = false }
alloy-rpc-client = { version = "0.3.5", default-features = false }
alloy-rpc-types-engine = { version = "0.3.5", default-features = false }
alloy-node-bindings = { version = "0.3.5", default-features = false }
alloy-transport-http = { version = "0.3.5", default-features = false }

# OP Alloy
op-alloy-consensus = { version = "0.2.11", default-features = false }
op-alloy-protocol = { version = "0.2.11", default-features = false }
op-alloy-genesis = { version = "0.2.11", default-features = false }
op-alloy-rpc-types-engine = { version = "0.2.11", default-features = false }
4 changes: 3 additions & 1 deletion bin/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ kona-derive.workspace = true
kona-executor.workspace = true
kona-primitives = { workspace = true, features = ["serde"] }
op-alloy-genesis = { workspace = true, features = ["serde"] }
op-alloy-protocol = { workspace = true, features = ["serde"] }
op-alloy-protocol.workspace = true
op-alloy-rpc-types-engine.workspace = true
alloy-rpc-types-engine.workspace = true

# Revm + Alloy
revm.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions bin/client/src/kona.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use kona_client::{
};
use kona_common_proc::client_entry;
use kona_executor::StatelessL2BlockExecutor;
use kona_primitives::L2AttributesWithParent;
use op_alloy_rpc_types_engine::OptimismAttributesWithParent;

pub(crate) mod fault;
use fault::{fpvm_handle_register, HINT_WRITER, ORACLE_READER};
Expand Down Expand Up @@ -58,7 +58,8 @@ fn main() -> Result<()> {
l2_provider.clone(),
)
.await?;
let L2AttributesWithParent { attributes, .. } = driver.produce_disputed_payload().await?;
let OptimismAttributesWithParent { attributes, .. } =
driver.produce_disputed_payload().await?;

let mut executor = StatelessL2BlockExecutor::builder(&boot.rollup_config)
.with_parent_header(driver.take_l2_safe_head_header())
Expand Down
16 changes: 8 additions & 8 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 [L2PayloadAttributes] derivation
//! Contains the [DerivationDriver] struct, which handles the [OptimismPayloadAttributes] derivation
//! process.
//!
//! [L2PayloadAttributes]: kona_primitives::L2PayloadAttributes
//! [OptimismPayloadAttributes]: op_alloy_rpc_types_engine::OptimismPayloadAttributes

use super::OracleL1ChainProvider;
use crate::{l2::OracleL2ChainProvider, BootInfo, HintType};
Expand All @@ -21,8 +21,8 @@ use kona_derive::{
};
use kona_mpt::TrieDBFetcher;
use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType};
use kona_primitives::L2AttributesWithParent;
use op_alloy_protocol::{BlockInfo, L2BlockInfo};
use op_alloy_rpc_types_engine::OptimismAttributesWithParent;
use tracing::{info, warn};

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

/// The [DerivationDriver] struct is responsible for handling the [L2PayloadAttributes] derivation
/// process.
/// The [DerivationDriver] struct is responsible for handling the [OptimismPayloadAttributes]
/// derivation process.
///
/// It contains an inner [OraclePipeline] that is used to derive the attributes, backed by
/// oracle-based data sources.
///
/// [L2PayloadAttributes]: kona_primitives::L2PayloadAttributes
/// [OptimismPayloadAttributes]: op_alloy_rpc_types_engine::OptimismPayloadAttributes
#[derive(Debug)]
pub struct DerivationDriver<O, B>
where
Expand Down Expand Up @@ -150,9 +150,9 @@ where
Ok(Self { l2_safe_head, l2_safe_head_header, pipeline })
}

/// Produces the disputed [L2AttributesWithParent] payload, directly after the starting L2
/// Produces the disputed [OptimismAttributesWithParent] payload, directly after the starting L2
/// output root passed through the [BootInfo].
pub async fn produce_disputed_payload(&mut self) -> Result<L2AttributesWithParent> {
pub async fn produce_disputed_payload(&mut self) -> Result<OptimismAttributesWithParent> {
// 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
3 changes: 3 additions & 0 deletions crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ alloy-eips.workspace = true
alloy-rlp = { workspace = true, features = ["derive"] }
alloy-consensus = { workspace = true, features = ["k256"] }
alloy-primitives = { workspace = true, features = ["rlp", "k256"] }
alloy-rpc-types-engine.workspace = true
op-alloy-consensus = { workspace = true, features = ["k256"] }
op-alloy-protocol.workspace = true
op-alloy-genesis.workspace = true
op-alloy-rpc-types-engine.workspace = true

# General
hashbrown.workspace = true
Expand Down Expand Up @@ -71,6 +73,7 @@ serde = [
"op-alloy-consensus/serde",
"op-alloy-protocol/serde",
"op-alloy-genesis/serde",
"op-alloy-rpc-types-engine/serde",
]
metrics = ["dep:prometheus", "dep:lazy_static"]
online = [
Expand Down
4 changes: 2 additions & 2 deletions crates/derive/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ pub enum StageError {
ChannelNotFound,
/// Missing L1 origin.
MissingOrigin,
/// Failed to build the [L2PayloadAttributes] for the next batch.
/// Failed to build the [OptimismPayloadAttributes] for the next batch.
///
/// [L2PayloadAttributes]: kona_primitives::L2PayloadAttributes
/// [OptimismPayloadAttributes]: op_alloy_rpc_types_engine::OptimismPayloadAttributes
AttributesBuild(BuilderError),
/// Reset the pipeline.
Reset(ResetError),
Expand Down
13 changes: 7 additions & 6 deletions crates/derive/src/pipeline/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use alloc::{boxed::Box, collections::VecDeque, sync::Arc};
use anyhow::bail;
use async_trait::async_trait;
use core::fmt::Debug;
use kona_primitives::L2AttributesWithParent;
use op_alloy_genesis::RollupConfig;
use op_alloy_protocol::{BlockInfo, L2BlockInfo};
use op_alloy_rpc_types_engine::OptimismAttributesWithParent;
use tracing::{error, trace, warn};

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

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

Expand Down
Loading

0 comments on commit f79724c

Please sign in to comment.