From a369ada9acb908acfd84adec9b5451f1d6594140 Mon Sep 17 00:00:00 2001 From: refcell Date: Sun, 16 Jun 2024 21:48:06 -0400 Subject: [PATCH] chore(deps): fast forward op alloy dep (#267) --- Cargo.lock | 101 ++++++++++++------ Cargo.toml | 2 +- bin/programs/client/src/l2/chain_provider.rs | 3 +- .../src/stages/attributes_queue/builder.rs | 2 +- crates/derive/src/types/ecotone.rs | 3 +- crates/executor/src/lib.rs | 39 +++---- crates/executor/src/util.rs | 60 ++++++++--- crates/primitives/src/deposits.rs | 3 +- crates/primitives/src/payload.rs | 3 +- 9 files changed, 132 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b00692f..dbe78254 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,15 +40,27 @@ name = "alloy-consensus" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=cb95183#cb95183d477024b57b27336035d10403e8ba55b8" dependencies = [ - "alloy-eips", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "c-kzg", "serde", "sha2", ] +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#060de7871a76e99863917e62717c97423c37cadf" +dependencies = [ + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy)", + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy)", + "serde", +] + [[package]] name = "alloy-eips" version = "0.1.0" @@ -56,19 +68,32 @@ source = "git+https://github.com/alloy-rs/alloy?rev=cb95183#cb95183d477024b57b27 dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "c-kzg", "once_cell", "serde", ] +[[package]] +name = "alloy-eips" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#060de7871a76e99863917e62717c97423c37cadf" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy)", + "c-kzg", + "serde", + "sha2", +] + [[package]] name = "alloy-genesis" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=cb95183#cb95183d477024b57b27336035d10403e8ba55b8" dependencies = [ "alloy-primitives", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "serde", ] @@ -89,8 +114,8 @@ name = "alloy-network" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=cb95183#cb95183d477024b57b27336035d10403e8ba55b8" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-json-rpc", "alloy-primitives", "alloy-rpc-types", @@ -142,7 +167,7 @@ name = "alloy-provider" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=cb95183#cb95183d477024b57b27336035d10403e8ba55b8" dependencies = [ - "alloy-eips", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-json-rpc", "alloy-network", "alloy-primitives", @@ -212,12 +237,12 @@ name = "alloy-rpc-types" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=cb95183#cb95183d477024b57b27336035d10403e8ba55b8" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-genesis", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-sol-types", "itertools 0.12.1", "serde", @@ -232,7 +257,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=cb95183#cb95183d477024b57b27 dependencies = [ "alloy-primitives", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "serde", "serde_json", ] @@ -247,6 +272,16 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-serde" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#060de7871a76e99863917e62717c97423c37cadf" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", +] + [[package]] name = "alloy-signer" version = "0.1.0" @@ -936,15 +971,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -1675,8 +1710,8 @@ dependencies = [ name = "kona-client" version = "0.1.0" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-primitives", "alloy-rlp", "anyhow", @@ -1724,8 +1759,8 @@ dependencies = [ name = "kona-derive" version = "0.0.1" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-node-bindings", "alloy-primitives", "alloy-provider", @@ -1760,8 +1795,8 @@ dependencies = [ name = "kona-executor" version = "0.0.1" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-primitives", "alloy-rlp", "anyhow", @@ -1778,8 +1813,8 @@ dependencies = [ name = "kona-host" version = "0.1.0" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-primitives", "alloy-provider", "alloy-rlp", @@ -1808,7 +1843,7 @@ dependencies = [ name = "kona-mpt" version = "0.0.1" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-primitives", "alloy-provider", "alloy-rlp", @@ -1828,7 +1863,7 @@ dependencies = [ name = "kona-plasma" version = "0.0.1" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-primitives", "alloy-provider", "alloy-transport-http", @@ -1862,8 +1897,8 @@ dependencies = [ name = "kona-primitives" version = "0.0.1" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-primitives", "alloy-rlp", "alloy-sol-types", @@ -2133,13 +2168,13 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "op-alloy-consensus" version = "0.1.0" -source = "git+https://github.com/clabby/op-alloy?branch=refcell/consensus-port#74ed6337b600a7f77fa10568be0f054042f70400" +source = "git+https://github.com/alloy-rs/op-alloy?branch=refcell/re-exports#d581e8a58b57ed008d0fa4368dac324f9a71b304" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy)", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy)", "serde", ] @@ -3037,10 +3072,10 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "superchain-primitives" version = "0.1.0" -source = "git+https://github.com/ethereum-optimism/superchain-registry?branch=main#5c043f856591b32409c29f2317886ca43dec19fb" +source = "git+https://github.com/ethereum-optimism/superchain-registry?branch=main#645bb0a309970f3cc03ef6ff84670fc35917772a" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=cb95183)", "alloy-genesis", "alloy-primitives", "alloy-sol-types", diff --git a/Cargo.toml b/Cargo.toml index acebe82f..8bdfd48e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ async-trait = "0.1.80" alloy-primitives = { version = "0.7.6", default-features = false } alloy-rlp = { version = "0.3.5", default-features = false } alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "cb95183", default-features = false } -op-alloy-consensus = { git = "https://github.com/clabby/op-alloy", branch = "refcell/consensus-port", default-features = false } +op-alloy-consensus = { git = "https://github.com/alloy-rs/op-alloy", branch = "refcell/re-exports", default-features = false } alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "cb95183", default-features = false } revm = { git = "https://github.com/bluealloy/revm", rev = "a832a4e", default-features = false } diff --git a/bin/programs/client/src/l2/chain_provider.rs b/bin/programs/client/src/l2/chain_provider.rs index 92cf3e90..ec70845a 100644 --- a/bin/programs/client/src/l2/chain_provider.rs +++ b/bin/programs/client/src/l2/chain_provider.rs @@ -3,7 +3,6 @@ use crate::{BootInfo, CachingOracle, HintType, HINT_WRITER}; use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloy_consensus::Header; -use alloy_eips::eip2718::Decodable2718; use alloy_primitives::{Bytes, B256}; use alloy_rlp::Decodable; use anyhow::{anyhow, Result}; @@ -14,7 +13,7 @@ use kona_preimage::{HintWriterClient, PreimageKey, PreimageKeyType, PreimageOrac use kona_primitives::{ L2BlockInfo, L2ExecutionPayloadEnvelope, OpBlock, RollupConfig, SystemConfig, }; -use op_alloy_consensus::OpTxEnvelope; +use op_alloy_consensus::{Decodable2718, OpTxEnvelope}; /// The oracle-backed L2 chain provider for the client program. #[derive(Debug, Clone)] diff --git a/crates/derive/src/stages/attributes_queue/builder.rs b/crates/derive/src/stages/attributes_queue/builder.rs index d0ba9ba8..f5733c47 100644 --- a/crates/derive/src/stages/attributes_queue/builder.rs +++ b/crates/derive/src/stages/attributes_queue/builder.rs @@ -10,9 +10,9 @@ use crate::{ }, }; use alloc::{boxed::Box, fmt::Debug, sync::Arc, vec, vec::Vec}; -use alloy_eips::eip2718::Encodable2718; use alloy_rlp::Encodable; use async_trait::async_trait; +use op_alloy_consensus::Encodable2718; /// The [AttributesBuilder] is responsible for preparing [L2PayloadAttributes] /// that can be used to construct an L2 Block containing only deposits. diff --git a/crates/derive/src/types/ecotone.rs b/crates/derive/src/types/ecotone.rs index f5bdd1ad..b83fa8af 100644 --- a/crates/derive/src/types/ecotone.rs +++ b/crates/derive/src/types/ecotone.rs @@ -4,9 +4,8 @@ use crate::types::{RawTransaction, UpgradeDepositSource}; use alloc::{string::String, vec, vec::Vec}; -use alloy_eips::eip2718::Encodable2718; use alloy_primitives::{address, bytes, Address, Bytes, TxKind, U256}; -use op_alloy_consensus::{OpTxEnvelope, TxDeposit}; +use op_alloy_consensus::{Encodable2718, OpTxEnvelope, TxDeposit}; use spin::Lazy; /// The UpdgradeTo Function Signature diff --git a/crates/executor/src/lib.rs b/crates/executor/src/lib.rs index acb519ae..a46111df 100644 --- a/crates/executor/src/lib.rs +++ b/crates/executor/src/lib.rs @@ -8,12 +8,11 @@ extern crate alloc; use alloc::vec::Vec; use alloy_consensus::{Header, Sealable, Sealed, EMPTY_OMMER_ROOT_HASH, EMPTY_ROOT_HASH}; -use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{address, keccak256, Address, Bytes, TxKind, B256, U256}; use anyhow::{anyhow, Result}; use kona_derive::types::{L2PayloadAttributes, RawTransaction, RollupConfig}; use kona_mpt::{ordered_trie_with_encoder, TrieDB, TrieDBFetcher, TrieDBHinter}; -use op_alloy_consensus::{OpReceipt, OpReceiptEnvelope, OpReceiptWithBloom, OpTxEnvelope}; +use op_alloy_consensus::{Decodable2718, Encodable2718, OpReceiptEnvelope, OpTxEnvelope}; use revm::{ db::{states::bundle_state::BundleRetention, State}, primitives::{ @@ -31,7 +30,7 @@ mod canyon; use canyon::ensure_create2_deployer_canyon; mod util; -use util::{extract_tx_gas_limit, is_system_transaction, logs_bloom, wrap_receipt_with_bloom}; +use util::{extract_tx_gas_limit, is_system_transaction, logs_bloom, receipt_envelope_from_parts}; /// The block executor for the L2 client program. Operates off of a [TrieDB] backed [State], /// allowing for stateless block execution of OP Stack blocks. @@ -194,30 +193,20 @@ where cumulative_gas_used += result.gas_used(); // Create receipt envelope. - let logs_bloom = logs_bloom(result.logs()); - let receipt_envelope = wrap_receipt_with_bloom( - OpReceiptWithBloom { - receipt: OpReceipt { - status: result.is_success(), - cumulative_gas_used: cumulative_gas_used as u128, - logs: result.into_logs(), - deposit_nonce: depositor - .as_ref() - .map(|depositor| depositor.account_info().unwrap_or_default().nonce), - // The deposit receipt version was introduced in Canyon to indicate an - // update to how receipt hashes should be computed - // when set. The state transition process - // ensures this is only set for post-Canyon deposit transactions. - deposit_receipt_version: depositor - .is_some() - .then(|| self.config.is_canyon_active(payload.timestamp).then_some(1)) - .flatten(), - }, - logs_bloom, - }, + let receipt = receipt_envelope_from_parts( + result.is_success(), + cumulative_gas_used as u128, + result.logs(), transaction.tx_type(), + depositor + .as_ref() + .map(|depositor| depositor.account_info().unwrap_or_default().nonce), + depositor + .is_some() + .then(|| self.config.is_canyon_active(payload.timestamp).then_some(1)) + .flatten(), ); - receipts.push(receipt_envelope); + receipts.push(receipt); } info!( diff --git a/crates/executor/src/util.rs b/crates/executor/src/util.rs index f11f1c9c..e585b6c6 100644 --- a/crates/executor/src/util.rs +++ b/crates/executor/src/util.rs @@ -1,8 +1,50 @@ //! Contains utilities for the L2 executor. -use alloy_consensus::Transaction; +use alloc::vec::Vec; use alloy_primitives::{Bloom, Log}; -use op_alloy_consensus::{OpReceiptEnvelope, OpReceiptWithBloom, OpTxEnvelope, OpTxType}; +use op_alloy_consensus::{ + Eip658Value, OpDepositReceipt, OpDepositReceiptWithBloom, OpReceiptEnvelope, OpTxEnvelope, + OpTxType, Receipt, ReceiptWithBloom, Transaction, +}; + +/// Constructs a [OpReceiptEnvelope] from a [Receipt] fields and [OpTxType]. +pub(crate) fn receipt_envelope_from_parts<'a>( + status: bool, + cumulative_gas_used: u128, + logs: impl IntoIterator, + tx_type: OpTxType, + deposit_nonce: Option, + deposit_receipt_version: Option, +) -> OpReceiptEnvelope { + let logs = logs.into_iter().cloned().collect::>(); + let logs_bloom = logs_bloom(&logs); + let inner_receipt = Receipt { status: Eip658Value::Eip658(status), cumulative_gas_used, logs }; + match tx_type { + OpTxType::Legacy => { + OpReceiptEnvelope::Legacy(ReceiptWithBloom { receipt: inner_receipt, logs_bloom }) + } + OpTxType::Eip2930 => { + OpReceiptEnvelope::Eip2930(ReceiptWithBloom { receipt: inner_receipt, logs_bloom }) + } + OpTxType::Eip1559 => { + OpReceiptEnvelope::Eip1559(ReceiptWithBloom { receipt: inner_receipt, logs_bloom }) + } + OpTxType::Eip4844 => { + OpReceiptEnvelope::Eip4844(ReceiptWithBloom { receipt: inner_receipt, logs_bloom }) + } + OpTxType::Deposit => { + let inner = OpDepositReceiptWithBloom { + receipt: OpDepositReceipt { + inner: inner_receipt, + deposit_nonce, + deposit_receipt_version, + }, + logs_bloom, + }; + OpReceiptEnvelope::Deposit(inner) + } + } +} /// Compute the logs bloom filter for the given logs. pub(crate) fn logs_bloom<'a>(logs: impl IntoIterator) -> Bloom { @@ -16,20 +58,6 @@ pub(crate) fn logs_bloom<'a>(logs: impl IntoIterator) -> Bloom { bloom } -/// Wrap an [OpReceiptWithBloom] in an [OpReceiptEnvelope], provided the receipt and a [OpTxType]. -pub(crate) fn wrap_receipt_with_bloom( - receipt: OpReceiptWithBloom, - tx_type: OpTxType, -) -> OpReceiptEnvelope { - match tx_type { - OpTxType::Legacy => OpReceiptEnvelope::Legacy(receipt), - OpTxType::Eip2930 => OpReceiptEnvelope::Eip2930(receipt), - OpTxType::Eip1559 => OpReceiptEnvelope::Eip1559(receipt), - OpTxType::Eip4844 => OpReceiptEnvelope::Eip4844(receipt), - OpTxType::Deposit => OpReceiptEnvelope::Deposit(receipt), - } -} - /// Extract the gas limit from an [OpTxEnvelope]. pub(crate) fn extract_tx_gas_limit(tx: &OpTxEnvelope) -> u128 { match tx { diff --git a/crates/primitives/src/deposits.rs b/crates/primitives/src/deposits.rs index 16537b8d..f65b1100 100644 --- a/crates/primitives/src/deposits.rs +++ b/crates/primitives/src/deposits.rs @@ -1,11 +1,10 @@ //! Contains deposit transaction types and helper methods. use alloc::{string::String, vec::Vec}; -use alloy_eips::eip2718::Encodable2718; use alloy_primitives::{b256, keccak256, Address, Bytes, Log, TxKind, B256, U256, U64}; use alloy_rlp::Encodable; use core::fmt::Display; -use op_alloy_consensus::{OpTxEnvelope, TxDeposit}; +use op_alloy_consensus::{Encodable2718, OpTxEnvelope, TxDeposit}; use crate::RawTransaction; diff --git a/crates/primitives/src/payload.rs b/crates/primitives/src/payload.rs index 568873c8..46d0677c 100644 --- a/crates/primitives/src/payload.rs +++ b/crates/primitives/src/payload.rs @@ -1,10 +1,9 @@ //! Contains the execution payload type. use alloc::vec::Vec; -use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, B256}; use anyhow::Result; -use op_alloy_consensus::{OpTxEnvelope, OpTxType}; +use op_alloy_consensus::{Decodable2718, Encodable2718, OpTxEnvelope, OpTxType}; /// Fixed and variable memory costs for a payload. /// ~1000 bytes per payload, with some margin for overhead like map data.