You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opgeth-decoupling: make op-service/sources the OP-aware eth client #20264
Under upstream go-ethereum, ethclient.BlockByNumber/BlockByHash/TransactionByHash on an L2 endpoint fail because the returned JSON contains deposit transactions (type 0x7E) that upstream's types.Transaction.UnmarshalJSON doesn't know. Extended Receipt fields (L1GasPrice, OperatorFeeScalar, etc.) silently drop. Solution: make op-service/sources the canonical OP-aware eth client; it already uses raw JSON-RPC so it can decode both.
Scope
op-service/sources — deposit-tx JSON decoding
op-service/sources/types.go — extend RPCBlock.Transactions JSON unmarshal to route type 0x7e to op-core/types.DepositTx and everything else to upstream types.Transaction.
Verify RPCBlock.Verify() still works (calls IsDepositTx() — switch to optypes.IsDepositTx).
op-service/apis/eth.go: change ReceiptFetcher.TransactionReceipt return type from *types.Receipt to *optypes.Receipt. Same for ReceiptsFetcher.FetchReceipts (return optypes.Receipts).
Implementation in op-service/sources (raw JSON-RPC) unmarshals into the extended type.
Downstream callers that only read standard fields continue to work because optypes.Receipt embeds types.Receipt.
op-batcher migration
op-batcher/batcher/driver.goL2Client interface (line ~77) and loadBlockIntoState (line ~320): stop using *ethclient.Client for L2 block fetches; use op-service/sources.EthClient (or a narrow interface it satisfies).
op-service/dial/ethclient_interface.goL2EndpointProvider.EthClient: return an apis.EthClient-shaped client instead of *ethclient.Client, or phase the interface out.
op-service/txinclude
The EL interface in op-service/txinclude/interfaces.go:44 returns *types.Receipt today. Change to *optypes.Receipt and wire the implementation through the updated sources client.
No ethclient changes needed in isthmus_cost_oracle.go — it reads contract storage via batch eth_call, not receipts.
Dependencies
Blocked on: #20262 (op-core/types.Receipt and DepositTx).
🤖 Claude says: Design resolution for the L2 transaction representation (from the #21356 discussion). Recording it here since this issue owns "make op-service/sources the OP-aware eth client".
No optypes.Transaction wrapper. Partition the L2 tx accessors by tx class instead. A go-ethereum-style Transaction+TxData wrapper would re-import the signer/hashing machinery the decoupling is trying to shed, for a list that is read typed-ly in very few places (the dominant L2-tx currency is already opaque []hexutil.Bytes via eth.ExecutionPayload). Where typed access is needed it's class-specific, and each class has a clean home type. So add to apis.EthClient (op-service/apis/eth.go):
InfoAndUserTxs(...) (eth.BlockInfo, types.Transactions, error) — excludes the synthetic OP types (0x7E deposits, 0x7D post-exec). The remainder are all standard Ethereum tx types, so the list is plain upstreamtypes.Transactions and decodes fine post-cutover. Serves the dominant "skip deposits, operate on user txs" pattern (op-batcher DA estimation; most test iterators).
InfoAndDeposits(...) (eth.BlockInfo, []*optypes.DepositTx, error) — deposits as op-core structs.
InfoAndFirstDeposit(...) (eth.BlockInfo, *optypes.DepositTx, error) — header + first tx (the L1-info deposit) only, for hot paths. This is the shape prototyped by refactor(op-service/sources): minimal-fetch path for L2BlockRef and SystemConfig #20532 (HeaderAndFirstTx / BlockRefFromHeaderAndDeposit), which closed unmerged but established the pattern — revive it here.
InfoAndTxsBy* stays unchanged for L1 (no OP tx types there). Internally RPCBlock keeps txs as raw per-tx bytes: the transactions-trie root recomputes directly from them (the trie leaf for a typed tx is its opaque MarshalBinary encoding), deposit/post-exec detection is a type-byte check, and the partitioned accessors decode each class on demand.
Lagoon makes 0x7D routing load-bearing. PostExecTx is a canonical block tx in Lagoon (trailing sequencer-rebate tx), so a Lagoon+ block's tx list is [deposit(0x7E), …user txs…, optional post-exec(0x7D)]. Under upstream go-ethereum the full-list decode fails on both0x7E and 0x7D; the accessors must route both out. InfoAndUserTxs excludes both; add an InfoAndPostExecTx-style accessor only if a consumer needs to read the rebate tx (most code only needs to exclude it).
Full write-up in docs/ai/opgeth-decoupling.md §11 (updated in #21356).
🤖 Claude says: Design correction for the op-batcher migration (found while planning the implementation; approved by @sebastianst).
op-batcher cannot migrate to InfoAndUserTxs — it goes payload-native instead. The earlier resolution assumed the batcher only iterates txs to filter deposits for DA estimation. That's incomplete: the fetched L2 block flows into channelMgr.AddL2Block → derive.BlockToSingularBatch, which
requirestxs[0] to be the L1-info deposit — it parses EpochNum/EpochHash/SequenceNumber out of its calldata (ErrNotDepositTx otherwise), and
includes post-exec (0x7D) txs in batch content when SDM is active (derivation expects them in span batches).
InfoAndUserTxs drops both classes, so it can't feed batch building. Instead the batcher fetches *eth.ExecutionPayloadEnvelope via the existing PayloadByNumber accessor: the payload's opaque []hexutil.Bytes txs are exactly the batch currency (deposit exclusion becomes a type-byte filter, bytes pass through verbatim), a new derive.PayloadToSingularBatch replaces BlockToSingularBatch (deleted), and derive.PayloadToBlockRef already exists for the block-ref metric. DA estimation (RawSize/EstimatedDABytes) computes value-identically from raw bytes. Batch-byte identity is pinned by parity tests.
The partitioned accessors (InfoAndUserTxs / InfoAndDeposits / InfoAndFirstDeposit) are still added as specified — they serve the #20265 test migrations; they're just not the batcher's vehicle.
Also surfaced during planning (consensus-critical for the receipts half): optypes.Receipts root derivation must hand-roll three OP arms — post-Canyon deposit receipts (nonce+version in the hash preimage), pre-Canyon deposit receipts (hashed without the nonce, deliberately diverging from MarshalBinary — see op-geth core/types/receipt.go:564-586), and 0x7D post-exec receipts (first-class typed receipts in op-geth). And FetchReceipts must derive tx hashes as keccak256(rawTx) rather than decoding typed txs, or L2 receipt fetching breaks at hash acquisition post-cutover.
Activity
sebastianst commentedon Jun 15, 2026
🤖 Claude says: Design resolution for the L2 transaction representation (from the #21356 discussion). Recording it here since this issue owns "make op-service/sources the OP-aware eth client".
No
optypes.Transactionwrapper. Partition the L2 tx accessors by tx class instead. A go-ethereum-styleTransaction+TxDatawrapper would re-import the signer/hashing machinery the decoupling is trying to shed, for a list that is read typed-ly in very few places (the dominant L2-tx currency is already opaque[]hexutil.Bytesviaeth.ExecutionPayload). Where typed access is needed it's class-specific, and each class has a clean home type. So add toapis.EthClient(op-service/apis/eth.go):InfoAndUserTxs(...) (eth.BlockInfo, types.Transactions, error)— excludes the synthetic OP types (0x7Edeposits,0x7Dpost-exec). The remainder are all standard Ethereum tx types, so the list is plain upstreamtypes.Transactionsand decodes fine post-cutover. Serves the dominant "skip deposits, operate on user txs" pattern (op-batcher DA estimation; most test iterators).InfoAndDeposits(...) (eth.BlockInfo, []*optypes.DepositTx, error)— deposits as op-core structs.InfoAndFirstDeposit(...) (eth.BlockInfo, *optypes.DepositTx, error)— header + first tx (the L1-info deposit) only, for hot paths. This is the shape prototyped by refactor(op-service/sources): minimal-fetch path for L2BlockRef and SystemConfig #20532 (HeaderAndFirstTx/BlockRefFromHeaderAndDeposit), which closed unmerged but established the pattern — revive it here.InfoAndTxsBy*stays unchanged for L1 (no OP tx types there). InternallyRPCBlockkeeps txs as raw per-tx bytes: the transactions-trie root recomputes directly from them (the trie leaf for a typed tx is its opaqueMarshalBinaryencoding), deposit/post-exec detection is a type-byte check, and the partitioned accessors decode each class on demand.Lagoon makes
0x7Drouting load-bearing. PostExecTx is a canonical block tx in Lagoon (trailing sequencer-rebate tx), so a Lagoon+ block's tx list is[deposit(0x7E), …user txs…, optional post-exec(0x7D)]. Under upstream go-ethereum the full-list decode fails on both0x7Eand0x7D; the accessors must route both out.InfoAndUserTxsexcludes both; add anInfoAndPostExecTx-style accessor only if a consumer needs to read the rebate tx (most code only needs to exclude it).Full write-up in
docs/ai/opgeth-decoupling.md§11 (updated in #21356).🤖 Generated by Claude Code
sebastianst commentedon Jul 20, 2026
🤖 Claude says: Design correction for the op-batcher migration (found while planning the implementation; approved by @sebastianst).
op-batcher cannot migrate to
InfoAndUserTxs— it goes payload-native instead. The earlier resolution assumed the batcher only iterates txs to filter deposits for DA estimation. That's incomplete: the fetched L2 block flows intochannelMgr.AddL2Block→derive.BlockToSingularBatch, whichtxs[0]to be the L1-info deposit — it parsesEpochNum/EpochHash/SequenceNumberout of its calldata (ErrNotDepositTxotherwise), and0x7D) txs in batch content when SDM is active (derivation expects them in span batches).InfoAndUserTxsdrops both classes, so it can't feed batch building. Instead the batcher fetches*eth.ExecutionPayloadEnvelopevia the existingPayloadByNumberaccessor: the payload's opaque[]hexutil.Bytestxs are exactly the batch currency (deposit exclusion becomes a type-byte filter, bytes pass through verbatim), a newderive.PayloadToSingularBatchreplacesBlockToSingularBatch(deleted), andderive.PayloadToBlockRefalready exists for the block-ref metric. DA estimation (RawSize/EstimatedDABytes) computes value-identically from raw bytes. Batch-byte identity is pinned by parity tests.The partitioned accessors (
InfoAndUserTxs/InfoAndDeposits/InfoAndFirstDeposit) are still added as specified — they serve the #20265 test migrations; they're just not the batcher's vehicle.Also surfaced during planning (consensus-critical for the receipts half):
optypes.Receiptsroot derivation must hand-roll three OP arms — post-Canyon deposit receipts (nonce+version in the hash preimage), pre-Canyon deposit receipts (hashed without the nonce, deliberately diverging fromMarshalBinary— see op-gethcore/types/receipt.go:564-586), and0x7Dpost-exec receipts (first-class typed receipts in op-geth). AndFetchReceiptsmust derive tx hashes askeccak256(rawTx)rather than decoding typed txs, or L2 receipt fetching breaks at hash acquisition post-cutover.🤖 Generated by Claude Code (Claude Fable 5)
op-batcher: load L2 blocks as execution payloads
op-batcher: load L2 blocks as execution payloads
op-batcher: load L2 blocks as execution payloads
op-batcher: load L2 blocks as execution payloads
op-batcher: load L2 blocks as execution payloads
op-batcher: load L2 blocks as execution payloads
op-batcher: load L2 blocks as execution payloads
op-batcher: load L2 blocks as execution payloads