Skip to content

Sync chain client with the stake-weight runtime#1

Open
aph5nt wants to merge 2 commits into
hayotensor:mainfrom
aph5nt:chain-sync-stake-weight
Open

Sync chain client with the stake-weight runtime#1
aph5nt wants to merge 2 commits into
hayotensor:mainfrom
aph5nt:chain-sync-stake-weight

Conversation

@aph5nt

@aph5nt aph5nt commented Jul 9, 2026

Copy link
Copy Markdown

Summary

The Python chain client had drifted behind the Network pallet. After the stake-weight
work 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 --dev node (see Verification),
not by inspection alone.

Changes

Consensus — chain_functions.py

  • propose_attestation and attest now take the required subnet_node_id; the runtime
    binds each proposal/attestation to the calling node. args / attest_data / data are
    ValidatorArgs (BoundedVec<u8>).

Registration — validator-identity model — chain_functions.py

  • Added register_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_data carries initial_validators: BTreeMap<u32, u32>
    (replaces initial_coldkeys). The maps are passed as native (key, value) pairs; since
    scale-info metadata leaves scalecodec's Map.map_key / Map.map_value unset, the element
    types are forced for this call and restored in a finally block.
  • register_subnet_node: leads with validator_id; delegate_reward_rate moved to
    register_validator.

Read path — chain_data.py

  • SubnetNode dropped hotkey / delegate_account / delegate_reward_rate /
    last_delegate_reward_rate_update (these live on the validator identity now) and gained
    validator_id. Updated the dataclass and fix_decoded_values so
    get_consensus_data_formatted decodes the consensus record instead of raising
    KeyError: 'hotkey'.

Verification

Against a local hypertensor-node --dev:

Step Result
register_validator ×3 validator ids 1, 2, 3
register_subnet subnet id 128001 (SubnetRegistered)
register_subnet_node ×3 registered with node peer ids
activate_subnet state Active (after the 3 nodes register)
elected validator propose_attestation success (ValidatorSubmission)
two peers attest success
get_consensus_data_formatted validator_id=2, data=[(1,3000), (2,4000), (3,3000)], attests=[1, 2, 3]

aphex5 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant