fix: Reject duplicate decisions in CreateMarket dimension prevalidation - #11
Open
giaki3003 wants to merge 3 commits into
Conversation
…fee blocks Bug: w3-20260627-1017-kimiclaw-confirm-openclaw- (primary) Finding: findings/20260627-1017-kimiclaw-confirm-openclaw-truthcoin-dc-buy-limit-fee-mismatch.md Severity: R5-T2 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit b72676b)
Bug: w3-20260701-2209-kimiclaw-confirm-glmclaw-t (primary) Finding: findings/20260701-2209-kimiclaw-confirm-glmclaw-truthcoin-dc-submitvote-voting-period-prevalidate-gap.md Severity: R5-T2 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit 3d6fd24)
…ut fail connect Bug: w3-20260705-0214-kimiclaw-confirm-openclaw- (primary) Finding: findings/20260705-0214-kimiclaw-confirm-openclaw-truthcoin-dc-createmarket-duplicate-dim-prevalidate-gap.md Severity: R5-T2 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit 341f111)
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.
What's wrong
generate_state_combosinlib/state/markets/market.rsrejects dimension specs that reference the same decision twice, returningMarketError::DuplicateDecision. That runs at connect time, underapply_market_creation, where the error propagates out and invalidates the whole block.MarketValidator::validate_market_creationinlib/validation/market.rshas no such check. It validates each spec independently, so it never notices that two specs name the sameDecisionId. ACreateMarkettransaction with a repeated decision is therefore accepted into the mempool and selected into a block that cannot connect.The fix
Add
validate_no_duplicate_dimensions, which walksdimension_specswith aHashSet<DecisionId>using the sameSingle | Categoricalextraction asgenerate_state_combos, and call it invalidate_market_creationbefore the per-spec loop. This mirrors the existing connect-time rule rather than adding a new one.Tests
duplicate_dimensions_rejectedinlib/validation/market.rscovers the distinct-decision, repeated-decision, and mixedSingle/Categoricalcases (the last being a duplicate too, matchinggenerate_state_combos).Finding report (access-controlled): https://giaki3003.tech/#/findings/20260705-0214-kimiclaw-confirm-openclaw-truthcoin-dc-createmarket-duplicate-dim-prevalidate-gap
Part of a short series for this repo (fix 3 of 4); builds on #10, so it reads best merged after that one. Happy to rebase or split if you'd prefer them independent.