Skip to content

chore(dkg): add debug logging for DKG deal flow and proof verification#79

Open
yingyangxu2026 wants to merge 1 commit into
mainfrom
debug/dkg-deal-logs
Open

chore(dkg): add debug logging for DKG deal flow and proof verification#79
yingyangxu2026 wants to merge 1 commit into
mainfrom
debug/dkg-deal-logs

Conversation

@yingyangxu2026

Copy link
Copy Markdown
Contributor

Motivation

While debugging DKG bootstrap failures on devnet, the existing kernel logging was too sparse to localize what was happening during dealing/finalization — committee construction, deal/response certification, and the verified-query proof checks. This adds debug/forensic logging so those paths are diagnosable from logs.

Logging-only — no behavior change.

What's added

  • new debug_dump helpers (fmtPubKeys/fmtRegs/fmtAddrs/hexHead) — compact, comparable fingerprints of committees and keys.
  • query_client.gogetDKGRegistration names the validator being proven; getStoreData logs key/height/is_non_existence (success at debug, failure at warn); verifyModuleNonExistenceProof dumps proof key, expected vs calculated root and the Left/Right neighbor keys on both success and failure (shared nonExistProofFields); GetAllParticipantDKGRegistrations dumps the resulting committee plus dropped/unregistered members.
  • round_context.gofetchRoundContext dumps the committee and sorted pub keys.
  • dist_key_gen.go — build/rebuild Resharing{Prev,Next}DKG dump OldNodes/NewNodes with a source label; replayMessages logs the committee on a deal replay failure.
  • dkg_generate_deals.goGenerateDeals logs this node's dealer index and recipients.
  • dkg_process_deals.go — logs the previously-silent out-of-range deal rejection and enumerates rejected sender indices.
  • dkg_finalize.go — dumps the committee on distributed key not certified and on success.

Log levels

High-frequency per-item logs at debug (off by default in production); per-operation committee dumps and summaries at info; rejections/failures at warn/error.

Context

These logs were used to localize #76 and #77 (and complement piplabs/story#845). Pairs with the story-side debug-logging PR.

Logging-only (no behavior change). Adds debug/forensic logging across the DKG
deal path, resharing committee construction, and the verified-query proof
checks, so dealing/finalization issues are diagnosable from logs:

- new debug_dump helpers (fmtPubKeys/fmtRegs/fmtAddrs/hexHead) produce compact,
  comparable fingerprints of committees and keys.
- query_client.go: getDKGRegistration names the validator being proven;
  getStoreData logs key/height/is_non_existence (success debug, failure warn);
  verifyModuleNonExistenceProof dumps proof key, expected vs calculated root and
  the Left/Right neighbor keys on both success and failure (shared
  nonExistProofFields); GetAllParticipantDKGRegistrations dumps the resulting
  committee plus the dropped/unregistered members.
- round_context.go: fetchRoundContext dumps the committee and sorted pub keys.
- dist_key_gen.go: build/rebuild Resharing{Prev,Next}DKG dump OldNodes/NewNodes
  with a source label; replayMessages logs the committee on a deal replay failure.
- dkg_generate_deals.go: GenerateDeals logs this node's dealer index and recipients.
- dkg_process_deals.go: logs the previously-silent out-of-range deal rejection and
  enumerates rejected sender indices.
- dkg_finalize.go: dumps the committee on "distributed key not certified" and on success.

High-frequency per-item logs are at debug level (off by default in production);
per-operation committee dumps and summaries at info; rejections/failures at warn/error.
@jinn-agent

jinn-agent Bot commented Jun 18, 2026

Copy link
Copy Markdown

Logging-only PR — no behavioral changes to the DKG protocol itself. The helper functions in debug_dump.go (both packages) are allocation-light and correct. Log level choices are appropriate (per-validator detail at debug, per-operation summaries at info/warn). One performance concern worth noting: nonExistProofFields is called unconditionally on the success path of verifyModuleNonExistenceProof (debug log), meaning moduleProof.Calculate() — a non-trivial Merkle root recomputation — runs even when debug logging is disabled in production. Everything else looks correct.


Review iteration 1 · Commit 2b8e0bd · 2026-06-18T10:05:37Z

Comment thread service/debug_dump.go

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.

Do we need this dump file in our repo?

Comment thread service/dist_key_gen.go
"num_deals": len(st.Deals),
"error": err,
}).Warn("failed to replay deal")
}).Warn("failed to replay deal (likely committee divergence: compare new_nodes vs chain-fetch committee)")

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.

Likely committee divergence when error is returned while processing deal? Isn't it enough to log error here?

Comment thread story/debug_dump.go

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.

Same question. Do we need this included in the repo?

Comment thread story/query_client.go
// committee (which keeps them). noReg = absence-proven (never registered, e.g.
// the non-TEE validator); dropped = registered but NOT in VERIFIED/FINALIZED
// (the INVALIDATED nodes that vanish here but persist in sealed state).
var noReg, dropped []string

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.

Why do we need to track noReg and dropped here?

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.

3 participants