Skip to content

chore(beacon): drand protobuf and drand fake signer - #7747

Open
EclesioMeloJunior wants to merge 8 commits into
mainfrom
fetch-beacon-gossipsub-3-drand-protobuf
Open

EclesioMeloJunior wants to merge 8 commits into
mainfrom
fetch-beacon-gossipsub-3-drand-protobuf

Conversation

@EclesioMeloJunior

@EclesioMeloJunior EclesioMeloJunior commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary of changes

  • Includes the drand gossipsub proto definition
  • Includes the fake drand signer, required for generating valid signatures while testing the gossipsub message handling & validation

Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • This pull request is based on an issue that a maintainer has accepted (see Before Opening a Pull Request).
  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Tests
    • Added coverage for decoding and verifying drand beacon entries across multiple rounds, including checks of response payloads. The tests also exercise beacon entry creation and signature validation using a simulated signer, helping confirm that valid entries are accepted across the tested rounds.

@EclesioMeloJunior
EclesioMeloJunior requested a review from a team as a code owner October 13, 2026 18:23
@EclesioMeloJunior
EclesioMeloJunior requested review from akaladarshi and sudo-shashank and removed request for a team October 13, 2026 18:23
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: fefd85aa-ec25-4534-ad2b-7be3f7a5abeb
📥 Commits

Reviewing files that changed from the base of the PR and between 5e0c737 and 67000a8.

📒 Files selected for processing: 5
  • proto/drand_pb.proto
  • src/beacon/mod.rs
  • src/beacon/signatures/mod.rs
  • src/beacon/tests/drand.rs
  • src/beacon/tests/fake_drand_signer.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

💤 Files with no reviewable changes: 1
  • src/beacon/mod.rs
🚧 Files skipped from review as they are similar to previous changes: 1
  • proto/drand_pb.proto

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Walkthrough

The changes add a test-only protobuf response type and a fake drand signer. A test encodes and decodes entries for rounds 1–5, then checks that the beacon verifies them.

Changes

Drand test support

Layer / File(s) Summary
Protobuf response and test wiring
proto/drand_pb.proto, src/beacon/drand_pb.rs, src/beacon/mod.rs, .gitattributes
The protobuf schema and Rust implementation define PublicRandResponse with round and signature fields. The module is compiled for tests, and the generated Rust file is marked as generated.
Fake signer and entry verification
src/beacon/signatures/mod.rs, src/beacon/tests/drand.rs, src/beacon/mod.rs, src/beacon/tests/fake_drand_signer.rs
CSUITE_G1 is visible within crate::beacon. The test-only fake signer configures an unchained Quicknet test chain, signs round messages, encodes and decodes responses, and tests verification for rounds 1–5. Beacon constructors use named Filecoin timing constants.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: Minimal · previous review 67000

This change only adds test support for drand gossipsub validation and does not affect production behavior. It has no actionable merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the two main changes: adding the drand protobuf and the fake signer.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.19048% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.68%. Comparing base (6523e98) to head (e2b9130).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/daemon/bundle.rs 56.66% 15 Missing and 11 partials ⚠️
src/beacon/drand_pb.rs 47.36% 5 Missing and 5 partials ⚠️
src/db/car/many.rs 0.00% 3 Missing ⚠️
src/db/car/plain.rs 0.00% 3 Missing ⚠️
src/db/parity_db/gc.rs 0.00% 3 Missing ⚠️
src/db/parity_db.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/beacon/signatures/mod.rs 82.55% <100.00%> (+0.63%) ⬆️
src/db/memory.rs 93.81% <100.00%> (+0.10%) ⬆️
src/db/mod.rs 62.00% <ø> (-2.16%) ⬇️
src/dev/subcommands/archive_missing_cmd.rs 69.91% <ø> (ø)
src/networks/actors_bundle.rs 89.47% <100.00%> (ø)
src/networks/calibnet/mod.rs 100.00% <ø> (ø)
src/networks/drand.rs 97.16% <100.00%> (-0.27%) ⬇️
src/networks/mainnet/mod.rs 100.00% <ø> (ø)
src/networks/mod.rs 91.05% <100.00%> (ø)
src/state_manager/chain_rand.rs 82.35% <ø> (ø)
... and 6 more

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6523e98...e2b9130. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

@EclesioMeloJunior the PR title is not actually feat it should either test or chore, since changes are not adding any features.

