-
Notifications
You must be signed in to change notification settings - Fork 66
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
Acp 77 PoS using sdk/validatorManager #2308
base: acp-77
Are you sure you want to change the base?
Conversation
add support for proxy Contract for PoA
if p.MinimumStakeAmount.Cmp(big.NewInt(0)) < 0 { | ||
return fmt.Errorf("minimum stake amount cannot be negative") | ||
} | ||
if p.MaximumStakeAmount.Cmp(big.NewInt(0)) < 0 { | ||
return fmt.Errorf("maximum stake amount cannot be negative") | ||
} | ||
if p.MaximumStakeAmount.Cmp(p.MinimumStakeAmount) < 0 { | ||
return fmt.Errorf("maximum stake amount cannot be less than minimum stake amount") | ||
} | ||
if p.WeightToValueFactor.Cmp(big.NewInt(0)) < 0 { | ||
return fmt.Errorf("weight to value factor cannot be negative") | ||
} |
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.
can they be 0?
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.
this means that WeightToValueFactor
can't be 0 and this is what we want
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.
I think for all these, better error is has to be greater than 0, or cannot be empty , compared to cannot be negative
@@ -47,7 +48,9 @@ jobs: | |||
- os: macos-14 | |||
suite: "\\[Public Subnet non SOV\\]" | |||
- os: ubuntu-latest |
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.
why are we excluding ubuntu?
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.
because we relay on avalanchego
binary as part of the assets as it's custom build of poc.6 branch.
We can add ubuntu if we replace this prebuilt binary with avalanchego git repo checkout and build as part of the e2e
cmd/blockchaincmd/add_validator.go
Outdated
@@ -207,6 +214,17 @@ func promptValidatorBalance(availableBalance uint64) (uint64, error) { | |||
return app.Prompt.CaptureValidatorBalance(txt, availableBalance) | |||
} | |||
|
|||
func GetNetworkBalanceForKey(kc *keychain.Keychain, network models.Network) (uint64, error) { |
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.
this can go somewhere to utils
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.
name is misleaving because it is a list of keys, that is a keychain
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.
moved to utils. fixed name. good idea
cmd/blockchaincmd/add_validator.go
Outdated
if err != nil { | ||
return err | ||
} | ||
stakeAmount, err = app.Prompt.CaptureUint64(fmt.Sprintf("Enter the amount of tokens to stake. Available: %d[%s]", avaliableTokens, sc.TokenName)) |
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.
can we use a capture that disables choosing more than available tokens? (by the way, nit, avaliableTokens should be availableTokens)
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.
added.
pkg/prompts/prompts.go
Outdated
includeXChain bool, | ||
includeCChain bool, | ||
avoidBlockchainName string, | ||
avoidPChain bool, |
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.
why changing the logic to all avoids?
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 double careful this may broke some calls to this func
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.
probably used on key transfer. should check
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.
my bad. fixed
pkg/prompts/prompts.go
Outdated
@@ -1063,11 +1109,6 @@ func PromptAddress( | |||
if err != nil { | |||
return "", err | |||
} | |||
case XChainFormat: |
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.
why removing X-Chain?
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.
my bad. not sure how it happened. checking and putting it back
if params.UsePoAValidatorManager { | ||
validatormanager.AddPoAValidatorManagerContractToAllocations(params.initialTokenAllocation) | ||
validatormanager.AddTransparentProxyContractToAllocations(params.initialTokenAllocation, proxyOwner) | ||
} else { | ||
validatormanager.AddPoSValidatorManagerContractToAllocations(params.initialTokenAllocation) |
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.
can it be this case that it is neither poa neither pos (old stuff)
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.
good catch. replaced with else if
@@ -233,6 +238,10 @@ func PromptSubnetEVMGenesisParams( | |||
return SubnetEVMGenesisParams{}, "", err | |||
} | |||
|
|||
if sc.PoS() || sc.PoA() { // Teleporter bytecode makes genesis too big given the current max size (we include the bytecode for ValidatorManager, a proxy, and proxy admin) | |||
params.UseTeleporter = false |
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.
this is not enough, you can still use teleporter, the only thing is that it is not going to be included in genesis
can we keep the teleporter flag on but avoid genesis deploy? but instead deploy afterwards
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.
agree. I suggest not fixing it in the scope of this PR and do it as part of the teleporter after blockchain creation deployment PR as we discussed
pkg/vm/evm_prompts.go
Outdated
params.nativeMinterPrecompileAllowList.EnabledAddresses = []common.Address{ | ||
common.HexToAddress(validatormanager.ValidatorContractAddress), | ||
} | ||
params.nativeMinterPrecompileAllowList.AdminAddresses = append( |
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.
why admin? is not enough to use enabled?
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.
changed to enabled
…this change is coming from
* add pos validator removal debug * continue debugging pos validator removal * r4r * lint * fix e2e Error: failure initializing validator removal: min stake duration not passed (tx failed to be submitted) * wait 90sec for min validation period * min stake duration is 100 * update sidecar after bootstrap validator removed * disable e2e for removing PoS bootstrap validator * use 100s * remove pos non bootstrap validator e2e * add validator and remove it * use 60s staking period * go back to 90 and 120s * small refactor * fix duration prompt * use minimum 100s * add prompt check for minimum validator staking timr * fix etna duration input * use etna for name * add debug info * rm debug force validator removal for PoS * no need to updatePchainHeight --------- Signed-off-by: arturrez <[email protected]>
cmd.Flags().BoolVar(&useDefaultStartTime, "default-start-time", false, "(for non sovereign blockchain) use default start time for subnet validator (5 minutes later for fuji & mainnet, 30 seconds later for devnet)") | ||
cmd.Flags().StringVar(&startTimeStr, "start-time", "", "(for non sovereign blockchain) UTC start time when this validator starts validating, in 'YYYY-MM-DD HH:MM:SS' format") | ||
cmd.Flags().BoolVar(&useDefaultDuration, "default-duration", false, "(for non sovereign blockchain) set duration so as to validate until primary validator ends its period") | ||
cmd.Flags().BoolVar(&defaultValidatorParams, "default-validator-params", false, "(for non sovereign blockchain) use default weight/start/duration params for subnet validator") | ||
cmd.Flags().StringSliceVar(&subnetAuthKeys, "subnet-auth-keys", nil, "(for non sovereign blockchain) control keys that will be used to authenticate add validator tx") | ||
cmd.Flags().StringVar(&outputTxPath, "output-tx-path", "", "(for non sovereign blockchain) file path of the add validator tx") | ||
cmd.Flags().BoolVar(&waitForTxAcceptance, "wait-for-tx-acceptance", true, "(for non sovereign blockchain) just issue the add validator tx, without waiting for its acceptance") | ||
cmd.Flags().BoolVar(&forcePoS, "pos", false, "(PoS only) force validator initialization as PoS validator") |
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.
whats this flag for?
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.
Seems that its for adding to a pos / poa? We can't get from sidecar instead if its poa / pos?
Why this should be merged
it adds PoS L1 support to CLI - Native Token for now (ERC20 token - to be added)
it adds transparent proxy to both PoS and PoA validator manager.
How this works
based on PoA/PoS choice it deploys needed smart contracts including transparentProxy.
flows are very similar to PoA except some additional parameters specific to PoS ValidationManagement.
Some params have reasonable defaults to make UX better.
How this was tested
How is this documented
not yet. Relevant document created by @owenwahlgren https://github.com/ava-labs/etna-devnet-resources/blob/main/guides/deploy-sovereign-pos-l1.md.
It's based on https://github.com/ava-labs/avalanche-cli/tree/acp-77-pos branch created by @owenwahlgren 🙌