Skip to content

fix: wrap dkg on chain txs for failures - #1790

Merged
ctrlc03 merged 2 commits into
mainfrom
fix/dkg-txs
Aug 11, 2026
Merged

fix: wrap dkg on chain txs for failures#1790
ctrlc03 merged 2 commits into
mainfrom
fix/dkg-txs

Conversation

@ctrlc03

@ctrlc03 ctrlc03 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability for committee finalization, ticket submission, and committee publication during retries or overlapping transactions.
    • Skips actions that are not currently possible or have already been completed.
    • Rechecks on-chain state after failed transactions to recognize successful completion by another submitter.
    • Preserves errors for conflicting commitments and failed finalization.
    • Added coverage for mined, already-completed, and unsuccessful transaction outcomes.
  • New Features

    • Added access to active committee nodes and their scores.

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview Aug 11, 2026 2:07pm
interfold-dashboard Ready Ready Preview Aug 11, 2026 2:07pm
interfold-docs Ready Ready Preview Aug 11, 2026 2:07pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 38431204-affd-4d97-98d3-0d71dca44c1b

📥 Commits

Reviewing files that changed from the base of the PR and between f8d09c5 and 509b2d3.

📒 Files selected for processing (3)
  • agent/flow-trace/03_E3_REQUEST_AND_COMMITTEE.md
  • crates/evm/src/ciphernode_registry/effects.rs
  • crates/evm/src/contracts.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • agent/flow-trace/03_E3_REQUEST_AND_COMMITTEE.md
  • crates/evm/src/ciphernode_registry/effects.rs

📝 Walkthrough

Walkthrough

The change adds idempotent transaction submission for registry operations. It detects state settled by another sender, preserves unresolved errors, updates handlers for outcomes without receipts, and documents concurrent committee finalization.

Changes

Registry transaction idempotency

Layer / File(s) Summary
Idempotent transaction outcome handling
crates/evm/src/helpers.rs
TxOutcome and send_tx_idempotent distinguish mined transactions from already-settled state. Tests cover settled, unresolved, and state-check failure outcomes.
Registry settlement checks
crates/evm/src/contracts.rs, crates/evm/src/ciphernode_registry/actor.rs, crates/evm/src/ciphernode_registry/effects.rs
Registry operations inspect on-chain state after failed transactions. Matching state returns success, while conflicting commitments remain errors.
Outcome handling and flow documentation
crates/evm/src/ciphernode_registry/handlers.rs, agent/flow-trace/03_E3_REQUEST_AND_COMMITTEE.md, agent/flow-trace/04_DKG_AND_COMPUTATION.md
Handlers process mined and already-settled outcomes. Flow descriptions document finalization preflight checks, concurrent submissions, and commitment reconciliation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RegistryHandler
  participant RegistryEffects
  participant send_tx_idempotent
  participant CiphernodeRegistry
  RegistryHandler->>RegistryEffects: request registry operation
  RegistryEffects->>send_tx_idempotent: submit transaction with retry handling
  send_tx_idempotent->>CiphernodeRegistry: check desired state after failure
  CiphernodeRegistry-->>send_tx_idempotent: state settled or work remains
  send_tx_idempotent-->>RegistryEffects: return Mined or AlreadySettled
  RegistryEffects-->>RegistryHandler: provide outcome for logging and continuation
Loading

Possibly related PRs

Suggested reviewers: hmzakhalid

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding failure handling around DKG on-chain transactions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dkg-txs

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

@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 (2)
crates/evm/src/helpers.rs (1)

397-417: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider retrying the settlement check.

settled runs one time. If the state read hits a transient RPC failure, a benign concurrent settlement becomes a hard error, and the caller reports it on the bus. The transaction path already uses retry_with_backoff. A short retry around the state read would make the benign case survive a single RPC blip.

This is optional. The current behavior fails closed, which is safe.

