Repository navigation
Description
Part of #20257. See plan §1, §2, §3 in the op-geth decoupling doc.
Goal
Create op-core/types with OP-Stack-specific transaction and receipt types. Consumers import as optypes.
Scope
DepositTx
Standalone RLP type matching op-geth's wire format (0x7E || RLP(struct)). Define without depending on go-ethereum's TxData interface:
const DepositTxType = byte(0x7E)
type DepositTx struct {
SourceHash common.Hash
From common.Address
To *common.Address
Mint *big.Int
Value *big.Int
Gas uint64
IsSystemTransaction bool
Data []byte
}
func (d *DepositTx) MarshalBinary() ([]byte, error)
func UnmarshalDepositTx(raw []byte) (*DepositTx, error)Helpers to replace op-geth Transaction methods
func IsDepositTx(tx *types.Transaction) bool { return tx.Type() == DepositTxType }
// + SourceHash(tx), Mint(tx), IsSystemTx(tx) helpers that decode raw bytes via UnmarshalDepositTxTxRollupCostData lives in op-core/fees (see #20261).
PostExecTx
Synthetic, unsigned OP Stack transaction (type 0x7D) carrying post-execution metadata in SDM blocks. Wire format is 0x7D || data — the payload is opaque bytes, not RLP:
const PostExecTxType = byte(0x7D)
type PostExecTx struct {
Data []byte
}
func (p *PostExecTx) MarshalBinary() ([]byte, error)
func UnmarshalPostExecTx(raw []byte) (*PostExecTx, error)
func IsPostExecTx(tx *types.Transaction) boolSame differential-test treatment as DepositTx. Note: op-geth (like upstream go-ethereum) rejects typed-tx envelopes of len <= 1, so an empty payload cannot round-trip; UnmarshalPostExecTx mirrors that and rejects it.
Differential test
Add a test in op-core/types/deposit_tx_test.go that imports op-geth's core/types.DepositTx and asserts byte-for-byte equivalence with optypes.DepositTx.MarshalBinary for a table of cases (likewise for PostExecTx). This test will be removed in the final cutover once the op-geth dependency is dropped.
Receipt type
// embeds upstream types.Receipt, adds OP fields; custom JSON unmarshaler
type Receipt struct {
types.Receipt
DepositNonce *uint64 `json:"depositNonce,omitempty"`
DepositReceiptVersion *uint64 `json:"depositReceiptVersion,omitempty"`
L1GasPrice *big.Int `json:"l1GasPrice,omitempty"`
L1BlobBaseFee *big.Int `json:"l1BlobBaseFee,omitempty"`
L1GasUsed *big.Int `json:"l1GasUsed,omitempty"`
L1Fee *big.Int `json:"l1Fee,omitempty"`
FeeScalar *big.Float `json:"l1FeeScalar,omitempty"`
L1BaseFeeScalar *uint64 `json:"l1BaseFeeScalar,omitempty"`
L1BlobBaseFeeScalar *uint64 `json:"l1BlobBaseFeeScalar,omitempty"`
OperatorFeeScalar *uint64 `json:"operatorFeeScalar,omitempty"`
OperatorFeeConstant *uint64 `json:"operatorFeeConstant,omitempty"`
DAFootprintGasScalar *uint64 `json:"daFootprintGasScalar,omitempty"`
}JSON tag names preserved verbatim from op-geth's types.Receipt for wire compatibility. Note the wire values are hex-encoded, so the custom JSON codec decodes via hexutil types. The type carries op-geth's complete OP receipt field set, not just the fields txinclude reads: the e2e suites also read L1Fee, DepositNonce, etc., and a partial set would silently drop those fields from receipt JSON at cutover.
Dependencies
None for the types themselves. Call-site swaps happen in #20263.
🤖 Generated by Claude Code
Activity
[-]opgeth-decoupling: create op-core/types (DepositTx with differential test, Receipt)[/-][+]opgeth-decoupling: create op-core/types (DepositTx and PostExecTx with differential tests, Receipt)[/+]sebastianst commentedon Jun 15, 2026
🤖 Claude says: Design note from the implementation PR (#21356), recording a refinement to how these types are consumed downstream.
The
*types.Transactionhelpers (IsDepositTx/SourceHash/Mint/IsSystemTx/IsPostExecTx) are transition-only. They take a go-ethereum*types.Transaction, which can carry a0x7E/0x7Dtx only while the build resolves to op-geth. After the final cutover to upstream go-ethereum, an upstream*types.Transactioncan never hold a deposit or post-exec tx (the type bytes are rejected on decode), so these helpers — and the differential test — are deleted at the cutover (§14). The durable shape never wraps an OP tx in a*types.Transaction: callers decode raw bytes intooptypes.DepositTx/optypes.PostExecTxand read fields off the struct. The helpers are now documented as such in the code, and they still earn their keep in #20263 as the incremental bridge off op-geth'sTransactionmethods.PostExecTxis a canonical block transaction, not a side channel. In the Lagoon hardfork it can be the last tx of a block (sequencer rebates), so it participates in the L2 block tx list — this is why the type is in scope here and why the decode path (#20264) must route both0x7Eand0x7Dout.🤖 Generated by Claude Code
op-core/types: add DepositTx, PostExecTx and Receipt types
op-core/types: add DepositTx, PostExecTx and Receipt types (ethereum-…
op-core/types: add DepositTx, PostExecTx and Receipt types (ethereum-…