Skip to content

fix: e3meta not available during sync replay#1457

Merged
ctrlc03 merged 4 commits into
mainfrom
fix/e3-cache-population-during-sync
Mar 19, 2026
Merged

fix: e3meta not available during sync replay#1457
ctrlc03 merged 4 commits into
mainfrom
fix/e3-cache-population-during-sync

Conversation

@hmzakhalid

@hmzakhalid hmzakhalid commented Mar 18, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Automatic subscription and handling for E3 requests on startup.
    • Enhanced E3 request caching to improve replay consistency.
  • Bug Fixes / Improvements

    • Graceful handling of partial failures when fetching batched events; continues processing remaining sources and reports failed aggregates.
    • Treat HistoricalNetSyncStart as an infrastructure event so it’s skipped during replay.
    • Improved informational logging when dialing peers.

@vercel

vercel Bot commented Mar 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview, Comment Mar 19, 2026 10:27am
enclave-docs Ready Ready Preview, Comment Mar 19, 2026 10:27am

Request Review

@coderabbitai

coderabbitai Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6eec3bc0-71d4-4a09-89a7-be5241080c13

📥 Commits

Reviewing files that changed from the base of the PR and between c2bded6 and f6c2382.

📒 Files selected for processing (3)
  • crates/net/src/net_interface.rs
  • crates/net/src/net_sync_manager.rs
  • crates/sortition/src/ciphernode_selector.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/net/src/net_interface.rs

📝 Walkthrough

Walkthrough

CiphernodeSelector now subscribes to and handles E3Requested events, inserting E3Meta into its e3_cache during replay; net sync now records per-aggregate failures and continues fetching other aggregates; historical net sync start events are treated as infrastructure events; peer-dial logging was added.

Changes

Cohort / File(s) Summary
Ciphernode selector / E3 handling
crates/sortition/src/ciphernode_selector.rs
Subscribe to EventType::E3Requested; route EnclaveEventData::E3Requested into TypedEvent<E3Requested>; add Handler<TypedEvent<E3Requested>> that inserts E3Meta into e3_cache during replay and reuse helper e3_meta_from.
Net sync manager / resilient fetch
crates/net/src/net_sync_manager.rs
Change fetch loop to match fetch_all_batched_events: on Ok aggregate events and update latest_timestamp; on Err log warning, record failed aggregate, continue; return error after loop if any aggregates failed.
Sync replay filtering
crates/sync/src/sync.rs
Add HistoricalNetSyncStart(_) to is_infrastructure_event so such events are skipped during replay/deduplication.
Net interface / dial logging
crates/net/src/net_interface.rs
Add structured info logging before spawning peer-dial task: logs count and peer list (no behavioral change).

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • ryardley
  • 0xjei
  • cedoor

Poem

🐰 I hopped through queues where E3s chime,
I cached a meta, saved some time,
Nets kept trying, some failed the race,
I logged the peers, then kept the pace. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the core issue: ensuring e3meta is available during sync replay, which is the primary objective reflected in the file changes to CiphernodeSelector and sync handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/e3-cache-population-during-sync
📝 Coding Plan
  • Generate coding plan for human review 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/sortition/src/ciphernode_selector.rs (1)

88-106: Consider extracting shared E3Meta mapping to avoid drift.

Lines 94-101 duplicate the same E3Meta construction 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

📥 Commits

Reviewing files that changed from the base of the PR and between 208d2f0 and 62600b5.

📒 Files selected for processing (1)
  • crates/sortition/src/ciphernode_selector.rs

ctrlc03
ctrlc03 previously approved these changes Mar 18, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 HistoricalNetSyncStart to replay filtering, but current tests don’t explicitly assert this variant. Please add a fixture/assertion for HistoricalNetSyncStart in 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

📥 Commits

Reviewing files that changed from the base of the PR and between 62600b5 and c2bded6.

📒 Files selected for processing (2)
  • crates/net/src/net_sync_manager.rs
  • crates/sync/src/sync.rs

Comment thread crates/net/src/net_sync_manager.rs

@ctrlc03 ctrlc03 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ctrlc03 ctrlc03 merged commit c188566 into main Mar 19, 2026
28 checks passed
@ctrlc03 ctrlc03 deleted the fix/e3-cache-population-during-sync branch March 19, 2026 14:00
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.

2 participants