Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Replace OpTxEnvelope with TxEnvelope #61

Merged
merged 27 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6dba570
Migrate DepositTransaction trait from op-alloy
emhane Jan 11, 2025
2f86666
Fix docs
emhane Jan 11, 2025
ebffa38
Add AT OpTransaction::DepositTx
emhane Jan 11, 2025
8a5e249
Remove redundant trait method DepositTransaction::is_deposit
emhane Jan 12, 2025
f993cd5
Remove super trait Transaction from OpTransaction
emhane Jan 12, 2025
7dbc26b
Remove redundant trait method OpTransaction::is_system_transaction
emhane Jan 12, 2025
8b25874
Rename OpTransaction->DepositTxEnvelope
emhane Jan 12, 2025
0ff6015
Migrate DepositTransaction trait from op-alloy
emhane Jan 11, 2025
8f5b012
Replace OpBlock in maili-protocol
emhane Jan 11, 2025
ef69d84
Add trait bound to BatchValidationProvider::Transaction
emhane Jan 11, 2025
e4e7e9a
fixup! Rename OpTransaction->DepositTxEnvelope
emhane Jan 12, 2025
6c1ed6a
Add super trait Typed2718 to DepositTxEnvelope
emhane Jan 12, 2025
e5080d1
Update docs
emhane Jan 12, 2025
7e19d15
Merge branch 'main' into emhane/op-tx
emhane Jan 12, 2025
ed2fb52
Port changes from emhane/replace-op-block
emhane Jan 12, 2025
bd68c34
Merge branch 'emhane/op-tx' into emhane/replace-op-block
emhane Jan 12, 2025
604fe4a
Fix docs
emhane Jan 12, 2025
a320f93
Merge branch 'emhane/op-tx' into emhane/replace-op-block
emhane Jan 12, 2025
ba75037
Fix test utils
emhane Jan 13, 2025
812c8f0
Shrink scope of DepositTxEnvelope, remove super trait Typed2718
emhane Jan 13, 2025
1343686
Merge branch 'main' into emhane/replace-op-block
emhane Jan 13, 2025
a015236
Add trait bound Typed2718 to BatchValidationProvider::Transaction
emhane Jan 13, 2025
49fa283
Merge branch 'emhane/replace-op-block' of github.com:op-rs/maili into…
emhane Jan 13, 2025
44a6b13
Merge branch 'main' into emhane/replace-op-block
emhane Jan 13, 2025
47aae83
Merge branch 'main' into emhane/replace-op-block
emhane Jan 14, 2025
ad6b48d
Replace OpTxEnvelope with TxEnvelope
emhane Jan 14, 2025
b11898f
Merge branch 'main' into emhane/replace-op-tx
emhane Jan 14, 2025
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
2 changes: 1 addition & 1 deletion crates/protocol/src/batch/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl SpanBatchTransactions {
} else {
true
};
let tx_envelope = tx.to_enveloped_tx(*nonce, *gas, to, chain_id, sig, is_protected)?;
let tx_envelope = tx.to_signed_tx(*nonce, *gas, to, chain_id, sig, is_protected)?;
let mut buf = Vec::new();
tx_envelope.encode_2718(&mut buf);
txs.push(buf);
Expand Down
10 changes: 4 additions & 6 deletions crates/protocol/src/batch/tx_data/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use alloy_consensus::{SignableTransaction, Signed, TxEip1559};
use alloy_eips::eip2930::AccessList;
use alloy_primitives::{Address, PrimitiveSignature as Signature, TxKind, U256};
use alloy_rlp::{Bytes, RlpDecodable, RlpEncodable};
use op_alloy_consensus::OpTxEnvelope;

/// The transaction data for an EIP-1559 transaction within a span batch.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
Expand All @@ -23,15 +22,15 @@ pub struct SpanBatchEip1559TransactionData {
}

impl SpanBatchEip1559TransactionData {
/// Converts [SpanBatchEip1559TransactionData] into an [OpTxEnvelope].
pub fn to_enveloped_tx(
/// Converts [SpanBatchEip1559TransactionData] into a signed [`TxEip1559`].
pub fn to_signed_tx(
&self,
nonce: u64,
gas: u64,
to: Option<Address>,
chain_id: u64,
signature: Signature,
) -> Result<OpTxEnvelope, SpanBatchError> {
) -> Result<Signed<TxEip1559>, SpanBatchError> {
let eip1559_tx = TxEip1559 {
chain_id,
nonce,
Expand All @@ -52,8 +51,7 @@ impl SpanBatchEip1559TransactionData {
access_list: self.access_list.clone(),
};
let signature_hash = eip1559_tx.signature_hash();
let signed_eip1559_tx = Signed::new_unchecked(eip1559_tx, signature, signature_hash);
Ok(OpTxEnvelope::Eip1559(signed_eip1559_tx))
Ok(Signed::new_unchecked(eip1559_tx, signature, signature_hash))
}
}

Expand Down
11 changes: 4 additions & 7 deletions crates/protocol/src/batch/tx_data/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use alloy_consensus::{SignableTransaction, Signed, TxEip2930};
use alloy_eips::eip2930::AccessList;
use alloy_primitives::{Address, PrimitiveSignature as Signature, TxKind, U256};
use alloy_rlp::{Bytes, RlpDecodable, RlpEncodable};
use op_alloy_consensus::OpTxEnvelope;

/// The transaction data for an EIP-2930 transaction within a span batch.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
Expand All @@ -21,15 +20,15 @@ pub struct SpanBatchEip2930TransactionData {
}

impl SpanBatchEip2930TransactionData {
/// Converts [SpanBatchEip2930TransactionData] into a [OpTxEnvelope].
pub fn to_enveloped_tx(
/// Converts [SpanBatchEip2930TransactionData] into a signed [`TxEip2930`].
pub fn to_signed_tx(
&self,
nonce: u64,
gas: u64,
to: Option<Address>,
chain_id: u64,
signature: Signature,
) -> Result<OpTxEnvelope, SpanBatchError> {
) -> Result<Signed<TxEip2930>, SpanBatchError> {
let access_list_tx = TxEip2930 {
chain_id,
nonce,
Expand All @@ -45,9 +44,7 @@ impl SpanBatchEip2930TransactionData {
access_list: self.access_list.clone(),
};
let signature_hash = access_list_tx.signature_hash();
let signed_access_list_tx =
Signed::new_unchecked(access_list_tx, signature, signature_hash);
Ok(OpTxEnvelope::Eip2930(signed_access_list_tx))
Ok(Signed::new_unchecked(access_list_tx, signature, signature_hash))
}
}

Expand Down
10 changes: 4 additions & 6 deletions crates/protocol/src/batch/tx_data/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{SpanBatchError, SpanDecodingError};
use alloy_consensus::{SignableTransaction, Signed, TxLegacy};
use alloy_primitives::{Address, PrimitiveSignature as Signature, TxKind, U256};
use alloy_rlp::{Bytes, RlpDecodable, RlpEncodable};
use op_alloy_consensus::OpTxEnvelope;

/// The transaction data for a legacy transaction within a span batch.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
Expand All @@ -18,16 +17,16 @@ pub struct SpanBatchLegacyTransactionData {
}

impl SpanBatchLegacyTransactionData {
/// Converts [SpanBatchLegacyTransactionData] into a [OpTxEnvelope].
pub fn to_enveloped_tx(
/// Converts [SpanBatchLegacyTransactionData] into a signed [`TxLegacy`].
pub fn to_signed_tx(
&self,
nonce: u64,
gas: u64,
to: Option<Address>,
chain_id: u64,
signature: Signature,
is_protected: bool,
) -> Result<OpTxEnvelope, SpanBatchError> {
) -> Result<Signed<TxLegacy>, SpanBatchError> {
let legacy_tx = TxLegacy {
chain_id: is_protected.then_some(chain_id),
nonce,
Expand All @@ -42,8 +41,7 @@ impl SpanBatchLegacyTransactionData {
input: self.data.clone().into(),
};
let signature_hash = legacy_tx.signature_hash();
let signed_legacy_tx = Signed::new_unchecked(legacy_tx, signature, signature_hash);
Ok(OpTxEnvelope::Legacy(signed_legacy_tx))
Ok(Signed::new_unchecked(legacy_tx, signature, signature_hash))
}
}

Expand Down
28 changes: 18 additions & 10 deletions crates/protocol/src/batch/tx_data/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use alloy_consensus::{Transaction, TxEnvelope, TxType};
use alloy_primitives::{Address, PrimitiveSignature as Signature, U256};
use alloy_rlp::{Bytes, Decodable, Encodable};
use op_alloy_consensus::OpTxEnvelope;

use crate::{
SpanBatchEip1559TransactionData, SpanBatchEip2930TransactionData, SpanBatchError,
Expand Down Expand Up @@ -114,22 +113,31 @@ impl SpanBatchTransactionData {
}
}

/// Converts the [SpanBatchTransactionData] into a [OpTxEnvelope].
pub fn to_enveloped_tx(
/// Converts the [SpanBatchTransactionData] into a singed transaction as [`TxEnvelope`].
pub fn to_signed_tx(
&self,
nonce: u64,
gas: u64,
to: Option<Address>,
chain_id: u64,
signature: Signature,
is_protected: bool,
) -> Result<OpTxEnvelope, SpanBatchError> {
match self {
Self::Legacy(data) => {
data.to_enveloped_tx(nonce, gas, to, chain_id, signature, is_protected)
) -> Result<TxEnvelope, SpanBatchError> {
Ok(match self {
Self::Legacy(data) => TxEnvelope::Legacy(data.to_signed_tx(
nonce,
gas,
to,
chain_id,
signature,
is_protected,
)?),
Self::Eip2930(data) => {
TxEnvelope::Eip2930(data.to_signed_tx(nonce, gas, to, chain_id, signature)?)
}
Self::Eip2930(data) => data.to_enveloped_tx(nonce, gas, to, chain_id, signature),
Self::Eip1559(data) => data.to_enveloped_tx(nonce, gas, to, chain_id, signature),
}
Self::Eip1559(data) => {
TxEnvelope::Eip1559(data.to_signed_tx(nonce, gas, to, chain_id, signature)?)
}
})
}
}
4 changes: 2 additions & 2 deletions crates/protocol/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ pub enum FromBlockError {
/// The first payload transaction has an unexpected type.
#[error("First payload transaction has unexpected type: {0}")]
UnexpectedTxType(u8),
/// Failed to decode the first transaction into an [OpTxEnvelope].
#[error("Failed to decode the first transaction into an OpTxEnvelope: {0}")]
/// Failed to decode the first transaction into an OP transaction.
#[error("Failed to decode the first transaction into an OP transaction: {0}")]
TxEnvelopeDecodeError(Eip2718Error),
/// The first payload transaction is not a deposit transaction.
#[error("First payload transaction is not a deposit transaction, type: {0}")]
Expand Down
8 changes: 4 additions & 4 deletions crates/protocol/src/info/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
use alloc::{format, string::ToString};
use alloy_consensus::Header;
use alloy_eips::{eip7840::BlobParams, BlockNumHash};
use alloy_primitives::{address, Address, Bytes, Sealable, TxKind, B256, U256};
use alloy_primitives::{address, Address, Bytes, Sealable, Sealed, TxKind, B256, U256};
use maili_genesis::{RollupConfig, SystemConfig};
use op_alloy_consensus::{OpTxEnvelope, TxDeposit};
use op_alloy_consensus::TxDeposit;

use crate::{
BlockInfoError, DecodeError, DepositSourceDomain, L1BlockInfoBedrock, L1BlockInfoEcotone,
Expand Down Expand Up @@ -100,7 +100,7 @@ impl L1BlockInfoTx {
sequence_number: u64,
l1_header: &Header,
l2_block_time: u64,
) -> Result<(Self, OpTxEnvelope), BlockInfoError> {
) -> Result<(Self, Sealed<TxDeposit>), BlockInfoError> {
let l1_info =
Self::try_new(rollup_config, system_config, sequence_number, l1_header, l2_block_time)?;

Expand All @@ -127,7 +127,7 @@ impl L1BlockInfoTx {
deposit_tx.gas_limit = REGOLITH_SYSTEM_TX_GAS;
}

Ok((l1_info, OpTxEnvelope::Deposit(deposit_tx.seal_slow())))
Ok((l1_info, deposit_tx.seal_slow()))
}

/// Decodes the [L1BlockInfoEcotone] object from ethereum transaction calldata.
Expand Down
Loading