Repository navigation
Description
Problem
ADR 019 Phase 2.1/2.2 require an operator to approve TOKEN, bond it, and declareMbps before registerNode (#929). There is no command for this — operators must hand-compute the bond amount (k × Mbps^α) and submit three transactions in order.
Decision: one idempotent command, not flags on register
bond() is additive (activeBond += amount) while registerNode() is one-shot. Bundling them into register would make a partial failure (bond lands, declareMbps reverts) unsafe to retry — a re-run would double-bond. So this is a separate command, split at the contract's real transaction boundary, matching the repo's one-subcommand-per-operation convention.
decdn node bond --mbps <N>
Idempotent "stake to capacity tier N". The operator passes only --mbps; the TOKEN amount is computed from the contract so nobody hand-calculates the curve.
- Read
bondRequired(N),activeBond(operator),minBond(),declaredMbps(operator),token(), and the current ERC20allowancefrom chain. target = max(minBond, bondRequired(N))(registerNode needsactiveBond ≥ minBondAND≥ bondRequired(declaredMbps)).shortfall = target.saturating_sub(activeBond). Ifshortfall > 0: checktoken.balanceOf(operator) ≥ shortfall(clear error otherwise),approvethe shortfall ifallowance < shortfall, thenbond(shortfall)— top up to target, never a flat re-bond, so re-running after a partial failure converges instead of over-bonding.declareMbps(N)unlessdeclaredMbps(operator) == Nalready (skip the pointless tx).- Report tier, prior/target bond, amount bonded, and tx hashes.
--dry-runprints the plan without submitting;--jsonfor machine output.
Band validation ([minCapacityMbps, maxCapacityMbps]) is left to the on-chain declareMbps revert (DeclaredCapacityOutOfBand) rather than re-checked client-side.
Implementation notes
- Stacks on the
decdn node registerbranch (Implementdecdn node register(ADR 019 §2.3 on-chain node registration) #929 / PR feat(cli): adddecdn node registerfor on-chain node registration (#929) #931): extract the shared chain plumbing (config-coordinate resolution, keystore-signer loading, wallet-provider build) fromregister.rsinto a sharedcommandsmodule both consume. - Extend the
CapacityBondsol!bindings (crates/incentive/src/capacity_bond.rs) withtoken(),activeBond,minBond,declaredMbps,bondRequired, and the writesbond/declareMbps. Reusedecdn_incentive::erc20::Erc20forallowance/approve/balanceOf. - Operator flow becomes two commands:
decdn node bond --mbps 1000thendecdn node register --region DE --multiaddr ….
Out of scope
registerNode(Implementdecdn node register(ADR 019 §2.3 on-chain node registration) #929).- The
decdn setupwizard that chains key-gen → bond → register (separate issue).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
feat(cli): add `decdn node bond` — idempotent stake-to-tier (#932)
feat(cli): add `decdn node bond` — idempotent stake-to-tier (#932)
feat(cli): add `decdn node bond` — idempotent stake-to-tier (#932) (#934