Repository navigation
fix(drand-tools): verify configured chain hash at startup - #697
Open
Adediwura-dev wants to merge 1 commit into
Open
Adediwura-dev wants to merge 1 commit into
Adediwura-dev wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(drand-tools): verify configured chain hash at startup
Summary
drand-toolsnow requires the expected Drand chain hash in configuration and validates fetched chain info against it before any round data is requested or accepted.DrandConfigloader that rejects missing or malformedDRAND_CHAIN_HASHbefore any network call, normalizes hex casing, and trims trailing slashes fromDRAND_API_URL.assertChainHashMatches()andDrandChainHashMismatchErrorwith the stable, non-secret messagedrand chain hash mismatchand codeDRAND_CHAIN_HASH_MISMATCH./infoand/public/<round>API paths, so an operator cannot silently validate a different chain than the one requested.chain-hash-mismatchdiagnostic event from the validation harness and keeps the process exit code at 1.DRAND_CHAIN_HASHas required in.env.example.Acceptance criteria
loadDrandConfig()fails closed whenDRAND_CHAIN_HASHis absent or not a 64-character hex digest.getChainInfo()verifiesinfo.hashimmediately after the response is parsed;getBeacon()is only called afterwards byindex.tsandvectors.ts.src/chain-hash.test.tsuses the frozentest-vectors/quicknet.jsonfixture with stubbedfetch, plus missing/malformed config cases, and is wired into the package test script.Verification
pnpm drand-tools:test— 10 tests pass (4 new chain-hash tests, 6 existing tests).pnpm env:check,pnpm workspaces:check,pnpm docs:check,pnpm snapshot:check,pnpm time:guard,pnpm line-lengths:check— pass.pnpm drand-tools:typecheck— the changed drand-tools sources typecheck cleanly once the pre-existing upstreampackages/tlock/src/seal.tsmerge break is restored (missingassertSealRoundWindowimport andrevealRounddestructure). That unrelated upstream baseline issue is not modified in this PR.pnpm logging:check,pnpm errors:normalize:check, andpnpm errors:checkcurrently fail on upstreammainbefore this change due unrelated existing drifts in scripts/web/contract files; no files in those areas are touched here.close #662