make public import to support SOV L1s#2746
Conversation
cmd/blockchaincmd/import_public.go
Outdated
| "the blockchain ID", | ||
| ) | ||
| cmd.Flags().StringVar(&rpcURL, "rpc", "", "rpc endpoint for the blockchain") | ||
| cmd.Flags().BoolVar(&noRPCAvailable, "no-rpc-available", false, "use this when an RPC if offline and can't be accesed") |
There was a problem hiding this comment.
Seems that noRPCAvailable flag needs to be set to true so that importBlockchain can:
if rpcIsAvailable {
sc.ValidatorManagement, err = validatorManagerSDK.GetValidatorManagerType(rpcURL, common.HexToAddress(validatorManagerAddress))
if err != nil {
return models.Sidecar{}, nil, fmt.Errorf("could not obtain validator manager type: %w", err)
}
printFunc(" Validation Kind: %s", sc.ValidatorManagement)
if sc.ValidatorManagement == validatormanagertypes.ProofOfAuthority {
owner, err := contract.GetContractOwner(rpcURL, common.HexToAddress(validatorManagerAddress))
if err != nil {
return models.Sidecar{}, nil, err
}
sc.ValidatorManagerOwner = owner.String()
printFunc(" Validator Manager Owner: %s", sc.ValidatorManagerOwner)
}
}
and
if rpcIsAvailable {
blockchainID, _ = precompiles.WarpPrecompileGetBlockchainID(rpcURL)
}
if blockchainID == ids.Empty {
blockchainID, err = app.Prompt.CaptureID("What is the Blockchain ID?")
if err != nil {
return models.Sidecar{}, nil, err
}
}
There was a problem hiding this comment.
why don't we just remove this flag and:
return error if rpc is unavailable when:
sc.ValidatorManagement, err = validatorManagerSDK.GetValidatorManagerType(rpcURL, common.HexToAddress(validatorManagerAddress)
since we need to know if poa/ pos anyways
and if
blockchainID, _ = precompiles.WarpPrecompileGetBlockchainID(rpcURL)
}
returns error due to url being unavailable we can just prompt for the blockchainID
There was a problem hiding this comment.
TLDR: I think we should remove this flag
There was a problem hiding this comment.
There are cases where a rpc in unavailable because all rpc nodes are down but you anyway want to be
able to partially import the L1, most notably to increase validator balances, or to try out some local tests, or for any
misc debugging reason like be able to easily have access to certain L1 info.
I indeed used this functionality twice in the past month
There was a problem hiding this comment.
eg if all your validator drawn the balance, you need to use increase balance, and a reasonable flow would be to
call first import on the rpc, and then increase the balances
There was a problem hiding this comment.
instead of using flag why not we just make a call to this RPC, and if this RPC is not returning any response then we know that it is not available (don't return the error) and respond accordingly as if we have the flag set as true
There was a problem hiding this comment.
it can be the case that there is a temporal network failure and the import from a failed rpc will be assumed to be successful, being not the case, also, the idea of this flag is to even avoid asking for the url instead of requiring the user to provide
a fake url.
not opposing to this but the flag, being kind of a bit more ugly, seems a better option to me.
as you wish
There was a problem hiding this comment.
or we can just accept any URL string at prompt, and tell the user which to use for empty rpc, eg just enter
|
TLDR: I think we want to avoid adding more flags into our commands. If possible we should replace / reuse our existing flags. |
Why this should be merged
Closes #2704
Currently,
avalanche blockchain import publiconly supports importing non SOV blockchains.As the trend is to only support L1, a change is needed here.
This also fixes
avalanche blockchain validatorsso as to correctly tell is the validator is SOV or NOSOVThis also removes local network version of helper to get subnet validators, changing also
avalanche blockchain validatorspart related to this.How this works
How this was tested
How is this documented