feat: sort finalized committee scores#1491
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughCommitteeFinalized on-chain events and corresponding SDK/Rust types were extended to include a per-member Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/enclave-sdk/src/events/types.ts`:
- Around line 100-104: The interface CommitteeFinalizedData has a field named
nodes that doesn't match the ABI-decoded event args (which use committee);
update the interface to rename nodes to committee so the shape matches the ABI
output, i.e. change CommitteeFinalizedData { e3Id: bigint; nodes: string[];
scores: bigint[] } to use committee: string[] instead, ensuring the event
listener that passes the ABI-decoded args will satisfy the type without
remapping.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: be6dac11-5be0-47fb-bf33-dd84ad677056
📒 Files selected for processing (13)
agent/flow-trace/03_E3_REQUEST_AND_COMMITTEE.mdcrates/events/src/enclave_event/committee_finalized.rscrates/evm/src/ciphernode_registry_sol.rscrates/tests/tests/integration.rspackages/enclave-contracts/artifacts/contracts/Enclave.sol/Enclave.jsonpackages/enclave-contracts/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.jsonpackages/enclave-contracts/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.jsonpackages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.jsonpackages/enclave-contracts/artifacts/contracts/interfaces/ISlashingManager.sol/ISlashingManager.jsonpackages/enclave-contracts/artifacts/contracts/registry/CiphernodeRegistryOwnable.sol/CiphernodeRegistryOwnable.jsonpackages/enclave-contracts/contracts/interfaces/ICiphernodeRegistry.solpackages/enclave-contracts/contracts/registry/CiphernodeRegistryOwnable.solpackages/enclave-sdk/src/events/types.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/tests/tests/integration.rs (1)
404-416: Make placeholder score semantics explicit to prevent accidental misuse.Line 412 hardcodes
ticket_id=0, so this helper can generate scores that differ from actual winner-ticket scores used in production sortition. Consider renaming it to a clearly test-only placeholder (or accept ticket IDs as input) so it isn’t reused as canonical scoring logic.Suggested minimal rename to make intent explicit
- fn compute_committee_scores(committee: &[String], e3_id: &E3id, seed: Seed) -> Vec<String> { + fn compute_placeholder_committee_scores( + committee: &[String], + e3_id: &E3id, + seed: Seed, + ) -> Vec<String> {- scores: compute_committee_scores(ð_addrs, &e3_id, seed.clone()), + scores: compute_placeholder_committee_scores(ð_addrs, &e3_id, seed.clone()),- scores: compute_committee_scores(ð_addrs, &E3id::new("1234", 1), seed.clone()), + scores: compute_placeholder_committee_scores(ð_addrs, &E3id::new("1234", 1), seed.clone()),- scores: compute_committee_scores(ð_addrs, &E3id::new("1234", 2), seed.clone()), + scores: compute_placeholder_committee_scores(ð_addrs, &E3id::new("1234", 2), seed.clone()),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/tests/tests/integration.rs` around lines 404 - 416, The helper compute_committee_scores currently hardcodes ticket_id=0 which can be mistaken for production logic; rename it to compute_placeholder_committee_scores (and update its doc comment to state it uses ticket_id=0 as a test-only placeholder) and then update all call sites to use the new name so tests remain correct and the intent is explicit; alternatively, if you prefer extending behavior, change the signature to accept a ticket_id parameter (e.g., ticket_id: u64) and pass that through to e3_sortition::hash_to_score wherever compute_committee_scores is used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/tests/tests/integration.rs`:
- Around line 404-416: The helper compute_committee_scores currently hardcodes
ticket_id=0 which can be mistaken for production logic; rename it to
compute_placeholder_committee_scores (and update its doc comment to state it
uses ticket_id=0 as a test-only placeholder) and then update all call sites to
use the new name so tests remain correct and the intent is explicit;
alternatively, if you prefer extending behavior, change the signature to accept
a ticket_id parameter (e.g., ticket_id: u64) and pass that through to
e3_sortition::hash_to_score wherever compute_committee_scores is used.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 07ef5b1d-7041-492b-a985-b50332192d59
📒 Files selected for processing (1)
crates/tests/tests/integration.rs
The
CommitteeFinalizedevent now emits the score as well as the addresses. Nodes sort the list before continuingSummary by CodeRabbit
New Features
Contracts
Tests