Consensus
The op-alloy-consensus
crate provides an Optimism consensus interface.
It contains constants, types, and functions for implementing Optimism EL
consensus and communication. This includes an extended OpTxEnvelope
type
with deposit transactions, and receipts containing OP Stack
specific fields (deposit_nonce
+ deposit_receipt_version
).
In general a type belongs in this crate if it exists in the
alloy-consensus
crate, but was modified from the base Ethereum protocol
in the OP Stack. For consensus types that are not modified by the OP Stack,
the alloy-consensus
types should be used instead.
Block
op-alloy-consensus
exports an Optimism block type, OpBlock
.
This type simply re-uses the alloy-consensus
block type, with OpTxEnvelope
as the type of transactions in the block.
Transactions
Optimism extends the Ethereum EIP-2718 transaction envelope to include a deposit variant.
OpTxEnvelope
The OpTxEnvelope
type is based on Alloy's
TxEnvelope
type.
Optimism modifies the TxEnvelope
to the following.
- Legacy
- EIP-2930
- EIP-1559
- EIP-7702
- Deposit
Deposit is a custom transaction type that is either an L1 attributes deposit transaction or a user-submitted deposit transaction. Read more about deposit transactions in the specs.
Transaction Types (OpTxType
)
The OpTxType
enumerates the transaction types using their byte identifier,
represents as a u8
in rust.
Receipt Types
Just like op-alloy-consensus
defines transaction types,
it also defines associated receipt types.
OpReceiptEnvelope
defines an Eip-2718 receipt envelope type
modified for the OP Stack. It contains the following variants - mapping
directly to the OpTxEnvelope
variants defined above.
- Legacy
- EIP-2930
- EIP-1559
- EIP-7702
- Deposit
There is also an OpDepositReceipt
type, extending the alloy receipt
type with a deposit nonce and deposit receipt version.
Hardforks
Aside from transactions and receipts, op-alloy-consensus
exports
one other core primitive called Hardforks
.
Hardforks provides hardfork transaction constructors - that is, it provides methods that return upgrade transactions for each hardfork. Some of these are the following.