Skip to main content

Module node_register

Module node_register 

Source
Expand description

Off-chain construction of the CapacityBond.registerNode signing inputs (ADR 019 § Step 2.3).

Two byte-exact encodings the on-chain CapacityBond depends on:

  • ownership_message_digest reproduces CapacityBond._verifyEd25519OwnershipSignature’s message hash keccak256(abi.encodePacked(nodeId, msg.sender, block.chainid, registrationNonce)). The operator signs this 32-byte digest with the iroh node key; the contract’s Ed25519Verifier treats the digest as the ed25519 message. A drift here makes registerNode revert InvalidEd25519Signature.
  • pack_multiaddrs builds the on-chain multiaddrs bytes field: a sequence of (uint16 length, bytes data) entries (ADR 019 § Multiaddr encoding). The length prefix is big-endian, matching the uint16 reading of the ADR. Nodes learn addresses via cdn/dht/v1 discovery (ADR 022) rather than from this field, so the ADR — not a consumer — is the authority for the format. unpack_multiaddrs is its inverse, read back only by decdn node rotate-key --key eth when it re-registers an operator’s existing addresses from a new Ethereum address.

The EIP-712 BindNodeId half of registration lives in crate::bind_sig and is reused as-is — binding_signing_hash produces the digest the operator signs with the Ethereum key.

Functions§

decode_dial_addrs
Decode the on-chain multiaddrs field into dialable UDP socket addresses, for use as iroh direct-address hints (ADR 001 § Node Discovery). Leniency is per entry: a non-UTF8 entry, or one that is not a /ip4|ip6/<addr>/udp/<port>/quic-v1 QUIC multiaddr, is skipped on its own while the valid entries around it survive. This walks the pack_multiaddrs framing directly rather than through unpack_multiaddrs, whose all-or- nothing contract would drop every entry on the first bad one. Only a length prefix that overruns the buffer stops the walk — past that point the next entry’s position is unknowable — so the entries decoded before it still count. A self-attested address is only ever one dial path among several, so a malformed or partial record can only fail to add a direct path, never remove a peer from the candidate set, leaving iroh discovery and the relay fallback intact.
ownership_message_digest
On-chain ownership-proof digest signed by the iroh node key during registerNode (ADR 019 § Step 2.3).
pack_multiaddrs
Pack QUIC multiaddr strings into the on-chain multiaddrs bytes field: a sequence of (uint16 length, bytes data) entries with big-endian length prefixes (ADR 019 § Multiaddr encoding). An empty slice yields empty bytes, which the contract accepts (a node may rely on the iroh relay / cdn/dht/v1 discovery for reachability until it promotes direct addresses via updateMultiaddrs).
unpack_multiaddrs
Inverse of pack_multiaddrs: decode the on-chain multiaddrs bytes field back into the strings that produced it.