Skip to content

Implement transaction execution pipeline #83

@mw2000

Description

@mw2000

Summary

Build the end-to-end transaction execution pipeline that takes a wire-format transaction and produces a state transition. Currently eevm can execute raw bytecode but has no pipeline for: decode tx → validate → deduct gas → execute → apply state changes → generate receipt.

Specification

The pipeline:

  1. Decode — deserialize from wire format using Transaction.Envelope.decode/1
  2. Recover sender — via Transaction.Signer.recover_sender/2
  3. Validate — via Transaction.Validator.validate/3
  4. Deduct upfront costgas_limit * gas_price + value from sender balance
  5. Calculate intrinsic gas — via Transaction.IntrinsicGas.calculate/1
  6. Set up execution context — populate Context.Transaction, Context.Block, Context.Contract
  7. Pre-warm access set — sender, recipient, coinbase, precompiles, access list entries
  8. Execute EVMEEVM.execute/2 for message calls, or CREATE for contract deployment
  9. Apply gas refundmin(refund, gas_used / 5) back to sender
  10. Transfer priority fee — to coinbase
  11. Generate receipt — status, cumulative gas, logs, bloom

Implementation Guide

  1. Create lib/eevm/transaction/executor.ex — the pipeline orchestrator
  2. Define EEVM.TransactionResult struct — status, gas_used, logs, receipt, state changes
  3. Wire together existing modules: Envelope, Signer, Validator, IntrinsicGas, Database, EEVM.execute
  4. Handle all tx types — Legacy, AccessList, FeeMarket, Blob (and eventually SetCode)
  5. Tests: execute a simple value transfer, execute a contract call, contract deployment, failed tx (validation error), reverted tx

Acceptance Criteria

  • Full pipeline from wire bytes to state transition
  • Sender balance deducted upfront, refund applied after
  • Priority fee transferred to coinbase
  • Works for all 4 tx types
  • Contract deployment via tx (to=nil)
  • Failed validation returns error without state change
  • Reverted tx still charges gas
  • Tests pass

Reference

  • Ethereum Yellow Paper §6 (Transaction Execution)
  • execution-specs: ethereum/execution-specs state_transition function

Metadata

Metadata

Assignees

No one assigned

    Labels

    block-processingBlock-level transaction processingcoreCore EVM functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions