Repository navigation
feat(dyn-abi): add indexed event topic encoding for DynSolValue - #1161
Merged
Merged
Conversation
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
force-pushed
the
mattsse/dyn-encode-topic
branch
from
August 6, 2026 19:48
962b26f to
e00edb9
Compare
DaniPopes
approved these changes
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
DynSolValue::encode_topic,encode_topic_preimage, andtopic_preimage_lengthas the dynamic counterparts ofEventTopic, 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
EventTopicimplementation and against solc-verified vectors, obtained by emitting the corresponding events with solc 0.8.20 and 0.8.30 and inspecting the logs viavm.recordLogs.One deliberate divergence, in solc's favor: solc contributes no bytes to composite preimages for empty
string/bytesvalues, so emittingE(string[] indexed)with[""]produceskeccak256("")as the topic, and an empty string struct member contributes nothing to the preimage. The staticencode_topic_bytescurrently pads empty contents to a full zero word instead. The new methods follow solc; fixing the static implementation is left to a separate PR.