Skip to content

Hardening#176

Merged
JesseAbram merged 21 commits into
developfrom
hardening
Jun 5, 2026
Merged

Hardening#176
JesseAbram merged 21 commits into
developfrom
hardening

Conversation

@JesseAbram

Copy link
Copy Markdown
Collaborator

No description provided.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 94982bc9-4dfe-406b-84a1-02ffeed4d95b

📥 Commits

Reviewing files that changed from the base of the PR and between f19574a and 513c7f2.

📒 Files selected for processing (11)
  • bin/orbis-node/src/constants.rs
  • bin/orbis-node/src/dkg/session_state.rs
  • bin/orbis-node/src/dkg/tests/dkg.rs
  • bin/orbis-node/src/pss/mod.rs
  • bin/orbis-node/src/pss/tests.rs
  • bin/orbis-node/src/ring_state.rs
  • bin/orbis-node/src/sign/coordinator/handlers.rs
  • bin/orbis-node/src/sign/coordinator/rounds/nonce.rs
  • bin/orbis-node/src/sign/response_state.rs
  • bin/orbis-node/src/sign/tests.rs
  • crates/crypto/src/decaf377/sign.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • bin/orbis-node/src/dkg/tests/dkg.rs
  • bin/orbis-node/src/dkg/session_state.rs
📜 Recent review details
⏰ 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). (2)
  • GitHub Check: lint
  • GitHub Check: build
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: crates/bulletin/src/sourcehub/mod.rs:12-14
Timestamp: 2026-05-11T14:28:55.018Z
Learning: In `crates/bulletin/src/sourcehub/mod.rs` (Rust), the `DEFAULT_THRESHOLD_SIGNATURE_SCHEME` constant references `crypto::THRESHOLD_SIGNATURE_SCHEME`. All builds of orbis-rs are expected to enable at least one crypto feature (bls12-381, decaf377, or a future equivalent), so this constant should NOT be feature-gated at the bulletin crate level. The feature enforcement is handled by the `crypto` crate itself. Avoid flagging missing cfg gates on this constant.
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 147
File: bin/orbis-node/src/store_secret/service.rs:0-0
Timestamp: 2026-04-29T16:47:26.051Z
Learning: In `bin/orbis-node/src/store_secret/service.rs`, the pre-store `verify_encryption` check (which previously passed ring key, effective key, and policy metadata into `validate_encrypted_document`) was intentionally removed as part of PR `#147` (closes issue `#139`). The rationale: running this verification before storing requires exposing ring key and policy metadata to the validation function, which leaks privacy. Since a caller could always store cryptographically junk data regardless of this check, removing it does not weaken the protocol's security invariants — it only improves privacy. Proof field validation (shared_point/challenge/response) is deferred to downstream consumers.
📚 Learning: 2026-04-29T16:47:26.051Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 147
File: bin/orbis-node/src/store_secret/service.rs:0-0
Timestamp: 2026-04-29T16:47:26.051Z
Learning: In `bin/orbis-node/src/store_secret/service.rs`, the pre-store `verify_encryption` check (which previously passed ring key, effective key, and policy metadata into `validate_encrypted_document`) was intentionally removed as part of PR `#147` (closes issue `#139`). The rationale: running this verification before storing requires exposing ring key and policy metadata to the validation function, which leaks privacy. Since a caller could always store cryptographically junk data regardless of this check, removing it does not weaken the protocol's security invariants — it only improves privacy. Proof field validation (shared_point/challenge/response) is deferred to downstream consumers.

Applied to files:

  • bin/orbis-node/src/pss/mod.rs
  • bin/orbis-node/src/pss/tests.rs
  • bin/orbis-node/src/ring_state.rs
  • bin/orbis-node/src/sign/response_state.rs
  • bin/orbis-node/src/sign/tests.rs
📚 Learning: 2026-04-28T14:49:17.416Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 142
File: bin/orbis-node/src/dkg/helpers.rs:126-145
Timestamp: 2026-04-28T14:49:17.416Z
Learning: In `bin/orbis-node/src/dkg/helpers.rs`, `load_reshare_ring_payload` intentionally prefers the local `RingIndex` bulletin_post_id over the wire-provided one for old-committee nodes. This is by design: local `RingIndex` and `RingShareBundle` are part of the validity boundary. An old-committee member with a stale or missing local post ID is considered unhealthy; falling back to the wire-supplied post ID would mask stale-state drift rather than surface it. Pure receivers (nodes not in the old committee, with no local index entry) are the only case where the wire `bulletin_post_id` is used as a fallback, which is explicitly allowed.

Applied to files:

  • bin/orbis-node/src/pss/mod.rs
  • bin/orbis-node/src/pss/tests.rs
  • bin/orbis-node/src/ring_state.rs
  • bin/orbis-node/src/sign/coordinator/handlers.rs
  • bin/orbis-node/src/sign/response_state.rs
  • bin/orbis-node/src/sign/tests.rs
📚 Learning: 2026-05-20T18:08:12.109Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 171
File: crates/bulletin/src/sourcehub/mod.rs:238-264
Timestamp: 2026-05-20T18:08:12.109Z
Learning: In `crates/bulletin/src/sourcehub/mod.rs`, the `block_number_nonce` field in `ring_finalized_canonical_hash` does NOT need to be manually incremented. The nonce is read directly from the on-chain bulletin post and is updated by a separate blockchain upon reshare finalization. When `ring_finalized_canonical_hash` is called for a subsequent reshare, the nonce is already current on-chain, so the local `finalized` ring struct should use `..ring` spread without modifying `block_number_nonce`.

Applied to files:

  • bin/orbis-node/src/pss/mod.rs
  • bin/orbis-node/src/sign/coordinator/rounds/nonce.rs
  • bin/orbis-node/src/ring_state.rs
  • bin/orbis-node/src/sign/coordinator/handlers.rs
  • bin/orbis-node/src/sign/response_state.rs
📚 Learning: 2026-04-30T20:31:37.077Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 148
File: bin/orbis-node/src/dkg/coordinator/phases.rs:689-695
Timestamp: 2026-04-30T20:31:37.077Z
Learning: In `bin/orbis-node/src/dkg/coordinator/phases.rs`, `wait_for_reshare_bulletin_finalized` intentionally gates PSS-claim release only on `next_peer_ids` and `new_threshold` being `None`. This is by design: an upcoming PR (related to PR `#148`) will make the threshold signature the trigger that clears those fields on the bulletin, so this poll condition will be sufficient once that change lands. Do not flag the absence of explicit signature-metadata verification in this function as a bug.

Applied to files:

  • bin/orbis-node/src/pss/mod.rs
  • bin/orbis-node/src/sign/coordinator/rounds/nonce.rs
  • bin/orbis-node/src/sign/coordinator/handlers.rs
  • bin/orbis-node/src/sign/response_state.rs
  • bin/orbis-node/src/sign/tests.rs
