Skip to content

Implement transaction receipt generation #84

@mw2000

Description

@mw2000

Summary

Generate transaction receipts after execution. Receipts contain the status, cumulative gas used, logs, and bloom filter — required for block validation and event querying.

Specification

Receipt struct:

%Receipt{
  status: 0 | 1,              # 0 = failure, 1 = success
  cumulative_gas_used: non_neg_integer(),
  logs: [log_entry()],
  logs_bloom: <<_::2048>>      # 256-byte bloom filter
}

Encoding

  • Legacy tx receipts: RLP.encode([status, cumulative_gas, bloom, logs])
  • Typed tx receipts: tx_type ++ RLP.encode([status, cumulative_gas, bloom, logs])

Implementation Guide

  1. Create lib/eevm/receipt.ex with the Receipt struct
  2. Generate receipt from TransactionResult — status from execution result, logs from MachineState, bloom via EEVM.Bloom
  3. Add encode/1 for RLP encoding (both legacy and typed)
  4. Cumulative gas is the sum of gas used by all txs in the block up to and including this one — tracked at the block level
  5. Tests: receipt from successful tx, receipt from reverted tx, receipt encoding, bloom filter matches logs

Acceptance Criteria

  • Receipt struct with all required fields
  • Status correctly reflects execution success/failure
  • Logs bloom computed from receipt logs
  • RLP encoding for legacy and typed receipts
  • Tests pass

Reference

  • Yellow Paper §4.3.1 (Receipt)
  • EIP-2718 (Typed receipts)

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