feat: integrate OpPrimitives (#13556)

This commit is contained in:
Arsenii Kulikov
2024-12-27 18:11:11 +03:00
committed by GitHub
parent c35fe4ac54
commit 4994cdf0b0
44 changed files with 524 additions and 506 deletions

View File

@ -14,25 +14,27 @@ extern crate alloc;
pub mod bedrock;
pub mod transaction;
use reth_primitives_traits::Block;
pub use transaction::{signed::OpTransactionSigned, tx_type::OpTxType};
mod receipt;
pub use receipt::OpReceipt;
/// Optimism primitive types.
pub type OpPrimitives = reth_primitives::EthPrimitives;
/// Optimism-specific block type.
pub type OpBlock = reth_primitives::Block<OpTransactionSigned>;
// TODO: once we are ready for separating primitive types, introduce a separate `NodePrimitives`
// implementation used exclusively by legacy engine.
//
// #[derive(Debug, Default, Clone, PartialEq, Eq)]
// pub struct OpPrimitives;
//
// impl NodePrimitives for OpPrimitives {
// type Block = Block;
// type BlockHeader = Header;
// type BlockBody = BlockBody;
// type SignedTx = TransactionSigned;
// type TxType = OpTxType;
// type Receipt = Receipt;
// }
/// Optimism-specific block body type.
pub type OpBlockBody = <OpBlock as Block>::Body;
/// Primitive types for Optimism Node.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct OpPrimitives;
#[cfg(feature = "optimism")]
impl reth_primitives::NodePrimitives for OpPrimitives {
type Block = OpBlock;
type BlockHeader = alloy_consensus::Header;
type BlockBody = OpBlockBody;
type SignedTx = OpTransactionSigned;
type Receipt = OpReceipt;
}

View File

@ -66,6 +66,11 @@ impl OpTransactionSigned {
pub fn new_unhashed(transaction: OpTypedTransaction, signature: Signature) -> Self {
Self { hash: Default::default(), signature, transaction }
}
/// Returns whether this transaction is a deposit.
pub const fn is_deposit(&self) -> bool {
matches!(self.transaction, OpTypedTransaction::Deposit(_))
}
}
impl SignedTransaction for OpTransactionSigned {