Skip to content

fix(geth): make L1 data fee fallback encoding tx-type exact #985

@panos-xyz

Description

@panos-xyz

Background

Morph L1 data fee calculation has two paths:

  • Real transactions use CalculateL1DataFee(tx), which calls tx.MarshalBinary() and preserves the actual transaction type and fields.
  • Simulation / estimation paths use EstimateL1DataFeeForMessage(msg, ...), which rebuilds a transaction from types.Message via rollup/fees.asUnsignedTx() before encoding it for fee calculation.

The fallback path currently reconstructs only legacy, access-list, dynamic-fee, and MorphTx transactions.

Problem

types.Message already carries EIP-7702 authorizations via SetCodeAuthorizations(), and execution uses them. However, rollup/fees.asUnsignedTx() does not reconstruct a SetCodeTx, so EIP-7702 authorization data is omitted from the bytes used for L1 data fee estimation.

This can under-estimate L1 data fee in simulation / estimation paths such as morph_estimateL1DataFee and gas allowance calculations. The real signed transaction path is not affected because it uses the actual encoded transaction bytes.

There is also a transaction-type exactness concern for EIP-2930 with an empty access list: fallback encoding should preserve the requested tx type rather than infer type only from field shape where possible.

Scope

  • Make the fallback L1 fee encoding path reconstruct transactions by explicit tx type / message semantics instead of losing type-specific fields.
  • Add a SetCodeTx branch when msg.SetCodeAuthorizations() is non-empty.
  • Preserve chain id, nonce, gas caps, value, data, access list, target address, and authorization list.
  • Review EIP-2930 empty access-list behavior and preserve typed transaction encoding where the request/message indicates access-list tx semantics.
  • Keep the real transaction path CalculateL1DataFee(tx) unchanged.

Acceptance Criteria

  • EIP-7702 fallback L1 fee encoding includes the authorization list bytes.
  • Tests show the L1 fee estimate differs from plain EIP-1559 when authorization list data is present.
  • Existing Legacy / EIP-2930 / EIP-1559 / MorphTx L1 fee fallback behavior remains covered.
  • Tests fail before the fix and pass after it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions