fix(beacon): centralize LOTUS_IGNORE_DRAND guard across all drand code paths - #13584
fix(beacon): centralize LOTUS_IGNORE_DRAND guard across all drand code paths#13584exp0nge wants to merge 1 commit into
Conversation
1b9e71b to
643a6be
Compare
There was a problem hiding this comment.
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_DRANDis set. - Add per-method short-circuits in
DrandBeacon.EntryandDrandBeacon.VerifyEntrywhenLOTUS_IGNORE_DRANDis set. - Add tests covering the ignore behavior for
EntryandVerifyEntry, 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.
e5fe5c7 to
eaca1f0
Compare
There was a problem hiding this comment.
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
RandomScheduleto use a mock beacon schedule whenLOTUS_IGNORE_DRAND=_yes_. - Add defense-in-depth guards in
DrandBeacon.EntryandDrandBeacon.VerifyEntryto no-op whenLOTUS_IGNORE_DRAND=_yes_. - Add unit tests covering the new
DrandBeaconignore 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.
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>
eaca1f0 to
c7f2cd0
Compare
Summary
LOTUS_IGNORE_DRANDenv var guard so it covers every path to aDrandBeacon, not onlyRandomSchedule. Previously, anyDrandBeaconthat leaked past theRandomScheduleearly-return could still reach external drand servers — the env var semantics were inconsistent.DrandBeacon.Entry(returns a deterministic 96-byte zero stub) andDrandBeacon.VerifyEntry(returnsnil) inchain/beacon/drand/drand.go, so anyDrandBeaconthat bypasses theRandomScheduleguard no-ops at request time.RandomScheduleearly-return innode/modules/services.goas the primary guard; the per-method guards are a safety net for hermetic / network-isolated test environments.Test plan
TestIgnoreDrandEntry— verifiesDrandBeacon.Entryreturns a 96-byte zero stub with the correct round whenLOTUS_IGNORE_DRANDis setTestIgnoreDrandVerifyEntry— verifiesDrandBeacon.VerifyEntryreturnsnil(no error) whenLOTUS_IGNORE_DRANDis setTestMaxBeaconRoundForEpochandTestQuicknetIsChainedstill pass (no regressions)🤖 Generated with Claude Code