Skip to content

feat!: sync mode and EventSystem [skip-line-limit]#1086

Merged
ryardley merged 75 commits into
mainfrom
ry/1050-storage
Dec 28, 2025
Merged

feat!: sync mode and EventSystem [skip-line-limit]#1086
ryardley merged 75 commits into
mainfrom
ry/1050-storage

Conversation

@ryardley

@ryardley ryardley commented Dec 7, 2025

Copy link
Copy Markdown
Contributor

Part of #1050

This sets up the EventSystem which logs events so they can be fetched and synced.

It stores them in a file:
./.enclave/data/log

It also creates a "sequence index" that is stored as a separate tree in:
./.enclave/data/db

This is preparation for the last couple of PRs in this task:

  • fetching events from external libp2p nodes
  • sync on startup

The following shows the event sequence the EventSystem makes:

sequenceDiagram
  participant B as BusHandle
  participant S as Sequencer(Actor)
  participant ES as EventStore (Actor)
  participant H as SequenceIndex
  participant C as EventLog
  participant SL as SledDb
  participant D as SledStore(Actor)
  participant BI as WriteBuffer(Actor)
  participant A as DataStore
  participant EB as EventBus

  A -->> BI:
  A -->> BI: 
  A -->> BI: 
  B ->> S: publish(event)
  S ->> ES: persist
  ES ->> C: persist
  C --) ES: ok(seq)
  ES ->> H: insert(hlc, seq)
  H --) ES: ok
  ES --) S: ok(seq)
  S ->> BI: CommitSnapshot(seq)
  BI ->> D: batch commit with seq num
  BI -->> D: 
  BI -->> D: 
  BI -->> D: 
  D ->> SL: commit transaction
  BI --) S: SequenceCommitted(seq)
  S ->> EB: EnclaveEvent<Sequenced>
Loading

This lists the things this PR does.

  • Created an EventSystem to act as an idempotent injector / factory for the event system: sequencer, eventstore, bus handle, write buffer, datastore.
  • Move EventBusFactory singleton to ciphernode-builder as it is is more appropriate and enables more ergonomic dependency resollution to separate factories from crates being created
  • Added log_file to app config default is ./.enclave/data/log
  • Node id is derived from name which should be unique.
  • Added EventSystem to CiphernodeBuilder
  • SledDb holds Tree instead of Db
  • impl KeySeeker for SledDb seek_after(target:&[u8]) -> V.
  • SequenceIndex responds to SeekAfter(target: &[u8]) for getting key close to but just after the target.
  • SequenceIndex responds to Insert the same as SledStore
  • InMemSequenceIndex responds to the same events as SledSequenceIndex in the same way that InMem does SledStore
  • EventLog wraps commitlog
  • EventStore holds SequenceIndex
  • EventStore holds EventLog
  • Datastore sends to WriteBuffer
  • InMem and SledStore both support InsertBatch event that uses transactions in the case of SledStore
  • Refactored CiphernodeSelector to use persistable snapshot to hold its own E3Meta cache.
  • Extracted sled caches and connection management to sled_utils file
  • Moved data events out of datastore to their own file.
  • Added a simple colorization library in e3-utils for easier identification of events in the logs
  • Remove the cache entry for expired E3s.
  • Fixed net test failing because solc was not installed in the Docker image

Notice an issue when HLC is too old we should refuse as a security measure. This has NOT been completed as part of this as this can be done at the net level.

next phase will involve fetching events part of which has already been completed:

sequenceDiagram
  participant N as Net
  participant ES as EventStore
  participant H as SequenceIndex (SledDb)
  participant C as EventLog

  N ->> ES: GetEventsAfter(ts)
  ES ->> H: SeekAfter(ts)
  H --) ES: seq
  ES ->> C: read(seq)
  C --) ES: Vec<log>
  ES --) N: Vec<EnclaveEvent>
Loading

Summary by CodeRabbit

  • New Features

    • Configurable EventSystem (in-memory or persisted) with sequencing, event store, replay, and batched commit buffer.
    • New storage backends and in-process sequence/index implementations; message types for batched key/value operations.
    • Bus enhancements: timestamp access, conditional piping, and colorized event display.
    • Config exposes log file path override.
  • Refactor

    • Builder/startup now accepts a config name and exposes datastore/repositories and bus from the built node.
    • Tests/helpers migrated to EventSystem-based setups for isolation and consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 7, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Introduce an EventSystem abstraction (in‑memory or persisted), rewire builder/startup to use it, add event-store/index traits and actors, move KV messages to an event-driven WriteBuffer, add sled/commitlog backends, and migrate tests/helpers to EventSystem wiring.

Changes

