From c640fcb68889deddc6a8a0be53efdb0ed04533e4 Mon Sep 17 00:00:00 2001 From: refcell Date: Fri, 6 Sep 2024 08:53:08 -0400 Subject: [PATCH] chore(primitives): Remove the RawTransaction type --- Cargo.lock | 18 +++---- Cargo.toml | 2 +- crates/derive/src/batch/single_batch.rs | 15 +++--- crates/derive/src/batch/span_batch/batch.rs | 8 ++-- crates/derive/src/batch/span_batch/element.rs | 7 ++- crates/derive/src/batch/span_batch/raw.rs | 4 +- .../src/batch/span_batch/transactions.rs | 9 +--- crates/derive/src/stages/attributes_queue.rs | 5 +- .../src/stages/attributes_queue/builder.rs | 14 +++--- .../src/stages/attributes_queue/deposits.rs | 8 ++-- crates/derive/src/stages/batch_queue.rs | 16 +------ crates/executor/src/lib.rs | 4 +- crates/primitives/src/attributes.rs | 6 +-- crates/primitives/src/deposits.rs | 16 ++----- crates/primitives/src/lib.rs | 18 ++++--- crates/primitives/src/raw_tx.rs | 47 ------------------- examples/trusted-sync/src/validation.rs | 10 ++-- 17 files changed, 63 insertions(+), 144 deletions(-) delete mode 100644 crates/primitives/src/raw_tx.rs diff --git a/Cargo.lock b/Cargo.lock index 940ae8244..c661754bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,9 +262,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb07629a5d0645d29f68d2fb6f4d0cf15c89ec0965be915f303967180929743f" +checksum = "2b4f201b0ac8f81315fbdc55269965a8ddadbc04ab47fa65a1a468f9a40f7a5f" dependencies = [ "num_enum", "strum", @@ -1086,9 +1086,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -1330,9 +1330,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -2888,7 +2888,7 @@ dependencies = [ [[package]] name = "op-alloy-protocol" version = "0.2.8" -source = "git+https://github.com/alloy-rs/op-alloy?branch=rf/fix/use-native-u64#ea93a1fd9e46d9ca38919ebbdbd21e448b475898" +source = "git+https://github.com/alloy-rs/op-alloy?branch=main#0d8ef62ae942c85d260e64f08d10e0a429c00289" dependencies = [ "alloy-primitives", "hashbrown 0.14.5", @@ -3742,9 +3742,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" dependencies = [ "bitflags 2.6.0", "errno", diff --git a/Cargo.toml b/Cargo.toml index 081c85083..1960d3a86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ codegen-units = 1 lto = "fat" [patch.crates-io] -op-alloy-protocol = { git = "https://github.com/alloy-rs/op-alloy", branch = "rf/fix/use-native-u64" } +op-alloy-protocol = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" } [workspace.dependencies] # Workspace diff --git a/crates/derive/src/batch/single_batch.rs b/crates/derive/src/batch/single_batch.rs index e25b74499..178f73263 100644 --- a/crates/derive/src/batch/single_batch.rs +++ b/crates/derive/src/batch/single_batch.rs @@ -2,9 +2,9 @@ use super::validity::BatchValidity; use alloc::vec::Vec; -use alloy_primitives::BlockHash; +use alloy_primitives::{BlockHash, Bytes}; use alloy_rlp::{RlpDecodable, RlpEncodable}; -use kona_primitives::{BlockID, BlockInfo, L2BlockInfo, RawTransaction, RollupConfig}; +use kona_primitives::{starts_with_2781_deposit, BlockID, BlockInfo, L2BlockInfo, RollupConfig}; use tracing::{info, warn}; /// Represents a single batch: a single encoded L2 block @@ -20,7 +20,7 @@ pub struct SingleBatch { /// The L2 block timestamp of this batch pub timestamp: u64, /// The L2 block transactions in this batch - pub transactions: Vec, + pub transactions: Vec, } impl SingleBatch { @@ -156,7 +156,7 @@ impl SingleBatch { warn!("transaction data must not be empty, but found empty tx at index {i}"); return BatchValidity::Drop; } - if tx.is_deposit() { + if starts_with_2781_deposit(tx) { warn!("sequencers may not embed any deposits into batch data, but found tx that has one at index: {i}"); return BatchValidity::Drop; } @@ -170,9 +170,8 @@ impl SingleBatch { mod tests { use super::SingleBatch; use alloc::vec; - use alloy_primitives::{hex, B256}; + use alloy_primitives::{hex, Bytes, B256}; use alloy_rlp::{BytesMut, Decodable, Encodable}; - use kona_primitives::RawTransaction; #[test] fn test_single_batch_rlp_roundtrip() { @@ -181,7 +180,7 @@ mod tests { epoch_num: 0xFF, epoch_hash: B256::ZERO, timestamp: 0xEE, - transactions: vec![RawTransaction(hex!("00").into())], + transactions: vec![Bytes::from(hex!("00"))], }; let mut out_buf = BytesMut::default(); @@ -198,7 +197,7 @@ mod tests { epoch_num: 0xFF, epoch_hash: B256::ZERO, timestamp: 0xEE, - transactions: vec![RawTransaction(hex!("7E").into())], + transactions: vec![Bytes::from(hex!("7E"))], }; assert!(single_batch.has_invalid_transactions()); diff --git a/crates/derive/src/batch/span_batch/batch.rs b/crates/derive/src/batch/span_batch/batch.rs index 5edb46140..671575b76 100644 --- a/crates/derive/src/batch/span_batch/batch.rs +++ b/crates/derive/src/batch/span_batch/batch.rs @@ -421,9 +421,7 @@ mod tests { }; use alloc::vec; use alloy_primitives::{b256, Bytes, B256}; - use kona_primitives::{ - BlockID, ChainGenesis, L2ExecutionPayload, L2ExecutionPayloadEnvelope, RawTransaction, - }; + use kona_primitives::{BlockID, ChainGenesis, L2ExecutionPayload, L2ExecutionPayloadEnvelope}; use op_alloy_consensus::OpTxType; use tracing::Level; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; @@ -1287,7 +1285,7 @@ mod tests { ..Default::default() }; let mut fetcher = TestL2ChainProvider { blocks: vec![l2_block], ..Default::default() }; - let filler_bytes = RawTransaction(Bytes::copy_from_slice(&[OpTxType::Eip1559 as u8])); + let filler_bytes = Bytes::copy_from_slice(&[OpTxType::Eip1559 as u8]); let first = SpanBatchElement { epoch_num: 10, timestamp: 20, @@ -1296,7 +1294,7 @@ mod tests { let second = SpanBatchElement { epoch_num: 10, timestamp: 20, - transactions: vec![RawTransaction(Bytes::copy_from_slice(&[OpTxType::Deposit as u8]))], + transactions: vec![Bytes::copy_from_slice(&[OpTxType::Deposit as u8])], }; let third = SpanBatchElement { epoch_num: 11, timestamp: 20, transactions: vec![filler_bytes] }; diff --git a/crates/derive/src/batch/span_batch/element.rs b/crates/derive/src/batch/span_batch/element.rs index 60b2248e3..ce85adb67 100644 --- a/crates/derive/src/batch/span_batch/element.rs +++ b/crates/derive/src/batch/span_batch/element.rs @@ -1,9 +1,8 @@ //! Span Batch Element -use alloc::vec::Vec; -use kona_primitives::RawTransaction; - use crate::batch::SingleBatch; +use alloc::vec::Vec; +use alloy_primitives::Bytes; /// A single batch element is similar to the [SingleBatch] type /// but does not contain the parent hash and epoch hash since spans @@ -15,7 +14,7 @@ pub struct SpanBatchElement { /// The timestamp of the L2 block pub timestamp: u64, /// The transactions in the L2 block - pub transactions: Vec, + pub transactions: Vec, } impl From for SpanBatchElement { diff --git a/crates/derive/src/batch/span_batch/raw.rs b/crates/derive/src/batch/span_batch/raw.rs index 4df88f53b..4e2d78547 100644 --- a/crates/derive/src/batch/span_batch/raw.rs +++ b/crates/derive/src/batch/span_batch/raw.rs @@ -1,7 +1,7 @@ //! Raw Span Batch use alloc::{vec, vec::Vec}; -use kona_primitives::{RawTransaction, RollupConfig}; +use kona_primitives::RollupConfig; use super::{SpanBatch, SpanBatchElement, SpanBatchError, SpanBatchPayload, SpanBatchPrefix}; use crate::batch::{BatchType, SpanDecodingError}; @@ -121,7 +121,7 @@ impl RawSpanBatch { acc.push(SpanBatchElement { epoch_num: block_origin_nums[i as usize], timestamp: genesis_time + self.prefix.rel_timestamp + block_time * i, - transactions: transactions.into_iter().map(|v| RawTransaction(v.into())).collect(), + transactions: transactions.into_iter().map(|v| v.into()).collect(), }); acc }); diff --git a/crates/derive/src/batch/span_batch/transactions.rs b/crates/derive/src/batch/span_batch/transactions.rs index 3e0004876..86e08f49e 100644 --- a/crates/derive/src/batch/span_batch/transactions.rs +++ b/crates/derive/src/batch/span_batch/transactions.rs @@ -8,9 +8,8 @@ use super::{ use alloc::vec::Vec; use alloy_consensus::{Transaction, TxEnvelope, TxType}; use alloy_eips::eip2718::Encodable2718; -use alloy_primitives::{Address, TxKind, U256}; +use alloy_primitives::{Address, Bytes, TxKind, U256}; use alloy_rlp::{Buf, Decodable, Encodable}; -use kona_primitives::RawTransaction; /// This struct contains the decoded information for transactions in a span batch. #[derive(Debug, Default, Clone, PartialEq, Eq)] @@ -338,11 +337,7 @@ impl SpanBatchTransactions { } /// Add raw transactions into the [SpanBatchTransactions]. - pub fn add_txs( - &mut self, - txs: Vec, - chain_id: u64, - ) -> Result<(), SpanBatchError> { + pub fn add_txs(&mut self, txs: Vec, chain_id: u64) -> Result<(), SpanBatchError> { let total_block_tx_count = txs.len() as u64; let offset = self.total_block_tx_count; diff --git a/crates/derive/src/stages/attributes_queue.rs b/crates/derive/src/stages/attributes_queue.rs index 02431676b..693dd3a45 100644 --- a/crates/derive/src/stages/attributes_queue.rs +++ b/crates/derive/src/stages/attributes_queue.rs @@ -223,8 +223,7 @@ mod tests { }, }; use alloc::{sync::Arc, vec, vec::Vec}; - use alloy_primitives::b256; - use kona_primitives::RawTransaction; + use alloy_primitives::{b256, Bytes}; fn new_attributes_queue( cfg: Option, @@ -327,7 +326,7 @@ mod tests { MockAttributesBuilder { attributes: vec![Ok(payload_attributes.clone())] }; let mut aq = AttributesQueue::new(Arc::new(cfg), mock, mock_builder); let parent = L2BlockInfo::default(); - let txs = vec![RawTransaction::default(), RawTransaction::default()]; + let txs = vec![Bytes::default(), Bytes::default()]; let batch = SingleBatch { transactions: txs.clone(), ..Default::default() }; let attributes = aq.create_next_attributes(batch, parent).await.unwrap(); // update the expected attributes diff --git a/crates/derive/src/stages/attributes_queue/builder.rs b/crates/derive/src/stages/attributes_queue/builder.rs index 2100470cf..0b11ce871 100644 --- a/crates/derive/src/stages/attributes_queue/builder.rs +++ b/crates/derive/src/stages/attributes_queue/builder.rs @@ -8,11 +8,11 @@ use crate::{ }; use alloc::{boxed::Box, fmt::Debug, sync::Arc, vec, vec::Vec}; use alloy_eips::eip2718::Encodable2718; +use alloy_primitives::Bytes; use alloy_rlp::Encodable; use async_trait::async_trait; use kona_primitives::{ - BlockID, Hardforks, L1BlockInfoTx, L2BlockInfo, L2PayloadAttributes, RawTransaction, - RollupConfig, + BlockID, Hardforks, L1BlockInfoTx, L2BlockInfo, L2PayloadAttributes, RollupConfig, }; /// The [AttributesBuilder] is responsible for preparing [L2PayloadAttributes] @@ -71,7 +71,7 @@ where epoch: BlockID, ) -> Result { let l1_header; - let deposit_transactions: Vec; + let deposit_transactions: Vec; let mut sys_config = self .config_fetcher .system_config_by_number(l2_parent.block_info.number, self.rollup_cfg.clone()) @@ -121,18 +121,16 @@ where )); } - let mut upgrade_transactions: Vec = vec![]; + let mut upgrade_transactions: Vec = vec![]; if self.rollup_cfg.is_ecotone_active(next_l2_time) && !self.rollup_cfg.is_ecotone_active(l2_parent.block_info.timestamp) { - upgrade_transactions = - Hardforks::ecotone_txs().into_iter().map(RawTransaction).collect(); + upgrade_transactions = Hardforks::ecotone_txs(); } if self.rollup_cfg.is_fjord_active(next_l2_time) && !self.rollup_cfg.is_fjord_active(l2_parent.block_info.timestamp) { - let mut txs = Hardforks::fjord_txs().into_iter().map(RawTransaction).collect(); - upgrade_transactions.append(&mut txs); + upgrade_transactions.append(&mut Hardforks::fjord_txs()); } // Build and encode the L1 info transaction for the current payload. diff --git a/crates/derive/src/stages/attributes_queue/deposits.rs b/crates/derive/src/stages/attributes_queue/deposits.rs index 9fbe49280..512e8ecd1 100644 --- a/crates/derive/src/stages/attributes_queue/deposits.rs +++ b/crates/derive/src/stages/attributes_queue/deposits.rs @@ -2,8 +2,8 @@ use alloc::vec::Vec; use alloy_consensus::{Eip658Value, Receipt}; -use alloy_primitives::{Address, B256}; -use kona_primitives::{decode_deposit, RawTransaction, DEPOSIT_EVENT_ABI_HASH}; +use alloy_primitives::{Address, Bytes, B256}; +use kona_primitives::{decode_deposit, DEPOSIT_EVENT_ABI_HASH}; /// Derive deposits for transaction receipts. /// @@ -14,7 +14,7 @@ pub(crate) async fn derive_deposits( block_hash: B256, receipts: Vec, deposit_contract: Address, -) -> anyhow::Result> { +) -> anyhow::Result> { let mut global_index = 0; let mut res = Vec::new(); for r in receipts.iter() { @@ -100,7 +100,7 @@ mod tests { let receipts = vec![]; let deposit_contract = Address::default(); let result = derive_deposits(B256::default(), receipts, deposit_contract).await; - assert_eq!(result.unwrap(), vec![]); + assert!(result.unwrap().is_empty()); } #[tokio::test] diff --git a/crates/derive/src/stages/batch_queue.rs b/crates/derive/src/stages/batch_queue.rs index f600374b3..b5acf90a1 100644 --- a/crates/derive/src/stages/batch_queue.rs +++ b/crates/derive/src/stages/batch_queue.rs @@ -548,20 +548,8 @@ mod tests { let mut second_batch_txs: Vec = vec![]; while let Some(batch) = reader.next_batch(cfg.as_ref()) { if let Batch::Span(span) = &batch { - let bys = span.batches[0] - .transactions - .iter() - .cloned() - .map(|tx| tx.0) - .collect::>(); - let sbys = span.batches[1] - .transactions - .iter() - .cloned() - .map(|tx| tx.0) - .collect::>(); - second_batch_txs.extend(sbys); - batch_txs.extend(bys); + batch_txs.extend(span.batches[0].transactions.clone()); + second_batch_txs.extend(span.batches[1].transactions.clone()); } batch_vec.push(Ok(batch)); } diff --git a/crates/executor/src/lib.rs b/crates/executor/src/lib.rs index 3b787739f..cceed97f2 100644 --- a/crates/executor/src/lib.rs +++ b/crates/executor/src/lib.rs @@ -13,7 +13,7 @@ use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{address, keccak256, Address, Bytes, TxKind, B256, U256}; use anyhow::{anyhow, Result}; use kona_mpt::{ordered_trie_with_encoder, TrieDB, TrieDBFetcher, TrieDBHinter}; -use kona_primitives::{L2PayloadAttributes, RawTransaction, RollupConfig}; +use kona_primitives::{L2PayloadAttributes, RollupConfig}; use op_alloy_consensus::{OpReceiptEnvelope, OpTxEnvelope}; use revm::{ db::{states::bundle_state::BundleRetention, State}, @@ -457,7 +457,7 @@ where /// /// ## Returns /// The computed transactions root. - fn compute_transactions_root(transactions: &[RawTransaction]) -> B256 { + fn compute_transactions_root(transactions: &[Bytes]) -> B256 { ordered_trie_with_encoder(transactions, |tx, buf| buf.put_slice(tx.as_ref())).root() } diff --git a/crates/primitives/src/attributes.rs b/crates/primitives/src/attributes.rs index 55ac86f51..76f9f3ccb 100644 --- a/crates/primitives/src/attributes.rs +++ b/crates/primitives/src/attributes.rs @@ -3,9 +3,9 @@ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use super::{L2BlockInfo, RawTransaction, Withdrawal}; +use super::{L2BlockInfo, Withdrawal}; use alloc::vec::Vec; -use alloy_primitives::{Address, B256}; +use alloy_primitives::{Address, Bytes, B256}; /// Payload attributes. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] @@ -31,7 +31,7 @@ pub struct L2PayloadAttributes { // Optimism additions. /// Transactions to force into the block (always at the start of the transactions list). #[cfg_attr(feature = "serde", serde(rename = "transactions"))] - pub transactions: Vec, + pub transactions: Vec, /// NoTxPool to disable adding any transactions from the transaction-pool. #[cfg_attr(feature = "serde", serde(rename = "noTxPool"))] pub no_tx_pool: bool, diff --git a/crates/primitives/src/deposits.rs b/crates/primitives/src/deposits.rs index ad54dfa81..431a87239 100644 --- a/crates/primitives/src/deposits.rs +++ b/crates/primitives/src/deposits.rs @@ -7,8 +7,6 @@ use alloy_rlp::Encodable; use core::fmt::Display; use op_alloy_consensus::{OpTxEnvelope, TxDeposit}; -use crate::RawTransaction; - /// Deposit log event abi signature. pub const DEPOSIT_EVENT_ABI: &str = "TransactionDeposited(address,address,uint256,bytes)"; @@ -296,11 +294,7 @@ impl UpgradeDepositSource { /// bytes opaqueData /// ); /// ``` -pub fn decode_deposit( - block_hash: B256, - index: usize, - log: &Log, -) -> Result { +pub fn decode_deposit(block_hash: B256, index: usize, log: &Log) -> Result { let topics = log.data.topics(); if topics.len() != 4 { return Err(DepositError::UnexpectedTopicsLen(topics.len())); @@ -387,11 +381,11 @@ pub fn decode_deposit( unmarshal_deposit_version0(&mut deposit_tx, to, opaque_data)?; - // Re-encode the deposit transaction and return as a RawTransaction + // Re-encode the deposit transaction let deposit_envelope = OpTxEnvelope::Deposit(deposit_tx); let mut buffer = Vec::with_capacity(deposit_envelope.length()); deposit_envelope.encode_2718(&mut buffer); - Ok(RawTransaction::from(buffer)) + Ok(Bytes::from(buffer)) } /// Unmarshals a deposit transaction from the opaque data. @@ -599,7 +593,7 @@ mod tests { }; let tx = decode_deposit(B256::default(), 0, &log).unwrap(); let raw_hex = hex!("7ef887a0ed428e1c45e1d9561b62834e1a2d3015a0caae3bfdc16b4da059ac885b01a14594000000000000000000000000000000000000000094000000000000000000000000000000000000000080808080b700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - let expected = RawTransaction::from(Bytes::from(raw_hex)); + let expected = Bytes::from(raw_hex); assert_eq!(tx, expected); } @@ -641,7 +635,7 @@ mod tests { }; let tx = decode_deposit(B256::default(), 0, &log).unwrap(); let raw_hex = hex!("7ef875a0ed428e1c45e1d9561b62834e1a2d3015a0caae3bfdc16b4da059ac885b01a145941111111111111111111111111111111111111111800a648203e880b700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - let expected = RawTransaction::from(Bytes::from(raw_hex)); + let expected = Bytes::from(raw_hex); assert_eq!(tx, expected); } diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 543f479e7..4569f565e 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -10,25 +10,26 @@ extern crate alloc; // Re-export `op-alloy-consensus` types. pub use op_alloy_consensus::Hardforks; -// Use op-alloy-protocol crate. +// Re-export `op-alloy-protocol` types. pub use op_alloy_protocol::{ - BlockInfo, Channel, ChannelId, Frame, L2BlockInfo, CHANNEL_ID_LENGTH, DERIVATION_VERSION_0, - FJORD_MAX_RLP_BYTES_PER_CHANNEL, FRAME_OVERHEAD, MAX_FRAME_LEN, MAX_RLP_BYTES_PER_CHANNEL, + starts_with_2781_deposit, BlockInfo, Channel, ChannelId, Frame, L2BlockInfo, CHANNEL_ID_LENGTH, + DERIVATION_VERSION_0, FJORD_MAX_RLP_BYTES_PER_CHANNEL, FRAME_OVERHEAD, MAX_FRAME_LEN, + MAX_RLP_BYTES_PER_CHANNEL, }; -// Re-export superchain-primitives. +// Re-export `superchain-primitives` types. pub use superchain_primitives::*; -// Re-export alloy-primitives. +// Re-export `alloy-primitives`. pub use alloy_primitives; -// Re-export alloy consensus primitives. +// Re-export `alloy-consensus` types. pub use alloy_consensus::{ Header, Receipt, Signed, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEnvelope, TxLegacy, }; -/// Re-export [alloy_eips] eip4844 primitives. +// Re-export `alloy-eips` eip4844 types. pub use alloy_eips::eip4844::{Blob, BYTES_PER_BLOB, VERSIONED_HASH_VERSION_KZG}; /// Re-export the [Withdrawal] type from the [alloy_eips] crate. @@ -42,9 +43,6 @@ pub use block::{Block, BlockKind, OpBlock}; pub mod block_info; pub use block_info::{L1BlockInfoBedrock, L1BlockInfoEcotone, L1BlockInfoTx}; -pub mod raw_tx; -pub use raw_tx::RawTransaction; - pub mod deposits; pub use deposits::{ decode_deposit, DepositError, DepositSourceDomain, DepositSourceDomainIdentifier, diff --git a/crates/primitives/src/raw_tx.rs b/crates/primitives/src/raw_tx.rs deleted file mode 100644 index 0e35172c5..000000000 --- a/crates/primitives/src/raw_tx.rs +++ /dev/null @@ -1,47 +0,0 @@ -//! Contains the [RawTransaction] type. - -use alloy_primitives::Bytes; -use alloy_rlp::{Decodable, Encodable}; - -/// A raw transaction -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Debug, Default, Clone, Hash, PartialEq, Eq)] -pub struct RawTransaction(pub Bytes); - -impl RawTransaction { - /// Returns if the transaction is empty - pub fn is_empty(&self) -> bool { - self.0.is_empty() - } - - /// Returns if the transaction is a deposit - pub fn is_deposit(&self) -> bool { - !self.0.is_empty() && self.0[0] == 0x7E - } -} - -impl> From for RawTransaction { - fn from(bytes: T) -> Self { - Self(bytes.into()) - } -} - -impl Encodable for RawTransaction { - fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { - self.0.encode(out) - } -} - -impl Decodable for RawTransaction { - /// Decodes RLP encoded bytes into [RawTransaction] bytes - fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - let tx_bytes = Bytes::decode(buf)?; - Ok(Self(tx_bytes)) - } -} - -impl AsRef<[u8]> for RawTransaction { - fn as_ref(&self) -> &[u8] { - self.0.as_ref() - } -} diff --git a/examples/trusted-sync/src/validation.rs b/examples/trusted-sync/src/validation.rs index 11be63cc0..f676293e8 100644 --- a/examples/trusted-sync/src/validation.rs +++ b/examples/trusted-sync/src/validation.rs @@ -1,10 +1,11 @@ //! Contains logic to validate derivation pipeline outputs. +use alloy_primitives::Bytes; use alloy_provider::{Provider, ReqwestProvider}; use alloy_rpc_types::{BlockNumberOrTag, BlockTransactionsKind, Header}; use alloy_transport::TransportResult; use anyhow::Result; -use kona_primitives::{L2AttributesWithParent, L2PayloadAttributes, RawTransaction, RollupConfig}; +use kona_primitives::{L2AttributesWithParent, L2PayloadAttributes, RollupConfig}; use std::vec::Vec; use tracing::{error, warn}; @@ -36,10 +37,7 @@ impl OnlineValidator { /// /// This method needs to fetch the non-hydrated block and then /// fetch the raw transactions using the `debug_*` namespace. - pub(crate) async fn get_block( - &self, - tag: BlockNumberOrTag, - ) -> Result<(Header, Vec)> { + pub(crate) async fn get_block(&self, tag: BlockNumberOrTag) -> Result<(Header, Vec)> { // Don't hydrate the block so we only get a list of transaction hashes. let block = self .provider @@ -50,7 +48,7 @@ impl OnlineValidator { // For each transaction hash, fetch the raw transaction RLP. let mut txs = vec![]; for tx in block.transactions.hashes() { - let tx: TransportResult = + let tx: TransportResult = self.provider.raw_request("debug_getRawTransaction".into(), [tx]).await; if let Ok(tx) = tx { txs.push(tx);