Skip to content

feat(dyn-abi): add indexed event topic encoding for DynSolValue - #1161

Merged
mattsse merged 1 commit into
mainfrom
mattsse/dyn-encode-topic
Aug 9, 2026
Merged

mattsse merged 1 commit into
mainfrom
mattsse/dyn-encode-topic

Conversation

@mattsse

@mattsse mattsse commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Adds DynSolValue::encode_topic, encode_topic_preimage, and topic_preimage_length as the dynamic counterparts of EventTopic, so code working with runtime-resolved types can construct indexed event topics without generated types. First consumer is foundry-rs/foundry#16049, which currently carries a local copy of this logic in cast and can switch to these methods on the next release.

The implementation is differentially tested against the static EventTopic implementation and against solc-verified vectors, obtained by emitting the corresponding events with solc 0.8.20 and 0.8.30 and inspecting the logs via vm.recordLogs.

One deliberate divergence, in solc's favor: solc contributes no bytes to composite preimages for empty string/bytes values, so emitting E(string[] indexed) with [""] produces keccak256("") as the topic, and an empty string struct member contributes nothing to the preimage. The static encode_topic_bytes currently pads empty contents to a full zero word instead. The new methods follow solc; fixing the static implementation is left to a separate PR.

Adds encode_topic, encode_topic_preimage, and topic_preimage_length,
the dynamic counterparts of the EventTopic methods, enabling indexed
event topic construction for runtime-resolved types. Differentially
tested against the static implementation and solc-verified vectors.
@mattsse
mattsse force-pushed the mattsse/dyn-encode-topic branch from 962b26f to e00edb9 Compare August 6, 2026 19:48
@mattsse mattsse closed this Aug 7, 2026
@mattsse mattsse reopened this Aug 7, 2026
@github-project-automation github-project-automation Bot moved this to Done in Alloy Aug 7, 2026
@github-project-automation github-project-automation Bot moved this from Done to In Progress in Alloy Aug 7, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Reviewed in Alloy Aug 8, 2026
@mattsse
mattsse merged commit 67251fe into main Aug 9, 2026
31 checks passed
@mattsse
mattsse deleted the mattsse/dyn-encode-topic branch August 9, 2026 06:52
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Aug 9, 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