Skip to content

feat: add transaction receipt module with EIP-2718 encoding#113

Merged
mw2000 merged 1 commit intomainfrom
issue-84
Apr 25, 2026
Merged

feat: add transaction receipt module with EIP-2718 encoding#113
mw2000 merged 1 commit intomainfrom
issue-84

Conversation

@mw2000
Copy link
Copy Markdown
Owner

@mw2000 mw2000 commented Apr 25, 2026

Summary

  • Adds EEVM.Receipt at lib/eevm/receipt.ex — the post-execution receipt struct (status, cumulative_gas_used, logs, logs_bloom) per Yellow Paper §4.3.1.
  • new/1 derives :logs_bloom from :logs automatically so the two can never drift; callers re-hydrating from RLP can pass :logs_bloom directly and skip :logs.
  • encode/2 produces the wire form. Default is the legacy RLP list [status, cumulative_gas, bloom, logs]; pass tx_type: :eip2930 | :eip1559 | :eip4844 (or a raw integer byte) to prepend the EIP-2718 type byte. Each log encodes as [address(20B), [topic(32B)...], data].

Notes

Closes #84.

Test plan

  • mix format --check-formatted
  • mix compile --warnings-as-errors
  • mix credo --strict
  • mix test (570 tests, 0 failures; 13 new in test/receipt_test.exs covering new/0, new/1 overrides, logs→bloom derivation, legacy + all four typed encoding variants, and bloom membership for emitted logs)

🤖 Generated with Claude Code

Introduce `EEVM.Receipt` — the post-execution summary that gets folded
into a block's receipts trie. Four fields per Yellow Paper §4.3.1:
`status`, `cumulative_gas_used`, `logs`, `logs_bloom`.

- `new/0` / `new/1` — keyword overrides; supplying `:logs` without an
  explicit `:logs_bloom` derives the bloom from the logs so the two
  cannot drift. A caller re-hydrating from RLP can pass `:logs_bloom`
  directly and skip `:logs`.
- `encode/2` — wire form. Default `tx_type: :legacy` produces a plain
  RLP list `[status, cumulative_gas, bloom, logs]`. Typed variants
  (`:eip2930` / `:eip1559` / `:eip4844`, or a raw integer byte) prepend
  the EIP-2718 type byte. Each log encodes as `[address(20B),
  [topic(32B)...], data]`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mw2000 mw2000 marked this pull request as ready for review April 25, 2026 19:16
@mw2000 mw2000 merged commit 54542bb into main Apr 25, 2026
2 checks passed
@mw2000 mw2000 deleted the issue-84 branch April 25, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement transaction receipt generation

1 participant