Comment thread src/beacon/tests/fake_drand_signer.rs Outdated
Comment thread src/beacon/tests/fake_drand_signer.rs
Comment thread proto/drand_pb.proto
Comment thread src/beacon/signatures/mod.rs Outdated
Comment thread src/beacon/tests/fake_drand_signer.rs Outdated
Comment thread src/beacon/tests/fake_drand_signer.rs Outdated
Comment thread src/beacon/tests/fake_drand_signer.rs Outdated
Comment thread src/beacon/tests/fake_drand_signer.rs Outdated
Comment thread src/beacon/mod.rs Outdated
@EclesioMeloJunior EclesioMeloJunior changed the title feat(beacon): drand protobuf and drand fake signer chore(beacon): drand protobuf and drand fake signer Oct 15, 2026
@akaladarshi
akaladarshi marked this pull request as draft October 16, 2026 10:10
stacked auto-merge was automatically disabled October 16, 2026 10:10

Pull request was converted to draft

@EclesioMeloJunior
EclesioMeloJunior force-pushed the fetch-beacon-gossipsub-3-drand-protobuf branch from 67000a8 to a129a48 Compare October 16, 2026 12:36
@EclesioMeloJunior
EclesioMeloJunior marked this pull request as ready for review October 16, 2026 12:37
Comment thread src/beacon/tests/drand.rs Outdated
Comment thread src/beacon/tests/drand.rs Outdated
Comment thread src/beacon/tests/fake_drand_signer.rs
Comment thread proto/drand_pb.proto Outdated
@LesnyRumcajs

Copy link
Copy Markdown
Member

Apart from the above, please address the comments from CC. They seem relevant (some are duplicate of mine).

Worth raising
1. src/beacon/tests/fake_drand_signer.rs:85: the only test encodes and decodes with the same generated PublicRandResponse. A wrong field number or type in drand_pb.proto would still pass while real relay gossip decodes to round 0 and an empty signature. It has no rejection case either: no tampered signature, wrong round or wrong key, and encode_raw is never called. Fix: add a captured real relay payload as a byte fixture, plus a rejection test using encode_raw.
2. proto/drand_pb.proto:10: previous_signature (field 3) is missing. Decoding only works for unchained networks, but DrandNetwork::Mainnet (chained) is still supported, so the planned gossip validator couldn't build message_chained for it. Adding the field later means regenerating the code.
3. fake_drand_signer.rs:74: the step that turns gossip bytes into a BeaconEntry exists only in the test fixture, using unwrap. Production will need its own copy, and the two can drift apart. Suggest a fallible production conversion (e.g. TryFrom<&[u8]> for BeaconEntry) that the fixture calls, which would also remove the cfg(test) gate on drand_pb.

Cleanups
4. fake_drand_signer.rs:60: the fixture's methods are inconsistent. encode_raw takes &self but never uses it, decode is an associated function while encode is a method, and encode_raw has no caller.
5. src/beacon/signatures/mod.rs:21: a test-only sign_unchained is added to the production crypto module, mainly because CSUITE_G1 is private. Making CSUITE_G1 pub(in crate::beacon) would let signing stay in the fixture.
6. src/beacon/tests/drand.rs:24: FIL_GENESIS_TIME and FIL_BLOCK_DELAY duplicate MAINNET_GENESIS_TIMESTAMP (chain_rand.rs:255, archive_missing_cmd.rs:23) and EPOCH_DURATION_SECONDS.
7. drand.rs:23: one /// comment covers two constants, so rustdoc attaches it only to the first. FIL_BLOCK_DELAY ends up with no doc.
8. fake_drand_signer.rs:30: FakeDrandChain::quicknet() builds every recorded entry just to read period and genesis_time. The quicknet chain info is now spread across 3 places; a shared QUICKNET_INFO const would fix both.
9. .gitattributes:2: only drand_pb.rs is marked linguist-generated, not bitswap_pb.rs. A *_pb.rs pattern would cover both.
10. fake_drand_signer.rs:42,84: two comments restate the code. This is your personal CLAUDE.md rule, not a project rule, so it's only a nit for someone else's PR.

Comment thread src/beacon/tests/fake_drand_signer.rs Outdated
Comment thread src/dev/subcommands/archive_missing_cmd.rs Outdated
LesnyRumcajs
LesnyRumcajs previously approved these changes Oct 20, 2026
LesnyRumcajs
LesnyRumcajs previously approved these changes Oct 21, 2026
@EclesioMeloJunior
EclesioMeloJunior force-pushed the fetch-beacon-gossipsub-3-drand-protobuf branch 2 times, most recently from e2b9130 to 524c565 Compare October 27, 2026 12:40

This branch has not been deployed

No deployments
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