Harden KOTH weight inputs and fallback - #434
Closed
kenobijon wants to merge 1 commit into
Closed
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.
Summary
Verification
Note
High Risk
Changes on-chain weight allocation and trust boundaries for external KOTH API data; mis-validation or cache behavior could mis-route emissions or burn discriminator share incorrectly.
Overview
Hardens King-of-the-Hill (KOTH) weight setting so validators only trust validated API data and fail safely when inputs are bad or stale.
Adds
resolve_koth_splitandvalidate_koth_payload: partial API splits overlay on protocol defaults; splits must be numeric, finite, non-negative, and sum to 1. Current-kings responses are normalized to kings, chain, and split only, with SS58 checks, one king per modality, and chain heads aligned with current kings.build_koth_weightsnow requires a valid owner/burn UID before building weights, deduplicates generator UIDs, and rejects non-unit or invalid final vectors. Modality lists useKOTH_MODALITIES.The validator validates live and cached current-kings payloads, persists
fetched_atwith a 24-hour TTL (legacy caches without timestamps are treated stale), and falls back to empty kings plusKOTH_SPLITwhen nothing valid is available—discriminator share burns with clearer logging.validator.config.jsfixes the PM2 CLI flag to--benchmark-api-url. New tests cover cache TTL/persistence and validation edge cases.Reviewed by Cursor Bugbot for commit 234932a. Bugbot is set up for automated code reviews on this repo. Configure here.