Skip to content

fix(revm): make L1 fee fallback encoding tx-type exact #128

@panos-xyz

Description

@panos-xyz

Background

morph-reth stores original encoded transaction bytes for real transactions, so real L1 fee calculation preserves the actual MorphTxEnvelope variant. Simulation paths such as eth_call / eth_estimateGas may not have original signed transaction bytes, so MorphTxEnv::encode_for_l1_fee() rebuilds an envelope for L1 fee accounting.

Problem

build_ethereum_envelope_for_l1_fee() currently infers the fallback transaction type from field shape:

  • no dynamic fee and no access list => Legacy
  • access list and no dynamic fee => EIP-2930
  • otherwise => EIP-1559

This misses EIP-7702 entirely, dropping authorization_list from simulated fee bytes. It can also mis-encode EIP-2930 transactions with an empty access list as Legacy because the type is inferred from access_list.is_empty().

Scope

  • Make MorphTxEnv::encode_for_l1_fee() / build_ethereum_envelope_for_l1_fee() preserve explicit transaction type where possible.
  • Add EIP-7702 fallback encoding using TxEip7702, including authorization list data.
  • Preserve EIP-2930 typed encoding even when the access list is empty if tx_type == 0x01.
  • Keep Legacy, EIP-1559, L1 message, MorphTx, and unsupported blob behavior explicit.
  • Add focused tests for the fallback encoder.

Acceptance Criteria

  • EIP-7702 fallback L1 fee encoding includes authorization list data.
  • Empty-access-list EIP-2930 fallback encoding remains typed as EIP-2930, not Legacy.
  • Existing Legacy / EIP-1559 / MorphTx fallback behavior is unchanged.
  • 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