Skip to content

feat: add subnet add-validator + align P-Chain command names with avalanchego tx types#33

Open
owenwahlgren wants to merge 3 commits into
mainfrom
feature/subnet-add-validator
Open

feat: add subnet add-validator + align P-Chain command names with avalanchego tx types#33
owenwahlgren wants to merge 3 commits into
mainfrom
feature/subnet-add-validator

Conversation

@owenwahlgren

@owenwahlgren owenwahlgren commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

What

Two related changes:

1. New command: subnet add-validator

Adds a validator to a permissioned subnet via AddSubnetValidatorTx — the gap where the CLI could add primary-network validators and L1 validators but not permissioned-subnet validators.

platform subnet add-validator \
  --subnet-id <SubnetID> --node-id NodeID-... --weight 100 \
  [--start now] [--duration 336h] --key-name <subnet-owner-key>
  • Node must already validate the primary network; validation window must fit within it.
  • Subnet owner authorizes via subnet auth (wallet loaded tracking the subnet).
  • --weight is sampling weight, not a stake amount.

2. Align command names with avalanchego tx types

Every P-Chain command now maps 1:1 to the avalanchego transaction it issues. Old names are kept as deprecated aliases that still work and print a warning pointing at the canonical name.

Old New (canonical) Tx type
validator add validator add-permissionless AddPermissionlessValidatorTx
validator delegate validator add-permissionless-delegator AddPermissionlessDelegatorTx
subnet convert-l1 subnet convert-to-l1 ConvertSubnetToL1Tx
l1 set-weight l1 set-validator-weight SetL1ValidatorWeightTx
l1 add-balance l1 increase-validator-balance IncreaseL1ValidatorBalanceTx

Unchanged (already canonical): subnet create, subnet transfer-ownership, subnet add-validator, l1 register-validator, l1 disable-validator, chain create. transfer send/export/import map to the generic BaseTx/ExportTx/ImportTx and are left as-is.

Each command's --help now also names the tx it issues, e.g.:

add-permissionless   Add a primary network validator (AddPermissionlessValidatorTx)

Deprecation warning example:

$ platform validator add ...
Warning: "add" is deprecated; use "platform validator add-permissionless" instead.

Changes

  • pkg/pchain: AddSubnetValidator + AddSubnetValidatorConfig + addSubnetValidatorTxIssuer seam (matches the existing interface-based issue*Tx pattern). pchain function names already mirrored the tx types.
  • cmd/: command renames + Aliases + warnIfDeprecatedAlias helper (in root.go); tx-type annotations in Short help.
  • Tests: TestIssueAddSubnetValidatorTx (unit); e2e coverage for the new command, the renamed help lists, and TestCLIDeprecatedAliasWarns.
  • Docs: docs/usage.md, docs/pchain-operations.md, CLAUDE.md.

Backward compatibility

No breaking changes — all old command names continue to work via aliases (with a deprecation warning).

Testing

  • go build, go vet ./..., staticcheck ./..., gofmt — clean
  • go test ./pkg/... — pass
  • go test -tags clie2e ./e2e/... -run "Help|MissingArgs|Params|DeprecatedAlias|EmptyValidators" — pass

Branched off origin/main, independent of the open ACP-236 PR.

Adds a validator to a permissioned subnet via AddSubnetValidatorTx, the
classic path for managing validators on a permissioned subnet (distinct
from `l1 register-validator`, which targets converted L1s).

- pkg/pchain: AddSubnetValidator + issuer seam/config, mirroring the
  existing interface-based issue*Tx helpers
- cmd/subnet: `subnet add-validator` with --subnet-id/--node-id/--weight
  /--start/--duration; subnet owner authorizes via subnet auth, so the
  wallet is loaded tracking the subnet
- tests: pchain unit test + e2e help/missing-args coverage
- docs: usage.md and pchain-operations.md
Rename commands so each maps 1:1 to the avalanchego transaction it issues,
keeping the previous names as deprecated aliases (a warning is printed when
an alias is used). pchain function names already matched the tx types.

Renames (old name kept as alias):
- validator add            -> validator add-permissionless
- validator delegate       -> validator add-permissionless-delegator
- subnet convert-l1        -> subnet convert-to-l1
- l1 set-weight            -> l1 set-validator-weight
- l1 add-balance           -> l1 increase-validator-balance

Also annotates each command's Short help with its tx type, adds a shared
warnIfDeprecatedAlias helper, an e2e alias-deprecation test, and updates
docs (usage.md, pchain-operations.md) and CLAUDE.md.
@owenwahlgren owenwahlgren changed the title feat: add subnet add-validator command (AddSubnetValidatorTx) feat: add subnet add-validator + align P-Chain command names with avalanchego tx types Jun 16, 2026
BREAKING CHANGE: the previous command names are removed entirely (no
aliases). Old names now error with "unknown command". Migrate:
- validator add        -> validator add-permissionless
- validator delegate   -> validator add-permissionless-delegator
- subnet convert-l1    -> subnet convert-to-l1
- l1 set-weight        -> l1 set-validator-weight
- l1 add-balance       -> l1 increase-validator-balance

- drop Aliases + warnIfDeprecatedAlias helper
- command groups (validator/subnet/l1) now reject unknown subcommands
  via requireSubcommand so removed names fail loudly (exit 1)
- e2e: assert old names are rejected; docs reframed as v2.0.0 migration
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.

2 participants