🤖 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 `@crates/evm/src/helpers.rs` around lines 397 - 417, Optionally wrap the
settled state read in a short retry-with-backoff flow, reusing the existing
retry mechanism, so transient RPC failures are retried before returning the
settlement-check error. Update the settled() call in the post-send_tx_with_retry
path while preserving the existing AlreadySettled, original error, and
contextual failure outcomes.
crates/evm/src/ciphernode_registry/effects.rs (1)

79-83: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider distinguishing a read failure from "not settled".

Both probes map every non-matching error to Ok(false), including RPC transport failures. send_tx_idempotent models a failed state check separately through the Err(check_error) arm, which adds the context "the on-chain state check after the failure also failed". With these implementations that arm is unreachable, so an operator cannot tell a genuine "work remains" result from an unreadable chain.

The propagated error is still the original transaction error, so behavior stays safe. This is a diagnostics improvement.

♻️ Proposed change for `committee_finalization_settled`
     let contract = ICiphernodeRegistry::new(contract_address, provider.provider());
     match contract.finalizeCommittee(e3_id_u256).call().await {
         Ok(_) => Ok(false),
-        Err(err) => Ok(reverts_with(
-            &anyhow::Error::from(err),
-            "CommitteeAlreadyFinalized",
-        )),
+        Err(err) => {
+            let err = anyhow::Error::from(err);
+            if reverts_with(&err, "CommitteeAlreadyFinalized") {
+                return Ok(true);
+            }
+            // A decoded revert that is not the settled marker means work remains.
+            if decode_error_from_str(&format!("{err:?}")).is_some() {
+                return Ok(false);
+            }
+            // An undecodable error is a read failure, not a state answer.
+            Err(err)
+        }
     }

Also applies to: 99-103

🤖 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 `@crates/evm/src/ciphernode_registry/effects.rs` around lines 79 - 83, Update
committee_finalization_settled and the corresponding second probe so only a
valid on-chain response indicating “not settled” returns Ok(false); propagate
RPC/transport and other read failures as Err instead of converting them to
false. Preserve the existing NodeAlreadySubmitted revert handling and allow
send_tx_idempotent’s Err(check_error) path to report failed state checks.
🤖 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/evm/src/ciphernode_registry/effects.rs`:
- Around line 91-104: Update committee_finalization_settled to distinguish a
CommitteeAlreadyFinalized revert caused by a previously failed committee from
one finalized successfully: query the committee stage and return false for the
Failed stage before treating the revert as settled. Preserve the existing true
result only for genuinely finalized committees, and do not add a .from(...) call
to finalizeCommittee.

---

Nitpick comments:
In `@crates/evm/src/ciphernode_registry/effects.rs`:
- Around line 79-83: Update committee_finalization_settled and the corresponding
second probe so only a valid on-chain response indicating “not settled” returns
Ok(false); propagate RPC/transport and other read failures as Err instead of
converting them to false. Preserve the existing NodeAlreadySubmitted revert
handling and allow send_tx_idempotent’s Err(check_error) path to report failed
state checks.

In `@crates/evm/src/helpers.rs`:
- Around line 397-417: Optionally wrap the settled state read in a short
retry-with-backoff flow, reusing the existing retry mechanism, so transient RPC
failures are retried before returning the settlement-check error. Update the
settled() call in the post-send_tx_with_retry path while preserving the existing
AlreadySettled, original error, and contextual failure outcomes.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a8d1e7c-0d45-402c-b00f-92033e4f9eb7

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd86c2 and f8d09c5.

📒 Files selected for processing (6)
  • agent/flow-trace/03_E3_REQUEST_AND_COMMITTEE.md
  • agent/flow-trace/04_DKG_AND_COMPUTATION.md
  • crates/evm/src/ciphernode_registry/actor.rs
  • crates/evm/src/ciphernode_registry/effects.rs
  • crates/evm/src/ciphernode_registry/handlers.rs
  • crates/evm/src/helpers.rs

Comment thread crates/evm/src/ciphernode_registry/effects.rs
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