Skip to content

Implement decdn node register (ADR 019 §2.3 on-chain node registration) #929

Closed

Description

@alpergundogdu

Problem

ADR 019 §2.3 describes the on-chain node-registration step in present tense:

Both signing operations are supported by the decdn CLI (decdn node register prints the required parameters, signs locally, submits the transaction).

But decdn node register does not exist. The CLI only has node {peers,health,status,channels,region-stats,reputation,evict,announce,reload,drain,top} — all of which talk to the loopback admin RPC. There is no command that performs Phase 2 Step 2.3: building the bindingSignature + ed25519Signature and submitting CapacityBond.registerNode(...).

Today an operator must hand-build an EIP-712 BindNodeId signature and an ed25519 ownership signature over keccak256(abi.encodePacked(nodeId, ethAddress, chainId, registrationNonce)), then submit the transaction manually. That is error-prone on a money/security path.

Scope

Implement decdn node register covering only ADR 019 Step 2.3 (the registerNode transaction). Phase 2.1/2.2 (approve / bond / declareMbps) remain separate and are an operator precondition (the contract already reverts registerNode with BondBelowMinimum / BondBelowCurve if the bond is not posted).

The command MUST:

  1. Resolve rpc_url, chain_id, capacity_bond_address, eth_keystore, and data_dir (config file + flag overrides, mirroring the existing node subcommand config resolution).
  2. Load the eth keystore signer (decdn_incentive::eth_identity::load_signer + read_password) and the iroh node SecretKey (decdn_common::identity::load_or_generate). nodeId = the iroh public key.
  3. Read bindingNonce[ethAddress] and registrationNonce[nodeId] from CapacityBond.
  4. Build bindingSignature (EIP-712 BindNodeId{nodeId, bindingNonce}, reusing decdn_incentive::bind_sig) and ed25519Signature (iroh key over the keccak ownership digest).
  5. Pack --multiaddr args into the on-chain (uint16 length, bytes data) format (ADR 019 § Multiaddr encoding).
  6. Submit CapacityBond.registerNode(nodeId, multiaddrs, regionHint, bindingSignature, ed25519Signature), await the receipt, report tx hash + status. Support --dry-run (print the params + signatures without submitting) and --json.

Correctness anchor

The ed25519 ownership digest MUST byte-match CapacityBond._verifyEd25519OwnershipSignature — keccak256(nodeId‖operator‖chainId(uint256 BE)‖registrationNonce(uint64 BE)), 92-byte preimage. The authoritative encoding lives in contracts/test/ed25519-vectors/src/main.rs; pin a Rust unit test against the committed vector constants in contracts/test/CapacityBondRegionE2E.t.sol (REG_NODE_ID / REG_OPERATOR / REG_CHAIN_ID / REG_ED25519_SIG).

Out of scope

  • approve / bond / declareMbps commands (Phase 2.1/2.2).
  • updateMultiaddrs automation and the decdn setup wizard (already deferred in ADR 019 § Deferred & Open).
  • Phase 3 startup state-sync (separate from registration).

Metadata

Metadata

Assignees

Labels

rust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions