Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Subnet to L1 for new commands ACP77 #2209

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/blockchaincmd/add_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
}

// TODO: implement getting validator manager controller address
//kcKeys, err := kc.PChainFormattedStrAddresses()

Check failure on line 195 in cmd/blockchaincmd/add_validator.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)
//if err != nil {
// return err
//}
Expand Down Expand Up @@ -223,7 +223,7 @@
ux.Logger.PrintToUser("Change Address: %s", changeAddr)
ux.Logger.PrintToUser("Inputs complete, issuing transaction to add the provided validator information...")

//type RegisterSubnetValidatorTx struct {

Check failure on line 226 in cmd/blockchaincmd/add_validator.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)
// // Metadata, inputs and outputs
// BaseTx
// // Balance <= sum($AVAX inputs) - sum($AVAX outputs) - TxFee.
Expand Down Expand Up @@ -267,7 +267,7 @@
if err != nil {
return err
}
tx, err := deployer.RegisterSubnetValidator(balance, blsInfo, changeOwner, message)
tx, err := deployer.RegisterL1Validator(balance, blsInfo, changeOwner, message)
if err != nil {
return err
}
Expand All @@ -275,7 +275,7 @@
return nil
}

func generateWarpMessageAddValidator(SubnetID ids.ID, NodeID ids.NodeID, weight uint64, blsPublicKey string, expiry uint64) (warpPlatformVM.Message, error) {

Check failure on line 278 in cmd/blockchaincmd/add_validator.go

View workflow job for this annotation

GitHub Actions / Lint

captLocal: `SubnetID' should not be capitalized (gocritic)
return warpPlatformVM.Message{}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/blockchaincmd/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ manage your Blockchain configurations and live deployments.`,
// subnet changeOwner
cmd.AddCommand(newChangeOwnerCmd())
// subnet changeWeight
cmd.AddCommand(newChangeWeightCmd())
cmd.AddCommand(newSetWeightCmd())
return cmd
}
14 changes: 7 additions & 7 deletions cmd/blockchaincmd/change_weight.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import (
"errors"
"fmt"

Check failure on line 7 in cmd/blockchaincmd/change_weight.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofumpt`-ed (gofumpt)
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/keychain"
Expand All @@ -18,17 +18,17 @@
"os"
)

var ()

Check failure on line 21 in cmd/blockchaincmd/change_weight.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofmt`-ed with `-s` (gofmt)

// avalanche blockchain addValidator
func newChangeWeightCmd() *cobra.Command {
// avalanche blockchain setWeight
func newSetWeightCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "changeWeight [blockchainName] [nodeID]",
Short: "Changes the weight of a Subnet validator",
Long: `The blockchain changeWeight command changes the weight of a Subnet Validator.
Use: "setWeight [blockchainName] [nodeID]",
Short: "Updates the weight of a Subnet validator",
Long: `The blockchain changeWeight command updates the weight of a Subnet Validator.

The Subnet has to be a Proof of Authority Subnet-Only Validator Subnet.`,
RunE: updateWeight,
RunE: setWeight,
Args: cobrautils.ExactArgs(2),
}
networkoptions.AddNetworkFlagsToCmd(cmd, &globalNetworkFlags, true, addValidatorSupportedNetworkOptions)
Expand All @@ -41,7 +41,7 @@
return cmd
}

func updateWeight(_ *cobra.Command, args []string) error {
func setWeight(_ *cobra.Command, args []string) error {
blockchainName := args[0]
_, err := ids.NodeIDFromString(args[1])
if err != nil {
Expand Down
36 changes: 19 additions & 17 deletions cmd/blockchaincmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@
"github.com/spf13/cobra"
)

// avalanche blockchain convert
// avalanche l1 convert
func newConvertCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "convert [blockchainName]",
Short: "Converts an Avalanche blockchain into a SOV (Subnet Only Validator) blockchain",
Long: `The blockchain convert command converts a non-SOV Avalanche blockchain (which requires
subnet validators to have at least 2000 AVAX staked in the Primary Network) into a SOV (Subnet Only
Validator) blockchain.
Use: "convert [l1Name]",
Short: "Converts an Avalanche L1 into a SOV (Subnet Only Validator) L1",
Long: `The l1 convert command converts a non-SOV Avalanche L1 (which requires subnet
validators to have at least 2000 AVAX staked in the Primary Network) into an SOV (Subnet Only
Validator) L1.

At the end of the call, the Owner Keys .
Once an L1 is successfully converted into a an SOV, the Owner Keys can no longer be used to modify
the L1's validator set. In addition, AddSubnetValidatorTx is disabled on the Subnet going forward.
The only action that the Owner key is able to take is removing any L1 validators that were added
using AddSubnetValidatorTx previously via RemoveSubnetValidatorTx.

Avalanche-CLI only supports deploying an individual Blockchain once per network. Subsequent
attempts to deploy the same Blockchain to the same network (local, Fuji, Mainnet) aren't
allowed. If you'd like to redeploy a Blockchain locally for testing, you must first call
avalanche network clean to reset all deployed chain state. Subsequent local deploys
redeploy the chain with fresh state. You can deploy the same Blockchain to multiple networks,
so you can take your locally tested Subnet and deploy it on Fuji or Mainnet.`,
RunE: convertSubnet,
Unless removed by the Owner key, any Subnet Validators added previously with an AddSubnetValidatorTx
will continue to validate the Subnet until their End time is reached. Once all Subnet Validators
added with AddSubnetValidatorTx are no longer in the validator set, the Owner key is powerless.
RegisterL1ValidatorTx and SetL1ValidatorWeightTx must be used to manage the Subnet's
validator set going forward.`,
RunE: convertL1,
PersistentPostRun: handlePostRun,
Args: cobrautils.ExactArgs(1),
}
Expand Down Expand Up @@ -58,9 +60,9 @@
return cmd
}

// // convertSubnet is the cobra command run for deploying subnets
func convertSubnet(cmd *cobra.Command, args []string) error {
// // convertL1 is the cobra command run for deploying subnets
func convertL1(cmd *cobra.Command, args []string) error {
//blockchainName := args[0]

Check failure on line 65 in cmd/blockchaincmd/convert.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)
//
//if err := CreateBlockchainFirst(cmd, blockchainName, skipCreatePrompt); err != nil {
// return err
Expand Down Expand Up @@ -387,7 +389,7 @@
//// return err
////}
//// TODO: replace with avalanchego subnetValidators once implemented
//isFullySigned, convertSubnetTxID, tx, remainingSubnetAuthKeys, err := deployer.ConvertSubnet(
//isFullySigned, convertSubnetTxID, tx, remainingSubnetAuthKeys, err := deployer.ConvertL1(
// controlKeys,
// subnetAuthKeys,
// subnetID,
Expand Down
6 changes: 3 additions & 3 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,12 @@
// SubnetAuth verify.Verifiable `json:"subnetAuthorization"`
// }

//avaGoBootstrapValidators, err := convertToAvalancheGoSubnetValidator(bootstrapValidators)

Check failure on line 627 in cmd/blockchaincmd/deploy.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)
//if err != nil {
// return err
//}
// TODO: replace with avalanchego subnetValidators once implemented
isFullySigned, convertSubnetTxID, tx, remainingSubnetAuthKeys, err := deployer.ConvertSubnet(
isFullySigned, ConvertL1TxID, tx, remainingSubnetAuthKeys, err := deployer.ConvertL1(
controlKeys,
subnetAuthKeys,
subnetID,
Expand All @@ -643,11 +643,11 @@
}

savePartialTx = !isFullySigned && err == nil
ux.Logger.PrintToUser("ConvertSubnetTx ID: %s", convertSubnetTxID)
ux.Logger.PrintToUser("ConvertL1Tx ID: %s", ConvertL1TxID)

if savePartialTx {
if err := SaveNotFullySignedTx(
"ConvertSubnetTx",
"ConvertL1Tx",
tx,
chain,
subnetAuthKeys,
Expand Down
2 changes: 1 addition & 1 deletion cmd/blockchaincmd/remove_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func removeValidatorSOV(deployer *subnet.PublicDeployer, network models.Network,
if err != nil {
return err
}
tx, err := deployer.SetSubnetValidatorWeight(message)
tx, err := deployer.SetL1ValidatorWeight(message)
if err != nil {
return err
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/subnet/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@
// // - Weight
// Message warp.Message `json:"message"`
// }
func (d *PublicDeployer) SetSubnetValidatorWeight(
func (d *PublicDeployer) SetL1ValidatorWeight(

Check warning on line 126 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-receiver: method receiver 'd' is not referenced in method's body, consider removing or renaming it as _ (revive)
message warp.Message,

Check warning on line 127 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'message' seems to be unused, consider removing or renaming it as _ (revive)
) (*txs.Tx, error) {
// create tx
//unsignedTx, err := wallet.P().Builder().NewSetSubnetValidatorWeightTx(args...)
//unsignedTx, err := wallet.P().Builder().NewSetL1ValidatorWeightTx(args...)

Check failure on line 130 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)
//if err != nil {
// return nil, fmt.Errorf("error building tx: %w", err)
//}
Expand All @@ -141,14 +141,14 @@
return nil, nil
}

func (d *PublicDeployer) RegisterSubnetValidator(
func (d *PublicDeployer) RegisterL1Validator(

Check warning on line 144 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-receiver: method receiver 'd' is not referenced in method's body, consider removing or renaming it as _ (revive)
balance uint64,

Check warning on line 145 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'balance' seems to be unused, consider removing or renaming it as _ (revive)
signer signer.Signer,

Check warning on line 146 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'signer' seems to be unused, consider removing or renaming it as _ (revive)
changeOwner fx.Owner,

Check warning on line 147 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'changeOwner' seems to be unused, consider removing or renaming it as _ (revive)
message warp.Message,

Check warning on line 148 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'message' seems to be unused, consider removing or renaming it as _ (revive)
) (*txs.Tx, error) {
// create tx
//unsignedTx, err := wallet.P().Builder().NewRegisterSubnetValidatorTx(args...)
//unsignedTx, err := wallet.P().Builder().NewRegisterL1ValidatorTx(args...)

Check failure on line 151 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)
//if err != nil {
// return nil, fmt.Errorf("error building tx: %w", err)
//}
Expand Down Expand Up @@ -411,15 +411,15 @@
return isFullySigned, id, tx, remainingSubnetAuthKeys, nil
}

// TODO: update ConvertSubnet once avalanchego implementation is up for ACP77
func (d *PublicDeployer) ConvertSubnet(
// TODO: update ConvertL1 once avalanchego implementation is up for ACP77
func (d *PublicDeployer) ConvertL1(
controlKeys []string,
subnetAuthKeysStrs []string,
subnetID ids.ID,
chainID ids.ID,
// validators []blockchaincmd.SubnetValidator,
) (bool, ids.ID, *txs.Tx, []string, error) {
ux.Logger.PrintToUser("Now calling ConvertSubnet Tx...")
ux.Logger.PrintToUser("Now calling ConvertL1 Tx...")

wallet, err := d.loadCacheWallet(subnetID)
if err != nil {
Expand All @@ -431,12 +431,12 @@
return false, ids.Empty, nil, nil, fmt.Errorf("failure parsing subnet auth keys: %w", err)
}

showLedgerSignatureMsg(d.kc.UsesLedger, d.kc.HasOnlyOneKey(), "ConvertSubnet transaction")
showLedgerSignatureMsg(d.kc.UsesLedger, d.kc.HasOnlyOneKey(), "ConvertL1 transaction")

var validatorManagerAddress []byte
// var validators []avalanchego.SubnetValidator

tx, err := d.createConvertSubnetTx(subnetAuthKeys, subnetID, chainID, validatorManagerAddress, wallet)
tx, err := d.createConvertL1Tx(subnetAuthKeys, subnetID, chainID, validatorManagerAddress, wallet)
if err != nil {
return false, ids.Empty, nil, nil, err
}
Expand Down Expand Up @@ -605,17 +605,17 @@
return &tx, nil
}

func (d *PublicDeployer) createConvertSubnetTx(
func (d *PublicDeployer) createConvertL1Tx(

Check warning on line 608 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-receiver: method receiver 'd' is not referenced in method's body, consider removing or renaming it as _ (revive)
subnetAuthKeys []ids.ShortID,

Check warning on line 609 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'subnetAuthKeys' seems to be unused, consider removing or renaming it as _ (revive)
subnetID ids.ID,

Check warning on line 610 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'subnetID' seems to be unused, consider removing or renaming it as _ (revive)
chainID ids.ID,
address []byte,
// validators []avalanchego.SubnetValidator,
wallet primary.Wallet,
) (*txs.Tx, error) {
//fxIDs := make([]ids.ID, 0)

Check failure on line 616 in pkg/subnet/public.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)
//options := d.getMultisigTxOptions(subnetAuthKeys)
//unsignedTx, err := wallet.P().Builder().NewConvertSubnetTx(
//unsignedTx, err := wallet.P().Builder().NewConvertL1Tx(
// subnetID,
//chainID,
//address,
Expand Down
Loading