Skip to content

fix(beacon): centralize LOTUS_IGNORE_DRAND guard across all drand code paths - #13584

Open
exp0nge wants to merge 1 commit into
filecoin-project:masterfrom
exp0nge:md/mock-drand-beacon-env-guard
Open

fix(beacon): centralize LOTUS_IGNORE_DRAND guard across all drand code paths#13584
exp0nge wants to merge 1 commit into
filecoin-project:masterfrom
exp0nge:md/mock-drand-beacon-env-guard

Conversation

@exp0nge

@exp0nge exp0nge commented Apr 20, 2026

Copy link
Copy Markdown

Summary

  • Extends the existing LOTUS_IGNORE_DRAND env var guard so it covers every path to a DrandBeacon, not only RandomSchedule. Previously, any DrandBeacon that leaked past the RandomSchedule early-return could still reach external drand servers — the env var semantics were inconsistent.
  • Adds defense-in-depth guards in DrandBeacon.Entry (returns a deterministic 96-byte zero stub) and DrandBeacon.VerifyEntry (returns nil) in chain/beacon/drand/drand.go, so any DrandBeacon that bypasses the RandomSchedule guard no-ops at request time.
  • Keeps the original RandomSchedule early-return in node/modules/services.go as the primary guard; the per-method guards are a safety net for hermetic / network-isolated test environments.

Test plan

  • TestIgnoreDrandEntry — verifies DrandBeacon.Entry returns a 96-byte zero stub with the correct round when LOTUS_IGNORE_DRAND is set
  • TestIgnoreDrandVerifyEntry — verifies DrandBeacon.VerifyEntry returns nil (no error) when LOTUS_IGNORE_DRAND is set
  • Existing TestMaxBeaconRoundForEpoch and TestQuicknetIsChained still pass (no regressions)
  • CI is green

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 20, 2026 20:25
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FilOz Apr 20, 2026
@exp0nge
exp0nge force-pushed the md/mock-drand-beacon-env-guard branch from 1b9e71b to 643a6be Compare April 20, 2026 20:27

Copilot AI 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.

Pull request overview

This PR aims to make LOTUS_IGNORE_DRAND consistently prevent any drand network access by guarding all drand-beacon code paths (not just RandomSchedule), with added defense-in-depth no-op behavior at request/verification time.

Changes:

  • Add an early-return mock beacon schedule when LOTUS_IGNORE_DRAND is set.
  • Add per-method short-circuits in DrandBeacon.Entry and DrandBeacon.VerifyEntry when LOTUS_IGNORE_DRAND is set.
  • Add tests covering the ignore behavior for Entry and VerifyEntry, plus a changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
node/modules/services.go Adds LOTUS_IGNORE_DRAND guard to return a mock beacon schedule early.
chain/beacon/drand/drand.go Adds defense-in-depth guards to stub Entry and skip VerifyEntry under LOTUS_IGNORE_DRAND.
chain/beacon/drand/drand_test.go Adds tests validating the ignore behavior for entry retrieval and verification.
CHANGELOG.md Documents the behavioral change in the unreleased changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chain/beacon/drand/drand.go
Comment thread chain/beacon/drand/drand_test.go Outdated
Comment thread chain/beacon/drand/drand_test.go Outdated
Comment thread CHANGELOG.md Outdated
Comment thread node/modules/services.go Outdated
Comment thread chain/beacon/drand/drand.go
Comment thread chain/beacon/drand/drand.go
@exp0nge
exp0nge force-pushed the md/mock-drand-beacon-env-guard branch 2 times, most recently from e5fe5c7 to eaca1f0 Compare April 20, 2026 20:32
@exp0nge
exp0nge requested a review from Copilot April 20, 2026 20:33

Copilot AI 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.

Pull request overview

Extends the LOTUS_IGNORE_DRAND behavior so all drand-backed randomness paths reliably short-circuit in hermetic / network-isolated environments, preventing any accidental dialing of external drand endpoints.

Changes:

  • Add an early-return in RandomSchedule to use a mock beacon schedule when LOTUS_IGNORE_DRAND=_yes_.
  • Add defense-in-depth guards in DrandBeacon.Entry and DrandBeacon.VerifyEntry to no-op when LOTUS_IGNORE_DRAND=_yes_.
  • Add unit tests covering the new DrandBeacon ignore behavior and document the change in the changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
node/modules/services.go Returns a mock beacon schedule when LOTUS_IGNORE_DRAND is enabled to avoid any drand network usage.
chain/beacon/drand/drand.go Adds per-method LOTUS_IGNORE_DRAND short-circuiting in Entry and VerifyEntry.
chain/beacon/drand/drand_test.go Adds tests validating the new ignore behavior for Entry and VerifyEntry.
CHANGELOG.md Notes the behavioral change under UNRELEASED bug fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chain/beacon/drand/drand.go Outdated
Comment thread chain/beacon/drand/drand_test.go Outdated
The existing LOTUS_IGNORE_DRAND env var guard only covered
RandomSchedule, so a DrandBeacon that leaked past that entry point
could still reach external drand servers. Add defense-in-depth guards
in DrandBeacon.Entry (returns a deterministic 96-byte stub) and
DrandBeacon.VerifyEntry (returns nil) so every code path that touches
a DrandBeacon short-circuits consistently when the env var is set.
This keeps the env var semantics hermetic for network-isolated test
environments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@exp0nge
exp0nge force-pushed the md/mock-drand-beacon-env-guard branch from eaca1f0 to c7f2cd0 Compare April 20, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📌 Triage

Development

Successfully merging this pull request may close these issues.

3 participants