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

Use local machine to join as validator on any L1 #2548

Merged
merged 18 commits into from
Jan 17, 2025

Conversation

sukantoraymond
Copy link
Collaborator

@sukantoraymond sukantoraymond commented Jan 10, 2025

This PR enables using local machine to join any L1 (Proof of Stake) as a validator.

To join an L1 as validator, call avalanche node local start <clusterName> followed by avalanche node local validate <clusterName>. User will be prompted for RPC URL.

If has more than 1 node in it, all nodes will be added as validators of the specified L1

E2E test will be implemented once #2528 is resolved


Sample output

AVL-7H2W7V:avalanche-cli raymondsukanto$ ./bin/avalanche node local validate newValidatorNode
✔ Fuji Testnet
✔ Use stored key
✔ newTestKey
Enter the amount of token to stake for each validator: 10
What is the RPC endpoint?: http://192.168.1.39:9650/ext/bc/qnk6K3xv5ryk5VpPHLonp3yapgAEteF22nEeNeBCBpdBkBPDg/rpc
Validator's balance is used to pay for continuous fee to the P-Chain
When this Balance reaches 0, the validator will be considered inactive and will no longer participate in validating the L1
How many AVAX do you want to each validator to start with?: 0.1
How many AVAX do you want to each validator to start with?: 0.1
✔ Get address from an existing stored key (created from avalanche key create or avalanche key import)
✔ newTestKey
✔ Get address from an existing stored key (created from avalanche key create or avalanche key import)
✔ newTestKey
A private key is needed to pay for initialization of the validator's registration (Blockchain gas token).
✔ Get private key from an existing stored key (created from avalanche key create or avalanche key import)
✔ newTestKey

Adding validator NodeID-96NKYng5sFfEykL3nwUZwHgXNTcbYBcm7

==============================================
Initializing a validator registration with PoS validator manager
Using rpcURL: http://192.168.1.39:9650/ext/bc/qnk6K3xv5ryk5VpPHLonp3yapgAEteF22nEeNeBCBpdBkBPDg/rpc
NodeID: NodeID-96NKYng5sFfEykL3nwUZwHgXNTcbYBcm7 staking 10 tokens
==============================================
ValidationID: GmifrnPauqBYQVdF29vJX4f4HYKMADYSan1twVEjgZ4SMZu2H
RegisterL1ValidatorTx fee: 0.000093580 AVAX
RegisterL1ValidatorTx ID: 2WNZcJioetRtuHSWQJu3iqN9hrG15XryYf5JpyAVYZ9wmCRfgd
Waiting for P-Chain to update validator information ... 100% [===============]           

  NodeID: NodeID-96NKYng5sFfEykL3nwUZwHgXNTcbYBcm7
  Network: Fuji
  Weight: 10
  Balance: 0.10000 AVAX
✓ Validator successfully added to the L1


Adding validator NodeID-BTg5dyzPYfGQGZZjgG9MdMMrqG7XzwrWA

==============================================
Initializing a validator registration with PoS validator manager
Using rpcURL: http://192.168.1.39:9650/ext/bc/qnk6K3xv5ryk5VpPHLonp3yapgAEteF22nEeNeBCBpdBkBPDg/rpc
NodeID: NodeID-BTg5dyzPYfGQGZZjgG9MdMMrqG7XzwrWA staking 10 tokens
==============================================
ValidationID: K9FhqzbWNeWH7EEqToc39eqqXpUvYvNbjFPm5LGXfPyNNvmTn
RegisterL1ValidatorTx fee: 0.000093580 AVAX
RegisterL1ValidatorTx ID: 2VdyWu5JM9k8RaWHKjqUTr4uYvGm3diJF3uZS8nAgJph7kx4sV
Waiting for P-Chain to update validator information ... 100% [===============]           

  NodeID: NodeID-BTg5dyzPYfGQGZZjgG9MdMMrqG7XzwrWA
  Network: Fuji
  Weight: 10
  Balance: 0.10000 AVAX
✓ Validator successfully added to the L1

✓ All validators are successfully added to the L1

@sukantoraymond sukantoraymond requested a review from a team as a code owner January 10, 2025 07:27
@sukantoraymond sukantoraymond marked this pull request as draft January 10, 2025 07:27
cmd/nodecmd/local.go Dismissed Show dismissed Hide dismissed
@meaghanfitzgerald
Copy link
Collaborator

Can you elaborate in the PR description how a user would accomplish this with the CLI? Is there a new command to import a new L1 configuration or add an active RPC endpoint as a known L1 network? How does this work exactly

@sukantoraymond sukantoraymond linked an issue Jan 13, 2025 that may be closed by this pull request
@sukantoraymond sukantoraymond marked this pull request as ready for review January 14, 2025 11:03
@@ -1563,60 +1519,6 @@ func ConvertURIToPeers(uris []string) ([]info.Peer, error) {
return aggregatorPeers, nil
}

func GetAggregatorExtraPeers(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moving these functions to blockchain pkg so that it can be re used across cmds

@@ -289,46 +289,3 @@ func getThreshold(maxLen int) (uint32, error) {
}
return uint32(intTh), err
}

func getKeyForChangeOwner(network models.Network) (string, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moving these functions to blockchain pkg so that it can be re used across cmds

cmd/nodecmd/local.go Outdated Show resolved Hide resolved
pkg/blockchain/helper.go Outdated Show resolved Hide resolved
pkg/validatormanager/registration.go Show resolved Hide resolved
pkg/validatormanager/registration.go Outdated Show resolved Hide resolved
cmd/nodecmd/local.go Show resolved Hide resolved
cmd/nodecmd/local.go Show resolved Hide resolved
cmd/nodecmd/local.go Show resolved Hide resolved
cmd/nodecmd/local.go Outdated Show resolved Hide resolved
cmd/nodecmd/local.go Outdated Show resolved Hide resolved
cmd/nodecmd/local.go Show resolved Hide resolved
cmd/nodecmd/local.go Show resolved Hide resolved
cmd/nodecmd/local.go Outdated Show resolved Hide resolved
cmd/nodecmd/local.go Show resolved Hide resolved
cmd/nodecmd/local.go Outdated Show resolved Hide resolved
cmd/nodecmd/local.go Outdated Show resolved Hide resolved
@sukantoraymond
Copy link
Collaborator Author

#2561

Copy link
Collaborator

@felipemadero felipemadero left a comment

Choose a reason for hiding this comment

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

LGTM

@sukantoraymond sukantoraymond merged commit d9dd3cd into main Jan 17, 2025
37 checks passed
@sukantoraymond sukantoraymond deleted the local-add-validator branch January 17, 2025 17:47
owenwahlgren pushed a commit that referenced this pull request Jan 23, 2025
* use local machine to join as validator

* fix lint

* update validate function

* local machine validate l1

* update command description

* lint

* lint

* address comments

* fix merge

* address comments

* enable more than 1 node in a cluster to validate

* address comments

* fix lint

* fix lint

---------

Signed-off-by: sukantoraymond <rsukanto@umich.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Support adding validators to remote L1s (Fuji)
3 participants