Repository navigation
fix(indexer): correct v2 event attribution and record-value handling - #138
Merged
Merged
Conversation
Index the indexed-value DataChanged variant, split the DNS root name from a malformed encoding, key transfer ownership on (token id, emitting registry) in replay and at-block too, and degate the approvals re-key.
mdtanrikulu
force-pushed
the
fix/v2-event-attribution
branch
from
September 30, 2026 12:41
5662057 to
b946c1f
Compare
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.
DataChanged: the only shape Sepolia emits was being dropped
indexedis not part of an event signature hash, so onetopic0is emitted bycontracts that disagree on how many parameters reach
data. A census of everyDataChanged(bytes32,string,string,bytes)log on Sepolia — re-run twice,independently:
{4: 79}— the 3-topic form has never occurred therekeccak256(payload string) == topics[2]for 79/79, zero mismatchestopics[3] == keccak256("")So the emitters mark
valueas indexed too:dataholds only the key, andtopics[3]iskeccak256(value). Atopics.len != 3guard rejected all 79, anddecoding a 4-topic payload against the two-parameter schema read the key's length
word as the value's tail offset — which is how one such log reached an unchecked
add in the codec and stalled a sync.
Both shapes are now handled, and the 4-topic arm proves its layout (the
decoded key must hash to
topics[2]) rather than trusting the topic count.Why no value is stored
A keccak preimage search over each transaction's calldata and sibling logs
recovers 41 of 78 non-empty values — sound, since a preimage match is proof,
but it needs an extra RPC plus an unbounded scan per event and still leaves 37
unknowable forever. So the honest representation is required either way.
resolver_datas.valueisTEXT NOT NULLand""already means cleared, sothere is nothing truthful to put there: the hash would be served as a 32-byte
value. Therefore
keccak256("")takes the existing delete path, and any otherhash stores no row — dropping a pre-existing one, since the chain says the
value changed — while the hash travels in event history as
valueHash, nevervalue. Replay is taught the same distinction.Three more attribution defects
DNS root vs. malformed.
decodeDNSNameToStringcollapsed both intonull,so a handler discarded three legitimate root-name records as undecodable while
its sibling correctly read the same
nullas the default binding. Fixed at thewrapper:
nullmeans the root and nothing else; a malformed encoding propagatesand is skipped per-event with its coordinates. The test that pinned the
conflation now pins them apart.
Transfer ownership was keyed wrongly in two of three places. A tokenId
collides across registries, so ownership must key on
(tokenId, emitting registry). The live path did;replayand at-block reconstruction keyed on theevents row's namehash — a denormalised copy that is NULL on an orphaned transfer.
Both now re-derive it, matching the
resolver_updatedarms that already did. Atransfer for an unknown token records a
tokenId:<dec>placeholder so theexisting repair ledger can heal it, instead of a row unreachable from its name.
The approvals re-key was gated on a namehash it never reads. It keys on
(tokenId, registry), both present in the log, so an un-indexed name left theapproval pointing at a retired token id permanently — the name row is re-keyed on
a later sighting, the approval never was.
Two fixture bugs found along the way
Replay's and conformance's
.transferrows were{"to":…}withcontract_address = Address.zero— a shape the live indexer never emits. Thatis what made a golden fail, so the fixtures were corrected (and a foreign-registry
transfer added, which must no-op); no golden was regenerated.
resolver_datas,resolver_linksandresolver_named_resourceswere inneither replay-parity gate, and the two gates disagreed on which they covered
— so the new replay arm would have shipped unverified. Added to both.
Schema descriptions that were false
data(key)documented itsnullas "unset" anddataKeysas "Alldata(key)keys set". Neither holds for a record whose value was only ever on chain as a
hash. Both now say what is true and point at the event surface.
Verification
test-alltest-pgtest-storage-pgtest-integration-pgSeven sabotage checks — each fix reverted, the suite confirmed to fail. Two of the
new tests initially passed under sabotage because they were guarded on a
configured contract address that is zero in the test environment; they were made
config-independent. Three existing tests are no-ops for that same reason and are
called out below.
Known limitations
test-pinned — exercising it needs database fault injection.
DataChangedwrites under the raw node while reads map throughresolveRecordKey, so on a resolver carrying aLinkedrow even a plain valuelands where no read looks. Pre-existing; separate fix.
.data_updatedarm has novalueHashbranch. Latent today, sincethat path is always plaintext.
(including CI) because they guard on a configured registry address.
dataKeys/data(key)needs a schema column anda product decision on how a hashed record reads; not attempted here.