Sync chain client with the stake-weight runtime#1
Open
aph5nt wants to merge 2 commits into
Open
Conversation
added 2 commits
July 9, 2026 12:42
The Python client had drifted from the current Network pallet. Update the extrinsic call surface to match the runtime shipped by the stake-weight work: - propose_attestation / attest: add the required `subnet_node_id` argument (the runtime binds each proposal/attestation to the calling node); `args` / `attest_data` / `data` are ValidatorArgs (BoundedVec<u8>). - register_validator: add the new validator-identity extrinsic (hotkey, delegate_reward_rate, delegate_account, identity). A validator identity owns subnet nodes and must be registered before register_subnet_node. - register_subnet: subnet_data now carries `initial_validators` (BTreeMap<u32,u32>) instead of `initial_coldkeys`; pass native (key,value) pairs and force the BTreeMap element types (scale-info metadata leaves scalecodec's Map.map_key/map_value unset), scoped with try/finally. - register_subnet_node: lead with `validator_id`; drop `delegate_reward_rate` (moved to register_validator). Verified against a local --dev node: register_validator x3, register_subnet, register_subnet_node x3, and activate_subnet all succeed; propose_attestation / attest compose against live metadata.
The runtime's SubnetNode dropped `hotkey` / `delegate_account` / `delegate_reward_rate` / `last_delegate_reward_rate_update` (those now live on the validator identity) and added `validator_id`. Update the dataclass and `fix_decoded_values` to match, so `get_consensus_data_formatted` decodes the consensus record instead of raising `KeyError: 'hotkey'`. Verified end-to-end against a local --dev node: after propose_attestation + attest, `get_consensus_data_formatted` returns validator_id, the per-node data vector, and the attestation set.
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
The Python chain client had drifted behind the
Networkpallet. After the stake-weightwork merged on-chain, the client's extrinsic and decode surface no longer matched the
runtime, so a subnet built on this template could not register or run consensus against a
current node. This re-syncs the client with the runtime.
Every change was verified end-to-end against a local
--devnode (see Verification),not by inspection alone.
Changes
Consensus —
chain_functions.pypropose_attestationandattestnow take the requiredsubnet_node_id; the runtimebinds each proposal/attestation to the calling node.
args/attest_data/dataareValidatorArgs(BoundedVec<u8>).Registration — validator-identity model —
chain_functions.pyregister_validator(hotkey, delegate_reward_rate, delegate_account, identity).A validator identity owns subnet nodes and must be registered before
register_subnet_node.register_subnet:subnet_datacarriesinitial_validators: BTreeMap<u32, u32>(replaces
initial_coldkeys). The maps are passed as native(key, value)pairs; sincescale-info metadata leaves scalecodec's
Map.map_key/Map.map_valueunset, the elementtypes are forced for this call and restored in a
finallyblock.register_subnet_node: leads withvalidator_id;delegate_reward_ratemoved toregister_validator.Read path —
chain_data.pySubnetNodedroppedhotkey/delegate_account/delegate_reward_rate/last_delegate_reward_rate_update(these live on the validator identity now) and gainedvalidator_id. Updated the dataclass andfix_decoded_valuessoget_consensus_data_formatteddecodes the consensus record instead of raisingKeyError: 'hotkey'.Verification
Against a local
hypertensor-node --dev:register_validator×3register_subnetSubnetRegistered)register_subnet_node×3activate_subnetActive(after the 3 nodes register)propose_attestationValidatorSubmission)attestget_consensus_data_formattedvalidator_id=2, data=[(1,3000), (2,4000), (3,3000)], attests=[1, 2, 3]