fix(indexer): match resolutionParser to the real on-chain event shape#666
Merged
Mimah97 merged 2 commits intoJun 30, 2026
Merged
Conversation
resolutionParser's topic constant ("market_resolved") never matched a
real event for the same reason as market_created: Soroban's
#[contractevent] macro snake-cases the full struct name including its
"Event" suffix, so MarketResolvedEvent (contracts/market/src/events.rs)
actually publishes under "market_resolved_event" — confirmed against
the contract's own test_emit_market_resolved unit test. Every
market_resolved event was silently skipped in production.
The "canonical on-chain tuple" shape the parser targeted was also a
guess that doesn't match the real event: MarketResolvedEvent carries
market_id as topics[1] (u32, a #[topic] field), with only
{ outcome: bool, resolved_at: u64 } in the value — not a 3-element
tuple packed into the value. parseResolutionPayload now reads
market_id from the topic for this shape, matching the issue's "u32
bool u64 payload" description exactly (u32 topic + bool/u64 value
fields, not a single tuple).
The pre-existing legacy ScvVec-tuple and legacy ScvMap (with
market_id/outcome/oracle in the value) code paths are left intact for
backward compatibility — detection now branches on whether the value
is an array, a map with "market_id", or a map without it (the real
shape).
Updated resolutionParser.test.ts and ingestion.test.ts's resolution
fixture to the real topic, and added new real-shape test vectors.
Updated docs/indexer-event-mapping.md and contract-event-vectors.json
to match.
Closes Vatix-Protocol#589
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.
Summary
resolutionParser's topic constant ("market_resolved") never matched a real event, for the same root cause asmarketCreatedParser(see Wire market_created parser into ingestion loop #590): Soroban's#[contractevent]macro snake-cases the full struct name including itsEventsuffix, soMarketResolvedEvent(contracts/market/src/events.rs) actually publishes undermarket_resolved_event— confirmed directly against the contract's owntest_emit_market_resolvedunit test. Everymarket_resolvedevent was being silently skipped in production.MarketResolvedEventcarriesmarket_idastopics[1](u32, a#[topic]field) with only{ outcome: bool, resolved_at: u64 }in the value — not a 3-element tuple packed into the value.parseResolutionPayloadnow readsmarket_idfrom the topic for this shape, which matches this issue's "u32 bool u64 payload" description precisely: au32topic plusbool/u64value fields, not a single tuple.ScvVec3-tuple and legacyScvMap(withmarket_id/outcome/oracleall in the value) code paths are left intact for backward compatibility. Shape detection now branches on whether the value is an array, a map containingmarket_id(legacy), or a map without it (the real on-chain shape).Why
Same class of bug as #590: the backend assumed a topic-naming convention that doesn't match what Soroban's
#[contractevent]macro actually generates, and the payload shape was guessed rather than read from the contract source.Test plan
apps/indexer/src/resolutionParser.test.tswith the real topic and new real-shape test vectors (topic-derivedmarket_id, missing-topic error case), alongside the existing legacy tuple/map coverage.apps/indexer/src/ingestion.test.ts'sRESOLUTION_TOPICfixture constant to the real topic so the end-to-end ingestion test still exercises a matching event.npx vitest run apps/indexer/src— all pass except 3 pre-existing, unrelated failures already present ondev(collateralDepositedParser.test.ts,storage.test.ts).docs/indexer-event-mapping.mdandapps/indexer/fixtures/contract-event-vectors.jsonto document the corrected topic and payload shape.Closes #589