📚 Learning: 2026-05-11T14:42:47.309Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs:274-282
Timestamp: 2026-05-11T14:42:47.309Z
Learning: In `bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs`, `block_number_nonce` in `RingPayload` is intentionally passed through unchanged in the signed `RingReshareUpdateStatement`. SourceHub (see sourcenetwork/sourcehub#110) rotates `block_number_nonce` atomically server-side when applying the threshold-signature bulletin update (together with `new_peer_ids`/`new_threshold` → `peer_ids`/`threshold`). A replay of an old signature is benign by design: if the prior update failed, the nodes were already in the ready state awaiting the chain update, so re-submitting the same signature has no harmful effect.

Applied to files:

  • bin/orbis-node/src/pss/mod.rs
  • bin/orbis-node/src/pss/tests.rs
  • bin/orbis-node/src/sign/coordinator/rounds/nonce.rs
  • bin/orbis-node/src/ring_state.rs
  • bin/orbis-node/src/sign/coordinator/handlers.rs
  • bin/orbis-node/src/constants.rs
  • bin/orbis-node/src/sign/response_state.rs
  • bin/orbis-node/src/sign/tests.rs
📚 Learning: 2026-02-12T17:49:15.841Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 48
File: crates/crypto/src/helpers.rs:26-33
Timestamp: 2026-02-12T17:49:15.841Z
Learning: In the decaf377 module usage, calling Fr::rand() without importing UniformRand is valid: the method is available directly on the type. During reviews of Rust code in crates/crypto/src, prefer using Fr::rand() without a UniformRand import when possible, and only import UniformRand if a method requires the trait explicitly. This helps distinguish library-specific extension behavior (e.g., decaf377) from other crates (e.g., ark_bls12_381) where trait imports may be necessary.

Applied to files:

  • crates/crypto/src/decaf377/sign.rs
📚 Learning: 2026-03-03T15:27:38.961Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 87
File: bin/orbis-node/src/tests/mod.rs:3-3
Timestamp: 2026-03-03T15:27:38.961Z
Learning: In the orbis-rs repository, integration tests (including Docker-based tests in bin/orbis-node/src/tests/integration.rs) should run by default during `cargo test` without requiring a feature flag.

Applied to files:

  • bin/orbis-node/src/pss/tests.rs
  • bin/orbis-node/src/sign/tests.rs
📚 Learning: 2026-05-13T18:55:29.338Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 161
File: bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs:147-163
Timestamp: 2026-05-13T18:55:29.338Z
Learning: In `bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs`, the partial-broadcast / local-rollback split-brain scenario in `run_selector` was explicitly considered and accepted as a pragmatic trade-off. The refresh health check is a diagnostic layer on top of the actual key ceremony; the underlying key material is persisted independently. Adding 2PC or compensating rollback broadcasts would just shift the same class of partial-failure risk to the new coordination round, creating an infinite nesting problem. The design intentionally accepts potential transient inconsistency in the health-check staging state.

Applied to files:

  • bin/orbis-node/src/pss/tests.rs
📚 Learning: 2026-05-11T14:28:55.018Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: crates/bulletin/src/sourcehub/mod.rs:12-14
Timestamp: 2026-05-11T14:28:55.018Z
Learning: In `crates/bulletin/src/sourcehub/mod.rs` (Rust), the `DEFAULT_THRESHOLD_SIGNATURE_SCHEME` constant references `crypto::THRESHOLD_SIGNATURE_SCHEME`. All builds of orbis-rs are expected to enable at least one crypto feature (bls12-381, decaf377, or a future equivalent), so this constant should NOT be feature-gated at the bulletin crate level. The feature enforcement is handled by the `crypto` crate itself. Avoid flagging missing cfg gates on this constant.

Applied to files:

  • bin/orbis-node/src/constants.rs
  • bin/orbis-node/src/sign/response_state.rs
  • bin/orbis-node/src/sign/tests.rs
🔇 Additional comments (12)
bin/orbis-node/src/constants.rs (4)

18-24: LGTM!


97-103: LGTM!


150-156: LGTM!


184-203: LGTM!

bin/orbis-node/src/pss/mod.rs (1)

107-111: LGTM!

bin/orbis-node/src/pss/tests.rs (1)

116-148: LGTM!

bin/orbis-node/src/ring_state.rs (1)

80-84: LGTM!

Also applies to: 106-109, 176-219

bin/orbis-node/src/sign/coordinator/handlers.rs (1)

50-50: LGTM!

Also applies to: 58-58, 83-87, 189-191, 212-217, 233-237, 248-267, 406-413

bin/orbis-node/src/sign/coordinator/rounds/nonce.rs (1)

155-161: LGTM!

bin/orbis-node/src/sign/response_state.rs (1)

21-60: LGTM!

Also applies to: 70-70, 112-139, 211-276, 317-319, 572-649, 751-942

bin/orbis-node/src/sign/tests.rs (1)

17-18: LGTM!

Also applies to: 1551-1602

crates/crypto/src/decaf377/sign.rs (1)

118-124: LGTM!


📝 Walkthrough

Walkthrough

Widen session identifiers from u64 to u128 across DKG/crypto/messages/state/bench/tests; add router ingress limits, metrics, and gRPC per-connection tuning; tighten PRE local-share verification and JWT leeway; update workspace dependency declarations and docs.

Changes

Runtime, networking, docs, and metrics

Layer / File(s) Summary
Workspace dependency consolidation
Cargo.toml, bin/cli-tool/Cargo.toml, bin/orbis-node/Cargo.toml, crates/authn/Cargo.toml, crates/proto/Cargo.toml
Workspace-managed versions introduced for tonic, prost, tonic-prost*; reqwest feature flags adjusted.
Node constants, CLI args, and gRPC wiring
bin/orbis-node/src/constants.rs, bin/orbis-node/src/helpers/launch.rs, bin/orbis-node/src/main.rs
New constants for JWT leeway, DKG completed-session TTL, sign nonce TTL, P2P and gRPC ingress limits; CLI args and server builder apply gRPC concurrency/stream caps.
Router builder wiring
bin/orbis-node/src/helpers/create_routers.rs
apply_ingress_limits helper configures router builders with ingress limits before registering protocol handlers.
Ingress limits API & re-exports
crates/network/src/trait.rs, crates/network/src/lib.rs
RouterIngressLimits struct and RouterBuilder methods max_concurrent_streams and max_streams_per_peer_per_second added and exported.
Iroh router implementation and tests
crates/network/src/iroh/router.rs, crates/network/src/iroh/tests.rs
Fixed-window per-peer rate limiter and shared semaphore for concurrency; acceptance gates on rate and concurrency, emits p2p_ingress_dropped_total; unit and integration tests added.
Ingress-drop metrics
crates/network/src/metrics.rs
Prometheus counter p2p_ingress_dropped_total and record_ingress_dropped helper added.
Docs, compose, and dashboard updates
bin/orbis-node/README.md, README.md, crates/network/README.md, docker/docker-compose*.yml, docker/grafana/dashboards/orbis.json
Docs: ingress-limit enforcement points, secure secret provisioning guidance; dash adds “P2P Ingress Dropped” panel; compose files annotated for test-only secrets.

Session ID migration and crypto/message contracts

Layer / File(s) Summary
Crypto share serialization and DKG contracts
crates/crypto/src/trait.rs, crates/crypto/src/bls12_381/dkg.rs, crates/crypto/src/decaf377/dkg.rs
DistributedShare header and serialized layout updated for 16-byte u128 session IDs; Dkg::new and DKG node structs accept u128.
Protocol messages and signing statements
bin/orbis-node/src/dkg/messages.rs, bin/orbis-node/src/sign/messages.rs, bin/orbis-node/src/store_secret/service.rs
DkgMessage variants and signing statement types now carry session_id: u128; proof-based signing uses u128 IDs.
Session ID derivation helpers
bin/orbis-node/src/dkg/helpers.rs, bin/orbis-node/src/helpers/helpers.rs
Derivation helpers return u128 by consuming 16 SHA-256 bytes; session_id_string_to_u128 replaces the u64 helper.
SessionStateManager and session storage
bin/orbis-node/src/dkg/session_state.rs
All internal maps, channels, dedup keys, background workers, and public/session APIs migrated from u64 to u128; create/remove/expiration logic updated.
Coordinator handlers, phases, network, refresh/reshare
bin/orbis-node/src/dkg/coordinator/*, bin/orbis-node/src/dkg/service.rs, bin/orbis-node/src/dkg/coordinator/network.rs
Coordinator entry points, phase drivers, message handlers, and routing APIs accept and thread u128 session IDs through state and messages (includes tests updated).
Reshare, refresh, and ring bundle flows
bin/orbis-node/src/dkg/coordinator/reshare/*, bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs, bin/orbis-node/src/dkg/helpers.rs
Reshare/refresh helpers and retry request-id generation migrated to use u128 session IDs.
Benchmarks and test harnesses
crates/crypto/benches/*, crates/crypto/src/test_helpers/test_helper.rs, crates/crypto/src/dkg_tests.rs, crates/crypto/src/lifecycle_tests.rs
Bench and test-generator closures updated to accept u128; fixture generation now uses 16 random bytes.
Property and unit tests adjustments
crates/crypto/src/*/tests/*, bin/orbis-node/src/dkg/tests/*, bin/orbis-node/src/pre/tests.rs, bin/orbis-node/src/sign/tests.rs
Tests adjusted for u128 session literals/inputs, buffer-size offsets in deserialization property tests, and updated helper signatures (e.g., wait_for_dkg_completion).

Sign/nonce hardening, PRE verification, JWT change, and misc fixes

Layer / File(s) Summary
Sign coordinator and response-state
bin/orbis-node/src/sign/coordinator/handlers.rs, bin/orbis-node/src/sign/response_state.rs, bin/orbis-node/src/sign/coordinator/rounds/nonce.rs
Thread sender_peer_id into responder handlers; store_nonce now binds coordinator_peer_id and stores zeroizing bytes; consume_nonce_for_sign_request added; context validation moved to ConsumedNonce::into_bytes_for_context; cleanup/reclaim behavior improved; tests updated.
PRE local-share verification
bin/orbis-node/src/pre/coordinator/initiator.rs, bin/orbis-node/src/pre/tests.rs
Local reencryption share is explicitly verified via dealer.verify(...) before being counted; regression test ensures unverified local share is not counted.
JWT expiration check and tests
crates/authn/src/lib.rs, crates/authn/src/tests.rs, bin/orbis-node/src/constants.rs
exp check logic altered to use saturating_sub with the leeway; clock-skew constant reduced from 16min to 5min; unit test added for boundary rejection.
Misc storage and ring parsing hardening
bin/orbis-node/src/ring_state.rs, bin/orbis-node/src/pss/*
Safer fallible conversions in RingShareBundle deserialization and new tests; pss_all_rings explicit empty-index handling and corrupt-index test added.
Crypto safety
crates/crypto/src/decaf377/sign.rs
Drop impl added for FrostSigningState zeroizing secret nonce scalars.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • Lodek

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
bin/orbis-node/src/dkg/session_state.rs (1)

739-759: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Check for an existing session before enforcing MAX_DKG_SESSIONS.

When the map is full and this session_id already exists, this returns LimitReached instead of AlreadyExists. The contract above this method says callers may ignore AlreadyExists but must clear PSS claims on LimitReached, so the current order can tear down a live claim for an already-running session.

[suggested fix]

Patch
         let mut states = self.states.write().await;
 
+        // A duplicate create for an existing session should stay idempotent even
+        // when the manager is already at capacity.
+        if states.contains_key(&session_id) {
+            tracing::debug!(
+                session_id = session_id,
+                "DKG session already exists for session_id"
+            );
+            return CreateSessionOutcome::AlreadyExists;
+        }
+
         // Enforce maximum concurrent session limit to prevent resource exhaustion
         if states.len() >= MAX_DKG_SESSIONS {
             tracing::warn!(
                 session_id = session_id,
                 active_sessions = states.len(),
@@
             );
             return CreateSessionOutcome::LimitReached;
         }
-
-        // Check if session already exists to avoid overwriting existing state
-        if states.contains_key(&session_id) {
-            tracing::debug!(
-                session_id = session_id,
-                "DKG session already exists for session_id"
-            );
-            return CreateSessionOutcome::AlreadyExists;
-        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bin/orbis-node/src/dkg/session_state.rs` around lines 739 - 759, The current
code checks MAX_DKG_SESSIONS before verifying if the session_id already exists,
causing an existing session to be reported as LimitReached; change the ordering
in the create session path so you first check states.contains_key(&session_id)
and return CreateSessionOutcome::AlreadyExists if present, and only then enforce
the MAX_DKG_SESSIONS limit (using states.len() >= MAX_DKG_SESSIONS to return
CreateSessionOutcome::LimitReached); update the block around states, session_id,
MAX_DKG_SESSIONS, CreateSessionOutcome::AlreadyExists and
CreateSessionOutcome::LimitReached accordingly.
🧹 Nitpick comments (2)
bin/orbis-node/src/sign/messages.rs (1)

33-68: ⚡ Quick win

Add one > u64::MAX round-trip test for the signed statements.

These are canonical payloads that end up under signature, but the migration here is only exercised by type changes. A remaining narrow cast would stay invisible until a large live session_id hits reshare or refresh signing. One serialize/deserialize test using something like (u64::MAX as u128) + 1 for both statements would lock down the new wire contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bin/orbis-node/src/sign/messages.rs` around lines 33 - 68, Add a unit test
that round-trips a value larger than u64::MAX for the session_id to lock the
wire contract: construct a RingReshareUpdateStatement (and its
RingReshareUpdateContext if used) and a RefreshHealthCheckStatement with
session_id set to (u64::MAX as u128) + 1, serialize them with the same canonical
serializer used by the codebase (e.g., serde_json or bincode), then deserialize
and assert equality of the original and deserialized structs; place the test
alongside existing message tests and reference the types
RingReshareUpdateStatement, RingReshareUpdateContext, and
RefreshHealthCheckStatement so future narrow casts are caught.
bin/orbis-node/src/dkg/PROTOCOL_FLOW.md (1)

1-22: 💤 Low value

Consider documenting the session ID data type.

The protocol flow references session_id (line 21) but does not mention that it uses a 128-bit identifier. Since this PR migrates session IDs to u128 and affects serialization size, adding a brief note in the "Overview" or as a comment near line 21 would help readers understand the protocol's data model.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bin/orbis-node/src/dkg/PROTOCOL_FLOW.md` around lines 1 - 22, Add a short
note near the StartDkgRequest/session_id mention explaining that session_id is
now a 128-bit unsigned integer (u128) and that this increases its serialized
size; update the "Overview" or the comment next to `session_id` in the
`start_dkg` flow to state: session_id: u128 (128-bit identifier) and note any
implications for serialization/transport size so readers understand the data
model change introduced by the PR.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bin/orbis-node/src/helpers/launch.rs`:
- Around line 68-79: The two CLI args grpc_concurrency_limit_per_connection and
grpc_max_concurrent_streams currently accept 0; add clap value parsers with a
positive range to validate inputs and fail fast. For
grpc_concurrency_limit_per_connection use value_parser =
clap::value_parser!(usize).range(1..) and for grpc_max_concurrent_streams use
value_parser = clap::value_parser!(u32).range(1..), placing these attributes on
the respective struct fields so passing 0 will be rejected.

---

Outside diff comments:
In `@bin/orbis-node/src/dkg/session_state.rs`:
- Around line 739-759: The current code checks MAX_DKG_SESSIONS before verifying
if the session_id already exists, causing an existing session to be reported as
LimitReached; change the ordering in the create session path so you first check
states.contains_key(&session_id) and return CreateSessionOutcome::AlreadyExists
if present, and only then enforce the MAX_DKG_SESSIONS limit (using states.len()
>= MAX_DKG_SESSIONS to return CreateSessionOutcome::LimitReached); update the
block around states, session_id, MAX_DKG_SESSIONS,
CreateSessionOutcome::AlreadyExists and CreateSessionOutcome::LimitReached
accordingly.

---

Nitpick comments:
In `@bin/orbis-node/src/dkg/PROTOCOL_FLOW.md`:
- Around line 1-22: Add a short note near the StartDkgRequest/session_id mention
explaining that session_id is now a 128-bit unsigned integer (u128) and that
this increases its serialized size; update the "Overview" or the comment next to
`session_id` in the `start_dkg` flow to state: session_id: u128 (128-bit
identifier) and note any implications for serialization/transport size so
readers understand the data model change introduced by the PR.

In `@bin/orbis-node/src/sign/messages.rs`:
- Around line 33-68: Add a unit test that round-trips a value larger than
u64::MAX for the session_id to lock the wire contract: construct a
RingReshareUpdateStatement (and its RingReshareUpdateContext if used) and a
RefreshHealthCheckStatement with session_id set to (u64::MAX as u128) + 1,
serialize them with the same canonical serializer used by the codebase (e.g.,
serde_json or bincode), then deserialize and assert equality of the original and
deserialized structs; place the test alongside existing message tests and
reference the types RingReshareUpdateStatement, RingReshareUpdateContext, and
RefreshHealthCheckStatement so future narrow casts are caught.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4e0ce70b-54f3-4bae-a3d5-65f1285cc3e4

📥 Commits

Reviewing files that changed from the base of the PR and between ce090d2 and 21dcd28.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (67)
  • Cargo.toml
  • README.md
  • bin/cli-tool/Cargo.toml
  • bin/orbis-node/Cargo.toml
  • bin/orbis-node/README.md
  • bin/orbis-node/src/constants.rs
  • bin/orbis-node/src/dkg/PROTOCOL_FLOW.md
  • bin/orbis-node/src/dkg/coordinator/message_handlers/commitment.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/session_init.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/share.rs
  • bin/orbis-node/src/dkg/coordinator/mod.rs
  • bin/orbis-node/src/dkg/coordinator/network.rs
  • bin/orbis-node/src/dkg/coordinator/phases/mod.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase1.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase2.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase4.rs
  • bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/cleanup.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/selection.rs
  • bin/orbis-node/src/dkg/coordinator/ring_storage.rs
  • bin/orbis-node/src/dkg/helpers.rs
  • bin/orbis-node/src/dkg/messages.rs
  • bin/orbis-node/src/dkg/service.rs
  • bin/orbis-node/src/dkg/session_state.rs
  • bin/orbis-node/src/dkg/tests/dkg.rs
  • bin/orbis-node/src/dkg/tests/refresh.rs
  • bin/orbis-node/src/dkg/tests/reshare.rs
  • bin/orbis-node/src/helpers/create_routers.rs
  • bin/orbis-node/src/helpers/helpers.rs
  • bin/orbis-node/src/helpers/launch.rs
  • bin/orbis-node/src/main.rs
  • bin/orbis-node/src/pre/tests.rs
  • bin/orbis-node/src/sign/messages.rs
  • bin/orbis-node/src/sign/tests.rs
  • bin/orbis-node/src/store_secret/service.rs
  • crates/authn/Cargo.toml
  • crates/crypto/benches/bls12_381/dkg.rs
  • crates/crypto/benches/bls12_381/pre.rs
  • crates/crypto/benches/bls12_381/sign.rs
  • crates/crypto/benches/decaf377/dkg.rs
  • crates/crypto/benches/decaf377/pre.rs
  • crates/crypto/benches/decaf377/sign.rs
  • crates/crypto/benches/dkg_benchmarks.rs
  • crates/crypto/src/bls12_381/dkg.rs
  • crates/crypto/src/bls12_381/tests/deserialization_prop_tests.rs
  • crates/crypto/src/bls12_381/tests/pre_tests.rs
  • crates/crypto/src/bls12_381/tests/sign_tests.rs
  • crates/crypto/src/decaf377/dkg.rs
  • crates/crypto/src/decaf377/tests/deserialization_prop_tests.rs
  • crates/crypto/src/decaf377/tests/pre_tests.rs
  • crates/crypto/src/decaf377/tests/sign_tests.rs
  • crates/crypto/src/dkg_tests.rs
  • crates/crypto/src/lifecycle_tests.rs
  • crates/crypto/src/test_helpers/test_helper.rs
  • crates/crypto/src/trait.rs
  • crates/network/README.md
  • crates/network/src/iroh/router.rs
  • crates/network/src/iroh/tests.rs
  • crates/network/src/lib.rs
  • crates/network/src/metrics.rs
  • crates/network/src/trait.rs
  • crates/proto/Cargo.toml
  • docker/docker-compose-integration-test.yml
  • docker/docker-compose-metrics-network-test.yml
  • docker/docker-compose.3-node.yml
  • docker/grafana/dashboards/orbis.json
📜 Review details
⏰ 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). (1)
  • GitHub Check: build
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: crates/bulletin/src/sourcehub/mod.rs:12-14
Timestamp: 2026-05-11T14:28:55.018Z
Learning: In `crates/bulletin/src/sourcehub/mod.rs` (Rust), the `DEFAULT_THRESHOLD_SIGNATURE_SCHEME` constant references `crypto::THRESHOLD_SIGNATURE_SCHEME`. All builds of orbis-rs are expected to enable at least one crypto feature (bls12-381, decaf377, or a future equivalent), so this constant should NOT be feature-gated at the bulletin crate level. The feature enforcement is handled by the `crypto` crate itself. Avoid flagging missing cfg gates on this constant.
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 147
File: bin/orbis-node/src/store_secret/service.rs:0-0
Timestamp: 2026-04-29T16:47:26.051Z
Learning: In `bin/orbis-node/src/store_secret/service.rs`, the pre-store `verify_encryption` check (which previously passed ring key, effective key, and policy metadata into `validate_encrypted_document`) was intentionally removed as part of PR `#147` (closes issue `#139`). The rationale: running this verification before storing requires exposing ring key and policy metadata to the validation function, which leaks privacy. Since a caller could always store cryptographically junk data regardless of this check, removing it does not weaken the protocol's security invariants — it only improves privacy. Proof field validation (shared_point/challenge/response) is deferred to downstream consumers.
📚 Learning: 2026-05-13T18:55:29.338Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 161
File: bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs:147-163
Timestamp: 2026-05-13T18:55:29.338Z
Learning: In `bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs`, the partial-broadcast / local-rollback split-brain scenario in `run_selector` was explicitly considered and accepted as a pragmatic trade-off. The refresh health check is a diagnostic layer on top of the actual key ceremony; the underlying key material is persisted independently. Adding 2PC or compensating rollback broadcasts would just shift the same class of partial-failure risk to the new coordination round, creating an infinite nesting problem. The design intentionally accepts potential transient inconsistency in the health-check staging state.

Applied to files:

  • crates/crypto/src/bls12_381/tests/pre_tests.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase1.rs
  • bin/orbis-node/src/dkg/coordinator/network.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/selection.rs
  • bin/orbis-node/src/dkg/tests/refresh.rs
  • bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs
📚 Learning: 2026-02-12T17:49:15.841Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 48
File: crates/crypto/src/helpers.rs:26-33
Timestamp: 2026-02-12T17:49:15.841Z
Learning: In the decaf377 module usage, calling Fr::rand() without importing UniformRand is valid: the method is available directly on the type. During reviews of Rust code in crates/crypto/src, prefer using Fr::rand() without a UniformRand import when possible, and only import UniformRand if a method requires the trait explicitly. This helps distinguish library-specific extension behavior (e.g., decaf377) from other crates (e.g., ark_bls12_381) where trait imports may be necessary.

Applied to files:

  • crates/crypto/src/bls12_381/tests/pre_tests.rs
  • crates/crypto/src/dkg_tests.rs
  • crates/crypto/src/decaf377/tests/pre_tests.rs
  • crates/crypto/src/bls12_381/tests/sign_tests.rs
  • crates/crypto/src/lifecycle_tests.rs
  • crates/crypto/src/decaf377/tests/sign_tests.rs
  • crates/crypto/src/decaf377/dkg.rs
  • crates/crypto/src/decaf377/tests/deserialization_prop_tests.rs
  • crates/crypto/src/bls12_381/tests/deserialization_prop_tests.rs
  • crates/crypto/src/bls12_381/dkg.rs
  • crates/crypto/src/trait.rs
  • crates/crypto/src/test_helpers/test_helper.rs
📚 Learning: 2026-03-03T15:27:38.961Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 87
File: bin/orbis-node/src/tests/mod.rs:3-3
Timestamp: 2026-03-03T15:27:38.961Z
Learning: In the orbis-rs repository, integration tests (including Docker-based tests in bin/orbis-node/src/tests/integration.rs) should run by default during `cargo test` without requiring a feature flag.

Applied to files:

  • docker/docker-compose-integration-test.yml
  • docker/docker-compose-metrics-network-test.yml
  • bin/orbis-node/README.md
  • bin/orbis-node/Cargo.toml
📚 Learning: 2026-04-28T20:40:09.735Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 145
File: .github/workflows/rust.yml:40-40
Timestamp: 2026-04-28T20:40:09.735Z
Learning: In the sourcenetwork/orbis-rs repository, the SourceHub Docker image is intentionally pulled using the mutable `dev` tag (e.g., `ghcr.io/sourcenetwork/sourcehub:dev`) in CI workflows and docker-compose files. The maintainer (JesseAbram) prefers this over pinning to a specific SHA or release tag because it forces active tracking and manual updates of the upstream SourceHub image. Do not flag this as a reproducibility issue.

Applied to files:

  • docker/docker-compose-integration-test.yml
  • docker/docker-compose-metrics-network-test.yml
📚 Learning: 2026-04-30T20:31:37.077Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 148
File: bin/orbis-node/src/dkg/coordinator/phases.rs:689-695
Timestamp: 2026-04-30T20:31:37.077Z
Learning: In `bin/orbis-node/src/dkg/coordinator/phases.rs`, `wait_for_reshare_bulletin_finalized` intentionally gates PSS-claim release only on `next_peer_ids` and `new_threshold` being `None`. This is by design: an upcoming PR (related to PR `#148`) will make the threshold signature the trigger that clears those fields on the bulletin, so this poll condition will be sufficient once that change lands. Do not flag the absence of explicit signature-metadata verification in this function as a bug.

Applied to files:

  • bin/orbis-node/src/dkg/coordinator/phases/phase2.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase1.rs
  • bin/orbis-node/src/sign/tests.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase4.rs
  • crates/crypto/benches/bls12_381/sign.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/cleanup.rs
  • crates/crypto/src/bls12_381/tests/sign_tests.rs
  • bin/orbis-node/src/dkg/tests/reshare.rs
  • bin/orbis-node/src/sign/messages.rs
  • bin/orbis-node/src/pre/tests.rs
  • bin/orbis-node/src/dkg/PROTOCOL_FLOW.md
  • bin/orbis-node/src/dkg/coordinator/phases/mod.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/share.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs
  • bin/orbis-node/src/dkg/helpers.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/selection.rs
  • bin/orbis-node/src/dkg/coordinator/mod.rs
  • bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs
  • bin/orbis-node/src/dkg/tests/dkg.rs
  • bin/orbis-node/src/dkg/session_state.rs
📚 Learning: 2026-05-11T14:42:47.309Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs:274-282
Timestamp: 2026-05-11T14:42:47.309Z
Learning: In `bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs`, `block_number_nonce` in `RingPayload` is intentionally passed through unchanged in the signed `RingReshareUpdateStatement`. SourceHub (see sourcenetwork/sourcehub#110) rotates `block_number_nonce` atomically server-side when applying the threshold-signature bulletin update (together with `new_peer_ids`/`new_threshold` → `peer_ids`/`threshold`). A replay of an old signature is benign by design: if the prior update failed, the nodes were already in the ready state awaiting the chain update, so re-submitting the same signature has no harmful effect.

Applied to files:

  • bin/orbis-node/src/dkg/coordinator/phases/phase2.rs
  • bin/orbis-node/src/dkg/coordinator/ring_storage.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/commitment.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/session_init.rs
  • bin/orbis-node/src/store_secret/service.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase1.rs
  • bin/orbis-node/src/sign/tests.rs
  • bin/orbis-node/README.md
  • crates/crypto/src/decaf377/tests/pre_tests.rs
  • crates/crypto/benches/decaf377/pre.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase4.rs
  • bin/orbis-node/src/dkg/service.rs
  • crates/crypto/benches/bls12_381/sign.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/cleanup.rs
  • crates/crypto/src/bls12_381/tests/sign_tests.rs
  • crates/crypto/benches/decaf377/sign.rs
  • crates/crypto/benches/bls12_381/dkg.rs
  • bin/orbis-node/src/dkg/tests/reshare.rs
  • crates/crypto/src/lifecycle_tests.rs
  • bin/orbis-node/src/sign/messages.rs
  • crates/crypto/benches/bls12_381/pre.rs
  • crates/crypto/src/decaf377/tests/sign_tests.rs
  • crates/crypto/src/decaf377/dkg.rs
  • crates/crypto/benches/decaf377/dkg.rs
  • crates/crypto/benches/dkg_benchmarks.rs
  • bin/orbis-node/src/pre/tests.rs
  • bin/orbis-node/src/dkg/PROTOCOL_FLOW.md
  • crates/crypto/src/bls12_381/dkg.rs
  • bin/orbis-node/src/dkg/coordinator/network.rs
  • bin/orbis-node/src/dkg/coordinator/phases/mod.rs
  • bin/orbis-node/src/dkg/messages.rs
  • crates/crypto/src/trait.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/share.rs
  • bin/orbis-node/src/helpers/helpers.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs
  • bin/orbis-node/src/dkg/helpers.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/selection.rs
  • bin/orbis-node/src/dkg/coordinator/mod.rs
  • bin/orbis-node/src/dkg/tests/refresh.rs
  • bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs
  • bin/orbis-node/src/dkg/tests/dkg.rs
  • crates/crypto/src/test_helpers/test_helper.rs
  • bin/orbis-node/src/dkg/session_state.rs
📚 Learning: 2026-04-28T14:49:17.416Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 142
File: bin/orbis-node/src/dkg/helpers.rs:126-145
Timestamp: 2026-04-28T14:49:17.416Z
Learning: In `bin/orbis-node/src/dkg/helpers.rs`, `load_reshare_ring_payload` intentionally prefers the local `RingIndex` bulletin_post_id over the wire-provided one for old-committee nodes. This is by design: local `RingIndex` and `RingShareBundle` are part of the validity boundary. An old-committee member with a stale or missing local post ID is considered unhealthy; falling back to the wire-supplied post ID would mask stale-state drift rather than surface it. Pure receivers (nodes not in the old committee, with no local index entry) are the only case where the wire `bulletin_post_id` is used as a fallback, which is explicitly allowed.

Applied to files:

  • bin/orbis-node/src/dkg/coordinator/phases/phase2.rs
  • bin/orbis-node/src/dkg/coordinator/ring_storage.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/commitment.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/session_init.rs
  • bin/orbis-node/src/dkg/coordinator/phases/phase1.rs
  • crates/network/README.md
  • bin/orbis-node/src/sign/tests.rs
  • bin/orbis-node/README.md
  • bin/orbis-node/src/dkg/service.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/cleanup.rs
  • bin/orbis-node/src/dkg/tests/reshare.rs
  • bin/orbis-node/src/sign/messages.rs
  • bin/orbis-node/src/pre/tests.rs
  • bin/orbis-node/src/dkg/PROTOCOL_FLOW.md
  • bin/orbis-node/src/dkg/coordinator/network.rs
  • bin/orbis-node/src/dkg/coordinator/phases/mod.rs
  • bin/orbis-node/src/dkg/messages.rs
  • bin/orbis-node/src/dkg/coordinator/message_handlers/share.rs
  • bin/orbis-node/src/helpers/helpers.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs
  • bin/orbis-node/src/dkg/helpers.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/selection.rs
  • bin/orbis-node/src/dkg/coordinator/mod.rs
  • bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs
  • bin/orbis-node/src/dkg/tests/dkg.rs
  • crates/crypto/src/test_helpers/test_helper.rs
  • bin/orbis-node/src/dkg/session_state.rs
📚 Learning: 2026-04-29T16:47:26.051Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 147
File: bin/orbis-node/src/store_secret/service.rs:0-0
Timestamp: 2026-04-29T16:47:26.051Z
Learning: In `bin/orbis-node/src/store_secret/service.rs`, the pre-store `verify_encryption` check (which previously passed ring key, effective key, and policy metadata into `validate_encrypted_document`) was intentionally removed as part of PR `#147` (closes issue `#139`). The rationale: running this verification before storing requires exposing ring key and policy metadata to the validation function, which leaks privacy. Since a caller could always store cryptographically junk data regardless of this check, removing it does not weaken the protocol's security invariants — it only improves privacy. Proof field validation (shared_point/challenge/response) is deferred to downstream consumers.

Applied to files:

  • bin/orbis-node/src/store_secret/service.rs
  • bin/orbis-node/README.md
  • README.md
  • bin/orbis-node/src/dkg/tests/reshare.rs
  • bin/orbis-node/src/sign/messages.rs
  • bin/orbis-node/src/dkg/PROTOCOL_FLOW.md
  • bin/orbis-node/src/dkg/helpers.rs
  • bin/orbis-node/src/dkg/session_state.rs
📚 Learning: 2026-05-11T14:28:55.018Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: crates/bulletin/src/sourcehub/mod.rs:12-14
Timestamp: 2026-05-11T14:28:55.018Z
Learning: In `crates/bulletin/src/sourcehub/mod.rs` (Rust), the `DEFAULT_THRESHOLD_SIGNATURE_SCHEME` constant references `crypto::THRESHOLD_SIGNATURE_SCHEME`. All builds of orbis-rs are expected to enable at least one crypto feature (bls12-381, decaf377, or a future equivalent), so this constant should NOT be feature-gated at the bulletin crate level. The feature enforcement is handled by the `crypto` crate itself. Avoid flagging missing cfg gates on this constant.

Applied to files:

  • bin/orbis-node/README.md
  • crates/crypto/benches/bls12_381/sign.rs
  • crates/crypto/src/bls12_381/tests/sign_tests.rs
  • crates/crypto/benches/decaf377/sign.rs
  • crates/crypto/benches/bls12_381/pre.rs
  • crates/crypto/src/decaf377/tests/sign_tests.rs
  • bin/orbis-node/src/constants.rs
  • crates/crypto/benches/decaf377/dkg.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs
📚 Learning: 2026-05-14T20:15:59.261Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 162
File: bin/cli-tool/src/commands.rs:93-94
Timestamp: 2026-05-14T20:15:59.261Z
Learning: `bin/cli-tool` is a test CLI tool in the `sourcenetwork/orbis-rs` repository. Using `.expect()` (panics) instead of proper error propagation is intentional and acceptable throughout this crate, as it is not production code.

Applied to files:

  • bin/orbis-node/README.md
📚 Learning: 2026-05-20T18:08:12.109Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 171
File: crates/bulletin/src/sourcehub/mod.rs:238-264
Timestamp: 2026-05-20T18:08:12.109Z
Learning: In `crates/bulletin/src/sourcehub/mod.rs`, the `block_number_nonce` field in `ring_finalized_canonical_hash` does NOT need to be manually incremented. The nonce is read directly from the on-chain bulletin post and is updated by a separate blockchain upon reshare finalization. When `ring_finalized_canonical_hash` is called for a subsequent reshare, the nonce is already current on-chain, so the local `finalized` ring struct should use `..ring` spread without modifying `block_number_nonce`.

Applied to files:

  • bin/orbis-node/src/dkg/coordinator/reshare/cleanup.rs
  • bin/orbis-node/src/dkg/tests/reshare.rs
  • bin/orbis-node/src/sign/messages.rs
  • crates/crypto/src/trait.rs
  • bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs
  • bin/orbis-node/src/dkg/helpers.rs
📚 Learning: 2026-05-20T18:07:01.094Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 171
File: crates/bulletin/src/dummy/mod.rs:152-173
Timestamp: 2026-05-20T18:07:01.094Z
Learning: `DummyBulletin` in `crates/bulletin/src/dummy/mod.rs` is only used for unit tests, not production. Production-level consistency concerns (e.g., nonce mirroring, exact trait contract fidelity) should not be flagged as issues for this type.

Applied to files:

  • crates/crypto/src/decaf377/tests/deserialization_prop_tests.rs
  • crates/crypto/src/bls12_381/tests/deserialization_prop_tests.rs
  • bin/orbis-node/src/dkg/tests/dkg.rs
🔇 Additional comments (61)
README.md (1)

333-343: LGTM!

bin/orbis-node/README.md (3)

17-21: LGTM!


54-79: LGTM!


83-83: LGTM!

crates/network/README.md (1)

49-49: LGTM!

Also applies to: 80-80, 93-102, 114-114

docker/docker-compose-integration-test.yml (1)

9-11: LGTM!

docker/docker-compose-metrics-network-test.yml (1)

3-5: LGTM!

docker/docker-compose.3-node.yml (1)

1-3: LGTM!

docker/grafana/dashboards/orbis.json (1)

1269-1314: LGTM!

Cargo.toml (2)

51-51: LGTM!


54-58: Verify MSRV compatibility for the tonic/prost 0.14.x upgrade before merge

This workspace declares workspace.package.rust-version = "1.70". Check that the Cargo.lock-resolved versions of prost, tonic, tonic-build, tonic-prost, and tonic-prost-build have crates.io version.rust_version metadata <= 1.70; if any require a newer compiler, bump the workspace MSRV or pin compatible crate versions.

bin/cli-tool/Cargo.toml (1)

12-12: LGTM!

bin/orbis-node/Cargo.toml (1)

17-17: LGTM!

crates/authn/Cargo.toml (1)

16-16: LGTM!

Also applies to: 19-19

crates/proto/Cargo.toml (1)

10-12: LGTM!

Also applies to: 15-16

bin/orbis-node/src/constants.rs (1)

175-195: LGTM!

bin/orbis-node/src/helpers/create_routers.rs (1)

2-4: LGTM!

Also applies to: 13-19, 40-40, 80-80, 134-134

bin/orbis-node/src/main.rs (1)

78-79: LGTM!

Also applies to: 360-363, 408-409

crates/network/src/trait.rs (1)

11-27: LGTM!

Also applies to: 128-132

crates/network/src/lib.rs (1)

19-19: LGTM!

crates/network/src/iroh/router.rs (1)

9-21: LGTM!

Also applies to: 46-46, 64-75, 77-100, 103-113, 115-155, 157-178, 180-208, 210-267, 269-289

crates/network/src/metrics.rs (1)

88-95: LGTM!

Also applies to: 111-111, 187-195

crates/network/src/iroh/tests.rs (1)

13-13: LGTM!

Also applies to: 19-28, 297-376

bin/orbis-node/src/dkg/coordinator/message_handlers/commitment.rs (1)

10-10: LGTM!

bin/orbis-node/src/dkg/coordinator/message_handlers/session_init.rs (1)

13-13: LGTM!

bin/orbis-node/src/dkg/coordinator/message_handlers/share.rs (1)

11-11: LGTM!

Also applies to: 129-129, 149-149, 165-165

bin/orbis-node/src/dkg/coordinator/mod.rs (1)

55-55: LGTM!

Also applies to: 67-67, 475-475, 504-504, 512-512, 532-532, 550-550, 561-561, 570-574, 581-581, 588-588

bin/orbis-node/src/dkg/coordinator/network.rs (1)

30-30: LGTM!

Also applies to: 59-59, 99-99, 412-412, 511-511

bin/orbis-node/src/dkg/coordinator/phases/mod.rs (1)

39-39: LGTM!

Also applies to: 53-53, 66-66, 106-106, 147-147, 183-183, 234-234

bin/orbis-node/src/dkg/coordinator/phases/phase1.rs (1)

5-5: LGTM!

Also applies to: 145-145

bin/orbis-node/src/dkg/coordinator/phases/phase2.rs (1)

5-5: LGTM!

bin/orbis-node/src/dkg/coordinator/phases/phase4.rs (1)

5-5: LGTM!

Also applies to: 14-14

bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs (1)

35-35: LGTM!

Also applies to: 177-177, 242-242, 256-256, 287-287, 440-440, 478-478, 503-503

bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs (1)

42-42: LGTM!

Also applies to: 198-198, 284-284, 333-333

bin/orbis-node/src/dkg/coordinator/reshare/cleanup.rs (1)

13-13: LGTM!

Also applies to: 29-29

bin/orbis-node/src/dkg/coordinator/reshare/selection.rs (1)

5-5: LGTM!

Also applies to: 74-74, 96-96, 147-147, 164-164, 303-303, 368-368

bin/orbis-node/src/dkg/coordinator/ring_storage.rs (1)

16-16: LGTM!

bin/orbis-node/src/dkg/service.rs (1)

130-130: LGTM!

bin/orbis-node/src/store_secret/service.rs (1)

193-193: LGTM!

bin/orbis-node/src/dkg/PROTOCOL_FLOW.md (1)

205-207: LGTM!

crates/crypto/benches/dkg_benchmarks.rs (1)

41-58: LGTM!

crates/crypto/benches/bls12_381/dkg.rs (1)

11-17: LGTM!

crates/crypto/benches/bls12_381/pre.rs (1)

18-29: LGTM!

crates/crypto/benches/bls12_381/sign.rs (1)

16-23: LGTM!

crates/crypto/benches/decaf377/dkg.rs (1)

11-17: LGTM!

crates/crypto/benches/decaf377/pre.rs (1)

16-29: LGTM!

crates/crypto/benches/decaf377/sign.rs (1)

16-23: LGTM!

crates/crypto/src/dkg_tests.rs (1)

51-55: LGTM!

crates/crypto/src/lifecycle_tests.rs (1)

147-153: LGTM!

Also applies to: 281-281

crates/crypto/src/test_helpers/test_helper.rs (1)

49-49: LGTM!

Also applies to: 70-73, 223-223, 262-262, 289-289, 303-303, 320-320, 354-354, 382-383, 387-390, 438-438, 473-473, 490-493, 595-595, 613-616, 707-707, 726-729

crates/crypto/src/bls12_381/tests/deserialization_prop_tests.rs (1)

52-52: LGTM!

Also applies to: 114-115

crates/crypto/src/bls12_381/tests/pre_tests.rs (1)

27-27: LGTM!

crates/crypto/src/bls12_381/tests/sign_tests.rs (1)

29-29: LGTM!

Also applies to: 76-76

crates/crypto/src/decaf377/tests/deserialization_prop_tests.rs (1)

50-50: LGTM!

Also applies to: 124-125

crates/crypto/src/decaf377/tests/pre_tests.rs (1)

25-25: LGTM!

crates/crypto/src/decaf377/tests/sign_tests.rs (1)

26-26: LGTM!

Also applies to: 60-60

bin/orbis-node/src/dkg/tests/dkg.rs (1)

831-831: LGTM!

Also applies to: 950-950, 994-994, 1042-1042, 1123-1123, 1158-1158, 1185-1185, 1212-1213, 1245-1245, 1281-1281, 1327-1327, 1368-1368, 1370-1370, 1380-1380, 1384-1384, 1392-1392, 1401-1401, 1429-1429

bin/orbis-node/src/dkg/tests/refresh.rs (1)

400-400: LGTM!

Also applies to: 498-498, 529-529

bin/orbis-node/src/dkg/tests/reshare.rs (1)

468-468: LGTM!

Also applies to: 547-547

bin/orbis-node/src/pre/tests.rs (1)

319-319: LGTM!

bin/orbis-node/src/sign/tests.rs (1)

211-211: LGTM!

Comment on lines +68 to +79
/// Maximum in-flight gRPC requests per client connection.
#[arg(
long,
default_value_t = crate::constants::GRPC_CONCURRENCY_LIMIT_PER_CONNECTION
)]
pub grpc_concurrency_limit_per_connection: usize,
/// Maximum concurrent HTTP/2 streams per gRPC client connection.
#[arg(
long,
default_value_t = crate::constants::GRPC_MAX_CONCURRENT_STREAMS
)]
pub grpc_max_concurrent_streams: u32,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Confirm the new args are defined without an existing range guard.
rg -n -C3 'grpc_concurrency_limit_per_connection|grpc_max_concurrent_streams|value_parser|range\(1\.\.\)' bin/orbis-node/src/helpers/launch.rs

# 2) Trace where these fields are consumed in server setup paths.
rg -n -C3 'grpc_concurrency_limit_per_connection|grpc_max_concurrent_streams|concurrency_limit_per_connection|http2_max_concurrent_streams' bin/orbis-node/src

Repository: sourcenetwork/orbis-rs

Length of output: 1947


Add positive range validation for the new gRPC limit CLI flags

These clap args have defaults but no value_parser/range guard, so passing 0 is currently allowed; constrain both to 1.. to fail fast on invalid configs.

Proposed fix
     #[arg(
         long,
+        value_parser = clap::value_parser!(usize).range(1..),
         default_value_t = crate::constants::GRPC_CONCURRENCY_LIMIT_PER_CONNECTION
     )]
     pub grpc_concurrency_limit_per_connection: usize,
@@
     #[arg(
         long,
+        value_parser = clap::value_parser!(u32).range(1..),
         default_value_t = crate::constants::GRPC_MAX_CONCURRENT_STREAMS
     )]
     pub grpc_max_concurrent_streams: u32,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bin/orbis-node/src/helpers/launch.rs` around lines 68 - 79, The two CLI args
grpc_concurrency_limit_per_connection and grpc_max_concurrent_streams currently
accept 0; add clap value parsers with a positive range to validate inputs and
fail fast. For grpc_concurrency_limit_per_connection use value_parser =
clap::value_parser!(usize).range(1..) and for grpc_max_concurrent_streams use
value_parser = clap::value_parser!(u32).range(1..), placing these attributes on
the respective struct fields so passing 0 will be rejected.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/crypto/src/decaf377/tests/sign_tests.rs`:
- Around line 136-157: The tests hash_to_sign_scalar_is_deterministic and
hash_to_sign_scalar_separates_domains currently compare Result<Fr> values;
change them to assert the calls succeed and compare the underlying Fr values
instead (e.g., call hash_to_sign_scalar(...).unwrap() or use an assert_ok
helper) so you validate the produced scalar rather than matching errors — update
both occurrences of hash_to_sign_scalar(FROST_BINDING_DOMAIN, transcript),
hash_to_sign_scalar(FROST_CHALLENGE_DOMAIN, transcript), and
hash_to_sign_scalar(SIGN_DERIVATION_DOMAIN, transcript) to unwrap or assert
success before asserting equality/inequality.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05b3664c-6a59-4eb0-94fb-d06c14ee17bc

📥 Commits

Reviewing files that changed from the base of the PR and between 702eed9 and aabe20b.

📒 Files selected for processing (4)
  • bin/orbis-node/src/pre/coordinator/initiator.rs
  • bin/orbis-node/src/pre/tests.rs
  • crates/crypto/src/decaf377/sign.rs
  • crates/crypto/src/decaf377/tests/sign_tests.rs
📜 Review details
⏰ 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). (2)
  • GitHub Check: lint
  • GitHub Check: build
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: crates/bulletin/src/sourcehub/mod.rs:12-14
Timestamp: 2026-05-11T14:28:55.018Z
Learning: In `crates/bulletin/src/sourcehub/mod.rs` (Rust), the `DEFAULT_THRESHOLD_SIGNATURE_SCHEME` constant references `crypto::THRESHOLD_SIGNATURE_SCHEME`. All builds of orbis-rs are expected to enable at least one crypto feature (bls12-381, decaf377, or a future equivalent), so this constant should NOT be feature-gated at the bulletin crate level. The feature enforcement is handled by the `crypto` crate itself. Avoid flagging missing cfg gates on this constant.
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 147
File: bin/orbis-node/src/store_secret/service.rs:0-0
Timestamp: 2026-04-29T16:47:26.051Z
Learning: In `bin/orbis-node/src/store_secret/service.rs`, the pre-store `verify_encryption` check (which previously passed ring key, effective key, and policy metadata into `validate_encrypted_document`) was intentionally removed as part of PR `#147` (closes issue `#139`). The rationale: running this verification before storing requires exposing ring key and policy metadata to the validation function, which leaks privacy. Since a caller could always store cryptographically junk data regardless of this check, removing it does not weaken the protocol's security invariants — it only improves privacy. Proof field validation (shared_point/challenge/response) is deferred to downstream consumers.
📚 Learning: 2026-04-29T16:47:26.051Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 147
File: bin/orbis-node/src/store_secret/service.rs:0-0
Timestamp: 2026-04-29T16:47:26.051Z
Learning: In `bin/orbis-node/src/store_secret/service.rs`, the pre-store `verify_encryption` check (which previously passed ring key, effective key, and policy metadata into `validate_encrypted_document`) was intentionally removed as part of PR `#147` (closes issue `#139`). The rationale: running this verification before storing requires exposing ring key and policy metadata to the validation function, which leaks privacy. Since a caller could always store cryptographically junk data regardless of this check, removing it does not weaken the protocol's security invariants — it only improves privacy. Proof field validation (shared_point/challenge/response) is deferred to downstream consumers.

Applied to files:

  • bin/orbis-node/src/pre/coordinator/initiator.rs
  • crates/crypto/src/decaf377/tests/sign_tests.rs
  • bin/orbis-node/src/pre/tests.rs
  • crates/crypto/src/decaf377/sign.rs
📚 Learning: 2026-04-30T20:31:37.077Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 148
File: bin/orbis-node/src/dkg/coordinator/phases.rs:689-695
Timestamp: 2026-04-30T20:31:37.077Z
Learning: In `bin/orbis-node/src/dkg/coordinator/phases.rs`, `wait_for_reshare_bulletin_finalized` intentionally gates PSS-claim release only on `next_peer_ids` and `new_threshold` being `None`. This is by design: an upcoming PR (related to PR `#148`) will make the threshold signature the trigger that clears those fields on the bulletin, so this poll condition will be sufficient once that change lands. Do not flag the absence of explicit signature-metadata verification in this function as a bug.

Applied to files:

  • bin/orbis-node/src/pre/coordinator/initiator.rs
  • bin/orbis-node/src/pre/tests.rs
📚 Learning: 2026-05-11T14:42:47.309Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs:274-282
Timestamp: 2026-05-11T14:42:47.309Z
Learning: In `bin/orbis-node/src/dkg/coordinator/reshare/bulletin_update.rs`, `block_number_nonce` in `RingPayload` is intentionally passed through unchanged in the signed `RingReshareUpdateStatement`. SourceHub (see sourcenetwork/sourcehub#110) rotates `block_number_nonce` atomically server-side when applying the threshold-signature bulletin update (together with `new_peer_ids`/`new_threshold` → `peer_ids`/`threshold`). A replay of an old signature is benign by design: if the prior update failed, the nodes were already in the ready state awaiting the chain update, so re-submitting the same signature has no harmful effect.

Applied to files:

  • bin/orbis-node/src/pre/coordinator/initiator.rs
  • crates/crypto/src/decaf377/tests/sign_tests.rs
  • bin/orbis-node/src/pre/tests.rs
📚 Learning: 2026-04-28T14:49:17.416Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 142
File: bin/orbis-node/src/dkg/helpers.rs:126-145
Timestamp: 2026-04-28T14:49:17.416Z
Learning: In `bin/orbis-node/src/dkg/helpers.rs`, `load_reshare_ring_payload` intentionally prefers the local `RingIndex` bulletin_post_id over the wire-provided one for old-committee nodes. This is by design: local `RingIndex` and `RingShareBundle` are part of the validity boundary. An old-committee member with a stale or missing local post ID is considered unhealthy; falling back to the wire-supplied post ID would mask stale-state drift rather than surface it. Pure receivers (nodes not in the old committee, with no local index entry) are the only case where the wire `bulletin_post_id` is used as a fallback, which is explicitly allowed.

Applied to files:

  • bin/orbis-node/src/pre/coordinator/initiator.rs
  • bin/orbis-node/src/pre/tests.rs
📚 Learning: 2026-05-11T14:28:55.018Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 152
File: crates/bulletin/src/sourcehub/mod.rs:12-14
Timestamp: 2026-05-11T14:28:55.018Z
Learning: In `crates/bulletin/src/sourcehub/mod.rs` (Rust), the `DEFAULT_THRESHOLD_SIGNATURE_SCHEME` constant references `crypto::THRESHOLD_SIGNATURE_SCHEME`. All builds of orbis-rs are expected to enable at least one crypto feature (bls12-381, decaf377, or a future equivalent), so this constant should NOT be feature-gated at the bulletin crate level. The feature enforcement is handled by the `crypto` crate itself. Avoid flagging missing cfg gates on this constant.

Applied to files:

  • crates/crypto/src/decaf377/tests/sign_tests.rs
  • bin/orbis-node/src/pre/tests.rs
  • crates/crypto/src/decaf377/sign.rs
📚 Learning: 2026-02-12T17:49:15.841Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 48
File: crates/crypto/src/helpers.rs:26-33
Timestamp: 2026-02-12T17:49:15.841Z
Learning: In the decaf377 module usage, calling Fr::rand() without importing UniformRand is valid: the method is available directly on the type. During reviews of Rust code in crates/crypto/src, prefer using Fr::rand() without a UniformRand import when possible, and only import UniformRand if a method requires the trait explicitly. This helps distinguish library-specific extension behavior (e.g., decaf377) from other crates (e.g., ark_bls12_381) where trait imports may be necessary.

Applied to files:

  • crates/crypto/src/decaf377/tests/sign_tests.rs
  • crates/crypto/src/decaf377/sign.rs
📚 Learning: 2026-05-13T18:55:29.338Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 161
File: bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs:147-163
Timestamp: 2026-05-13T18:55:29.338Z
Learning: In `bin/orbis-node/src/dkg/coordinator/refresh_health_check.rs`, the partial-broadcast / local-rollback split-brain scenario in `run_selector` was explicitly considered and accepted as a pragmatic trade-off. The refresh health check is a diagnostic layer on top of the actual key ceremony; the underlying key material is persisted independently. Adding 2PC or compensating rollback broadcasts would just shift the same class of partial-failure risk to the new coordination round, creating an infinite nesting problem. The design intentionally accepts potential transient inconsistency in the health-check staging state.

Applied to files:

  • bin/orbis-node/src/pre/tests.rs
📚 Learning: 2026-03-03T15:27:38.961Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 87
File: bin/orbis-node/src/tests/mod.rs:3-3
Timestamp: 2026-03-03T15:27:38.961Z
Learning: In the orbis-rs repository, integration tests (including Docker-based tests in bin/orbis-node/src/tests/integration.rs) should run by default during `cargo test` without requiring a feature flag.

Applied to files:

  • bin/orbis-node/src/pre/tests.rs
📚 Learning: 2026-05-20T18:07:01.094Z
Learnt from: JesseAbram
Repo: sourcenetwork/orbis-rs PR: 171
File: crates/bulletin/src/dummy/mod.rs:152-173
Timestamp: 2026-05-20T18:07:01.094Z
Learning: `DummyBulletin` in `crates/bulletin/src/dummy/mod.rs` is only used for unit tests, not production. Production-level consistency concerns (e.g., nonce mirroring, exact trait contract fidelity) should not be flagged as issues for this type.

Applied to files:

  • bin/orbis-node/src/pre/tests.rs
🔇 Additional comments (15)
bin/orbis-node/src/pre/coordinator/initiator.rs (1)

203-225: LGTM!

bin/orbis-node/src/pre/tests.rs (3)

14-16: LGTM!

Also applies to: 23-23, 29-29


316-347: LGTM!


1335-1435: LGTM!

crates/crypto/src/decaf377/sign.rs (8)

22-25: LGTM!

Also applies to: 34-34, 161-162


166-183: LGTM!


214-228: LGTM!


230-240: LGTM!


378-402: LGTM!


442-458: LGTM!


520-532: LGTM!


535-551: LGTM!

crates/crypto/src/decaf377/tests/sign_tests.rs (3)

2-5: LGTM!


28-31: LGTM!


62-65: LGTM!

Comment thread crates/crypto/src/decaf377/tests/sign_tests.rs Outdated
@JesseAbram JesseAbram merged commit 9530a00 into develop Jun 5, 2026
4 of 5 checks passed
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.

1 participant