Testnet Tensor
  • Introduction
  • Explorer
  • GPT
  • DSN Dashboard
  • Create Account
    • Wallet
    • CLI
    • Faucet
  • Hypertensor CLI
    • Hypertensor CLI
  • Run A Subnet Node
    • Getting Started
    • Wiki
      • Running on AMD GPU
      • Running on Windows Using WSL
      • Troubleshooting
    • Generate Keypair
    • Register & Stake
    • Add
    • Start Validator Node
    • Start Bootstrap Node
    • Activate
    • Update Delegate Reward Rate
    • Deactivate
    • Remove
    • Keys
  • Delegate Staking
    • Introduction
    • Add Delegate Stake
    • Transfer Delegate Stake
    • Remove Delegate Stake
    • Claim Delegate Stake
  • Node Delegate Staking
    • Introduction
    • Add Node Delegate Stake
    • Transfer Node Delegate Stake
    • Remove Node Delegate Stake
    • Claim Node Delegate Stake
  • Delegate Staking Utils
    • Introduction
    • Subnet to Node
    • Node to Subnet
  • Build a Subnet
    • Introduction
    • DSN Standard
    • Subnet Consensus Protocol (SCP)
      • Incentives
      • Accounting
      • Proposals
    • Subnet
      • Registration
      • Activation
      • Deactivation
    • Subnet Nodes
      • Registration
      • Activation
      • Deactivate
  • Contribute
Powered by GitBook
On this page
  1. Build a Subnet
  2. Subnet Nodes

Registration

Every subnet must have a way for subnet nodes to register on-chain using the Hypertensor extrinsic:

pub fn register_subnet_node(
    origin: OriginFor<T>, 
    subnet_id: u32, 
    peer_id: PeerId, 
    bootstrap_peer_id: PeerId, 
    stake_to_be_added: u128,
    a: Option<BoundedVec<u8, DefaultSubnetNodeParamLimit>>,
    b: Option<BoundedVec<u8, DefaultSubnetNodeParamLimit>>,
    c: Option<BoundedVec<u8, DefaultSubnetNodeParamLimit>>,
)

For example, in the Hypertensor DSN standard, each subnet node must stake on-chain to verify its proof-of-stake before being authenticated to enter the subnet. Once the subnet is registered on-chain, it will then enter using the CLI within the subnet before activating itself on-chain.

After registering, the subnet node has up to the MaxSubnetNodeRegistrationEpochsto activate before removal on the first attested epoch following the MaxSubnetNodeRegistrationEpochs.

For example, in Python:

def register_subnet_node(
  substrate: SubstrateInterface,
  keypair: Keypair,
  subnet_id: int,
  peer_id: str,
  bootstrap_peer_id: str,
  stake_to_be_added: int,
  a: Optional[str] = None,
  b: Optional[str] = None,
  c: Optional[str] = None,
) -> ExtrinsicReceipt:
  call = substrate.compose_call(
    call_module='Network',
    call_function='register_subnet_node',
    call_params={
      'subnet_id': subnet_id,
      'peer_id': peer_id,
      'bootstrap_peer_id': bootstrap_peer_id,
      'stake_to_be_added': stake_to_be_added,
      'a': a,
      'b': b,
      'c': c,
    }
  )

  extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)

  @retry(wait=wait_exponential(multiplier=1, min=4, max=10), stop=stop_after_attempt(4))
  def submit_extrinsic():
    try:
      receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
      return receipt
    except SubstrateRequestException as e:
      print("Failed to send: {}".format(e))

  return submit_extrinsic()
PreviousSubnet NodesNextActivation

Last updated 1 month ago