feat(control-plane): show active Network Validators on the dashboard - #66
Merged
Merged
Conversation
Contained slice of #29/ADR-011's dashboard bullet: validator count and list, the smallest honest piece of 'dashboard shows validator count, challenge outcomes, score history, and degraded quorum' -- the rest (challenge outcomes, score history, degraded-quorum-per-round) needs reading pallet-network-validator's Rounds/Evidence StorageNMap, which requires correctly replicating Substrate's Blake2_128Concat/ Twox64Concat multi-key hashing for a 3-key map. That is real additional risk to get right blind (no live chain in this sandbox to verify against), so it is deliberately left for a follow-up rather than shipped half-verified. internal/blockchainbridge/networkvalidator.go: reads pallet-network-validator's ActiveValidatorSet (a StorageValue, so only a fixed twox128(pallet)+twox128(item) key -- no per-entry hashing) and SCALE-decodes the compact-prefixed Vec<AccountId32> it holds. Adds a decodeCompactUint counterpart to the existing compactUint encoder (registrar.go) and round-trips every mode (single-byte, two-byte, four-byte, big-integer) against it in tests, since a subtly wrong decode would silently misread real validator counts rather than error. dashboard.go: ValidatorsActive is -1 on a failed read, never 0 -- ADR-011's own requirement that a degraded observation must not read as false success applies here as much as to any on-chain state. A pinned JSON-contract test (TestOverviewReportsUnavailableValidatorSetDistinctlyFromZero) guards the sentinel against a refactor silently dropping it back to Go's int zero value. index.html/app.js render the same distinction: '-' for unavailable, the real count (including 0) otherwise. Verified (control-plane/): go build ./...; go vet ./...; gofmt -l .; go test ./... (full suite, incl. 6 new blockchainbridge SCALE-decode tests and the dashboard JSON-contract test). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Contained slice of #29 / ADR-011's dashboard bullet: validator count and list.
Scope, and why it stops here
The full ADR-011 dashboard requirement is "validator count, challenge outcomes, score history, and degraded quorum." This PR ships the count/list honestly. The rest — challenge outcomes, score history, degraded-quorum-per-round — needs reading
pallet-network-validator'sRounds/EvidenceStorageNMap, which requires correctly replicating Substrate'sBlake2_128Concat/Twox64Concatmulti-key hashing for a 3-key map. That's real additional risk to get right blind — this sandbox has no live chain to verify decoding against — so it's deliberately left for a follow-up rather than shipped half-verified.What's here
internal/blockchainbridge/networkvalidator.go: readspallet-network-validator'sActiveValidatorSet(aStorageValue, so only a fixedtwox128(pallet)+twox128(item)key — no per-entry hashing needed) and SCALE-decodes the compact-prefixedVec<AccountId32>it holds. Adds adecodeCompactUintcounterpart to the existingcompactUintencoder (registrar.go) and round-trips every mode (single-byte, two-byte, four-byte, big-integer) against it in tests — a subtly wrong decode would silently misread real validator counts rather than error, so this is exactly the kind of logic that needs a real round-trip test, not just "it compiles."dashboard.go:ValidatorsActiveis-1on a failed read, never0— ADR-011's own requirement that a degraded observation must not read as false success applies here as much as to any on-chain state. A pinned JSON-contract test guards the sentinel against a refactor silently dropping it back to Go'sintzero value.index.html/app.jsrender the same distinction:—for unavailable, the real count (including a genuine0) otherwise.Verification
Full suite green, including 6 new
blockchainbridgeSCALE-decode tests and the dashboard JSON-contract test.🤖 Generated with Claude Code