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

Integrate ConvertSubnetTx AvalancheGo #2213

Merged
merged 17 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
52 changes: 17 additions & 35 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/ava-labs/avalanchego/vms/platformvm/warp/message"
"os"
"path/filepath"
"strings"

"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/vms/platformvm/fx"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"

"github.com/ava-labs/avalanche-cli/pkg/utils"

"github.com/ava-labs/avalanche-cli/pkg/binutils"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
Expand Down Expand Up @@ -607,34 +606,16 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
}

if !sidecar.NotSOV {
arturrez marked this conversation as resolved.
Show resolved Hide resolved
// type ConvertSubnetTx struct {
// // Metadata, inputs and outputs
// BaseTx
// // ID of the Subnet to transform
// // Restrictions:
// // - Must not be the Primary Network ID
// Subnet ids.ID `json:"subnetID"`
// // BlockchainID where the Subnet manager lives
// ChainID ids.ID `json:"chainID"`
// // Address of the Subnet manager
// Address []byte `json:"address"`
// // Initial pay-as-you-go validators for the Subnet
// Validators []SubnetValidator `json:"validators"`
// // Authorizes this conversion
// SubnetAuth verify.Verifiable `json:"subnetAuthorization"`
// }

//avaGoBootstrapValidators, err := convertToAvalancheGoSubnetValidator(bootstrapValidators)
//if err != nil {
// return err
//}
// TODO: replace with avalanchego subnetValidators once implemented
avaGoBootstrapValidators, err := convertToAvalancheGoSubnetValidator(bootstrapValidators)
if err != nil {
return err
}
isFullySigned, convertSubnetTxID, tx, remainingSubnetAuthKeys, err := deployer.ConvertSubnet(
controlKeys,
subnetAuthKeys,
subnetID,
blockchainID,
// avaGoBootstrapValidators,
avaGoBootstrapValidators,
)
if err != nil {
ux.Logger.PrintToUser(logging.Red.Wrap(
Expand Down Expand Up @@ -669,7 +650,7 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
return app.UpdateSidecarNetworks(&sidecar, network, subnetID, blockchainID, "", "", bootstrapValidators)
}

func getBLSInfo(publicKey, proofOfPossesion string) (signer.Signer, error) {
func getBLSInfo(publicKey, proofOfPossesion string) (signer.ProofOfPossession, error) {
type jsonProofOfPossession struct {
PublicKey string
ProofOfPossession string
Expand All @@ -680,18 +661,19 @@ func getBLSInfo(publicKey, proofOfPossesion string) (signer.Signer, error) {
}
popBytes, err := json.Marshal(jsonPop)
if err != nil {
return nil, err
return signer.ProofOfPossession{}, err
}
pop := &signer.ProofOfPossession{}
err = pop.UnmarshalJSON(popBytes)
if err != nil {
return nil, err
return signer.ProofOfPossession{}, err
}
return pop, nil
return *pop, nil
}

func convertToAvalancheGoSubnetValidator(subnetValidators []models.SubnetValidator) ([]SubnetValidator, error) {
bootstrapValidators := []SubnetValidator{}
// TODO: add deactivation owner?
func convertToAvalancheGoSubnetValidator(subnetValidators []models.SubnetValidator) ([]txs.ConvertSubnetValidator, error) {
bootstrapValidators := []txs.ConvertSubnetValidator{}
for _, validator := range subnetValidators {
nodeID, err := ids.NodeIDFromString(validator.NodeID)
if err != nil {
Expand All @@ -705,14 +687,14 @@ func convertToAvalancheGoSubnetValidator(subnetValidators []models.SubnetValidat
if err != nil {
return nil, fmt.Errorf("failure parsing change owner address: %w", err)
}
bootstrapValidator := SubnetValidator{
bootstrapValidator := txs.ConvertSubnetValidator{
NodeID: nodeID,
Weight: validator.Weight,
Balance: validator.Balance,
Signer: blsInfo,
ChangeOwner: &secp256k1fx.OutputOwners{
RemainingBalanceOwner: message.PChainOwner{
Threshold: 1,
Addrs: addrs,
Addresses: addrs,
},
}
bootstrapValidators = append(bootstrapValidators, bootstrapValidator)
Expand Down
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module github.com/ava-labs/avalanche-cli

go 1.22.7
go 1.22.8

require (
github.com/ava-labs/apm v1.0.0
github.com/ava-labs/avalanche-network-runner v1.8.4-0.20240930181211-bfc2f5f85973
github.com/ava-labs/avalanchego v1.11.11
github.com/ava-labs/awm-relayer v1.4.1-0.20240910171125-3c2ae781fb32
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732
github.com/ava-labs/subnet-evm v0.6.9
github.com/aws/aws-sdk-go-v2 v1.30.5
github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20241002194838-cc9f7aeec3db
github.com/ava-labs/awm-relayer v1.4.1-0.20240926140105-25c13e053ed9
github.com/ava-labs/coreth v0.13.8
github.com/ava-labs/subnet-evm v0.6.10
github.com/aws/aws-sdk-go-v2 v1.31.0
github.com/aws/aws-sdk-go-v2/config v1.27.26
github.com/aws/aws-sdk-go-v2/service/ec2 v1.162.0
github.com/chelnak/ysmrr v0.4.0
Expand All @@ -30,7 +30,7 @@ require (
github.com/pborman/ansi v1.0.0
github.com/pingcap/errors v0.11.4
github.com/posthog/posthog-go v1.2.24
github.com/prometheus/client_golang v1.20.3
github.com/prometheus/client_golang v1.20.4
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.1
Expand All @@ -42,7 +42,7 @@ require (
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/mod v0.20.0
golang.org/x/net v0.28.0
golang.org/x/oauth2 v0.21.0
golang.org/x/oauth2 v0.22.0
golang.org/x/sync v0.8.0
golang.org/x/text v0.17.0
google.golang.org/api v0.184.0
Expand All @@ -54,7 +54,7 @@ require (
require (
cloud.google.com/go/auth v0.5.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
Expand All @@ -68,16 +68,16 @@ require (
github.com/ava-labs/teleporter v1.0.7 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.26 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.17 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.17 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect
github.com/aws/aws-sdk-go-v2/service/kms v1.35.7 // indirect
github.com/aws/aws-sdk-go-v2/service/kms v1.36.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.22.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 // indirect
github.com/aws/smithy-go v1.20.4 // indirect
github.com/aws/smithy-go v1.21.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
Expand Down Expand Up @@ -136,7 +136,7 @@ require (
github.com/googleapis/gax-go/v2 v2.12.4 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/rpc v1.2.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
Expand Down Expand Up @@ -221,9 +221,9 @@ require (
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.24.0 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/grpc v1.66.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
Loading
Loading