Skip to content

opgeth-decoupling: create op-core/types (DepositTx and PostExecTx with differential tests, Receipt) #20262

Closed

Description

@sebastianst

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 UnmarshalDepositTx

TxRollupCostData 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) bool

Same 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

  1. self-assigned this
    on May 5, 2026
  2. changed the title [-]opgeth-decoupling: create op-core/types (DepositTx with differential test, Receipt)[/-] [+]opgeth-decoupling: create op-core/types (DepositTx and PostExecTx with differential tests, Receipt)[/+] on Jun 11, 2026
  3. sebastianst commented on Jun 15, 2026

    @sebastianst
    MemberAuthor

    🤖 Claude says: Design note from the implementation PR (#21356), recording a refinement to how these types are consumed downstream.

    The *types.Transaction helpers (IsDepositTx/SourceHash/Mint/IsSystemTx/IsPostExecTx) are transition-only. They take a go-ethereum *types.Transaction, which can carry a 0x7E/0x7D tx only while the build resolves to op-geth. After the final cutover to upstream go-ethereum, an upstream *types.Transaction can 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 into optypes.DepositTx / optypes.PostExecTx and 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's Transaction methods.

    PostExecTx is 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 both 0x7E and 0x7D out.

    🤖 Generated by Claude Code

  4. added a commit that references this issue on Jun 17, 2026
    00055d6
  5. added a commit that references this issue on Jun 18, 2026
    bfd9fef
  6. added a commit that references this issue on Sep 19, 2026
    6601c10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions