-
Notifications
You must be signed in to change notification settings - Fork 86
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
Support PoA ACP99 + Externals EVM signatures for validator setup txs #2650
base: main
Are you sure you want to change the base?
Changes from 14 commits
6df6a16
6904684
7b017c9
72cdb89
bb529dd
b7da868
bb1beb5
40ff358
242e2ce
2e2792a
df36580
0b9553f
a3c9f08
76776e3
d619ad2
f31af89
23b1ef8
d3d540a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import ( | |
"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/evm" | ||
"github.com/ava-labs/avalanche-cli/pkg/keychain" | ||
"github.com/ava-labs/avalanche-cli/pkg/models" | ||
"github.com/ava-labs/avalanche-cli/pkg/networkoptions" | ||
|
@@ -31,31 +32,31 @@ import ( | |
"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" | ||
) | ||
|
||
var ( | ||
nodeIDStr string | ||
nodeEndpoint string | ||
balanceAVAX float64 | ||
weight uint64 | ||
startTimeStr string | ||
duration time.Duration | ||
defaultValidatorParams bool | ||
useDefaultStartTime bool | ||
useDefaultDuration bool | ||
useDefaultWeight bool | ||
waitForTxAcceptance bool | ||
publicKey string | ||
pop string | ||
remainingBalanceOwnerAddr string | ||
disableOwnerAddr string | ||
rpcURL string | ||
aggregatorLogLevel string | ||
aggregatorLogToStdout bool | ||
delegationFee uint16 | ||
|
||
nodeIDStr string | ||
nodeEndpoint string | ||
balanceAVAX float64 | ||
weight uint64 | ||
startTimeStr string | ||
duration time.Duration | ||
defaultValidatorParams bool | ||
useDefaultStartTime bool | ||
useDefaultDuration bool | ||
useDefaultWeight bool | ||
waitForTxAcceptance bool | ||
publicKey string | ||
pop string | ||
remainingBalanceOwnerAddr string | ||
disableOwnerAddr string | ||
rpcURL string | ||
aggregatorLogLevel string | ||
aggregatorLogToStdout bool | ||
delegationFee uint16 | ||
errNoSubnetID = errors.New("failed to find the subnet ID for this subnet, has it been deployed/created on this network?") | ||
errMutuallyExclusiveDurationOptions = errors.New("--use-default-duration/--use-default-validator-params and --staking-period are mutually exclusive") | ||
errMutuallyExclusiveStartOptions = errors.New("--use-default-start-time/--use-default-validator-params and --start-time are mutually exclusive") | ||
|
@@ -65,6 +66,8 @@ var ( | |
aggregatorAllowPrivatePeers bool | ||
clusterNameFlagValue string | ||
createLocalValidator bool | ||
externalValidatorManagerOwner bool | ||
validatorManagerOwner string | ||
) | ||
|
||
const ( | ||
|
@@ -122,8 +125,9 @@ Testnet or Mainnet.`, | |
cmd.Flags().BoolVar(&waitForTxAcceptance, "wait-for-tx-acceptance", true, "(for Subnets, not L1s) just issue the add validator tx, without waiting for its acceptance") | ||
cmd.Flags().Uint16Var(&delegationFee, "delegation-fee", 100, "(PoS only) delegation fee (in bips)") | ||
cmd.Flags().StringVar(&subnetIDstr, "subnet-id", "", "subnet ID (only if blockchain name is not provided)") | ||
cmd.Flags().StringVar(&validatorManagerOwnerAddress, "validator-manager-owner", "", "validator manager owner address (only if blockchain name is not provided)") | ||
cmd.Flags().Uint64Var(&weight, validatorWeightFlag, uint64(constants.DefaultStakeWeight), "set the weight of the validator") | ||
cmd.Flags().StringVar(&validatorManagerOwner, "validator-manager-owner", "", "force using this address to issue transactions to the validator manager") | ||
cmd.Flags().BoolVar(&externalValidatorManagerOwner, "external-validator-manager-owner", false, "validator manager owner is external, make hex dump of ech evm transactions, so they can be signed in a separate flow") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unclear what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or i think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and say in description for multisig or ledger |
||
|
||
return cmd | ||
} | ||
|
@@ -404,17 +408,26 @@ func CallAddValidator( | |
return fmt.Errorf("unable to find Validator Manager address") | ||
} | ||
validatorManagerAddress = sc.Networks[network.Name()].ValidatorManagerAddress | ||
ownerPrivateKeyFound, _, _, ownerPrivateKey, err := contract.SearchForManagedKey( | ||
app, | ||
network, | ||
common.HexToAddress(sc.ValidatorManagerOwner), | ||
true, | ||
) | ||
if err != nil { | ||
return err | ||
|
||
if validatorManagerOwner == "" { | ||
validatorManagerOwner = sc.ValidatorManagerOwner | ||
} | ||
if !ownerPrivateKeyFound { | ||
return fmt.Errorf("private key for Validator manager owner %s is not found", sc.ValidatorManagerOwner) | ||
|
||
var ownerPrivateKey string | ||
if !externalValidatorManagerOwner { | ||
var ownerPrivateKeyFound bool | ||
ownerPrivateKeyFound, _, _, ownerPrivateKey, err = contract.SearchForManagedKey( | ||
app, | ||
network, | ||
common.HexToAddress(validatorManagerOwner), | ||
true, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
if !ownerPrivateKeyFound { | ||
return fmt.Errorf("private key for Validator manager owner %s is not found", validatorManagerOwner) | ||
} | ||
} | ||
|
||
pos := sc.PoS() | ||
|
@@ -428,7 +441,14 @@ func CallAddValidator( | |
} | ||
} | ||
} | ||
ux.Logger.PrintToUser(logging.Yellow.Wrap("Validation manager owner %s pays for the initialization of the validator's registration (Blockchain gas token)"), sc.ValidatorManagerOwner) | ||
|
||
if sc.UseACP99 { | ||
ux.Logger.PrintToUser(logging.Yellow.Wrap("Validator Manager Protocol: ACP99")) | ||
} else { | ||
ux.Logger.PrintToUser(logging.Yellow.Wrap("Validator Manager Protocol: v1.0.0")) | ||
} | ||
|
||
ux.Logger.PrintToUser(logging.Yellow.Wrap("Validation manager owner %s pays for the initialization of the validator's registration (Blockchain gas token)"), validatorManagerOwner) | ||
|
||
if rpcURL == "" { | ||
rpcURL, _, err = contract.GetBlockchainEndpoints( | ||
|
@@ -523,12 +543,14 @@ func CallAddValidator( | |
} | ||
aggregatorCtx, aggregatorCancel := sdkutils.GetTimedContext(constants.SignatureAggregatorTimeout) | ||
defer aggregatorCancel() | ||
signedMessage, validationID, err := validatormanager.InitValidatorRegistration( | ||
signedMessage, validationID, rawTx, err := validatormanager.InitValidatorRegistration( | ||
aggregatorCtx, | ||
app, | ||
network, | ||
rpcURL, | ||
chainSpec, | ||
externalValidatorManagerOwner, | ||
validatorManagerOwner, | ||
ownerPrivateKey, | ||
nodeID, | ||
blsInfo.PublicKey[:], | ||
|
@@ -543,10 +565,14 @@ func CallAddValidator( | |
delegationFee, | ||
duration, | ||
validatorManagerAddress, | ||
sc.UseACP99, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
if rawTx != nil { | ||
return evm.TxDump("Initializing Validator Registration", rawTx) | ||
} | ||
ux.Logger.PrintToUser("ValidationID: %s", validationID) | ||
|
||
txID, _, err := deployer.RegisterL1Validator(balance, blsInfo, signedMessage) | ||
|
@@ -566,21 +592,27 @@ func CallAddValidator( | |
|
||
aggregatorCtx, aggregatorCancel = sdkutils.GetTimedContext(constants.SignatureAggregatorTimeout) | ||
defer aggregatorCancel() | ||
if err := validatormanager.FinishValidatorRegistration( | ||
rawTx, err = validatormanager.FinishValidatorRegistration( | ||
aggregatorCtx, | ||
app, | ||
network, | ||
rpcURL, | ||
chainSpec, | ||
externalValidatorManagerOwner, | ||
validatorManagerOwner, | ||
ownerPrivateKey, | ||
validationID, | ||
extraAggregatorPeers, | ||
aggregatorAllowPrivatePeers, | ||
aggregatorLogger, | ||
validatorManagerAddress, | ||
); err != nil { | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
if rawTx != nil { | ||
return evm.TxDump("Finish Validator Registration", rawTx) | ||
} | ||
|
||
ux.Logger.PrintToUser(" NodeID: %s", nodeID) | ||
ux.Logger.PrintToUser(" Network: %s", network.Name()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we technically dont even need to get validator manager using flag anymore. Currently we only get validator manager from on chain if user doesn't provide argument to add validator. But I think its better if we just do this for all cases -> meaning even if user provides argument to add validator. This means that we don't even need
validator-manager-owner
flag anymore in add_validator, same goes forremove_validator
andchange_weight