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

Validate convert txs #2641

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Validate convert txs #2641

wants to merge 7 commits into from

Conversation

felipemadero
Copy link
Collaborator

@felipemadero felipemadero commented Feb 26, 2025

Why this should be merged

  • It adds validation of blockchain ID, subnet ID, manager address before generating
    a convert tx.
  • It gives details on the tx about to be signed or committed before deciding to do so, on
    multisig management commands
  • fixes flow for when the user does not want to overwrite a previous deploy of the same l1

How this works

How this was tested

How is this documented

Comment on lines +564 to +571
if doStrongInputChecks && subnetID != ids.Empty {
ux.Logger.PrintToUser("Subnet ID to be used is %s", subnetID)
if acceptValue, err := app.Prompt.CaptureYesNo("Is this value correct?"); err != nil {
return err
} else if !acceptValue {
subnetID = ids.Empty
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think we need to do this check because users will already check details of subnet id and blockchain id in line 444. A user not using skip check flag will have to verify three times

Copy link
Collaborator Author

@felipemadero felipemadero Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user will have to verify two times, not three times (unless I miss something). And
the second verification includes much more information.
This specific check and input for blockchain id was requested and accorded (i added the subnet id
which is in similar state), so probably the 444 check can be
removed. I will let devrel to vote on this cc @martineckardt after trying out the command.
cc @learyce

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very critical operation. The more confirmation the better

Comment on lines +579 to +586
if doStrongInputChecks && blockchainID != ids.Empty {
ux.Logger.PrintToUser("Blockchain ID to be used is %s", blockchainID)
if acceptValue, err := app.Prompt.CaptureYesNo("Is this value correct?"); err != nil {
return err
} else if !acceptValue {
blockchainID = ids.Empty
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Better to double check. If this value is messed up, the L1 cannot be recovered

import "errors"

var (
ErrNoBlockchainID = errors.New("failed to find the blockchain ID for this subnet, has it been deployed/created on this network?\nyou can use 'avalanche blockchain import' if having partial information on a deployed subnet")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no blockchain ID found. Use 'avalanche blockchain import' to provide the required Subnet details

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blckchain ID can also be absent for the blockchain not being deployed. np changing if you also include reference to this option


var (
ErrNoBlockchainID = errors.New("failed to find the blockchain ID for this subnet, has it been deployed/created on this network?\nyou can use 'avalanche blockchain import' if having partial information on a deployed subnet")
ErrNoSubnetID = errors.New("failed to find the subnet ID for this subnet, has it been deployed/created on this network?\nyou can use 'avalanche blockchain import' if having partial information on a deployed subnet")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no Subnet ID found. Use 'avalanche blockchain import' to provide the required Subnet details

@@ -0,0 +1,11 @@
// Copyright (C) 2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package clierrors
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better to place this under pkg/constants/error.go?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im fine either way

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets keep it here but happy to hear @learyce opinion

ux.Logger.PrintToUser(" Validators:")
for _, val := range bootstrapValidators {
ux.Logger.PrintToUser(" Node ID: %s", val.NodeID)
ux.Logger.PrintToUser(" Balance: %.5f", float64(val.Balance)/float64(units.Avax))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also show weight here

Comment on lines +564 to +571
if doStrongInputChecks && subnetID != ids.Empty {
ux.Logger.PrintToUser("Subnet ID to be used is %s", subnetID)
if acceptValue, err := app.Prompt.CaptureYesNo("Is this value correct?"); err != nil {
return err
} else if !acceptValue {
subnetID = ids.Empty
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very critical operation. The more confirmation the better

Comment on lines +579 to +586
if doStrongInputChecks && blockchainID != ids.Empty {
ux.Logger.PrintToUser("Blockchain ID to be used is %s", blockchainID)
if acceptValue, err := app.Prompt.CaptureYesNo("Is this value correct?"); err != nil {
return err
} else if !acceptValue {
blockchainID = ids.Empty
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Better to double check. If this value is messed up, the L1 cannot be recovered

return false, fmt.Errorf("unexpected node ID on tx")
}
ux.Logger.PrintToUser(" Node ID: %s", nodeID)
ux.Logger.PrintToUser(" Balance: %.5f", float64(val.Balance)/float64(units.Avax))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weight of validator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress 🏗
Development

Successfully merging this pull request may close these issues.

3 participants