fix: e3meta not available during sync replay#1457
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughCiphernodeSelector now subscribes to and handles Changes
Sequence Diagram(s)sequenceDiagram
participant Enclave as EnclaveEvent source
participant PubSub as EventBus / TypedEvent
participant Selector as CiphernodeSelector
participant Cache as e3_cache
participant Downstream as downstream processing
Enclave->>PubSub: publish E3Requested
PubSub->>Selector: deliver TypedEvent<E3Requested>
Selector->>Cache: try_mutate / or_insert_with(e3_meta_from)
Cache-->>Selector: inserted / existing E3Meta
Selector->>Downstream: continue existing ticket/selection flow
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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.
🧹 Nitpick comments (1)
crates/sortition/src/ciphernode_selector.rs (1)
88-106: Consider extracting sharedE3Metamapping to avoid drift.Lines 94-101 duplicate the same
E3Metaconstruction logic used again at Lines 124-131. A small helper would reduce future mismatch risk when metadata fields evolve.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/sortition/src/ciphernode_selector.rs` around lines 88 - 106, The E3Meta construction is duplicated in the CiphernodeSelector handler for TypedEvent<E3Requested> and elsewhere; create a single helper to build the metadata (e.g., impl E3Meta::from_request(req: &E3Requested) -> E3Meta or a free fn build_e3_meta(evt: &E3Requested) -> E3Meta) that copies/borrows the same fields (seed, threshold_n, threshold_m, params, esi_per_ct, error_size) and replace the inline E3Meta { ... } usages inside e3_cache.try_mutate and the other location with a call to that helper (ensuring clones remain where necessary).
🤖 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/sortition/src/ciphernode_selector.rs`:
- Around line 88-106: The E3Meta construction is duplicated in the
CiphernodeSelector handler for TypedEvent<E3Requested> and elsewhere; create a
single helper to build the metadata (e.g., impl E3Meta::from_request(req:
&E3Requested) -> E3Meta or a free fn build_e3_meta(evt: &E3Requested) -> E3Meta)
that copies/borrows the same fields (seed, threshold_n, threshold_m, params,
esi_per_ct, error_size) and replace the inline E3Meta { ... } usages inside
e3_cache.try_mutate and the other location with a call to that helper (ensuring
clones remain where necessary).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dbb02b29-8dae-433d-9423-8aea7ddd70f5
📒 Files selected for processing (1)
crates/sortition/src/ciphernode_selector.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/sync/src/sync.rs (1)
26-33: Add regression coverage for the new infrastructure-event branch.Line 32 adds
HistoricalNetSyncStartto replay filtering, but current tests don’t explicitly assert this variant. Please add a fixture/assertion forHistoricalNetSyncStartin the infrastructure detection/replay-filter tests to prevent regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/sync/src/sync.rs` around lines 26 - 33, Add explicit test coverage for the new branch by asserting that EnclaveEventData::HistoricalNetSyncStart is treated as an infrastructure event: create a test that constructs an EnclaveEvent containing EnclaveEventData::HistoricalNetSyncStart, call is_infrastructure_event (or run the existing replay-filter/infrastructure-detection test flow that uses that predicate), and assert it returns true / is included in replay-filtering results; update or add the fixture/assertion alongside other infrastructure-event cases to prevent regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/net/src/net_sync_manager.rs`:
- Around line 370-398: The fetch_all_batched_events call currently swallows
errors (in the Err(e) branch) and only logs a warn, which allows the code later
to emit SyncRequestSucceeded; change the Err branch to fail the sync instead by
propagating or returning an error (or setting a failure flag) so success is not
emitted: specifically, in the match handling
fetch_all_batched_events::<EnclaveEvent<Unsequenced>>(...) for each
aggregate_id, replace the warn! branch with either a return Err(...) (propagate
a descriptive error including aggregate_id and e) or set a fetch_failed boolean
and break out so the caller emits SyncRequestFailed instead of
SyncRequestSucceeded; ensure any callers that expect a Result handle the
propagated error and that references to SyncRequestSucceeded are only reached
when no fetch_all_batched_events errors occurred.
---
Nitpick comments:
In `@crates/sync/src/sync.rs`:
- Around line 26-33: Add explicit test coverage for the new branch by asserting
that EnclaveEventData::HistoricalNetSyncStart is treated as an infrastructure
event: create a test that constructs an EnclaveEvent containing
EnclaveEventData::HistoricalNetSyncStart, call is_infrastructure_event (or run
the existing replay-filter/infrastructure-detection test flow that uses that
predicate), and assert it returns true / is included in replay-filtering
results; update or add the fixture/assertion alongside other
infrastructure-event cases to prevent regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8ea4b7d1-1265-4acd-bcec-6905a3de2fa6
📒 Files selected for processing (2)
crates/net/src/net_sync_manager.rscrates/sync/src/sync.rs
Summary by CodeRabbit
New Features
Bug Fixes / Improvements