Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "rf/protocol-fix" }

[workspace.dependencies]
# Workspace
Expand Down
15 changes: 7 additions & 8 deletions crates/derive/src/batch/single_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_2718_deposit, BlockID, BlockInfo, L2BlockInfo, RollupConfig};
use tracing::{info, warn};

/// Represents a single batch: a single encoded L2 block
Expand All @@ -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<RawTransaction>,
pub transactions: Vec<Bytes>,
}

impl SingleBatch {
Expand Down Expand Up @@ -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_2718_deposit(tx) {
warn!("sequencers may not embed any deposits into batch data, but found tx that has one at index: {i}");
return BatchValidity::Drop;
}
Expand All @@ -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() {
Expand All @@ -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();
Expand All @@ -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());
Expand Down
8 changes: 3 additions & 5 deletions crates/derive/src/batch/span_batch/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
Expand All @@ -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] };
Expand Down
7 changes: 3 additions & 4 deletions crates/derive/src/batch/span_batch/element.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<RawTransaction>,
pub transactions: Vec<Bytes>,
}

impl From<SingleBatch> for SpanBatchElement {
Expand Down
4 changes: 2 additions & 2 deletions crates/derive/src/batch/span_batch/raw.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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
});
Expand Down
9 changes: 2 additions & 7 deletions crates/derive/src/batch/span_batch/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -338,11 +337,7 @@ impl SpanBatchTransactions {
}

/// Add raw transactions into the [SpanBatchTransactions].
pub fn add_txs(
&mut self,
txs: Vec<RawTransaction>,
chain_id: u64,
) -> Result<(), SpanBatchError> {
pub fn add_txs(&mut self, txs: Vec<Bytes>, chain_id: u64) -> Result<(), SpanBatchError> {
let total_block_tx_count = txs.len() as u64;
let offset = self.total_block_tx_count;

Expand Down
5 changes: 2 additions & 3 deletions crates/derive/src/stages/attributes_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RollupConfig>,
Expand Down Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions crates/derive/src/stages/attributes_queue/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -71,7 +71,7 @@ where
epoch: BlockID,
) -> Result<L2PayloadAttributes, BuilderError> {
let l1_header;
let deposit_transactions: Vec<RawTransaction>;
let deposit_transactions: Vec<Bytes>;
let mut sys_config = self
.config_fetcher
.system_config_by_number(l2_parent.block_info.number, self.rollup_cfg.clone())
Expand Down Expand Up @@ -121,18 +121,16 @@ where
));
}

let mut upgrade_transactions: Vec<RawTransaction> = vec![];
let mut upgrade_transactions: Vec<Bytes> = 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.
Expand Down
8 changes: 4 additions & 4 deletions crates/derive/src/stages/attributes_queue/deposits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -14,7 +14,7 @@ pub(crate) async fn derive_deposits(
block_hash: B256,
receipts: Vec<Receipt>,
deposit_contract: Address,
) -> anyhow::Result<Vec<RawTransaction>> {
) -> anyhow::Result<Vec<Bytes>> {
let mut global_index = 0;
let mut res = Vec::new();
for r in receipts.iter() {
Expand Down Expand Up @@ -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]
Expand Down
16 changes: 2 additions & 14 deletions crates/derive/src/stages/batch_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,20 +548,8 @@ mod tests {
let mut second_batch_txs: Vec<Bytes> = 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::<Vec<Bytes>>();
let sbys = span.batches[1]
.transactions
.iter()
.cloned()
.map(|tx| tx.0)
.collect::<Vec<Bytes>>();
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));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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()
}

Expand Down
6 changes: 3 additions & 3 deletions crates/primitives/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand All @@ -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<RawTransaction>,
pub transactions: Vec<Bytes>,
/// NoTxPool to disable adding any transactions from the transaction-pool.
#[cfg_attr(feature = "serde", serde(rename = "noTxPool"))]
pub no_tx_pool: bool,
Expand Down
Loading