From 48d6e1add2bc21833bfe4fab4a5a25b45d83fbe0 Mon Sep 17 00:00:00 2001 From: morito Date: Thu, 5 Dec 2024 23:22:44 +0900 Subject: [PATCH 01/16] chore: Bump alloy to 0.7.3 (#334) ## Motivation ## Solution ## PR Checklist - [ ] Added Tests - [ ] Added Documentation - [ ] Breaking changes --- Cargo.toml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8eaff2f4..81a56085 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,16 +47,16 @@ op-alloy-rpc-jsonrpsee = { version = "0.7.3", path = "crates/rpc-jsonrpsee", def op-alloy-rpc-types-engine = { version = "0.7.3", path = "crates/rpc-types-engine", default-features = false } # Alloy -alloy-eips = { version = "0.7.2", default-features = false } -alloy-serde = { version = "0.7.2", default-features = false } -alloy-signer = { version = "0.7.2", default-features = false } -alloy-network = { version = "0.7.2", default-features = false } -alloy-provider = { version = "0.7.2", default-features = false } -alloy-transport = { version = "0.7.2", default-features = false } -alloy-consensus = { version = "0.7.2", default-features = false } -alloy-rpc-types-eth = { version = "0.7.2", default-features = false } -alloy-rpc-types-engine = { version = "0.7.2", default-features = false } -alloy-network-primitives = { version = "0.7.2", default-features = false } +alloy-eips = { version = "0.7.3", default-features = false } +alloy-serde = { version = "0.7.3", default-features = false } +alloy-signer = { version = "0.7.3", default-features = false } +alloy-network = { version = "0.7.3", default-features = false } +alloy-provider = { version = "0.7.3", default-features = false } +alloy-transport = { version = "0.7.3", default-features = false } +alloy-consensus = { version = "0.7.3", default-features = false } +alloy-rpc-types-eth = { version = "0.7.3", default-features = false } +alloy-rpc-types-engine = { version = "0.7.3", default-features = false } +alloy-network-primitives = { version = "0.7.3", default-features = false } # Alloy RLP alloy-rlp = { version = "0.3", default-features = false } From 8ba8cc6ed94cf0a1d7a1b28ae7fdf22fa8bd875b Mon Sep 17 00:00:00 2001 From: refcell Date: Fri, 6 Dec 2024 10:59:18 -0500 Subject: [PATCH 02/16] chore(registry): Bump superchain-registry commit (#336) ### Description Bumps the `superchain-registry` commit. --- crates/registry/superchain-registry | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/registry/superchain-registry b/crates/registry/superchain-registry index 19f25872..58ab8df7 160000 --- a/crates/registry/superchain-registry +++ b/crates/registry/superchain-registry @@ -1 +1 @@ -Subproject commit 19f2587283e33a3eb74a442982f53b698ca6f08e +Subproject commit 58ab8df79925126e6b2ad55daae74a3be7f8b1f3 From aea3363e28f7b14a960496cddc8ac67434f11f2a Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 10 Dec 2024 15:39:07 +0400 Subject: [PATCH 03/16] chore: bump alloy (#338) ## Motivation ## Solution ## PR Checklist - [ ] Added Tests - [ ] Added Documentation - [ ] Breaking changes --- Cargo.toml | 20 ++++++++-------- crates/consensus/src/receipt/receipts.rs | 4 +--- crates/consensus/src/transaction/deposit.rs | 12 ++++++---- crates/consensus/src/transaction/envelope.rs | 24 +++++++++++--------- crates/consensus/src/transaction/typed.rs | 24 +++++++++++--------- crates/rpc-types-engine/src/envelope.rs | 2 +- crates/rpc-types/src/transaction.rs | 16 ++++++------- 7 files changed, 52 insertions(+), 50 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 81a56085..0f969010 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,16 +47,16 @@ op-alloy-rpc-jsonrpsee = { version = "0.7.3", path = "crates/rpc-jsonrpsee", def op-alloy-rpc-types-engine = { version = "0.7.3", path = "crates/rpc-types-engine", default-features = false } # Alloy -alloy-eips = { version = "0.7.3", default-features = false } -alloy-serde = { version = "0.7.3", default-features = false } -alloy-signer = { version = "0.7.3", default-features = false } -alloy-network = { version = "0.7.3", default-features = false } -alloy-provider = { version = "0.7.3", default-features = false } -alloy-transport = { version = "0.7.3", default-features = false } -alloy-consensus = { version = "0.7.3", default-features = false } -alloy-rpc-types-eth = { version = "0.7.3", default-features = false } -alloy-rpc-types-engine = { version = "0.7.3", default-features = false } -alloy-network-primitives = { version = "0.7.3", default-features = false } +alloy-eips = { version = "0.8", default-features = false } +alloy-serde = { version = "0.8", default-features = false } +alloy-signer = { version = "0.8", default-features = false } +alloy-network = { version = "0.8", default-features = false } +alloy-provider = { version = "0.8", default-features = false } +alloy-transport = { version = "0.8", default-features = false } +alloy-consensus = { version = "0.8", default-features = false } +alloy-rpc-types-eth = { version = "0.8", default-features = false } +alloy-rpc-types-engine = { version = "0.8", default-features = false } +alloy-network-primitives = { version = "0.8", default-features = false } # Alloy RLP alloy-rlp = { version = "0.3", default-features = false } diff --git a/crates/consensus/src/receipt/receipts.rs b/crates/consensus/src/receipt/receipts.rs index 5a1fc0d5..c2c31ec1 100644 --- a/crates/consensus/src/receipt/receipts.rs +++ b/crates/consensus/src/receipt/receipts.rs @@ -7,8 +7,6 @@ use alloy_consensus::{ use alloy_primitives::{Bloom, Log}; use alloy_rlp::{Buf, BufMut, Decodable, Encodable, Header}; -use core::borrow::Borrow; - /// Receipt containing result of transaction execution. #[derive(Clone, Debug, PartialEq, Eq, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -116,7 +114,7 @@ impl AsRef> for OpDepositReceipt { impl TxReceipt for OpDepositReceipt where - T: Borrow + Clone + core::fmt::Debug + PartialEq + Eq + Send + Sync, + T: AsRef + Clone + core::fmt::Debug + PartialEq + Eq + Send + Sync, { type Log = T; diff --git a/crates/consensus/src/transaction/deposit.rs b/crates/consensus/src/transaction/deposit.rs index 2b973a88..d0cf7d17 100644 --- a/crates/consensus/src/transaction/deposit.rs +++ b/crates/consensus/src/transaction/deposit.rs @@ -3,7 +3,7 @@ use super::OpTxType; use crate::DepositTransaction; use alloc::vec::Vec; -use alloy_consensus::{Sealable, Transaction}; +use alloy_consensus::{Sealable, Transaction, Typed2718}; use alloy_eips::{ eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718}, eip2930::AccessList, @@ -225,6 +225,12 @@ impl TxDeposit { } } +impl Typed2718 for TxDeposit { + fn ty(&self) -> u8 { + OpTxType::Deposit as u8 + } +} + impl Transaction for TxDeposit { fn chain_id(&self) -> Option { None @@ -282,10 +288,6 @@ impl Transaction for TxDeposit { &self.input } - fn ty(&self) -> u8 { - OpTxType::Deposit as u8 - } - fn access_list(&self) -> Option<&AccessList> { None } diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index 28446562..b9392fd9 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -1,6 +1,6 @@ use alloy_consensus::{ transaction::RlpEcdsaTx, Sealable, Sealed, Signed, Transaction, TxEip1559, TxEip2930, - TxEip7702, TxLegacy, + TxEip7702, TxLegacy, Typed2718, }; use alloy_eips::{ eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718}, @@ -80,6 +80,18 @@ impl From> for OpTxEnvelope { } } +impl Typed2718 for OpTxEnvelope { + fn ty(&self) -> u8 { + match self { + Self::Legacy(tx) => tx.tx().ty(), + Self::Eip2930(tx) => tx.tx().ty(), + Self::Eip1559(tx) => tx.tx().ty(), + Self::Eip7702(tx) => tx.tx().ty(), + Self::Deposit(tx) => tx.ty(), + } + } +} + impl Transaction for OpTxEnvelope { fn chain_id(&self) -> Option { match self { @@ -211,16 +223,6 @@ impl Transaction for OpTxEnvelope { } } - fn ty(&self) -> u8 { - match self { - Self::Legacy(tx) => tx.tx().ty(), - Self::Eip2930(tx) => tx.tx().ty(), - Self::Eip1559(tx) => tx.tx().ty(), - Self::Eip7702(tx) => tx.tx().ty(), - Self::Deposit(tx) => tx.ty(), - } - } - fn access_list(&self) -> Option<&AccessList> { match self { Self::Legacy(tx) => tx.tx().access_list(), diff --git a/crates/consensus/src/transaction/typed.rs b/crates/consensus/src/transaction/typed.rs index c92e7ff1..eda32684 100644 --- a/crates/consensus/src/transaction/typed.rs +++ b/crates/consensus/src/transaction/typed.rs @@ -1,5 +1,5 @@ use crate::{OpTxEnvelope, OpTxType, TxDeposit}; -use alloy_consensus::{Transaction, TxEip1559, TxEip2930, TxEip7702, TxLegacy}; +use alloy_consensus::{Transaction, TxEip1559, TxEip2930, TxEip7702, TxLegacy, Typed2718}; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Address, Bytes, TxKind}; @@ -115,6 +115,18 @@ impl OpTypedTransaction { } } +impl Typed2718 for OpTypedTransaction { + fn ty(&self) -> u8 { + match self { + Self::Legacy(_) => OpTxType::Legacy as u8, + Self::Eip2930(_) => OpTxType::Eip2930 as u8, + Self::Eip1559(_) => OpTxType::Eip1559 as u8, + Self::Eip7702(_) => OpTxType::Eip7702 as u8, + Self::Deposit(_) => OpTxType::Deposit as u8, + } + } +} + impl Transaction for OpTypedTransaction { fn chain_id(&self) -> Option { match self { @@ -246,16 +258,6 @@ impl Transaction for OpTypedTransaction { } } - fn ty(&self) -> u8 { - match self { - Self::Legacy(_) => OpTxType::Legacy as u8, - Self::Eip2930(_) => OpTxType::Eip2930 as u8, - Self::Eip1559(_) => OpTxType::Eip1559 as u8, - Self::Eip7702(_) => OpTxType::Eip7702 as u8, - Self::Deposit(_) => OpTxType::Deposit as u8, - } - } - fn access_list(&self) -> Option<&AccessList> { match self { Self::Legacy(tx) => tx.access_list(), diff --git a/crates/rpc-types-engine/src/envelope.rs b/crates/rpc-types-engine/src/envelope.rs index 377d9f20..a05ac599 100644 --- a/crates/rpc-types-engine/src/envelope.rs +++ b/crates/rpc-types-engine/src/envelope.rs @@ -3,7 +3,7 @@ //! This module uses the `snappy` compression algorithm to decompress the payload. //! The license for snappy can be found in the `SNAPPY-LICENSE` at the root of the repository. -use alloy_primitives::{keccak256, Signature, B256}; +use alloy_primitives::{keccak256, PrimitiveSignature as Signature, B256}; use alloy_rpc_types_engine::ExecutionPayload; /// Optimism execution payload envelope in network format. diff --git a/crates/rpc-types/src/transaction.rs b/crates/rpc-types/src/transaction.rs index b0227775..9a3d19c4 100644 --- a/crates/rpc-types/src/transaction.rs +++ b/crates/rpc-types/src/transaction.rs @@ -1,6 +1,6 @@ //! Optimism specific types related to transactions. -use alloy_consensus::Transaction as _; +use alloy_consensus::{Transaction as _, Typed2718}; use alloy_eips::{eip2930::AccessList, eip7702::SignedAuthorization}; use alloy_primitives::{Address, BlockHash, Bytes, ChainId, TxKind, B256, U256}; use alloy_serde::OtherFields; @@ -29,6 +29,12 @@ pub struct Transaction { pub deposit_receipt_version: Option, } +impl Typed2718 for Transaction { + fn ty(&self) -> u8 { + self.inner.ty() + } +} + impl alloy_consensus::Transaction for Transaction { fn chain_id(&self) -> Option { self.inner.chain_id() @@ -90,10 +96,6 @@ impl alloy_consensus::Transaction for Transaction { self.inner.input() } - fn ty(&self) -> u8 { - self.inner.ty() - } - fn access_list(&self) -> Option<&AccessList> { self.inner.access_list() } @@ -127,10 +129,6 @@ impl alloy_network_primitives::TransactionResponse for Transaction { fn from(&self) -> Address { self.inner.from() } - - fn to(&self) -> Option
{ - alloy_consensus::Transaction::to(&self.inner) - } } /// Optimism specific transaction fields From aa643145553644e69e597437f93998537455c423 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 10 Dec 2024 12:40:46 +0100 Subject: [PATCH 04/16] chore: release 0.8.0 --- CHANGELOG.md | 8 ++++++-- Cargo.toml | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48d82aa1..944763d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.7.3](https://github.com/alloy-rs/op-alloy -/releases/tag/v0.7.3) - 2024-12-04 +## [0.8.0](https://github.com/alloy-rs/op-alloy +/releases/tag/v0.8.0) - 2024-12-10 ### Dependencies +- Bump alloy ([#338](https://github.com/alloy-rs/op-alloy/issues/338)) +- [registry] Bump superchain-registry commit ([#336](https://github.com/alloy-rs/op-alloy/issues/336)) +- Bump alloy to 0.7.3 ([#334](https://github.com/alloy-rs/op-alloy/issues/334)) - Enable alloy-primitives/arbitrary in dev-deps ([#329](https://github.com/alloy-rs/op-alloy/issues/329)) ### Features @@ -25,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Other +- 0.7.3 ([#333](https://github.com/alloy-rs/op-alloy/issues/333)) - Add placeholder for isthmus time to genesis ([#331](https://github.com/alloy-rs/op-alloy/issues/331)) - Propagate arbitrary ([#330](https://github.com/alloy-rs/op-alloy/issues/330)) diff --git a/Cargo.toml b/Cargo.toml index 0f969010..19e7c740 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.7.3" +version = "0.8.0" edition = "2021" rust-version = "1.81" authors = ["Alloy Contributors"] @@ -36,15 +36,15 @@ rustdoc-args = ["--cfg", "docsrs"] [workspace.dependencies] # Workspace -op-alloy-genesis = { version = "0.7.3", path = "crates/genesis", default-features = false } -op-alloy-protocol = { version = "0.7.3", path = "crates/protocol", default-features = false } -op-alloy-consensus = { version = "0.7.3", path = "crates/consensus", default-features = false } -op-alloy-network = { version = "0.7.3", path = "crates/network", default-features = false } -op-alloy-provider = { version = "0.7.3", path = "crates/provider", default-features = false } -op-alloy-registry = { version = "0.7.3", path = "crates/registry", default-features = false } -op-alloy-rpc-types = { version = "0.7.3", path = "crates/rpc-types", default-features = false } -op-alloy-rpc-jsonrpsee = { version = "0.7.3", path = "crates/rpc-jsonrpsee", default-features = false } -op-alloy-rpc-types-engine = { version = "0.7.3", path = "crates/rpc-types-engine", default-features = false } +op-alloy-genesis = { version = "0.8.0", path = "crates/genesis", default-features = false } +op-alloy-protocol = { version = "0.8.0", path = "crates/protocol", default-features = false } +op-alloy-consensus = { version = "0.8.0", path = "crates/consensus", default-features = false } +op-alloy-network = { version = "0.8.0", path = "crates/network", default-features = false } +op-alloy-provider = { version = "0.8.0", path = "crates/provider", default-features = false } +op-alloy-registry = { version = "0.8.0", path = "crates/registry", default-features = false } +op-alloy-rpc-types = { version = "0.8.0", path = "crates/rpc-types", default-features = false } +op-alloy-rpc-jsonrpsee = { version = "0.8.0", path = "crates/rpc-jsonrpsee", default-features = false } +op-alloy-rpc-types-engine = { version = "0.8.0", path = "crates/rpc-types-engine", default-features = false } # Alloy alloy-eips = { version = "0.8", default-features = false } From 8439401ee76ca781f434c92df46bca1c44b24677 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 10 Dec 2024 19:42:59 +0400 Subject: [PATCH 05/16] chore: reuse methods for receipt rlp (#339) Reuses methods from alloy receipt for deposit receipt and makes them pub for reuse in reth --- crates/consensus/src/receipt/receipts.rs | 38 +++++++++++------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/crates/consensus/src/receipt/receipts.rs b/crates/consensus/src/receipt/receipts.rs index c2c31ec1..d10cfd87 100644 --- a/crates/consensus/src/receipt/receipts.rs +++ b/crates/consensus/src/receipt/receipts.rs @@ -56,20 +56,16 @@ impl OpDepositReceipt { } impl OpDepositReceipt { - fn rlp_encoded_fields_length_with_bloom(&self, bloom: &Bloom) -> usize { - self.inner.status.length() - + self.inner.cumulative_gas_used.length() - + bloom.length() - + self.inner.logs.length() + /// Returns length of RLP-encoded receipt fields with the given [`Bloom`] without an RLP header. + pub fn rlp_encoded_fields_length_with_bloom(&self, bloom: &Bloom) -> usize { + self.inner.rlp_encoded_fields_length_with_bloom(bloom) + self.deposit_nonce.map_or(0, |nonce| nonce.length()) + self.deposit_receipt_version.map_or(0, |version| version.length()) } - fn rlp_encode_fields_with_bloom(&self, bloom: &Bloom, out: &mut dyn BufMut) { - self.inner.status.encode(out); - self.inner.cumulative_gas_used.encode(out); - bloom.encode(out); - self.inner.logs.encode(out); + /// RLP-encodes receipt fields with the given [`Bloom`] without an RLP header. + pub fn rlp_encode_fields_with_bloom(&self, bloom: &Bloom, out: &mut dyn BufMut) { + self.inner.rlp_encode_fields_with_bloom(bloom, out); if let Some(nonce) = self.deposit_nonce { nonce.encode(out); @@ -79,29 +75,29 @@ impl OpDepositReceipt { } } - fn rlp_header_with_bloom(&self, bloom: &Bloom) -> Header { + /// Returns RLP header for this receipt encoding with the given [`Bloom`]. + pub fn rlp_header_with_bloom(&self, bloom: &Bloom) -> Header { Header { list: true, payload_length: self.rlp_encoded_fields_length_with_bloom(bloom) } } } impl OpDepositReceipt { - fn rlp_decode_fields_with_bloom(buf: &mut &[u8]) -> alloy_rlp::Result> { - let status = Decodable::decode(buf)?; - let cumulative_gas_used = Decodable::decode(buf)?; - let logs_bloom = Decodable::decode(buf)?; - let logs = Decodable::decode(buf)?; + /// RLP-decodes receipt's field with a [`Bloom`]. + /// + /// Does not expect an RLP header. + pub fn rlp_decode_fields_with_bloom( + buf: &mut &[u8], + ) -> alloy_rlp::Result> { + let ReceiptWithBloom { receipt: inner, logs_bloom } = + Receipt::rlp_decode_fields_with_bloom(buf)?; let deposit_nonce = (!buf.is_empty()).then(|| Decodable::decode(buf)).transpose()?; let deposit_receipt_version = (!buf.is_empty()).then(|| Decodable::decode(buf)).transpose()?; Ok(ReceiptWithBloom { - receipt: Self { - inner: Receipt { status, cumulative_gas_used, logs }, - deposit_nonce, - deposit_receipt_version, - }, logs_bloom, + receipt: Self { inner, deposit_nonce, deposit_receipt_version }, }) } } From c8ba1716c40b49c2bec80c1bb507f68abdb31af5 Mon Sep 17 00:00:00 2001 From: Tien Nguyen <116023870+htiennv@users.noreply.github.com> Date: Wed, 11 Dec 2024 02:00:23 +0700 Subject: [PATCH 06/16] feat: add serde for OpTxType (#317) Closes #262 --------- Co-authored-by: Matthias Seitz --- crates/consensus/src/transaction/tx_type.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/consensus/src/transaction/tx_type.rs b/crates/consensus/src/transaction/tx_type.rs index 4808b8ec..ef84a084 100644 --- a/crates/consensus/src/transaction/tx_type.rs +++ b/crates/consensus/src/transaction/tx_type.rs @@ -19,6 +19,8 @@ pub const DEPOSIT_TX_TYPE_ID: u8 = 126; // 0x7E /// [deposit-spec]: https://specs.optimism.io/protocol/deposits.html #[repr(u8)] #[derive(Debug, Copy, Clone, Eq, Default, PartialEq, PartialOrd, Ord, Hash, Display)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(into = "U8", try_from = "U64"))] pub enum OpTxType { /// Legacy transaction type. #[default] From 34230cd19097ddb06a652cda8f7f6fc24992627d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 12 Dec 2024 12:24:32 +0100 Subject: [PATCH 07/16] chore: release 0.8.1 --- CHANGELOG.md | 12 ++++++++++++ Cargo.toml | 20 ++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 944763d4..979f939a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.1](https://github.com/alloy-rs/op-alloy +/releases/tag/v0.8.1) - 2024-12-12 + +### Features + +- Add serde for OpTxType ([#317](https://github.com/alloy-rs/op-alloy/issues/317)) + +### Miscellaneous Tasks + +- Reuse methods for receipt rlp ([#339](https://github.com/alloy-rs/op-alloy/issues/339)) + ## [0.8.0](https://github.com/alloy-rs/op-alloy /releases/tag/v0.8.0) - 2024-12-10 @@ -24,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Miscellaneous Tasks +- Release 0.8.0 - [registry] Update SCR ([#327](https://github.com/alloy-rs/op-alloy/issues/327)) ### Other diff --git a/Cargo.toml b/Cargo.toml index 19e7c740..4de119ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.8.0" +version = "0.8.1" edition = "2021" rust-version = "1.81" authors = ["Alloy Contributors"] @@ -36,15 +36,15 @@ rustdoc-args = ["--cfg", "docsrs"] [workspace.dependencies] # Workspace -op-alloy-genesis = { version = "0.8.0", path = "crates/genesis", default-features = false } -op-alloy-protocol = { version = "0.8.0", path = "crates/protocol", default-features = false } -op-alloy-consensus = { version = "0.8.0", path = "crates/consensus", default-features = false } -op-alloy-network = { version = "0.8.0", path = "crates/network", default-features = false } -op-alloy-provider = { version = "0.8.0", path = "crates/provider", default-features = false } -op-alloy-registry = { version = "0.8.0", path = "crates/registry", default-features = false } -op-alloy-rpc-types = { version = "0.8.0", path = "crates/rpc-types", default-features = false } -op-alloy-rpc-jsonrpsee = { version = "0.8.0", path = "crates/rpc-jsonrpsee", default-features = false } -op-alloy-rpc-types-engine = { version = "0.8.0", path = "crates/rpc-types-engine", default-features = false } +op-alloy-genesis = { version = "0.8.1", path = "crates/genesis", default-features = false } +op-alloy-protocol = { version = "0.8.1", path = "crates/protocol", default-features = false } +op-alloy-consensus = { version = "0.8.1", path = "crates/consensus", default-features = false } +op-alloy-network = { version = "0.8.1", path = "crates/network", default-features = false } +op-alloy-provider = { version = "0.8.1", path = "crates/provider", default-features = false } +op-alloy-registry = { version = "0.8.1", path = "crates/registry", default-features = false } +op-alloy-rpc-types = { version = "0.8.1", path = "crates/rpc-types", default-features = false } +op-alloy-rpc-jsonrpsee = { version = "0.8.1", path = "crates/rpc-jsonrpsee", default-features = false } +op-alloy-rpc-types-engine = { version = "0.8.1", path = "crates/rpc-types-engine", default-features = false } # Alloy alloy-eips = { version = "0.8", default-features = false } From a7d43922a6e12f4b4285f6ba56cd01771d5b9aaf Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 12 Dec 2024 21:05:17 +0100 Subject: [PATCH 08/16] feat: upstream decode extradata fn (#340) add reth function with was duplicated code https://github.com/paradigmxyz/reth/blob/c816a3b758a39640388cc179abafd924ff9103b9/crates/optimism/chainspec/src/lib.rs#L268-L279 we already have the `decode_eip_1559_params` fn but were missing the decode from extradata slice. this renames the previous `decode_holocene_extra_data` function to encode_ because this actually encodes --- crates/consensus/src/eip1559.rs | 28 +++++++++++++++++++---- crates/consensus/src/lib.rs | 7 ++++-- crates/rpc-types-engine/src/attributes.rs | 6 ++--- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/crates/consensus/src/eip1559.rs b/crates/consensus/src/eip1559.rs index 11625f13..01fa9e4a 100644 --- a/crates/consensus/src/eip1559.rs +++ b/crates/consensus/src/eip1559.rs @@ -14,11 +14,28 @@ pub fn decode_eip_1559_params(eip_1559_params: B64) -> (u32, u32) { (u32::from_be_bytes(elasticity), u32::from_be_bytes(denominator)) } -/// Extracts the `eip1559` parameters for the payload. -pub fn decode_holocene_extra_data( +/// Decodes the `eip1559` parameters from the `extradata` bytes. +/// +/// Returns (`elasticity`, `denominator`) +pub fn decode_holocene_extra_data(extra_data: &[u8]) -> Result<(u32, u32), EIP1559ParamError> { + if extra_data.len() < 9 { + return Err(EIP1559ParamError::NoEIP1559Params); + } + + if extra_data[0] != 0 { + // version must be 0: https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/holocene/exec-engine.md#eip-1559-parameters-in-block-header + return Err(EIP1559ParamError::InvalidVersion(extra_data[0])); + } + // skip the first version byte + Ok(decode_eip_1559_params(B64::from_slice(&extra_data[1..9]))) +} + +/// Encodes the `eip1559` parameters for the payload. +pub fn encode_holocene_extra_data( eip_1559_params: B64, default_base_fee_params: BaseFeeParams, ) -> Result { + // 9 bytes: 1 byte for version (0) and 8 bytes for eip1559 params let mut extra_data = [0u8; 9]; // If eip 1559 params aren't set, use the canyon base fee param constants // otherwise use them @@ -47,6 +64,9 @@ pub fn decode_holocene_extra_data( /// Error type for EIP-1559 parameters #[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq)] pub enum EIP1559ParamError { + /// Thrown if the extra data begins with the wrong version byte. + #[error("Invalid EIP1559 version byte: {0}")] + InvalidVersion(u8), /// No EIP-1559 parameters provided. #[error("No EIP1559 parameters provided")] NoEIP1559Params, @@ -66,14 +86,14 @@ mod tests { #[test] fn test_get_extra_data_post_holocene() { let eip_1559_params = B64::from_str("0x0000000800000008").unwrap(); - let extra_data = decode_holocene_extra_data(eip_1559_params, BaseFeeParams::new(80, 60)); + let extra_data = encode_holocene_extra_data(eip_1559_params, BaseFeeParams::new(80, 60)); assert_eq!(extra_data.unwrap(), Bytes::copy_from_slice(&[0, 0, 0, 0, 8, 0, 0, 0, 8])); } #[test] fn test_get_extra_data_post_holocene_default() { let eip_1559_params = B64::ZERO; - let extra_data = decode_holocene_extra_data(eip_1559_params, BaseFeeParams::new(80, 60)); + let extra_data = encode_holocene_extra_data(eip_1559_params, BaseFeeParams::new(80, 60)); assert_eq!(extra_data.unwrap(), Bytes::copy_from_slice(&[0, 0, 0, 0, 80, 0, 0, 0, 60])); } } diff --git a/crates/consensus/src/lib.rs b/crates/consensus/src/lib.rs index aafd20ef..9363e080 100644 --- a/crates/consensus/src/lib.rs +++ b/crates/consensus/src/lib.rs @@ -19,8 +19,11 @@ pub use transaction::{ DEPOSIT_TX_TYPE_ID, }; -mod eip1559; -pub use eip1559::{decode_eip_1559_params, decode_holocene_extra_data, EIP1559ParamError}; +pub mod eip1559; +pub use eip1559::{ + decode_eip_1559_params, decode_holocene_extra_data, encode_holocene_extra_data, + EIP1559ParamError, +}; mod hardforks; pub use hardforks::{Ecotone, Fjord, Hardfork, Hardforks}; diff --git a/crates/rpc-types-engine/src/attributes.rs b/crates/rpc-types-engine/src/attributes.rs index 0256031d..2f522f19 100644 --- a/crates/rpc-types-engine/src/attributes.rs +++ b/crates/rpc-types-engine/src/attributes.rs @@ -4,7 +4,7 @@ use alloc::vec::Vec; use alloy_eips::eip1559::BaseFeeParams; use alloy_primitives::{Bytes, B64}; use alloy_rpc_types_engine::PayloadAttributes; -use op_alloy_consensus::{decode_eip_1559_params, decode_holocene_extra_data, EIP1559ParamError}; +use op_alloy_consensus::{decode_eip_1559_params, encode_holocene_extra_data, EIP1559ParamError}; use op_alloy_protocol::L2BlockInfo; /// Optimism Payload Attributes @@ -36,13 +36,13 @@ pub struct OpPayloadAttributes { } impl OpPayloadAttributes { - /// Extracts the `eip1559` parameters for the payload. + /// Encodes the `eip1559` parameters for the payload. pub fn get_holocene_extra_data( &self, default_base_fee_params: BaseFeeParams, ) -> Result { self.eip_1559_params - .map(|params| decode_holocene_extra_data(params, default_base_fee_params)) + .map(|params| encode_holocene_extra_data(params, default_base_fee_params)) .ok_or(EIP1559ParamError::NoEIP1559Params)? } From 8e7062280564786ce95f3ecb00284c3044c60a25 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 12 Dec 2024 21:09:14 +0100 Subject: [PATCH 09/16] chore: release 0.8.2 --- CHANGELOG.md | 8 ++++++++ Cargo.toml | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 979f939a..5f491781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.2](https://github.com/alloy-rs/op-alloy +/releases/tag/v0.8.2) - 2024-12-12 + +### Features + +- Upstream decode extradata fn ([#340](https://github.com/alloy-rs/op-alloy/issues/340)) + ## [0.8.1](https://github.com/alloy-rs/op-alloy /releases/tag/v0.8.1) - 2024-12-12 @@ -14,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Miscellaneous Tasks +- Release 0.8.1 - Reuse methods for receipt rlp ([#339](https://github.com/alloy-rs/op-alloy/issues/339)) ## [0.8.0](https://github.com/alloy-rs/op-alloy diff --git a/Cargo.toml b/Cargo.toml index 4de119ed..cab86f07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.8.1" +version = "0.8.2" edition = "2021" rust-version = "1.81" authors = ["Alloy Contributors"] @@ -36,15 +36,15 @@ rustdoc-args = ["--cfg", "docsrs"] [workspace.dependencies] # Workspace -op-alloy-genesis = { version = "0.8.1", path = "crates/genesis", default-features = false } -op-alloy-protocol = { version = "0.8.1", path = "crates/protocol", default-features = false } -op-alloy-consensus = { version = "0.8.1", path = "crates/consensus", default-features = false } -op-alloy-network = { version = "0.8.1", path = "crates/network", default-features = false } -op-alloy-provider = { version = "0.8.1", path = "crates/provider", default-features = false } -op-alloy-registry = { version = "0.8.1", path = "crates/registry", default-features = false } -op-alloy-rpc-types = { version = "0.8.1", path = "crates/rpc-types", default-features = false } -op-alloy-rpc-jsonrpsee = { version = "0.8.1", path = "crates/rpc-jsonrpsee", default-features = false } -op-alloy-rpc-types-engine = { version = "0.8.1", path = "crates/rpc-types-engine", default-features = false } +op-alloy-genesis = { version = "0.8.2", path = "crates/genesis", default-features = false } +op-alloy-protocol = { version = "0.8.2", path = "crates/protocol", default-features = false } +op-alloy-consensus = { version = "0.8.2", path = "crates/consensus", default-features = false } +op-alloy-network = { version = "0.8.2", path = "crates/network", default-features = false } +op-alloy-provider = { version = "0.8.2", path = "crates/provider", default-features = false } +op-alloy-registry = { version = "0.8.2", path = "crates/registry", default-features = false } +op-alloy-rpc-types = { version = "0.8.2", path = "crates/rpc-types", default-features = false } +op-alloy-rpc-jsonrpsee = { version = "0.8.2", path = "crates/rpc-jsonrpsee", default-features = false } +op-alloy-rpc-types-engine = { version = "0.8.2", path = "crates/rpc-types-engine", default-features = false } # Alloy alloy-eips = { version = "0.8", default-features = false } From f7c5270c59bac5d44ac525b0f26c7c6c43740fa6 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Sat, 14 Dec 2024 03:24:35 -0500 Subject: [PATCH 10/16] feat: add OpPooledTransaction (#341) ## Motivation We need a type that represents a pooled transaction, this cannot include deposit transactions ## Solution Implemented `OpPooledTransaction`, which is like `OpTxEnvelope` but without the deposit variant. ## PR Checklist - [ ] Added Tests - [ ] Added Documentation - [ ] Breaking changes --------- Co-authored-by: Matthias Seitz --- crates/consensus/src/lib.rs | 4 +- crates/consensus/src/transaction/mod.rs | 3 + crates/consensus/src/transaction/pooled.rs | 523 +++++++++++++++++++++ 3 files changed, 528 insertions(+), 2 deletions(-) create mode 100644 crates/consensus/src/transaction/pooled.rs diff --git a/crates/consensus/src/lib.rs b/crates/consensus/src/lib.rs index 9363e080..ab118c65 100644 --- a/crates/consensus/src/lib.rs +++ b/crates/consensus/src/lib.rs @@ -15,8 +15,8 @@ pub use receipt::{OpDepositReceipt, OpDepositReceiptWithBloom, OpReceiptEnvelope mod transaction; pub use transaction::{ DepositSourceDomain, DepositSourceDomainIdentifier, DepositTransaction, L1InfoDepositSource, - OpTxEnvelope, OpTxType, OpTypedTransaction, TxDeposit, UpgradeDepositSource, UserDepositSource, - DEPOSIT_TX_TYPE_ID, + OpPooledTransaction, OpTxEnvelope, OpTxType, OpTypedTransaction, TxDeposit, + UpgradeDepositSource, UserDepositSource, DEPOSIT_TX_TYPE_ID, }; pub mod eip1559; diff --git a/crates/consensus/src/transaction/mod.rs b/crates/consensus/src/transaction/mod.rs index 8e11d943..74a130cd 100644 --- a/crates/consensus/src/transaction/mod.rs +++ b/crates/consensus/src/transaction/mod.rs @@ -12,6 +12,9 @@ pub use envelope::OpTxEnvelope; mod typed; pub use typed::OpTypedTransaction; +mod pooled; +pub use pooled::OpPooledTransaction; + mod source; pub use source::{ DepositSourceDomain, DepositSourceDomainIdentifier, L1InfoDepositSource, UpgradeDepositSource, diff --git a/crates/consensus/src/transaction/pooled.rs b/crates/consensus/src/transaction/pooled.rs new file mode 100644 index 00000000..461e6125 --- /dev/null +++ b/crates/consensus/src/transaction/pooled.rs @@ -0,0 +1,523 @@ +//! Defines the exact transaction variants that are allowed to be propagated over the eth p2p +//! protocol in op. + +use crate::{OpTxEnvelope, OpTxType}; +use alloy_consensus::{ + transaction::{RlpEcdsaTx, TxEip1559, TxEip2930, TxLegacy}, + SignableTransaction, Signed, Transaction, TxEip7702, TxEnvelope, Typed2718, +}; +use alloy_eips::{ + eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718}, + eip2930::AccessList, + eip7702::SignedAuthorization, +}; +use alloy_primitives::{ + bytes, Bytes, ChainId, PrimitiveSignature as Signature, TxHash, TxKind, B256, U256, +}; +use alloy_rlp::{Decodable, Encodable, Header}; +use core::hash::{Hash, Hasher}; + +/// All possible transactions that can be included in a response to `GetPooledTransactions`. +/// A response to `GetPooledTransactions`. This can include a typed signed transaction, but cannot +/// include a deposit transaction or EIP-4844 transaction. +/// +/// The difference between this and the [`OpTxEnvelope`](crate::OpTxEnvelope) is that this type +/// does not have the deposit transaction variant, which is not expected to be pooled. +#[derive(Clone, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(all(any(test, feature = "arbitrary"), feature = "k256"), derive(arbitrary::Arbitrary))] +pub enum OpPooledTransaction { + /// An untagged [`TxLegacy`]. + Legacy(Signed), + /// A [`TxEip2930`] transaction tagged with type 1. + Eip2930(Signed), + /// A [`TxEip1559`] transaction tagged with type 2. + Eip1559(Signed), + /// A [`TxEip7702`] transaction tagged with type 4. + Eip7702(Signed), +} + +impl OpPooledTransaction { + /// Heavy operation that returns the signature hash over rlp encoded transaction. It is only + /// for signature signing or signer recovery. + pub fn signature_hash(&self) -> B256 { + match self { + Self::Legacy(tx) => tx.signature_hash(), + Self::Eip2930(tx) => tx.signature_hash(), + Self::Eip1559(tx) => tx.signature_hash(), + Self::Eip7702(tx) => tx.signature_hash(), + } + } + + /// Reference to transaction hash. Used to identify transaction. + pub const fn hash(&self) -> &TxHash { + match self { + Self::Legacy(tx) => tx.hash(), + Self::Eip2930(tx) => tx.hash(), + Self::Eip1559(tx) => tx.hash(), + Self::Eip7702(tx) => tx.hash(), + } + } + + /// Returns the signature of the transaction. + pub const fn signature(&self) -> &Signature { + match self { + Self::Legacy(tx) => tx.signature(), + Self::Eip2930(tx) => tx.signature(), + Self::Eip1559(tx) => tx.signature(), + Self::Eip7702(tx) => tx.signature(), + } + } + + /// The length of the 2718 encoded envelope in network format. This is the + /// length of the header + the length of the type flag and inner encoding. + fn network_len(&self) -> usize { + let mut payload_length = self.encode_2718_len(); + if !Encodable2718::is_legacy(self) { + payload_length += Header { list: false, payload_length }.length(); + } + + payload_length + } + + /// Recover the signer of the transaction. + #[cfg(feature = "k256")] + pub fn recover_signer( + &self, + ) -> Result { + match self { + Self::Legacy(tx) => tx.recover_signer(), + Self::Eip2930(tx) => tx.recover_signer(), + Self::Eip1559(tx) => tx.recover_signer(), + Self::Eip7702(tx) => tx.recover_signer(), + } + } + + /// This encodes the transaction _without_ the signature, and is only suitable for creating a + /// hash intended for signing. + pub fn encode_for_signing(&self, out: &mut dyn bytes::BufMut) { + match self { + Self::Legacy(tx) => tx.tx().encode_for_signing(out), + Self::Eip2930(tx) => tx.tx().encode_for_signing(out), + Self::Eip1559(tx) => tx.tx().encode_for_signing(out), + Self::Eip7702(tx) => tx.tx().encode_for_signing(out), + } + } + + /// Converts the transaction into the ethereum [`TxEnvelope`]. + pub fn into_envelope(self) -> TxEnvelope { + match self { + Self::Legacy(tx) => tx.into(), + Self::Eip2930(tx) => tx.into(), + Self::Eip1559(tx) => tx.into(), + Self::Eip7702(tx) => tx.into(), + } + } + + /// Converts the transaction into the optimism [`OpTxEnvelope`]. + pub fn into_op_envelope(self) -> OpTxEnvelope { + match self { + Self::Legacy(tx) => tx.into(), + Self::Eip2930(tx) => tx.into(), + Self::Eip1559(tx) => tx.into(), + Self::Eip7702(tx) => tx.into(), + } + } + + /// Returns the [`TxLegacy`] variant if the transaction is a legacy transaction. + pub const fn as_legacy(&self) -> Option<&TxLegacy> { + match self { + Self::Legacy(tx) => Some(tx.tx()), + _ => None, + } + } + + /// Returns the [`TxEip2930`] variant if the transaction is an EIP-2930 transaction. + pub const fn as_eip2930(&self) -> Option<&TxEip2930> { + match self { + Self::Eip2930(tx) => Some(tx.tx()), + _ => None, + } + } + + /// Returns the [`TxEip1559`] variant if the transaction is an EIP-1559 transaction. + pub const fn as_eip1559(&self) -> Option<&TxEip1559> { + match self { + Self::Eip1559(tx) => Some(tx.tx()), + _ => None, + } + } + + /// Returns the [`TxEip7702`] variant if the transaction is an EIP-7702 transaction. + pub const fn as_eip7702(&self) -> Option<&TxEip7702> { + match self { + Self::Eip7702(tx) => Some(tx.tx()), + _ => None, + } + } +} + +impl From> for OpPooledTransaction { + fn from(v: Signed) -> Self { + Self::Legacy(v) + } +} + +impl From> for OpPooledTransaction { + fn from(v: Signed) -> Self { + Self::Eip2930(v) + } +} + +impl From> for OpPooledTransaction { + fn from(v: Signed) -> Self { + Self::Eip1559(v) + } +} + +impl From> for OpPooledTransaction { + fn from(v: Signed) -> Self { + Self::Eip7702(v) + } +} + +impl Hash for OpPooledTransaction { + fn hash(&self, state: &mut H) { + self.trie_hash().hash(state); + } +} + +impl Encodable for OpPooledTransaction { + /// This encodes the transaction _with_ the signature, and an rlp header. + /// + /// For legacy transactions, it encodes the transaction data: + /// `rlp(tx-data)` + /// + /// For EIP-2718 typed transactions, it encodes the transaction type followed by the rlp of the + /// transaction: + /// `rlp(tx-type || rlp(tx-data))` + fn encode(&self, out: &mut dyn bytes::BufMut) { + self.network_encode(out); + } + + fn length(&self) -> usize { + self.network_len() + } +} + +impl Decodable for OpPooledTransaction { + /// Decodes an enveloped [`OpPooledTransaction`]. + /// + /// CAUTION: this expects that `buf` is `rlp(tx_type || rlp(tx-data))` + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + Ok(Self::network_decode(buf)?) + } +} + +impl Encodable2718 for OpPooledTransaction { + fn type_flag(&self) -> Option { + match self { + Self::Legacy(_) => None, + Self::Eip2930(_) => Some(0x01), + Self::Eip1559(_) => Some(0x02), + Self::Eip7702(_) => Some(0x04), + } + } + + fn encode_2718_len(&self) -> usize { + match self { + Self::Legacy(tx) => tx.eip2718_encoded_length(), + Self::Eip2930(tx) => tx.eip2718_encoded_length(), + Self::Eip1559(tx) => tx.eip2718_encoded_length(), + Self::Eip7702(tx) => tx.eip2718_encoded_length(), + } + } + + fn encode_2718(&self, out: &mut dyn alloy_rlp::BufMut) { + match self { + Self::Legacy(tx) => tx.eip2718_encode(out), + Self::Eip2930(tx) => tx.eip2718_encode(out), + Self::Eip1559(tx) => tx.eip2718_encode(out), + Self::Eip7702(tx) => tx.eip2718_encode(out), + } + } + + fn trie_hash(&self) -> B256 { + *self.hash() + } +} + +impl Decodable2718 for OpPooledTransaction { + fn typed_decode(ty: u8, buf: &mut &[u8]) -> Eip2718Result { + match ty.try_into().map_err(|_| alloy_rlp::Error::Custom("unexpected tx type"))? { + OpTxType::Eip2930 => Ok(TxEip2930::rlp_decode_signed(buf)?.into()), + OpTxType::Eip1559 => Ok(TxEip1559::rlp_decode_signed(buf)?.into()), + OpTxType::Eip7702 => Ok(TxEip7702::rlp_decode_signed(buf)?.into()), + OpTxType::Legacy => Err(Eip2718Error::UnexpectedType(OpTxType::Legacy.into())), + OpTxType::Deposit => Err(Eip2718Error::UnexpectedType(OpTxType::Deposit.into())), + } + } + + fn fallback_decode(buf: &mut &[u8]) -> Eip2718Result { + TxLegacy::rlp_decode_signed(buf).map(Into::into).map_err(Into::into) + } +} + +impl Transaction for OpPooledTransaction { + fn chain_id(&self) -> Option { + match self { + Self::Legacy(tx) => tx.tx().chain_id(), + Self::Eip2930(tx) => tx.tx().chain_id(), + Self::Eip1559(tx) => tx.tx().chain_id(), + Self::Eip7702(tx) => tx.tx().chain_id(), + } + } + + fn nonce(&self) -> u64 { + match self { + Self::Legacy(tx) => tx.tx().nonce(), + Self::Eip2930(tx) => tx.tx().nonce(), + Self::Eip1559(tx) => tx.tx().nonce(), + Self::Eip7702(tx) => tx.tx().nonce(), + } + } + + fn gas_limit(&self) -> u64 { + match self { + Self::Legacy(tx) => tx.tx().gas_limit(), + Self::Eip2930(tx) => tx.tx().gas_limit(), + Self::Eip1559(tx) => tx.tx().gas_limit(), + Self::Eip7702(tx) => tx.tx().gas_limit(), + } + } + + fn gas_price(&self) -> Option { + match self { + Self::Legacy(tx) => tx.tx().gas_price(), + Self::Eip2930(tx) => tx.tx().gas_price(), + Self::Eip1559(tx) => tx.tx().gas_price(), + Self::Eip7702(tx) => tx.tx().gas_price(), + } + } + + fn max_fee_per_gas(&self) -> u128 { + match self { + Self::Legacy(tx) => tx.tx().max_fee_per_gas(), + Self::Eip2930(tx) => tx.tx().max_fee_per_gas(), + Self::Eip1559(tx) => tx.tx().max_fee_per_gas(), + Self::Eip7702(tx) => tx.tx().max_fee_per_gas(), + } + } + + fn max_priority_fee_per_gas(&self) -> Option { + match self { + Self::Legacy(tx) => tx.tx().max_priority_fee_per_gas(), + Self::Eip2930(tx) => tx.tx().max_priority_fee_per_gas(), + Self::Eip1559(tx) => tx.tx().max_priority_fee_per_gas(), + Self::Eip7702(tx) => tx.tx().max_priority_fee_per_gas(), + } + } + + fn max_fee_per_blob_gas(&self) -> Option { + match self { + Self::Legacy(tx) => tx.tx().max_fee_per_blob_gas(), + Self::Eip2930(tx) => tx.tx().max_fee_per_blob_gas(), + Self::Eip1559(tx) => tx.tx().max_fee_per_blob_gas(), + Self::Eip7702(tx) => tx.tx().max_fee_per_blob_gas(), + } + } + + fn priority_fee_or_price(&self) -> u128 { + match self { + Self::Legacy(tx) => tx.tx().priority_fee_or_price(), + Self::Eip2930(tx) => tx.tx().priority_fee_or_price(), + Self::Eip1559(tx) => tx.tx().priority_fee_or_price(), + Self::Eip7702(tx) => tx.tx().priority_fee_or_price(), + } + } + + fn effective_gas_price(&self, base_fee: Option) -> u128 { + match self { + Self::Legacy(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip2930(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip1559(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip7702(tx) => tx.tx().effective_gas_price(base_fee), + } + } + + fn is_dynamic_fee(&self) -> bool { + match self { + Self::Legacy(tx) => tx.tx().is_dynamic_fee(), + Self::Eip2930(tx) => tx.tx().is_dynamic_fee(), + Self::Eip1559(tx) => tx.tx().is_dynamic_fee(), + Self::Eip7702(tx) => tx.tx().is_dynamic_fee(), + } + } + + fn kind(&self) -> TxKind { + match self { + Self::Legacy(tx) => tx.tx().kind(), + Self::Eip2930(tx) => tx.tx().kind(), + Self::Eip1559(tx) => tx.tx().kind(), + Self::Eip7702(tx) => tx.tx().kind(), + } + } + + fn is_create(&self) -> bool { + match self { + Self::Legacy(tx) => tx.tx().is_create(), + Self::Eip2930(tx) => tx.tx().is_create(), + Self::Eip1559(tx) => tx.tx().is_create(), + Self::Eip7702(tx) => tx.tx().is_create(), + } + } + + fn value(&self) -> U256 { + match self { + Self::Legacy(tx) => tx.tx().value(), + Self::Eip2930(tx) => tx.tx().value(), + Self::Eip1559(tx) => tx.tx().value(), + Self::Eip7702(tx) => tx.tx().value(), + } + } + + fn input(&self) -> &Bytes { + match self { + Self::Legacy(tx) => tx.tx().input(), + Self::Eip2930(tx) => tx.tx().input(), + Self::Eip1559(tx) => tx.tx().input(), + Self::Eip7702(tx) => tx.tx().input(), + } + } + + fn access_list(&self) -> Option<&AccessList> { + match self { + Self::Legacy(tx) => tx.tx().access_list(), + Self::Eip2930(tx) => tx.tx().access_list(), + Self::Eip1559(tx) => tx.tx().access_list(), + Self::Eip7702(tx) => tx.tx().access_list(), + } + } + + fn blob_versioned_hashes(&self) -> Option<&[B256]> { + match self { + Self::Legacy(tx) => tx.tx().blob_versioned_hashes(), + Self::Eip2930(tx) => tx.tx().blob_versioned_hashes(), + Self::Eip1559(tx) => tx.tx().blob_versioned_hashes(), + Self::Eip7702(tx) => tx.tx().blob_versioned_hashes(), + } + } + + fn authorization_list(&self) -> Option<&[SignedAuthorization]> { + match self { + Self::Legacy(tx) => tx.tx().authorization_list(), + Self::Eip2930(tx) => tx.tx().authorization_list(), + Self::Eip1559(tx) => tx.tx().authorization_list(), + Self::Eip7702(tx) => tx.tx().authorization_list(), + } + } +} + +impl Typed2718 for OpPooledTransaction { + fn ty(&self) -> u8 { + match self { + Self::Legacy(tx) => tx.tx().ty(), + Self::Eip2930(tx) => tx.tx().ty(), + Self::Eip1559(tx) => tx.tx().ty(), + Self::Eip7702(tx) => tx.tx().ty(), + } + } +} + +impl From for TxEnvelope { + fn from(tx: OpPooledTransaction) -> Self { + tx.into_envelope() + } +} + +impl From for OpTxEnvelope { + fn from(tx: OpPooledTransaction) -> Self { + tx.into_op_envelope() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use alloy_primitives::{address, hex}; + use bytes::Bytes; + + #[test] + fn invalid_legacy_pooled_decoding_input_too_short() { + let input_too_short = [ + // this should fail because the payload length is longer than expected + &hex!("d90b0280808bc5cd028083c5cdfd9e407c56565656")[..], + // these should fail decoding + // + // The `c1` at the beginning is a list header, and the rest is a valid legacy + // transaction, BUT the payload length of the list header is 1, and the payload is + // obviously longer than one byte. + &hex!("c10b02808083c5cd028883c5cdfd9e407c56565656"), + &hex!("c10b0280808bc5cd028083c5cdfd9e407c56565656"), + // this one is 19 bytes, and the buf is long enough, but the transaction will not + // consume that many bytes. + &hex!("d40b02808083c5cdeb8783c5acfd9e407c5656565656"), + &hex!("d30102808083c5cd02887dc5cdfd9e64fd9e407c56"), + ]; + + for hex_data in &input_too_short { + let input_rlp = &mut &hex_data[..]; + let res = OpPooledTransaction::decode(input_rlp); + + assert!( + res.is_err(), + "expected err after decoding rlp input: {:x?}", + Bytes::copy_from_slice(hex_data) + ); + + // this is a legacy tx so we can attempt the same test with decode_enveloped + let input_rlp = &mut &hex_data[..]; + let res = OpPooledTransaction::decode_2718(input_rlp); + + assert!( + res.is_err(), + "expected err after decoding enveloped rlp input: {:x?}", + Bytes::copy_from_slice(hex_data) + ); + } + } + + // + #[test] + fn decode_eip1559_enveloped() { + let data = hex!("02f903d382426882ba09832dc6c0848674742682ed9694714b6a4ea9b94a8a7d9fd362ed72630688c8898c80b90364492d24749189822d8512430d3f3ff7a2ede675ac08265c08e2c56ff6fdaa66dae1cdbe4a5d1d7809f3e99272d067364e597542ac0c369d69e22a6399c3e9bee5da4b07e3f3fdc34c32c3d88aa2268785f3e3f8086df0934b10ef92cfffc2e7f3d90f5e83302e31382e302d64657600000000000000000000000000000000000000000000569e75fc77c1a856f6daaf9e69d8a9566ca34aa47f9133711ce065a571af0cfd000000000000000000000000e1e210594771824dad216568b91c9cb4ceed361c00000000000000000000000000000000000000000000000000000000000546e00000000000000000000000000000000000000000000000000000000000e4e1c00000000000000000000000000000000000000000000000000000000065d6750c00000000000000000000000000000000000000000000000000000000000f288000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cf600000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000000f1628e56fa6d8c50e5b984a58c0df14de31c7b857ce7ba499945b99252976a93d06dcda6776fc42167fbe71cb59f978f5ef5b12577a90b132d14d9c6efa528076f0161d7bf03643cfc5490ec5084f4a041db7f06c50bd97efa08907ba79ddcac8b890f24d12d8db31abbaaf18985d54f400449ee0559a4452afe53de5853ce090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000c080a01428023fc54a27544abc421d5d017b9a7c5936ad501cbdecd0d9d12d04c1a033a0753104bbf1c87634d6ff3f0ffa0982710612306003eb022363b57994bdef445a" +); + + let res = OpPooledTransaction::decode_2718(&mut &data[..]).unwrap(); + assert_eq!(res.to(), Some(address!("714b6a4ea9b94a8a7d9fd362ed72630688c8898c"))); + } + + #[test] + fn legacy_valid_pooled_decoding() { + // d3 <- payload length, d3 - c0 = 0x13 = 19 + // 0b <- nonce + // 02 <- gas_price + // 80 <- gas_limit + // 80 <- to (Create) + // 83 c5cdeb <- value + // 87 83c5acfd9e407c <- input + // 56 <- v (eip155, so modified with a chain id) + // 56 <- r + // 56 <- s + let data = &hex!("d30b02808083c5cdeb8783c5acfd9e407c565656")[..]; + + let input_rlp = &mut &data[..]; + let res = OpPooledTransaction::decode(input_rlp); + assert!(res.is_ok()); + assert!(input_rlp.is_empty()); + + // we can also decode_enveloped + let res = OpPooledTransaction::decode_2718(&mut &data[..]); + assert!(res.is_ok()); + } +} From d5b9014fe1d7eff126886b088c871dedc1ddf447 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 14 Dec 2024 21:05:34 +0100 Subject: [PATCH 11/16] chore: reorder impl fns (#342) use same order as trait --- crates/consensus/src/transaction/deposit.rs | 8 +-- crates/consensus/src/transaction/envelope.rs | 72 ++++++++++---------- crates/consensus/src/transaction/typed.rs | 72 ++++++++++---------- crates/rpc-types/src/transaction.rs | 8 +-- 4 files changed, 80 insertions(+), 80 deletions(-) diff --git a/crates/consensus/src/transaction/deposit.rs b/crates/consensus/src/transaction/deposit.rs index d0cf7d17..75149600 100644 --- a/crates/consensus/src/transaction/deposit.rs +++ b/crates/consensus/src/transaction/deposit.rs @@ -236,10 +236,6 @@ impl Transaction for TxDeposit { None } - fn is_create(&self) -> bool { - self.to.is_create() - } - fn nonce(&self) -> u64 { 0u64 } @@ -280,6 +276,10 @@ impl Transaction for TxDeposit { self.to } + fn is_create(&self) -> bool { + self.to.is_create() + } + fn value(&self) -> U256 { self.value } diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index b9392fd9..42c4e92d 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -103,16 +103,6 @@ impl Transaction for OpTxEnvelope { } } - fn is_create(&self) -> bool { - match self { - Self::Legacy(tx) => tx.tx().is_create(), - Self::Eip2930(tx) => tx.tx().is_create(), - Self::Eip1559(tx) => tx.tx().is_create(), - Self::Eip7702(tx) => tx.tx().is_create(), - Self::Deposit(tx) => tx.is_create(), - } - } - fn nonce(&self) -> u64 { match self { Self::Legacy(tx) => tx.tx().nonce(), @@ -183,13 +173,23 @@ impl Transaction for OpTxEnvelope { } } - fn to(&self) -> Option
{ + fn effective_gas_price(&self, base_fee: Option) -> u128 { match self { - Self::Legacy(tx) => tx.tx().to(), - Self::Eip2930(tx) => tx.tx().to(), - Self::Eip1559(tx) => tx.tx().to(), - Self::Eip7702(tx) => tx.tx().to(), - Self::Deposit(tx) => tx.to(), + Self::Legacy(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip2930(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip1559(tx) => tx.tx().effective_gas_price(base_fee), + Self::Eip7702(tx) => tx.tx().effective_gas_price(base_fee), + Self::Deposit(tx) => tx.effective_gas_price(base_fee), + } + } + + fn is_dynamic_fee(&self) -> bool { + match self { + Self::Legacy(tx) => tx.tx().is_dynamic_fee(), + Self::Eip2930(tx) => tx.tx().is_dynamic_fee(), + Self::Eip1559(tx) => tx.tx().is_dynamic_fee(), + Self::Eip7702(tx) => tx.tx().is_dynamic_fee(), + Self::Deposit(tx) => tx.is_dynamic_fee(), } } @@ -203,6 +203,26 @@ impl Transaction for OpTxEnvelope { } } + fn is_create(&self) -> bool { + match self { + Self::Legacy(tx) => tx.tx().is_create(), + Self::Eip2930(tx) => tx.tx().is_create(), + Self::Eip1559(tx) => tx.tx().is_create(), + Self::Eip7702(tx) => tx.tx().is_create(), + Self::Deposit(tx) => tx.is_create(), + } + } + + fn to(&self) -> Option
{ + match self { + Self::Legacy(tx) => tx.tx().to(), + Self::Eip2930(tx) => tx.tx().to(), + Self::Eip1559(tx) => tx.tx().to(), + Self::Eip7702(tx) => tx.tx().to(), + Self::Deposit(tx) => tx.to(), + } + } + fn value(&self) -> U256 { match self { Self::Legacy(tx) => tx.tx().value(), @@ -252,26 +272,6 @@ impl Transaction for OpTxEnvelope { Self::Deposit(tx) => tx.authorization_list(), } } - - fn is_dynamic_fee(&self) -> bool { - match self { - Self::Legacy(tx) => tx.tx().is_dynamic_fee(), - Self::Eip2930(tx) => tx.tx().is_dynamic_fee(), - Self::Eip1559(tx) => tx.tx().is_dynamic_fee(), - Self::Eip7702(tx) => tx.tx().is_dynamic_fee(), - Self::Deposit(tx) => tx.is_dynamic_fee(), - } - } - - fn effective_gas_price(&self, base_fee: Option) -> u128 { - match self { - Self::Legacy(tx) => tx.tx().effective_gas_price(base_fee), - Self::Eip2930(tx) => tx.tx().effective_gas_price(base_fee), - Self::Eip1559(tx) => tx.tx().effective_gas_price(base_fee), - Self::Eip7702(tx) => tx.tx().effective_gas_price(base_fee), - Self::Deposit(tx) => tx.effective_gas_price(base_fee), - } - } } impl OpTxEnvelope { diff --git a/crates/consensus/src/transaction/typed.rs b/crates/consensus/src/transaction/typed.rs index eda32684..d223f471 100644 --- a/crates/consensus/src/transaction/typed.rs +++ b/crates/consensus/src/transaction/typed.rs @@ -138,16 +138,6 @@ impl Transaction for OpTypedTransaction { } } - fn is_create(&self) -> bool { - match self { - Self::Legacy(tx) => tx.is_create(), - Self::Eip2930(tx) => tx.is_create(), - Self::Eip1559(tx) => tx.is_create(), - Self::Eip7702(tx) => tx.is_create(), - Self::Deposit(tx) => tx.is_create(), - } - } - fn nonce(&self) -> u64 { match self { Self::Legacy(tx) => tx.nonce(), @@ -218,13 +208,23 @@ impl Transaction for OpTypedTransaction { } } - fn to(&self) -> Option
{ + fn effective_gas_price(&self, base_fee: Option) -> u128 { match self { - Self::Legacy(tx) => tx.to(), - Self::Eip2930(tx) => tx.to(), - Self::Eip1559(tx) => tx.to(), - Self::Eip7702(tx) => tx.to(), - Self::Deposit(tx) => tx.to(), + Self::Legacy(tx) => tx.effective_gas_price(base_fee), + Self::Eip2930(tx) => tx.effective_gas_price(base_fee), + Self::Eip1559(tx) => tx.effective_gas_price(base_fee), + Self::Eip7702(tx) => tx.effective_gas_price(base_fee), + Self::Deposit(tx) => tx.effective_gas_price(base_fee), + } + } + + fn is_dynamic_fee(&self) -> bool { + match self { + Self::Legacy(tx) => tx.is_dynamic_fee(), + Self::Eip2930(tx) => tx.is_dynamic_fee(), + Self::Eip1559(tx) => tx.is_dynamic_fee(), + Self::Eip7702(tx) => tx.is_dynamic_fee(), + Self::Deposit(tx) => tx.is_dynamic_fee(), } } @@ -238,6 +238,26 @@ impl Transaction for OpTypedTransaction { } } + fn is_create(&self) -> bool { + match self { + Self::Legacy(tx) => tx.is_create(), + Self::Eip2930(tx) => tx.is_create(), + Self::Eip1559(tx) => tx.is_create(), + Self::Eip7702(tx) => tx.is_create(), + Self::Deposit(tx) => tx.is_create(), + } + } + + fn to(&self) -> Option
{ + match self { + Self::Legacy(tx) => tx.to(), + Self::Eip2930(tx) => tx.to(), + Self::Eip1559(tx) => tx.to(), + Self::Eip7702(tx) => tx.to(), + Self::Deposit(tx) => tx.to(), + } + } + fn value(&self) -> alloy_primitives::U256 { match self { Self::Legacy(tx) => tx.value(), @@ -287,26 +307,6 @@ impl Transaction for OpTypedTransaction { Self::Deposit(tx) => tx.authorization_list(), } } - - fn is_dynamic_fee(&self) -> bool { - match self { - Self::Legacy(tx) => tx.is_dynamic_fee(), - Self::Eip2930(tx) => tx.is_dynamic_fee(), - Self::Eip1559(tx) => tx.is_dynamic_fee(), - Self::Eip7702(tx) => tx.is_dynamic_fee(), - Self::Deposit(tx) => tx.is_dynamic_fee(), - } - } - - fn effective_gas_price(&self, base_fee: Option) -> u128 { - match self { - Self::Legacy(tx) => tx.effective_gas_price(base_fee), - Self::Eip2930(tx) => tx.effective_gas_price(base_fee), - Self::Eip1559(tx) => tx.effective_gas_price(base_fee), - Self::Eip7702(tx) => tx.effective_gas_price(base_fee), - Self::Deposit(tx) => tx.effective_gas_price(base_fee), - } - } } #[cfg(feature = "serde")] diff --git a/crates/rpc-types/src/transaction.rs b/crates/rpc-types/src/transaction.rs index 9a3d19c4..81504d5b 100644 --- a/crates/rpc-types/src/transaction.rs +++ b/crates/rpc-types/src/transaction.rs @@ -40,10 +40,6 @@ impl alloy_consensus::Transaction for Transaction { self.inner.chain_id() } - fn is_create(&self) -> bool { - self.inner.is_create() - } - fn nonce(&self) -> u64 { self.inner.nonce() } @@ -84,6 +80,10 @@ impl alloy_consensus::Transaction for Transaction { self.inner.kind() } + fn is_create(&self) -> bool { + self.inner.is_create() + } + fn to(&self) -> Option
{ self.inner.to() } From 569f82b9cba03c055adc200a472ecc801c9e8133 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 14 Dec 2024 21:06:30 +0100 Subject: [PATCH 12/16] docs: fix docs (#343) --- crates/consensus/src/transaction/pooled.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/consensus/src/transaction/pooled.rs b/crates/consensus/src/transaction/pooled.rs index 461e6125..d3ee5943 100644 --- a/crates/consensus/src/transaction/pooled.rs +++ b/crates/consensus/src/transaction/pooled.rs @@ -21,8 +21,8 @@ use core::hash::{Hash, Hasher}; /// A response to `GetPooledTransactions`. This can include a typed signed transaction, but cannot /// include a deposit transaction or EIP-4844 transaction. /// -/// The difference between this and the [`OpTxEnvelope`](crate::OpTxEnvelope) is that this type -/// does not have the deposit transaction variant, which is not expected to be pooled. +/// The difference between this and the [`OpTxEnvelope`] is that this type does not have the deposit +/// transaction variant, which is not expected to be pooled. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(all(any(test, feature = "arbitrary"), feature = "k256"), derive(arbitrary::Arbitrary))] From 443070786a2fd07af956c7ea44501545ff3b0c64 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 14 Dec 2024 21:06:51 +0100 Subject: [PATCH 13/16] chore: release 0.8.3 --- CHANGELOG.md | 19 +++++++++++++++++++ Cargo.toml | 20 ++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f491781..db848803 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.3](https://github.com/alloy-rs/op-alloy +/releases/tag/v0.8.3) - 2024-12-14 + +### Documentation + +- Fix docs ([#343](https://github.com/alloy-rs/op-alloy/issues/343)) + +### Features + +- Add OpPooledTransaction ([#341](https://github.com/alloy-rs/op-alloy/issues/341)) + +### Miscellaneous Tasks + +- Reorder impl fns ([#342](https://github.com/alloy-rs/op-alloy/issues/342)) + ## [0.8.2](https://github.com/alloy-rs/op-alloy /releases/tag/v0.8.2) - 2024-12-12 @@ -12,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Upstream decode extradata fn ([#340](https://github.com/alloy-rs/op-alloy/issues/340)) +### Miscellaneous Tasks + +- Release 0.8.2 + ## [0.8.1](https://github.com/alloy-rs/op-alloy /releases/tag/v0.8.1) - 2024-12-12 diff --git a/Cargo.toml b/Cargo.toml index cab86f07..562a11b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.8.2" +version = "0.8.3" edition = "2021" rust-version = "1.81" authors = ["Alloy Contributors"] @@ -36,15 +36,15 @@ rustdoc-args = ["--cfg", "docsrs"] [workspace.dependencies] # Workspace -op-alloy-genesis = { version = "0.8.2", path = "crates/genesis", default-features = false } -op-alloy-protocol = { version = "0.8.2", path = "crates/protocol", default-features = false } -op-alloy-consensus = { version = "0.8.2", path = "crates/consensus", default-features = false } -op-alloy-network = { version = "0.8.2", path = "crates/network", default-features = false } -op-alloy-provider = { version = "0.8.2", path = "crates/provider", default-features = false } -op-alloy-registry = { version = "0.8.2", path = "crates/registry", default-features = false } -op-alloy-rpc-types = { version = "0.8.2", path = "crates/rpc-types", default-features = false } -op-alloy-rpc-jsonrpsee = { version = "0.8.2", path = "crates/rpc-jsonrpsee", default-features = false } -op-alloy-rpc-types-engine = { version = "0.8.2", path = "crates/rpc-types-engine", default-features = false } +op-alloy-genesis = { version = "0.8.3", path = "crates/genesis", default-features = false } +op-alloy-protocol = { version = "0.8.3", path = "crates/protocol", default-features = false } +op-alloy-consensus = { version = "0.8.3", path = "crates/consensus", default-features = false } +op-alloy-network = { version = "0.8.3", path = "crates/network", default-features = false } +op-alloy-provider = { version = "0.8.3", path = "crates/provider", default-features = false } +op-alloy-registry = { version = "0.8.3", path = "crates/registry", default-features = false } +op-alloy-rpc-types = { version = "0.8.3", path = "crates/rpc-types", default-features = false } +op-alloy-rpc-jsonrpsee = { version = "0.8.3", path = "crates/rpc-jsonrpsee", default-features = false } +op-alloy-rpc-types-engine = { version = "0.8.3", path = "crates/rpc-types-engine", default-features = false } # Alloy alloy-eips = { version = "0.8", default-features = false } From 3584cc614c4b20c9c550682386e82990dc24fb5d Mon Sep 17 00:00:00 2001 From: "SangyunOck(adi-dunamu)" Date: Tue, 17 Dec 2024 22:23:58 +0900 Subject: [PATCH 14/16] [Bug] miner_setMaxDASize should return bool type (#346) ## Motivation op batcher prints error `ERROR[12-17|18:17:23.568] Result of SetMaxDASize was false, retrying.` command for op-bathcer ```shell op-batcher \ --l2-eth-rpc=http://localhost:8545 \ --rollup-rpc=http://localhost:9545 \ --poll-interval=1s \ --sub-safety-margin=6 \ --num-confirmations=1 \ --safe-abort-nonce-too-low-count=3 \ --resubmission-timeout=30s \ --rpc.addr=0.0.0.0 \ --rpc.port=8548 \ --rpc.enable-admin \ --max-channel-duration=25 \ --l1-eth-rpc=$L1_RPC_URL \ --private-key=$GS_BATCHER_PRIVATE_KEY ``` golang implementation of optimism's op-geth [returns bool](https://github.com/ethereum-optimism/op-geth/blob/optimism/eth/api_miner.go#L62) type for `miner_setMaxDASize` call. Therefore, expected response might be like following: ```json { "jsonrpc": "2.0", "id": 0, "result": true } ``` On the other hand, current trait [returns `()`](https://github.com/alloy-rs/op-alloy/blob/main/crates/rpc-jsonrpsee/src/traits.rs#L146), represents null for json. ```rust pub trait MinerApiExt { /// Sets the maximum data availability size of any tx allowed in a block, and the total max l1 /// data size of the block. 0 means no maximum. #[method(name = "setMaxDASize")] async fn set_max_da_size(&self, max_tx_size: U64, max_block_size: U64) -> RpcResult<()>; // should return bool } ``` ```json { "jsonrpc": "2.0", "id": 0, "result": null } ``` ref: #325, #345 ## Solution alter `()` to `bool` for return type ```rust async fn set_max_da_size(&self, max_tx_size: U64, max_block_size: U64) -> RpcResult; ``` ## PR Checklist - [ ] Added Tests - [ ] Added Documentation - [x] Breaking changes --- crates/rpc-jsonrpsee/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rpc-jsonrpsee/src/traits.rs b/crates/rpc-jsonrpsee/src/traits.rs index a3304f31..abc59488 100644 --- a/crates/rpc-jsonrpsee/src/traits.rs +++ b/crates/rpc-jsonrpsee/src/traits.rs @@ -143,5 +143,5 @@ pub trait MinerApiExt { /// Sets the maximum data availability size of any tx allowed in a block, and the total max l1 /// data size of the block. 0 means no maximum. #[method(name = "setMaxDASize")] - async fn set_max_da_size(&self, max_tx_size: U64, max_block_size: U64) -> RpcResult<()>; + async fn set_max_da_size(&self, max_tx_size: U64, max_block_size: U64) -> RpcResult; } From 95784f665fa8a2c04ebf8f89a43d9bba3fdbaedd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 17 Dec 2024 14:41:22 +0100 Subject: [PATCH 15/16] chore: bump alloy 081 (#344) --- Cargo.toml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 562a11b6..a90652cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,16 +47,16 @@ op-alloy-rpc-jsonrpsee = { version = "0.8.3", path = "crates/rpc-jsonrpsee", def op-alloy-rpc-types-engine = { version = "0.8.3", path = "crates/rpc-types-engine", default-features = false } # Alloy -alloy-eips = { version = "0.8", default-features = false } -alloy-serde = { version = "0.8", default-features = false } -alloy-signer = { version = "0.8", default-features = false } -alloy-network = { version = "0.8", default-features = false } -alloy-provider = { version = "0.8", default-features = false } -alloy-transport = { version = "0.8", default-features = false } -alloy-consensus = { version = "0.8", default-features = false } -alloy-rpc-types-eth = { version = "0.8", default-features = false } -alloy-rpc-types-engine = { version = "0.8", default-features = false } -alloy-network-primitives = { version = "0.8", default-features = false } +alloy-eips = { version = "0.8.1", default-features = false } +alloy-serde = { version = "0.8.1", default-features = false } +alloy-signer = { version = "0.8.1", default-features = false } +alloy-network = { version = "0.8.1", default-features = false } +alloy-provider = { version = "0.8.1", default-features = false } +alloy-transport = { version = "0.8.1", default-features = false } +alloy-consensus = { version = "0.8.1", default-features = false } +alloy-rpc-types-eth = { version = "0.8.1", default-features = false } +alloy-rpc-types-engine = { version = "0.8.1", default-features = false } +alloy-network-primitives = { version = "0.8.1", default-features = false } # Alloy RLP alloy-rlp = { version = "0.3", default-features = false } From c097c0126c1e0a6b3131e7f2a948ada93fe3e435 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 17 Dec 2024 14:42:14 +0100 Subject: [PATCH 16/16] chore: release 0.8.4 --- CHANGELOG.md | 12 ++++++++++++ Cargo.toml | 20 ++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db848803..344c085a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.4](https://github.com/alloy-rs/op-alloy +/releases/tag/v0.8.4) - 2024-12-17 + +### Dependencies + +- Bump alloy 081 ([#344](https://github.com/alloy-rs/op-alloy/issues/344)) + +### Other + +- [Bug] miner_setMaxDASize should return bool type ([#346](https://github.com/alloy-rs/op-alloy/issues/346)) + ## [0.8.3](https://github.com/alloy-rs/op-alloy /releases/tag/v0.8.3) - 2024-12-14 @@ -18,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Miscellaneous Tasks +- Release 0.8.3 - Reorder impl fns ([#342](https://github.com/alloy-rs/op-alloy/issues/342)) ## [0.8.2](https://github.com/alloy-rs/op-alloy diff --git a/Cargo.toml b/Cargo.toml index a90652cf..72d33fbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.8.3" +version = "0.8.4" edition = "2021" rust-version = "1.81" authors = ["Alloy Contributors"] @@ -36,15 +36,15 @@ rustdoc-args = ["--cfg", "docsrs"] [workspace.dependencies] # Workspace -op-alloy-genesis = { version = "0.8.3", path = "crates/genesis", default-features = false } -op-alloy-protocol = { version = "0.8.3", path = "crates/protocol", default-features = false } -op-alloy-consensus = { version = "0.8.3", path = "crates/consensus", default-features = false } -op-alloy-network = { version = "0.8.3", path = "crates/network", default-features = false } -op-alloy-provider = { version = "0.8.3", path = "crates/provider", default-features = false } -op-alloy-registry = { version = "0.8.3", path = "crates/registry", default-features = false } -op-alloy-rpc-types = { version = "0.8.3", path = "crates/rpc-types", default-features = false } -op-alloy-rpc-jsonrpsee = { version = "0.8.3", path = "crates/rpc-jsonrpsee", default-features = false } -op-alloy-rpc-types-engine = { version = "0.8.3", path = "crates/rpc-types-engine", default-features = false } +op-alloy-genesis = { version = "0.8.4", path = "crates/genesis", default-features = false } +op-alloy-protocol = { version = "0.8.4", path = "crates/protocol", default-features = false } +op-alloy-consensus = { version = "0.8.4", path = "crates/consensus", default-features = false } +op-alloy-network = { version = "0.8.4", path = "crates/network", default-features = false } +op-alloy-provider = { version = "0.8.4", path = "crates/provider", default-features = false } +op-alloy-registry = { version = "0.8.4", path = "crates/registry", default-features = false } +op-alloy-rpc-types = { version = "0.8.4", path = "crates/rpc-types", default-features = false } +op-alloy-rpc-jsonrpsee = { version = "0.8.4", path = "crates/rpc-jsonrpsee", default-features = false } +op-alloy-rpc-types-engine = { version = "0.8.4", path = "crates/rpc-types-engine", default-features = false } # Alloy alloy-eips = { version = "0.8.1", default-features = false }