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

bump to latest sa rc #2617

Merged
merged 12 commits into from
Feb 20, 2025
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
17 changes: 10 additions & 7 deletions cmd/blockchaincmd/add_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import (
"time"

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

"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/utils/units"

"github.com/ethereum/go-ethereum/common"

"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/contract"
Expand All @@ -29,12 +23,16 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-cli/pkg/validatormanager"
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
"github.com/ava-labs/avalanche-cli/sdk/validator"
"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
avagoconstants "github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/units"
warpMessage "github.com/ava-labs/avalanchego/vms/platformvm/warp/message"
"github.com/ethereum/go-ethereum/common"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -177,7 +175,8 @@ func addValidator(_ *cobra.Command, args []string) error {
clusterNameFlagValue = sc.Networks[network.Name()].ClusterName
}

fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.AddSubnetValidatorFee
// TODO: will estimate fee in subsecuent PR
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
"to pay for transaction fees on P-Chain",
Expand Down Expand Up @@ -501,7 +500,10 @@ func CallAddValidator(
if err != nil {
return err
}
aggregatorCtx, aggregatorCancel := sdkutils.GetTimedContext(constants.SignatureAggregatorTimeout)
defer aggregatorCancel()
signedMessage, validationID, err := validatormanager.InitValidatorRegistration(
aggregatorCtx,
app,
network,
rpcURL,
Expand Down Expand Up @@ -543,6 +545,7 @@ func CallAddValidator(
}

if err := validatormanager.FinishValidatorRegistration(
aggregatorCtx,
app,
network,
rpcURL,
Expand Down
3 changes: 2 additions & 1 deletion cmd/blockchaincmd/change_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func changeOwner(_ *cobra.Command, args []string) error {
return err
}

fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.TxFee
// TODO: will estimate fee in subsecuent PR
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
"pay fees",
Expand Down
3 changes: 2 additions & 1 deletion cmd/blockchaincmd/change_weight.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func setWeight(_ *cobra.Command, args []string) error {
return err
}

fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.TxFee
// TODO: will estimate fee in subsecuent PR
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
"to pay for transaction fees on P-Chain",
Expand Down
5 changes: 5 additions & 0 deletions cmd/blockchaincmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-cli/pkg/vm"
blockchainSDK "github.com/ava-labs/avalanche-cli/sdk/blockchain"
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
validatorManagerSDK "github.com/ava-labs/avalanche-cli/sdk/validatormanager"
"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/config"
Expand Down Expand Up @@ -330,9 +331,12 @@ func InitializeValidatorManager(blockchainName,
if err != nil {
return tracked, err
}
aggregatorCtx, aggregatorCancel := sdkutils.GetTimedContext(constants.SignatureAggregatorTimeout)
defer aggregatorCancel()
if pos {
ux.Logger.PrintToUser("Initializing Native Token Proof of Stake Validator Manager contract on blockchain %s ...", blockchainName)
if err := subnetSDK.InitializeProofOfStake(
aggregatorCtx,
network,
genesisPrivateKey,
extraAggregatorPeers,
Expand All @@ -355,6 +359,7 @@ func InitializeValidatorManager(blockchainName,
} else {
ux.Logger.PrintToUser("Initializing Proof of Authority Validator Manager contract on blockchain %s ...", blockchainName)
if err := subnetSDK.InitializeProofOfAuthority(
aggregatorCtx,
network,
genesisPrivateKey,
extraAggregatorPeers,
Expand Down
9 changes: 3 additions & 6 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,13 +552,10 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
}
}

// TODO: will estimate fee in subsecuent PR
// !subnetonly: add blockchain fee
// createSubnet: add subnet fee
fee := uint64(0)
if !subnetOnly {
fee += network.GenesisParams().TxFeeConfig.StaticFeeConfig.CreateBlockchainTxFee
}
if createSubnet {
fee += network.GenesisParams().TxFeeConfig.StaticFeeConfig.CreateSubnetTxFee
}

kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
Expand Down
2 changes: 1 addition & 1 deletion cmd/blockchaincmd/prompt_genesis_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func generateNewNodeAndBLS() (string, string, string, error) {
if err != nil {
return "", "", "", err
}
blsSignerKey, err := bls.NewSecretKey()
blsSignerKey, err := bls.NewSigner()
if err != nil {
return "", "", "", err
}
Expand Down
9 changes: 8 additions & 1 deletion cmd/blockchaincmd/remove_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-cli/pkg/validatormanager"
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
validatormanagerSDK "github.com/ava-labs/avalanche-cli/sdk/validatormanager"
"github.com/ava-labs/avalanchego/genesis"
"github.com/ava-labs/avalanchego/ids"
Expand Down Expand Up @@ -98,7 +99,8 @@ func removeValidator(_ *cobra.Command, args []string) error {
if network.ClusterName != "" {
network = models.ConvertClusterToNetwork(network)
}
fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.TxFee
// TODO: will estimate fee in subsecuent PR
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
"to pay for transaction fees on P-Chain",
Expand Down Expand Up @@ -287,8 +289,11 @@ func removeValidatorSOV(
signedMessage *warp.Message
validationID ids.ID
)
aggregatorCtx, aggregatorCancel := sdkutils.GetTimedContext(constants.SignatureAggregatorTimeout)
defer aggregatorCancel()
// try to remove the validator. If err is "delegator ineligible for rewards" confirm with user and force remove
signedMessage, validationID, err = validatormanager.InitValidatorRemoval(
aggregatorCtx,
app,
network,
rpcURL,
Expand All @@ -313,6 +318,7 @@ func removeValidatorSOV(
return fmt.Errorf("validator %s is not eligible for rewards. Use --force flag to force removal", nodeID)
}
signedMessage, validationID, err = validatormanager.InitValidatorRemoval(
aggregatorCtx,
app,
network,
rpcURL,
Expand Down Expand Up @@ -351,6 +357,7 @@ func removeValidatorSOV(
}

if err := validatormanager.FinishValidatorRemoval(
aggregatorCtx,
app,
network,
rpcURL,
Expand Down
2 changes: 1 addition & 1 deletion cmd/blockchaincmd/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func printPublicValidators(subnetID ids.ID, network models.Network) error {
}

func printValidatorsFromList(validators []platformvm.ClientPermissionlessValidator) error {
header := []string{"NodeID", "Stake Amount", "Delegator Weight", "Start Time", "End Time", "Type"}
header := []string{"NodeID", "Weight", "Delegator Weight", "Start Time", "End Time", "Type"}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader(header)
table.SetRowLine(true)
Expand Down
5 changes: 5 additions & 0 deletions cmd/contractcmd/init_validator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-cli/pkg/validatormanager"
blockchainSDK "github.com/ava-labs/avalanche-cli/sdk/blockchain"
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
validatorManagerSDK "github.com/ava-labs/avalanche-cli/sdk/validatormanager"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/logging"
Expand Down Expand Up @@ -194,10 +195,13 @@ func initValidatorManager(_ *cobra.Command, args []string) error {
OwnerAddress: &ownerAddress,
RPC: validatorManagerFlags.rpcEndpoint,
}
aggregatorCtx, aggregatorCancel := sdkutils.GetTimedContext(constants.SignatureAggregatorTimeout)
defer aggregatorCancel()
switch {
case sc.PoA(): // PoA
ux.Logger.PrintToUser(logging.Yellow.Wrap("Initializing Proof of Authority Validator Manager contract on blockchain %s"), blockchainName)
if err := validatormanager.SetupPoA(
aggregatorCtx,
subnetSDK,
network,
privateKey,
Expand All @@ -215,6 +219,7 @@ func initValidatorManager(_ *cobra.Command, args []string) error {
initPOSManagerFlags.rewardCalculatorAddress = validatorManagerSDK.RewardCalculatorAddress
}
if err := validatormanager.SetupPoS(
aggregatorCtx,
subnetSDK,
network,
privateKey,
Expand Down
13 changes: 4 additions & 9 deletions cmd/keycmd/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
"github.com/ava-labs/avalanchego/wallet/subnet/primary"
"github.com/ava-labs/avalanchego/wallet/subnet/primary/common"
"github.com/ava-labs/coreth/plugin/evm"
"github.com/ava-labs/coreth/plugin/evm/atomic"
goethereumcommon "github.com/ethereum/go-ethereum/common"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -593,12 +593,7 @@ func pToPSend(
return err
}
pContext := wallet.P().Builder().Context()
var pFeeCalculator avagofee.Calculator
if pContext.GasPrice != 0 {
pFeeCalculator = avagofee.NewDynamicCalculator(pContext.ComplexityWeights, pContext.GasPrice)
} else {
pFeeCalculator = avagofee.NewStaticCalculator(pContext.StaticFeeConfig)
}
pFeeCalculator := avagofee.NewDynamicCalculator(pContext.ComplexityWeights, pContext.GasPrice)
txFee, err := pFeeCalculator.CalculateFee(unsignedTx)
if err != nil {
return err
Expand Down Expand Up @@ -809,7 +804,7 @@ func importIntoC(
if err != nil {
return fmt.Errorf("error building tx: %w", err)
}
tx := evm.Tx{UnsignedAtomicTx: unsignedTx}
tx := atomic.Tx{UnsignedAtomicTx: unsignedTx}
if err := wallet.C().Signer().SignAtomic(context.Background(), &tx); err != nil {
return fmt.Errorf("error signing tx: %w", err)
}
Expand Down Expand Up @@ -918,7 +913,7 @@ func exportFromC(
if err != nil {
return fmt.Errorf("error building tx: %w", err)
}
tx := evm.Tx{UnsignedAtomicTx: unsignedTx}
tx := atomic.Tx{UnsignedAtomicTx: unsignedTx}
if err := wallet.C().Signer().SignAtomic(context.Background(), &tx); err != nil {
return fmt.Errorf("error signing tx: %w", err)
}
Expand Down
32 changes: 18 additions & 14 deletions cmd/nodecmd/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,31 @@ import (
"strings"
"time"

"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/api"

"github.com/ava-labs/avalanchego/api/info"

"github.com/ava-labs/avalanche-cli/pkg/blockchain"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/subnet"
"github.com/ava-labs/avalanche-cli/pkg/validatormanager"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/formatting/address"
warpMessage "github.com/ava-labs/avalanchego/vms/platformvm/warp/message"

"github.com/ava-labs/avalanche-cli/pkg/binutils"
"github.com/ava-labs/avalanche-cli/pkg/blockchain"
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/contract"
"github.com/ava-labs/avalanche-cli/pkg/keychain"
"github.com/ava-labs/avalanche-cli/pkg/models"
"github.com/ava-labs/avalanche-cli/pkg/networkoptions"
"github.com/ava-labs/avalanche-cli/pkg/node"
"github.com/ava-labs/avalanche-cli/pkg/prompts"
"github.com/ava-labs/avalanche-cli/pkg/subnet"
"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-cli/pkg/validatormanager"
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/formatting/address"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/api"
warpMessage "github.com/ava-labs/avalanchego/vms/platformvm/warp/message"

"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -322,7 +321,8 @@ func localValidate(_ *cobra.Command, args []string) error {
return err
}

fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.AddSubnetValidatorFee
// TODO: will estimate fee in subsecuent PR
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
"to pay for transaction fees on P-Chain",
Expand Down Expand Up @@ -540,7 +540,10 @@ func addAsValidator(network models.Network,
return fmt.Errorf("failure parsing BLS info: %w", err)
}

aggregatorCtx, aggregatorCancel := sdkutils.GetTimedContext(constants.SignatureAggregatorTimeout)
defer aggregatorCancel()
signedMessage, validationID, err := validatormanager.InitValidatorRegistration(
aggregatorCtx,
app,
network,
rpcURL,
Expand Down Expand Up @@ -583,6 +586,7 @@ func addAsValidator(network models.Network,
}

if err := validatormanager.FinishValidatorRegistration(
aggregatorCtx,
app,
network,
rpcURL,
Expand Down
4 changes: 3 additions & 1 deletion cmd/nodecmd/validate_primary.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ func validatePrimaryNetwork(_ *cobra.Command, args []string) error {
hosts := clusterConfig.GetValidatorHosts(allHosts) // exlude api nodes
defer node.DisconnectHosts(hosts)

fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.AddPrimaryNetworkValidatorFee * uint64(len(hosts))
// TODO: will estimate fee in subsecuent PR
// AddPrimaryNetworkValidatorFee * uint64(len(hosts))
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
constants.PayTxsFeesMsg,
Expand Down
4 changes: 3 additions & 1 deletion cmd/nodecmd/validate_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ func validateSubnet(_ *cobra.Command, args []string) error {
nonPrimaryValidators++
}
}
fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.AddPrimaryNetworkValidatorFee*uint64(nonPrimaryValidators) + network.GenesisParams().TxFeeConfig.StaticFeeConfig.AddSubnetValidatorFee*uint64(len(hosts))
// TODO: will estimate fee in subsecuent PR
// AddPrimaryNetworkValidatorFee*uint64(nonPrimaryValidators) + AddSubnetValidatorFee*uint64(len(hosts))
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
constants.PayTxsFeesMsg,
Expand Down
3 changes: 2 additions & 1 deletion cmd/primarycmd/add_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ func addValidator(_ *cobra.Command, _ []string) error {
return fmt.Errorf("illegal weight, must be greater than or equal to %d: %d", minValStake, weight)
}

fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.AddPrimaryNetworkValidatorFee
// TODO: will estimate fee in subsecuent PR
fee := uint64(0)
kc, err := keychain.GetKeychain(app, false, useLedger, ledgerAddresses, keyName, network, fee)
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion cmd/validatorcmd/increaseBalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func increaseBalance(_ *cobra.Command, _ []string) error {
return fmt.Errorf("the specified node is not a L1 validator")
}

fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.TxFee
// TODO: will estimate fee in subsecuent PR
fee := uint64(0)
kc, err := keychain.GetKeychainFromCmdLineFlags(
app,
constants.PayTxsFeesMsg,
Expand Down
Loading
Loading