Cohort / File(s) Summary
Ciphernode builder & EventSystem
crates/ciphernode-builder/src/ciphernode_builder.rs, crates/ciphernode-builder/src/event_system.rs, crates/ciphernode-builder/src/eventbus_factory.rs, crates/ciphernode-builder/src/lib.rs, crates/ciphernode-builder/Cargo.toml
Add EventSystem (InMem/Persisted) with lazy wiring; extend CiphernodeBuilder (name, in_mem_store, event_system); new APIs .with_in_mem_datastore, .with_persistence; change get_enclave_bus_handle sig to accept config and return Result.
Event traits, store & sequencer
crates/events/src/traits.rs, crates/events/src/events.rs, crates/events/src/eventstore.rs, crates/events/src/sequencer.rs, crates/events/src/bus_handle.rs, crates/events/src/hlc.rs, crates/events/src/lib.rs, crates/events/Cargo.toml
Add SequenceIndex/EventLog traits and event messages; implement EventStore actor; refactor Sequencer to use EventStore + WriteBuffer; extend BusHandle (ts, pipe_to, BusHandlePipe); make Hlc clonable/PartialEq; adjust re-exports and tests.
Data layer: messages, buffer, stores
crates/data/src/events.rs, crates/data/src/write_buffer.rs, crates/data/src/data_store.rs, crates/data/src/in_mem.rs
Move KV messages into events.rs (Insert/InsertBatch/Get/Remove/InsertSync); add WriteBuffer actor (buffering, ForwardTo, CommitSnapshot flush -> InsertBatch); add DataStore::from_sled_store/from_in_mem constructors; add InsertBatch handling in InMemStore.
In-memory event implementations
crates/data/src/in_mem_event_log.rs, crates/data/src/in_mem_sequence_index.rs
Add InMemEventLog and InMemSequenceIndex implementing EventLog/SequenceIndex with tests.
Persistent storage & sled utilities
crates/data/src/sled_utils.rs, crates/data/src/sled_db.rs, crates/data/src/sled_sequence_index.rs, crates/data/src/sled_store.rs, crates/data/Cargo.toml
Add sled utilities (process-wide cache), SledDb wrapper and SledSequenceIndex; refactor SledStore to use SledDb, add InsertBatch handler; add commitlog and e3-utils workspace deps.
CommitLog event log & keying
crates/data/src/commit_log_event_log.rs, crates/data/src/into_key.rs
Add CommitLog-backed EventLog implementation and IntoKey for u128.
Config & paths
crates/config/src/app_config.rs, crates/config/src/paths_engine.rs, crates/config/src/store_keys.rs
Add log_file to NodeDefinition/AppConfig; extend PathsEngine to accept/resolve log_file overrides and DEFAULT_LOG_NAME; add StoreKeys::ciphernode_selector().
Sortition / ciphernode selector
crates/sortition/src/ciphernode_selector.rs, crates/sortition/src/repo.rs, crates/sortition/Cargo.toml
Replace datastore repository usage with a Persistable<HashMap<E3id,E3Meta>> cache; add CiphernodeSelectorFactory trait and accessor; update handlers to use cache and emit CiphernodeSelected from cached metadata.
Entrypoint / startup changes
crates/entrypoint/src/helpers/datastore.rs, crates/entrypoint/src/start/aggregator_start.rs, crates/entrypoint/src/start/start.rs
Call get_enclave_bus_handle(config)?; pass config.name() to CiphernodeBuilder::new; replace .with_datastore with .with_persistence/.with_in_mem_datastore; build returns node exposing store() and bus.
Tests & helpers migrated to EventSystem
crates/test-helpers/src/*, crates/tests/tests/*, crates/evm/tests/*, crates/net/src/document_publisher.rs, crates/tests/Cargo.toml, crates/evm/Cargo.toml
Migrate tests/helpers from direct EventBus usage to EventSystem; adjust helper return types and test wiring to use EventSystem handles and propagate handle() errors.
Network & docker infra
crates/net/tests/Dockerfile, crates/net/tests/docker-compose.yaml, crates/net/tests/run.sh, crates/net/Cargo.toml
Dockerfile adds solc/system packages and build bootstrap; docker-compose uses a common image anchor; run.sh tags images with git SHA; add e3-ciphernode-builder dependency.
Misc / format & small tweaks
crates/utils/src/formatters.rs, crates/events/src/enclave_event/mod.rs, crates/keyshare/src/threshold_keyshare.rs, crates/request/src/router.rs, crates/net/src/events.rs, crates/net/src/net_event_translator.rs
Add Color enum and colorize(); colorize EnclaveEvent Display; minor import/log tweaks and one added info log in threshold_keyshare; small import cleanup in net modules.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant App
    participant CB as CiphernodeBuilder
    participant ES as EventSystem
    participant Bus as EventBus
    participant Seq as Sequencer
    participant EStore as EventStore
    participant WB as WriteBuffer
    participant Store as DataStore

    App->>CB: CiphernodeBuilder::new(name, rng, cipher)
    CB->>ES: select backend (InMem | Persisted)
    CB->>ES: with_fresh_bus / with_event_bus
    CB->>App: build() -> node { bus, store, ... }

    App->>Bus: publish EnclaveEvent(Unsequenced)
    Bus->>Seq: deliver Unsequenced event
    Seq->>EStore: StoreEventRequested(event, reply_to=ctx.address())
    EStore->>EStore: append -> seq
    EStore->>Seq: EventStored(sequenced_event)
    Seq->>WB: CommitSnapshot(seq)
    WB->>Store: InsertBatch (batched KV writes)
    Seq->>Bus: publish EnclaveEvent(Sequenced)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

ciphernode, technical debt

Suggested reviewers

  • hmzakhalid

"A rabbit hops with code in paw,
I wire buses, stores, and more—hurrah! 🐇
Events flow, logs persist, tests run bright,
I nibble bugs away through the night.
Build and hop — the system's right!"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 'feat!: sync mode and EventSystem' accurately reflects the main feature additions—EventSystem infrastructure and preparation for sync mode—making it a strong, specific summary of the primary changes in this large changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ry/1050-storage

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c910511 and 956916a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • crates/ciphernode-builder/Cargo.toml
  • crates/ciphernode-builder/src/ciphernode_builder.rs
  • crates/events/Cargo.toml
  • crates/events/src/enclave_event/mod.rs
  • crates/keyshare/src/threshold_keyshare.rs
  • crates/net/src/document_publisher.rs
  • crates/tests/tests/integration.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • crates/events/src/enclave_event/mod.rs
  • crates/ciphernode-builder/Cargo.toml
  • crates/events/Cargo.toml
  • crates/keyshare/src/threshold_keyshare.rs
🧰 Additional context used
🧠 Learnings (18)
📓 Common learnings
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:21-29
Timestamp: 2025-12-17T05:58:25.984Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), if log.append succeeds but index.insert fails in handle_store_event_requested, the event is persisted in the log but not indexed. This is intentional design: such events are ignored during sync operations, as the index is the source of truth for timestamp-based event retrieval.
📚 Learning: 2024-10-08T19:45:18.209Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 107
File: packages/ciphernode/sortition/src/distance.rs:1-1
Timestamp: 2024-10-08T19:45:18.209Z
Learning: In `packages/ciphernode/core/src/events.rs`, the import statements use the correct and updated `alloy::primitives` module.

Applied to files:

  • crates/tests/tests/integration.rs
  • crates/ciphernode-builder/src/ciphernode_builder.rs
  • crates/net/src/document_publisher.rs
📚 Learning: 2024-10-10T23:24:43.341Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 143
File: packages/ciphernode/sortition/src/sortition.rs:4-9
Timestamp: 2024-10-10T23:24:43.341Z
Learning: In the `Sortition` module (`packages/ciphernode/sortition/src/sortition.rs`), errors are sent to the event bus using `self.bus.err`, which handles logging and printing. Therefore, explicit use of the `tracing` crate for logging errors may not be necessary in this context.

Applied to files:

  • crates/tests/tests/integration.rs
  • crates/net/src/document_publisher.rs
📚 Learning: 2025-04-30T06:25:14.721Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 372
File: packages/ciphernode/events/src/eventbus.rs:15-15
Timestamp: 2025-04-30T06:25:14.721Z
Learning: EnclaveEvent implements Display in packages/ciphernode/events/src/enclave_event/mod.rs, which satisfies the Event trait requirement. Static analysis tools may incorrectly flag implementations as missing when they do exist.

Applied to files:

  • crates/tests/tests/integration.rs
  • crates/ciphernode-builder/src/ciphernode_builder.rs
  • crates/net/src/document_publisher.rs
📚 Learning: 2025-10-27T15:37:59.138Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 904
File: crates/net/src/bin/p2p_test.rs:22-45
Timestamp: 2025-10-27T15:37:59.138Z
Learning: In test files (especially integration test binaries like p2p_test.rs), suggesting correlation ID filtering for DHT events may be unnecessarily complex since test environments are typically more controlled and false positives are less of a concern.

Applied to files:

  • crates/tests/tests/integration.rs
  • crates/net/src/document_publisher.rs
📚 Learning: 2024-10-22T03:39:29.448Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/evm/src/enclave_sol_reader.rs:87-89
Timestamp: 2024-10-22T03:39:29.448Z
Learning: In the `ciphernode` project, specifically in `packages/ciphernode/evm/src/enclave_sol_reader.rs`, the method `EnclaveSolReader::attach` should be retained even if it directly calls `EvmEventReader::attach` without additional processing. Avoid suggesting its removal in future reviews.

Applied to files:

  • crates/tests/tests/integration.rs
  • crates/ciphernode-builder/src/ciphernode_builder.rs
  • crates/net/src/document_publisher.rs
📚 Learning: 2024-10-16T09:52:53.807Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/data/src/data_store.rs:74-75
Timestamp: 2024-10-16T09:52:53.807Z
Learning: In this project, the actor model handles potential errors internally, so methods like `checkpoint` in the `Checkpoint` trait do not need to explicitly handle or propagate errors.

Applied to files:

  • crates/tests/tests/integration.rs
📚 Learning: 2024-10-28T12:04:26.578Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/enclave_node/src/ciphernode.rs:26-28
Timestamp: 2024-10-28T12:04:26.578Z
Learning: In the `setup_ciphernode` function in `packages/ciphernode/enclave_node/src/ciphernode.rs`, panicking on errors during setup is acceptable.

Applied to files:

  • crates/tests/tests/integration.rs
  • crates/ciphernode-builder/src/ciphernode_builder.rs
  • crates/net/src/document_publisher.rs
📚 Learning: 2024-10-03T23:02:41.732Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 133
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:137-139
Timestamp: 2024-10-03T23:02:41.732Z
Learning: In `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs`, using the same RNG instance `rng_test` for generating multiple key shares without advancing its state is acceptable.

Applied to files:

  • crates/tests/tests/integration.rs
📚 Learning: 2024-11-25T09:56:11.195Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 184
File: packages/ciphernode/net/src/network_relay.rs:0-0
Timestamp: 2024-11-25T09:56:11.195Z
Learning: In `NetworkPeer::new` in `packages/ciphernode/net/src/network_peer.rs`, peers are converted to multiaddrs, and validation of the address format occurs during this conversion. Duplicate addresses are managed as connections are deduplicated.

Applied to files:

  • crates/tests/tests/integration.rs
  • crates/net/src/document_publisher.rs
📚 Learning: 2024-11-05T06:49:46.285Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/enclave_node/src/datastore.rs:14-16
Timestamp: 2024-11-05T06:49:46.285Z
Learning: In `packages/ciphernode/enclave_node/src/datastore.rs`, for internal functions like `get_in_mem_store`, adding extensive documentation and error handling may not be necessary if they are not client-facing.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-11-05T06:51:46.701Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/evm/src/event_reader.rs:270-286
Timestamp: 2024-11-05T06:51:46.701Z
Learning: In `packages/ciphernode/evm/src/event_reader.rs`, the `state.ids` HashSet is intended to grow indefinitely to store all processed event IDs for deduplication purposes until an alternative like a bloom filter is implemented.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-16T09:51:10.038Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/router/src/committee_meta.rs:43-43
Timestamp: 2024-10-16T09:51:10.038Z
Learning: In `packages/ciphernode/router/src/committee_meta.rs`, avoid suggesting making the `on_event` method in `CommitteMetaFeature` asynchronous or adding error handling for the `write` operation to the data store.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
  • crates/net/src/document_publisher.rs
📚 Learning: 2025-12-17T05:58:25.984Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:21-29
Timestamp: 2025-12-17T05:58:25.984Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), if log.append succeeds but index.insert fails in handle_store_event_requested, the event is persisted in the log but not indexed. This is intentional design: such events are ignored during sync operations, as the index is the source of truth for timestamp-based event retrieval.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-08T07:15:06.690Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 139
File: packages/ciphernode/evm/src/ciphernode_registry_sol.rs:133-143
Timestamp: 2024-10-08T07:15:06.690Z
Learning: In `packages/ciphernode/evm/src/ciphernode_registry_sol.rs`, the function `helpers::stream_from_evm` in Rust returns `()`, not a `Result`, so error handling with `if let Err(e) = ...` is not applicable.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-11-05T06:48:58.177Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/config/src/app_config.rs:13-21
Timestamp: 2024-11-05T06:48:58.177Z
Learning: In the `packages/ciphernode/config/src/app_config.rs` file, for the `Contract` enum, the team prefers to use `String` type for `address` fields, relying on parsing to handle validation, instead of using the `Address` type.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-29T00:05:52.278Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/config/src/app_config.rs:133-144
Timestamp: 2024-10-29T00:05:52.278Z
Learning: In the `load_config` function in `packages/ciphernode/config/src/app_config.rs`, Figment ensures correct types for the final configuration from defaults, reducing the need for additional validation after loading.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-23T02:03:02.008Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/keyshare/src/encryption.rs:45-45
Timestamp: 2024-10-23T02:03:02.008Z
Learning: In the `packages/ciphernode/keyshare/src/encryption.rs` file, the environment variable `CIPHERNODE_SECRET` is used for the encryption password. A secure secret management solution is not currently available, but may be considered in future iterations.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
🧬 Code graph analysis (3)
crates/tests/tests/integration.rs (3)
crates/ciphernode-builder/src/ciphernode_builder.rs (2)
  • new (105-129)
  • new (561-567)
crates/events/src/bus_handle.rs (2)
  • new (39-49)
  • new (317-319)
crates/events/src/eventbus.rs (2)
  • new (54-60)
  • new (154-159)
crates/ciphernode-builder/src/ciphernode_builder.rs (3)
crates/sortition/src/ciphernode_selector.rs (2)
  • new (35-47)
  • attach (49-64)
crates/ciphernode-builder/src/event_system.rs (4)
  • store (241-263)
  • persisted (127-143)
  • in_mem_from_store (110-124)
  • in_mem (93-107)
crates/request/src/context.rs (1)
  • repositories (136-138)
crates/net/src/document_publisher.rs (2)
crates/ciphernode-builder/src/event_system.rs (1)
  • new (88-90)
crates/ciphernode-builder/src/ciphernode.rs (2)
  • bus (37-39)
  • history (41-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: build_ciphernode_image
  • GitHub Check: build_crisp_sdk
  • GitHub Check: build_sdk
  • GitHub Check: integration_prebuild
  • GitHub Check: test_net
  • GitHub Check: build_enclave_cli
  • GitHub Check: rust_integration
  • GitHub Check: rust_unit
🔇 Additional comments (6)
crates/net/src/document_publisher.rs (1)

556-602: LGTM! Clean test infrastructure migration.

The EventSystem-based test setup is well-implemented:

  • Proper error propagation via Result type
  • Consistent EventSystem::new("test").with_fresh_bus() pattern for test isolation
  • All test callsites updated to use ? operator

The migration preserves test behavior while aligning with the new persistence-ready architecture.

Also applies to: 607-607, 679-679, 743-743, 791-791

crates/tests/tests/integration.rs (1)

9-9: LGTM! Integration test properly updated.

The changes correctly integrate EventSystem and the updated CiphernodeBuilder API:

  • EventSystem initialization follows the established pattern
  • CiphernodeBuilder constructor now receives the address as the node name (line 182, 198)
  • Test logging addition (line 89) aids debugging

The integration preserves test semantics while adopting the new persistence-capable infrastructure.

Also applies to: 89-89, 121-122, 182-198

crates/ciphernode-builder/src/ciphernode_builder.rs (4)

42-46: Good design: EventSystemType enum and field additions.

The EventSystemType enum cleanly separates persisted and in-memory modes:

  • Persisted variant holds log and KV paths
  • InMem variant requires no configuration
  • Non-public visibility is appropriate for this internal abstraction

The new fields (name, in_mem_store, event_system) support the flexible backend selection logic introduced in this PR.

Also applies to: 55-64


100-129: LGTM! Constructor and persistence configuration methods.

The updated constructor and new builder methods provide clear configuration:

  • new(name, rng, cipher) now requires a unique node name (line 105), supporting EventSystem's node_id derivation
  • with_in_mem_datastore() allows injecting a pre-populated store for testing scenarios
  • with_persistence() explicitly opts into persisted mode with specified paths

Default to in-memory mode (line 119) is appropriate for development and test environments.

Also applies to: 157-171


335-348: Explicit EventSystem instantiation with clear precedence.

The build logic correctly instantiates the appropriate EventSystem backend:

  1. Persisted mode takes priority if with_persistence() was called
  2. InMem with injected store if with_in_mem_datastore() was called
  3. Plain InMem as fallback

The precedence order is explicit and the logic is easy to follow. The EventSystem is correctly wired with the local bus before extracting the handle and store.


364-365: Correct: CiphernodeSelector now uses typed repository.

The updated call to CiphernodeSelector::attach now receives repositories.ciphernode_selector(), which provides a Repository<HashMap<E3id, E3Meta>> instead of a raw store reference. This aligns with the PR's goal of making CiphernodeSelector's E3Meta cache persistable.


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.

@vercel

vercel Bot commented Dec 7, 2025

Copy link
Copy Markdown

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

Project Deployment Review Updated (UTC)
crisp Ready Ready Preview, Comment Dec 27, 2025 11:06pm
enclave-docs Ready Ready Preview, Comment Dec 27, 2025 11:06pm

@ryardley

ryardley commented Dec 9, 2025

Copy link
Copy Markdown
Contributor Author

I have found this has a difficult construction dependency tree that needs to be calculated and constructed:

Persisted:

graph TD
    subgraph data
      SB[SnapshotBuffer]
      DS[DataStore]
      SS[SledStore]
      SSI[SledSequenceIndex]
      CLEL[CommitLogEventLog]
      DB[SledFactory]
    end
    subgraph events
      BH[BusHandle] --> EB[EventBus]
      BH --> SEQ[Sequencer]
      BH --> HLC[Hlc]
      ES[EventStore]
    end
    subgraph config
       P["./some/sled/path"]
      CP["./some/commit/log"]
    end
    SEQ --> EB
    SEQ --> ES
    SEQ --> SB
    DS --> SB
    SB --> SS
    ES --> SSI
    ES --> CLEL
    DS --> BH
    SS --> DB
    SSI --> DB
    DB --> P
    CLEL --> CP

Loading

In Mem

graph TD
    subgraph data
      SB[SnapshotBuffer]
      DS[DataStore]
      SS[InMemStore]
      SSI[InMemSequenceIndex]
      CLEL[InMemEventLog]
    end
    subgraph events
      BH[BusHandle] --> EB[EventBus]
      BH --> SEQ[Sequencer]
      BH --> HLC[Hlc]
      ES[EventStore]
    end
    SEQ --> EB
    SEQ --> ES
    SEQ --> SB
    DS --> SB
    SB --> SS
    ES --> SSI
    ES --> CLEL
    DS --> BH
Loading

The factories constructing this should be in ciphernode-builder which we could consider renaming factories

@ryardley

Copy link
Copy Markdown
Contributor Author

@coderabbitai generate docstrings

@coderabbitai

coderabbitai Bot commented Dec 17, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

@coderabbitai

coderabbitai Bot commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #1120

@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/ciphernode-builder/src/ciphernode_builder.rs (1)

335-365: Consider flattening nested conditionals for readability.

The nested if let ... else { if let ... else { ... } } pattern at lines 340-344 can be simplified to a more readable else if chain or match expression.

         let event_system =
             if let EventSystemType::Persisted { kv_path, log_path } = self.event_system.clone() {
                 EventSystem::persisted(&addr, log_path, kv_path).with_event_bus(local_bus)
+            } else if let Some(ref store) = self.in_mem_store {
+                EventSystem::in_mem_from_store(&addr, store).with_event_bus(local_bus)
             } else {
-                if let Some(ref store) = self.in_mem_store {
-                    EventSystem::in_mem_from_store(&addr, store).with_event_bus(local_bus)
-                } else {
-                    EventSystem::in_mem(&addr).with_event_bus(local_bus)
-                }
+                EventSystem::in_mem(&addr).with_event_bus(local_bus)
             };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f917621 and 1b37e3f.

📒 Files selected for processing (1)
  • crates/ciphernode-builder/src/ciphernode_builder.rs (8 hunks)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:21-29
Timestamp: 2025-12-17T05:58:15.450Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), if log.append succeeds but index.insert fails in handle_store_event_requested, the event is persisted in the log but not indexed. This is intentional design: such events are ignored during sync operations, as the index is the source of truth for timestamp-based event retrieval.
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/evm/src/event_reader.rs:270-286
Timestamp: 2024-11-05T06:51:46.701Z
Learning: In `packages/ciphernode/evm/src/event_reader.rs`, the `state.ids` HashSet is intended to grow indefinitely to store all processed event IDs for deduplication purposes until an alternative like a bloom filter is implemented.
📚 Learning: 2024-09-26T03:11:29.311Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 107
File: packages/ciphernode/sortition/src/distance.rs:1-1
Timestamp: 2024-09-26T03:11:29.311Z
Learning: In `packages/ciphernode/core/src/events.rs`, the import statements use the correct and updated `alloy::primitives` module.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-11-05T06:49:46.285Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/enclave_node/src/datastore.rs:14-16
Timestamp: 2024-11-05T06:49:46.285Z
Learning: In `packages/ciphernode/enclave_node/src/datastore.rs`, for internal functions like `get_in_mem_store`, adding extensive documentation and error handling may not be necessary if they are not client-facing.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-11-05T06:51:46.701Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/evm/src/event_reader.rs:270-286
Timestamp: 2024-11-05T06:51:46.701Z
Learning: In `packages/ciphernode/evm/src/event_reader.rs`, the `state.ids` HashSet is intended to grow indefinitely to store all processed event IDs for deduplication purposes until an alternative like a bloom filter is implemented.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2025-04-30T06:25:14.721Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 372
File: packages/ciphernode/events/src/eventbus.rs:15-15
Timestamp: 2025-04-30T06:25:14.721Z
Learning: EnclaveEvent implements Display in packages/ciphernode/events/src/enclave_event/mod.rs, which satisfies the Event trait requirement. Static analysis tools may incorrectly flag implementations as missing when they do exist.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-12T10:24:07.572Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 139
File: packages/ciphernode/evm/src/ciphernode_registry_sol.rs:133-143
Timestamp: 2024-10-12T10:24:07.572Z
Learning: In `packages/ciphernode/evm/src/ciphernode_registry_sol.rs`, the function `helpers::stream_from_evm` in Rust returns `()`, not a `Result`, so error handling with `if let Err(e) = ...` is not applicable.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-28T12:04:26.578Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/enclave_node/src/ciphernode.rs:26-28
Timestamp: 2024-10-28T12:04:26.578Z
Learning: In the `setup_ciphernode` function in `packages/ciphernode/enclave_node/src/ciphernode.rs`, panicking on errors during setup is acceptable.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-11-05T06:48:58.177Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/config/src/app_config.rs:13-21
Timestamp: 2024-11-05T06:48:58.177Z
Learning: In the `packages/ciphernode/config/src/app_config.rs` file, for the `Contract` enum, the team prefers to use `String` type for `address` fields, relying on parsing to handle validation, instead of using the `Address` type.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-29T00:05:52.278Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/config/src/app_config.rs:133-144
Timestamp: 2024-10-29T00:05:52.278Z
Learning: In the `load_config` function in `packages/ciphernode/config/src/app_config.rs`, Figment ensures correct types for the final configuration from defaults, reducing the need for additional validation after loading.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-23T02:03:02.008Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/keyshare/src/encryption.rs:45-45
Timestamp: 2024-10-23T02:03:02.008Z
Learning: In the `packages/ciphernode/keyshare/src/encryption.rs` file, the environment variable `CIPHERNODE_SECRET` is used for the encryption password. A secure secret management solution is not currently available, but may be considered in future iterations.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
📚 Learning: 2024-10-16T09:51:10.038Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/router/src/committee_meta.rs:43-43
Timestamp: 2024-10-16T09:51:10.038Z
Learning: In `packages/ciphernode/router/src/committee_meta.rs`, avoid suggesting making the `on_event` method in `CommitteMetaFeature` asynchronous or adding error handling for the `write` operation to the data store.

Applied to files:

  • crates/ciphernode-builder/src/ciphernode_builder.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: build_sdk
  • GitHub Check: build_crisp_sdk
  • GitHub Check: build_enclave_cli
  • GitHub Check: integration_prebuild
  • GitHub Check: rust_unit
  • GitHub Check: test_net
  • GitHub Check: build_ciphernode_image
  • GitHub Check: rust_integration
🔇 Additional comments (5)
crates/ciphernode-builder/src/ciphernode_builder.rs (5)

7-7: LGTM!

Import changes correctly support the new EventSystem integration and persistence configuration.

Also applies to: 18-19, 35-39


42-46: LGTM!

The EventSystemType enum cleanly encapsulates the deferred configuration choice between persisted and in-memory event systems.


54-77: LGTM!

Struct fields are well-organized. The addition of name, optional in_mem_store, and event_system configuration cleanly supports both in-memory and persisted modes.


99-129: LGTM!

Constructor signature change is a breaking change (consistent with feat! in PR title). The name parameter is well-documented and defaults sensibly to in-memory mode.


347-350: LGTM!

The EventSystem integration is well-wired: handle() and store() provide the bus and store respectively, which are then used consistently throughout the build process for router construction and the final CiphernodeHandle.

Also applies to: 470-470, 518-524

Comment thread crates/ciphernode-builder/src/ciphernode_builder.rs

@hmzakhalid hmzakhalid 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.

Thank a lot for this Rudi, left a few comments.

Comment thread crates/events/src/eventstore.rs Outdated
Comment thread crates/events/src/sequencer.rs
Comment thread crates/entrypoint/src/start/start.rs Outdated
Comment thread crates/entrypoint/src/start/aggregator_start.rs Outdated
Comment thread crates/events/src/eventstore.rs
Comment thread crates/data/src/write_buffer.rs
Comment thread crates/data/src/commit_log_event_log.rs

@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: 0

🧹 Nitpick comments (2)
crates/data/src/commit_log_event_log.rs (2)

20-23: Drive message size from config before production deployment.

The 32MB message_max_bytes limit is hardcoded and marked with a TODO. This should be configurable to handle different deployment scenarios and prevent issues with oversized events.


50-52: Log read errors for debugging.

Read errors from self.log.read() silently break the loop. Consider logging these errors to aid troubleshooting.

🔎 Proposed fix
-            let message_buf = match self.log.read(current_offset, ReadLimit::default()) {
-                Ok(msgs) => msgs,
-                Err(_) => break,
-            };
+            let message_buf = match self.log.read(current_offset, ReadLimit::default()) {
+                Ok(msgs) => msgs,
+                Err(e) => {
+                    error!("Error reading from log at offset {}: {:?}", current_offset, e);
+                    break;
+                }
+            };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b37e3f and 3dc7a0b.

📒 Files selected for processing (3)
  • Cargo.toml
  • crates/data/Cargo.toml
  • crates/data/src/commit_log_event_log.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/data/Cargo.toml
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:21-29
Timestamp: 2025-12-17T05:58:25.984Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), if log.append succeeds but index.insert fails in handle_store_event_requested, the event is persisted in the log but not indexed. This is intentional design: such events are ignored during sync operations, as the index is the source of truth for timestamp-based event retrieval.
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/evm/src/event_reader.rs:270-286
Timestamp: 2024-11-05T06:51:46.701Z
Learning: In `packages/ciphernode/evm/src/event_reader.rs`, the `state.ids` HashSet is intended to grow indefinitely to store all processed event IDs for deduplication purposes until an alternative like a bloom filter is implemented.
📚 Learning: 2024-10-22T02:36:01.448Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/data/Cargo.toml:0-0
Timestamp: 2024-10-22T02:36:01.448Z
Learning: In `packages/ciphernode/data/Cargo.toml`, `actix-rt` is only used in tests and should remain in `[dev-dependencies]`.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-12-17T05:58:25.984Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:21-29
Timestamp: 2025-12-17T05:58:25.984Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), if log.append succeeds but index.insert fails in handle_store_event_requested, the event is persisted in the log but not indexed. This is intentional design: such events are ignored during sync operations, as the index is the source of truth for timestamp-based event retrieval.

Applied to files:

  • crates/data/src/commit_log_event_log.rs
📚 Learning: 2025-04-30T06:25:14.721Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 372
File: packages/ciphernode/events/src/eventbus.rs:15-15
Timestamp: 2025-04-30T06:25:14.721Z
Learning: EnclaveEvent implements Display in packages/ciphernode/events/src/enclave_event/mod.rs, which satisfies the Event trait requirement. Static analysis tools may incorrectly flag implementations as missing when they do exist.

Applied to files:

  • crates/data/src/commit_log_event_log.rs
📚 Learning: 2025-12-17T05:55:15.023Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:52-70
Timestamp: 2025-12-17T05:55:15.023Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), error handling in handlers for StoreEventRequested and GetEventsAfter intentionally logs errors using tracing::error without sending error responses back to the sender. This is by design.

Applied to files:

  • crates/data/src/commit_log_event_log.rs
📚 Learning: 2024-11-05T03:56:22.254Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 170
File: packages/ciphernode/evm/tests/evm_reader.rs:63-63
Timestamp: 2024-11-05T03:56:22.254Z
Learning: In the Rust test function `test_logs` in `packages/ciphernode/evm/tests/evm_reader.rs`, a sleep duration of 1 millisecond is sufficient for reliable event processing, even in CI environments.

Applied to files:

  • crates/data/src/commit_log_event_log.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: rust_integration
  • GitHub Check: build_crisp_sdk
  • GitHub Check: integration_prebuild
  • GitHub Check: rust_unit
  • GitHub Check: build_sdk
  • GitHub Check: test_net
  • GitHub Check: build_ciphernode_image
  • GitHub Check: build_enclave_cli
🔇 Additional comments (6)
Cargo.toml (1)

118-118: No action required. Version 0.2.0 is the latest release of the commitlog crate and has no known security vulnerabilities.

crates/data/src/commit_log_event_log.rs (5)

28-36: LGTM!

The offset-to-sequence conversion (0-indexed to 1-indexed) is clearly documented and correctly implemented.


39-42: LGTM!

The serialization and append logic is straightforward and correct.


49-72: Infinite loop bug is resolved.

The previous concern about an infinite loop when deserialization fails has been addressed:

  • Line 64 always advances current_offset regardless of deserialization success
  • Line 69 breaks the loop when no messages are read

The test at lines 130-143 validates this fix by ensuring corrupted events don't cause hangs.


57-63: Deserialization error handling is intentional.

Corrupted events are logged and skipped rather than stopping iteration or returning errors. Based on learnings, this aligns with the EventStore design where the index is the source of truth and unindexed events are intentionally ignored during sync operations.


78-166: Excellent test coverage!

The test suite comprehensively covers:

  • Basic append/read operations
  • Reading from specific offsets
  • Handling of corrupted data without infinite loops
  • Empty log scenarios
  • Reading beyond available data

The corruption test (lines 130-143) specifically validates the infinite loop fix from the previous review.

@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: 0

🧹 Nitpick comments (1)
crates/events/src/eventstore.rs (1)

21-32: Consider adding explicit context for try_send failures.

Line 30's try_send failure propagates through ? and logs at line 60, but the error context may not clearly indicate whether the failure was from log.append, index.insert, or try_send. As discussed in past reviews, adding explicit logging or panic for try_send failures would aid debugging when the sequencer channel is full or closed.

🔎 Optional: Add explicit context for try_send failures
-        sender.try_send(EventStored(event.into_sequenced(seq)))?;
-        Ok(())
+        sender
+            .try_send(EventStored(event.into_sequenced(seq)))
+            .map_err(|e| anyhow::anyhow!("Failed to send EventStored to sequencer: {e}"))?;
+        Ok(())

Based on past review discussions.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3dc7a0b and 5400f03.

📒 Files selected for processing (1)
  • crates/events/src/eventstore.rs
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:21-29
Timestamp: 2025-12-17T05:58:25.984Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), if log.append succeeds but index.insert fails in handle_store_event_requested, the event is persisted in the log but not indexed. This is intentional design: such events are ignored during sync operations, as the index is the source of truth for timestamp-based event retrieval.
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/evm/src/event_reader.rs:270-286
Timestamp: 2024-11-05T06:51:46.701Z
Learning: In `packages/ciphernode/evm/src/event_reader.rs`, the `state.ids` HashSet is intended to grow indefinitely to store all processed event IDs for deduplication purposes until an alternative like a bloom filter is implemented.
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/router/src/committee_meta.rs:43-43
Timestamp: 2024-10-16T09:51:10.038Z
Learning: In `packages/ciphernode/router/src/committee_meta.rs`, avoid suggesting making the `on_event` method in `CommitteMetaFeature` asynchronous or adding error handling for the `write` operation to the data store.
📚 Learning: 2025-12-17T05:58:25.984Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:21-29
Timestamp: 2025-12-17T05:58:25.984Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), if log.append succeeds but index.insert fails in handle_store_event_requested, the event is persisted in the log but not indexed. This is intentional design: such events are ignored during sync operations, as the index is the source of truth for timestamp-based event retrieval.

Applied to files:

  • crates/events/src/eventstore.rs
📚 Learning: 2025-12-17T05:55:15.023Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 1086
File: crates/events/src/eventstore.rs:52-70
Timestamp: 2025-12-17T05:55:15.023Z
Learning: In the EventStore implementation (crates/events/src/eventstore.rs), error handling in handlers for StoreEventRequested and GetEventsAfter intentionally logs errors using tracing::error without sending error responses back to the sender. This is by design.

Applied to files:

  • crates/events/src/eventstore.rs
📚 Learning: 2024-10-16T09:51:10.038Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/router/src/committee_meta.rs:43-43
Timestamp: 2024-10-16T09:51:10.038Z
Learning: In `packages/ciphernode/router/src/committee_meta.rs`, avoid suggesting making the `on_event` method in `CommitteMetaFeature` asynchronous or adding error handling for the `write` operation to the data store.

Applied to files:

  • crates/events/src/eventstore.rs
📚 Learning: 2024-10-22T02:30:19.534Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/data/src/data_store.rs:0-0
Timestamp: 2024-10-22T02:30:19.534Z
Learning: In the `write` method of the `DataStore` struct in `data_store.rs`, errors during serialization are logged instead of returning a `Result`.

Applied to files:

  • crates/events/src/eventstore.rs
📚 Learning: 2024-10-10T23:24:43.341Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 143
File: packages/ciphernode/sortition/src/sortition.rs:4-9
Timestamp: 2024-10-10T23:24:43.341Z
Learning: In the `Sortition` module (`packages/ciphernode/sortition/src/sortition.rs`), errors are sent to the event bus using `self.bus.err`, which handles logging and printing. Therefore, explicit use of the `tracing` crate for logging errors may not be necessary in this context.

Applied to files:

  • crates/events/src/eventstore.rs
📚 Learning: 2024-11-05T06:49:46.285Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/enclave_node/src/datastore.rs:14-16
Timestamp: 2024-11-05T06:49:46.285Z
Learning: In `packages/ciphernode/enclave_node/src/datastore.rs`, for internal functions like `get_in_mem_store`, adding extensive documentation and error handling may not be necessary if they are not client-facing.

Applied to files:

  • crates/events/src/eventstore.rs
📚 Learning: 2024-10-28T12:00:09.010Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/enclave/src/commands/wallet/set.rs:17-23
Timestamp: 2024-10-28T12:00:09.010Z
Learning: In the `enclave` package of the `ciphernode` project, prefer using `println!` over logging macros like `error!` from the `tracing` crate for error output in CLI commands.

Applied to files:

  • crates/events/src/eventstore.rs
🧬 Code graph analysis (1)
crates/events/src/eventstore.rs (3)
crates/events/src/events.rs (6)
  • events (71-73)
  • seq (21-23)
  • new (17-19)
  • new (35-43)
  • new (55-60)
  • new (68-70)
crates/utils/src/actix.rs (1)
  • bail (12-14)
crates/events/src/bus_handle.rs (1)
  • ts (67-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: build_crisp_sdk
  • GitHub Check: build_sdk
  • GitHub Check: rust_unit
  • GitHub Check: test_net
  • GitHub Check: build_ciphernode_image
  • GitHub Check: build_e3_support_dev
  • GitHub Check: integration_prebuild
  • GitHub Check: rust_integration
  • GitHub Check: build_enclave_cli
🔇 Additional comments (2)
crates/events/src/eventstore.rs (2)

34-35: Verify intended behavior when seek returns None.

When index.seek(msg.ts) returns None, the code defaults to sequence 1, effectively replaying all events from the beginning. Is this the intended behavior? For example, if msg.ts is older than all indexed events or if the index is empty, should the response include all events, or should it return an empty result or error?

Based on unresolved question from past review.


55-73: LGTM: Error handling follows established pattern.

The handlers correctly delegate to the public methods and log errors without sending responses to callers, which is consistent with the established design pattern for this codebase.

Based on learnings.

@ryardley

Copy link
Copy Markdown
Contributor Author

Fixed up the minor things with this PR. Will look at it again tomorrrow.

hmzakhalid
hmzakhalid previously approved these changes Dec 25, 2025
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