Skip to content

fix(dispute): validate evidence and reasoning CIDs before sending - #9

Merged
DamirAGI merged 1 commit into
mainfrom
fix/dispute-cid-validation
Nov 29, 2026
Merged

DamirAGI merged 1 commit into
mainfrom
fix/dispute-cid-validation

Conversation

@DamirAGI

Copy link
Copy Markdown
Contributor

Validates evidenceCID and reasoningCID on the dispute escalation path before any transaction is sent. A CID is accepted only if the whole string is a CIDv0 (Qm + 44 base58btc) or a CIDv1 in base32 (b + at least 58 of [a-z2-7]), at most 256 characters; anything else raises InvalidCIDError.

Shared acceptance vectors: test-vectors/dispute/cid-validation-vectors.json (identical in the JavaScript and Python SDKs). The dispute fixtures now use valid CIDs.

🤖 Generated with Claude Code

BondEscalation rejects evidence and reasoning references that are not a
bare CID. The SDK forwarded both strings unchecked, so a malformed value
only failed on-chain, and in UMAHelper.requester_force_dvm only after the
USDC approval had already been sent.

- validate_cid matches the whole string (re.fullmatch), so a trailing
  newline is no longer accepted, enforces MAX_CID_LENGTH (256, the
  contract limit) and returns False for non-string input. Existing
  callers keep the boolean contract.
- Add ensure_valid_cid, which raises InvalidCIDError with the field name
  (InvalidCIDError gains an optional field argument, reported in details).
- BondEscalationClient.submit_ai_ruling and escalate_to_uma validate both
  CIDs before building or sending the transaction.
- UMAHelper.requester_force_dvm validates both CIDs before any read,
  approve or bond transfer.
- Add the shared CID acceptance vectors and a test that runs every
  accept and reject vector through all three calls for both fields, plus
  validate_cid directly.
- Replace placeholder CIDs on these paths with well-formed ones and take
  the regenerated dispute golden vectors and UMA self-dispute vectors
  byte-for-byte from the TypeScript SDK (evidence: the CIDv1 accept
  vector, reasoning: the CIDv0 accept vector).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DamirAGI
DamirAGI merged commit fc3c069 into main Nov 29, 2026
18 checks passed
@DamirAGI
DamirAGI deleted the fix/dispute-cid-validation branch November 30, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant