Skip to content

fix(primitives): require list header when decoding logs - #1166

Merged
DaniPopes merged 1 commit into
alloy-rs:mainfrom
0xalpharush:fix/log-rlp-require-list
Aug 21, 2026
Merged

DaniPopes merged 1 commit into
alloy-rs:mainfrom
0xalpharush:fix/log-rlp-require-list

Conversation

@0xalpharush

@0xalpharush 0xalpharush commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

An Ethereum log is encoded as the RLP list [address, topics, data].

Log::decode validated the payload length but did not require the decoded RLP header to be a list. A string containing otherwise valid log fields was therefore accepted and re-encoded as a list, violating canonical decode/encode behavior.

Solution

Return UnexpectedString when the log's outer RLP header is not a list.

The regression test verifies rejection of a string-wrapped log, while the existing canonical log round-trip test remains unchanged.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Specification

The Ethereum Wire Protocol receipt encoding defines every log as the RLP list [address, topics, data]. go-ethereum models those same consensus fields in types.Log, and its generated RLP encoder emits an outer list.

@0xalpharush
0xalpharush marked this pull request as ready for review August 21, 2026 01:18
@github-project-automation github-project-automation Bot moved this to Reviewed in Alloy Aug 21, 2026
@DaniPopes
DaniPopes enabled auto-merge (squash) August 21, 2026 01:25
@DaniPopes
DaniPopes merged commit 6cddb17 into alloy-rs:main Aug 21, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants