chore: crisp fixes#1274
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds multi-option tally support across CRISP (decoder, models, repo, indexer, client), renames a mock token deployment key, removes an unused import, and appends a ThresholdNotMet error code to the EVM registry finalizeCommittee retry payload. Changes
Sequence Diagram(s)sequenceDiagram
participant EventSource as EventEmitter
participant Indexer as Indexer
participant Decoder as TallyDecoder
participant Repo as CrispRepository
participant Storage as DB
EventSource->>Indexer: plaintextOutput event
Indexer->>Repo: get_num_options()
Repo-->>Indexer: num_choices
Indexer->>Decoder: decode_tally(plaintextOutput, num_choices)
Decoder-->>Indexer: Vec<BigUint> (vote counts)
Indexer->>Repo: set_votes(Vec<BigUint>)
Repo->>Storage: persist tally
Repo-->>Indexer: ack
Indexer->>Indexer: mark finished / log results
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
20eac6e to
cbc9a83
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
examples/CRISP/crates/crisp-utils/src/lib.rs (1)
21-33:⚠️ Potential issue | 🟡 MinorStale doc comment — still describes the old yes/no decoding.
The doc comment references "yes votes in the first half and no votes in the second half" and a
VoteCountsreturn type. Update it to reflect the newnum_choices-based segmented decoding andVec<BigUint>return.
🤖 Fix all issues with AI agents
In `@examples/CRISP/crates/crisp-utils/src/lib.rs`:
- Line 42: The division using let segment_size = values.len() / num_choices; can
silently drop trailing bytes when values.len() is not divisible by num_choices;
change the logic to validate divisibility first (check values.len() %
num_choices == 0) and return a meaningful error (or propagate one) instead of
proceeding, then compute segment_size only after the check; update the
surrounding function signature (e.g., return Result<...>) or error-handling path
that contains segment_size, values, and num_choices so callers receive a clear
error when the tally byte length is not evenly divisible.
🧹 Nitpick comments (2)
examples/CRISP/crates/crisp-utils/src/lib.rs (2)
80-90: Weak test:test_decode_tally_with_wrong_num_optionsonly asserts inequality.This test verifies the results differ from the 2-option case but doesn't validate what the correct behavior should be. With the divisibility check suggested above, this should instead assert that calling
decode_tallywith a mismatchednum_choicesreturns anErr.Proposed test update (assuming divisibility validation is added)
#[test] fn test_decode_tally_with_wrong_num_options() { - // Expected: yes = 10000000000, no = 30000000000 let tally_hex = "00000000000000000000000000000000..."; // same hex let bytes = hex::decode(tally_hex.strip_prefix("0x").unwrap_or(tally_hex)).unwrap(); - let result = decode_tally(&bytes, 3).unwrap(); - - assert!(result[0] != BigUint::from(10000000000u64)); - assert!(result[1] != BigUint::from(30000000000u64)); + let result = decode_tally(&bytes, 3); + assert!(result.is_err(), "Expected error for indivisible tally length"); }
14-19: Remove unusedVoteCountsstruct.The
VoteCountsstruct (lines 14-19) is no longer used sincedecode_tallynow returnsVec<BigUint>. Remove the struct definition and the stale doc comment referencing it (line 33).
92ffb27 to
16155cb
Compare
Small fixes in CRISP
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Tests