From 89fc97f714c0edd13a94fa96488cf7b03f84273c Mon Sep 17 00:00:00 2001 From: sukantoraymond Date: Wed, 27 Nov 2024 04:22:32 -0500 Subject: [PATCH] Updated fuji tutorial for L1 (#1962) * edit fuji l1 * lint * add suggestions * Update content/docs/avalanche-l1s/deploy-a-avalanche-l1/fuji-testnet.mdx Signed-off-by: Ashutosh Tripathi <39340292+ashucoder9@users.noreply.github.com> --------- Signed-off-by: Ashutosh Tripathi <39340292+ashucoder9@users.noreply.github.com> Co-authored-by: Ashutosh Tripathi Co-authored-by: Ashutosh Tripathi <39340292+ashucoder9@users.noreply.github.com> --- .../deploy-a-avalanche-l1/fuji-testnet.mdx | 445 +++--------------- package.json | 1 + 2 files changed, 79 insertions(+), 367 deletions(-) diff --git a/content/docs/avalanche-l1s/deploy-a-avalanche-l1/fuji-testnet.mdx b/content/docs/avalanche-l1s/deploy-a-avalanche-l1/fuji-testnet.mdx index 676cb0918d3..cdce25107cb 100644 --- a/content/docs/avalanche-l1s/deploy-a-avalanche-l1/fuji-testnet.mdx +++ b/content/docs/avalanche-l1s/deploy-a-avalanche-l1/fuji-testnet.mdx @@ -32,42 +32,6 @@ Avalanche can run multiple blockchains. Each blockchain is an instance of a [Vir This chain implements the Ethereum Virtual Machine and supports Solidity smart contracts as well as most other Ethereum client features. -Fuji Testnet[​](#fuji-testnet "Direct link to heading") -------------------------------------------------------- - -For this tutorial, it's recommended that you follow [Run an Avalanche Node Manually](/nodes/run-a-node/manually#run-an-avalanche-node-from-source) and this step below particularly to start your node on `Fuji`: - -_To connect to the Fuji Testnet instead of the main net, use argument `--network-id=Fuji`_ - -Also it's worth pointing out that [it only needs 1 AVAX to become a validator on the Fuji Testnet](/nodes/validate/what-is-staking) and you can get the test token from the [faucet](https://core.app/tools/testnet-faucet/). If you already have an AVAX balance greater than zero on Mainnet, paste your C-Chain address there, and request test tokens. Otherwise, please request a faucet coupon on [Guild](https://guild.xyz/avalanche). Admins and mods on the official [Discord](https://discord.com/invite/RwXY7P6) can provide testnet AVAX if developers are unable to obtain it from the other two options. - -To get the NodeID of this `Fuji` node, call the following curl command to [info.getNodeID](/api-reference/info-api#infogetnodeid): - -```bash -curl -X POST --data '{ - "jsonrpc":"2.0", - "id" :1, - "method" :"info.getNodeID" -}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/info -``` - -The response should look something like: - -```json -{ - "jsonrpc": "2.0", - "result": { - "nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD" - }, - "id": 1 -} -``` - -That portion that says, `NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD` is the NodeID, the entire thing. The user is going to need this ID in the later section when calling [addValidator](#add-a-validator). - - -With more data on `Fuji`, it may take a while to bootstrap `Fuji` Testnet from scratch. You can use [State-Sync](/nodes/chain-configs/c-chain#state-sync-enabled) to shorten the time for bootstrapping. - Avalanche-CLI[​](#avalanche-cli "Direct link to heading") --------------------------------------------------------- @@ -167,8 +131,8 @@ avalanche key list Do these steps only to follow this tutorial for `Fuji` addresses. To access the wallet for `Mainnet`, the use of a ledger device is strongly recommended. -1. A newly created key has no funds on it. Send funds via transfer to its correspondent addresses if you already have funds on a different address, or get it from the faucet at [`https://core.app/tools/testnet-faucet/`](https://core.app/tools/testnet-faucet/) using your **C-Chain address**. If you already have an AVAX balance greater than zero on Mainnet, paste your C-Chain address there, and request test tokens. Otherwise, please request a faucet coupon on [Guild](https://guild.xyz/avalanche). Admins and mods on the official [Discord](https://discord.com/invite/RwXY7P6) can provide testnet AVAX if developers are unable to obtain it from the other two options. -2. Export your key via the `avalanche key export` command. The output is your private key, which will help you [import](https://support.avax.network/en/articles/6821877-core-extension-how-can-i-import-an-account) your account into the Core extension. +1. A newly created key has no funds on it. Send funds via transfer to its correspondent addresses if you already have funds on a different address, or get it from the faucet at [`https://core.app/tools/testnet-faucet/`](https://core.app/tools/testnet-faucet/) using your **C-Chain address**. If you already have an AVAX balance greater than zero on Mainnet, paste your C-Chain address there, and request test tokens. Otherwise, please request a faucet coupon on [Guild](https://guild.xyz/avalanche). Admins and mods on the official [Discord](https://discord.com/invite/RwXY7P6) can provide testnet AVAX if developers are unable to obtain it from the other two options. +2. Export your key via the `avalanche key export` command. The output is your private key, which will help you [import](https://support.avax.network/en/articles/6821877-core-extension-how-can-i-import-an-account) your account into the Core extension. 3. Connect Core extension to [Core web](https://core.app/), and move the test funds from C-Chain to the P-Chain by clicking Stake, then Cross-Chain Transfer (find more details on [this tutorial](https://support.avax.network/en/articles/8133713-core-web-how-do-i-make-cross-chain-transfers-in-core-stake)). After following these 3 steps, your test key should now have a balance on the P-Chain on `Fuji` Testnet. @@ -198,7 +162,7 @@ As you want to create an EVM Avalanche L1, just accept the default `Subnet-EVM`. Choose either Proof of Authority (PoA) or Proof of Stake (PoS) as your consensus mechanism. ```bash -? Which validator management type would you like to use in your blockchain?: +? Which validator management type would you like to use in your blockchain?: ▸ Proof Of Authority Proof Of Stake Explain the difference @@ -208,15 +172,38 @@ For this tutorial, select `Proof of Authority (PoA)`. For more info, reference the [Validator Management Contracts](/evm-l1s/validator-manager/contract). ```bash -Which address do you want to enable as controller of ValidatorManager contract?: +Which address do you want to enable as controller of ValidatorManager contract?: ▸ Get address from an existing stored key (created from avalanche key create or avalanche key import) Custom ``` This address will be able to add and remove validators from your Avalanche L1. You can either use an existing key or create a new one. In addition to being the PoA owner, this address will also be the owner of the `ProxyAdmin` contract of the Validator Manager's `TransparentUpgradeableProxy`. This address will be able to upgrade (PoA -> PoS) the Validator Manager implementation through updating the proxy. +Next, CLI will ask for blockchain configuration values. Since we are deploying to Fuji, select `I want to use defaults for a production environment`. + +```bash +? Do you want to use default values for the Blockchain configuration?: + ▸ I want to use defaults for a test environment + I want to use defaults for a production environment + I don't want to use default values + Explain the difference +``` - Next, CLI asks for the ChainID. You should provide your own ID. Check [chainlist.org](https://chainlist.org/) to see if the value you'd like is already in use. +The default values for production environment: + +- Use latest Subnet-EVM release +- Allocate 1 million tokens to: + 1. **a newly created key (production)**: name of this key will be in the format of `subnet_blockchainName_airdrop` + 2. **ewoq address (test)**: 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC +- Supply of the native token will be hard-capped +- Set gas fee config as low throughput (12 million gas per block) +- Use constant gas prices +- Disable further adjustments in transaction fee configuration +- Transaction fees are burned +- Enable interoperability with other blockchains +- Allow any user to deploy smart contracts, send transactions, and interact with your blockchain. + +Next, CLI asks for the ChainID. You should provide your own ID. Check [chainlist.org](https://chainlist.org/) to see if the value you'd like is already in use. ```bash ✔ Subnet-EVM @@ -232,51 +219,6 @@ Select a symbol for your Avalanche L1's native token Token symbol: TST ``` -At this point, CLI prompts the user for the fee structure of the Avalanche L1, so that he can tune the fees to the needs: - -```bash -Use the arrow keys to navigate: ↓ ↑ → ← -? How would you like to set fees: - ▸ Low disk use / Low Throughput 1.5 mil gas/s (C-Chain's setting) - Medium disk use / Medium Throughput 2 mil gas/s - High disk use / High Throughput 5 mil gas/s - Customize fee config - Go back to previous step -``` - -You can navigate with the arrow keys to select the suitable setting. Use `Low disk use / Low Throughput 1.5 mil gas/s` for this tutorial. - -The next question is about the airdrop: - -```bash -✔ Low disk use / Low Throughput 1.5 mil gas/s -Use the arrow keys to navigate: ↓ ↑ → ← -? How would you like to distribute funds: - ▸ Airdrop 1 million tokens to the default address (do not use in production) - Customize your airdrop - Go back to previous step -``` - -You can accept the default -again, NOT for production-, or customize your airdrop. In the latter case the wizard would continue. Assume the default here. - -The final question is asking for precompiles. Precompiles are powerful customizations of your EVM. Read about them at [precompiles](/avalanche-l1s/upgrade/customize-avalanche-l1#precompiles). - -```bash -✔ Airdrop 1 million tokens to the default address (do not use in production) -Use the arrow keys to navigate: ↓ ↑ → ← -? Advanced: Would you like to add a custom precompile to modify the EVM?: - ▸ No - Yes - Go back to previous step -``` - -For this tutorial, assume the simple case of no additional precompile. This finalizes the prompt sequence and the command exits: - -```bash -✔ No -Successfully created genesis -``` - It's possible to end the process with Ctrl-C at any time. At this point, CLI creates the specification of the new Avalanche L1 on disk, but isn't deployed yet. @@ -286,6 +228,7 @@ Print the specification to disk by running the `describe` command: ```bash avalanche blockchain describe testblockchain ``` + ```bash +------------------------------------------------------------------+ | TESTBLOCKCHAIN | @@ -338,32 +281,6 @@ avalanche blockchain describe testblockchain ``` -Also you can list the available Avalanche L1s: - -```bash -avalanche blockchain list -go run main.go subnet list -+-------------+-------------+----------+---------------------------------------------------+------------+-----------+ -| Avalanche L1 | CHAIN | CHAIN ID | VM ID | TYPE | FROM REPO | -+-------------+-------------+----------+---------------------------------------------------+------------+-----------+ -| testblockchain | testblockchain | 3333 | tGBrM94jbkesczgqsL1UaxjrdxRQQobs3MZTNQ4GrfhzvpiE8 | Subnet-EVM | false | -+-------------+-------------+----------+---------------------------------------------------+------------+-----------+ -``` - -List deployed information: - -```bash -avalanche blockchain list --deployed -go run main.go subnet list --deployed -+-------------+-------------+---------------------------------------------------+---------------+-----------------------------------------------------------------+---------+ -| Avalanche L1 | CHAIN | VM ID | LOCAL NETWORK | FUJI (TESTNET) | MAINNET | -+-------------+-------------+---------------------------------------------------+---------------+-----------------------------------------------------------------+---------+ -| testblockchain | testblockchain | tGBrM94jbkesczgqsL1UaxjrdxRQQobs3MZTNQ4GrfhzvpiE8 | Yes | SubnetID: XTK7AM2Pw5A4cCtQ3rTugqbeLCU9mVixML3YwwLYUJ4WXN2Kt | No | -+ + + + +-----------------------------------------------------------------+---------+ -| | | | | BlockchainID: 5ce2WhnyeMELzg9UtfpCDGNwRa2AzMzRhBWfTqmFuiXPWE4TR | No | -+-------------+-------------+---------------------------------------------------+---------------+-----------------------------------------------------------------+---------+ - -``` Deploy the Avalanche L1[​](#deploy-the-avalanche-l1 "Direct link to heading") ----------------------------------------------------------------- @@ -388,7 +305,7 @@ Use the arrow keys to navigate: ↓ ↑ → ← Mainnet ``` -This tutorial is about deploying to `Fuji`, so navigate with the arrow keys to `Fuji` and hit enter. The user is then asked to provide which private key to use for the deployment. The deployment basically consists in running a `createSubnet` transaction. Therefore the key needs to have funds. +This tutorial is about deploying to `Fuji`, so navigate with the arrow keys to `Fuji` and hit enter. The user is then asked to provide which private key to use for the deployment. Select a key to has P-Chain AVAX to pay for transaction fees. Also, this tutorial assumes that a node is up running, fully bootstrapped on `Fuji`, and runs from the **same** box. @@ -401,307 +318,107 @@ Use the arrow keys to navigate: ↓ ↑ → ← ▸ mytestkey ``` -Avalanche L1s are currently permissioned only. Therefore, the process now requires the user to provide _which keys can control the Avalanche L1_. CLI prompts the user to provide one or more **P-Chain addresses**. Only the keys corresponding to these addresses are going to be able to add or remove validators. Make sure to provide **Fuji P-Chain** addresses -`P-Fuji....`\-. - -```bash -Configure which addresses may add new validators to the Avalanche L1. -These addresses are known as your control keys. You are going to also -set how many control keys are required to add a validator. -Use the arrow keys to navigate: ↓ ↑ → ← -? Set control keys: - ▸ Add control key - Done - Cancel -``` - -Enter at `Add control key` and provide at least one key. You can enter multiple addresses, just use one here. When finishing, hit `Done`. (The address provided here is intentionally invalid. The address has a checksum and the tool is going to make sure it's a valid address). - -```bash -✔ Add control key -Enter P-Chain address (Ex: `P-...`): P-fuji1vaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasz -Use the arrow keys to navigate: ↓ ↑ → ← -? Set control keys: - Add control key - ▸ Done - Cancel -``` - -Finally, there is a need to define the threshold of how many keys to require for a change to be valid -there is some input validation-. For example, if the is one control key, as preceding, just enter 1. The threshold _could_ be arbitrary depending on the needs, for example 2 of 4 addresses, 1 of 3, 3 of 5, etc., but currently this tool only works if _the private key used here owns at least one control key and the threshold is 1_. - -```bash -✔ Enter required number of control key signatures to add a validator: 1 -``` - -Here the wizard completes, and CLI attempts the transaction. - -If the private key isn't funded or doesn't have enough funds, the error message is going to be: - -```bash -Error: insufficient funds: provided UTXOs need 100000000 more units of asset "U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK" -``` - -If the private key has funds, but the **control key** is incorrect (not controlled by the private key), the CLI is going to create the Avalanche L1, but _not the blockchain_: +Avalanche L1s require bootstrap validators during creation process. Avalanche CLI has enabled using local machine as a bootstrap validator on the blockchain. +This means that you don't have to to set up a remote server on a cloud service (e.g. AWS / GCP) to be a validator on the blockchain. -```bash -Avalanche L1 has been created with ID: 2EkPnvnDiLgudnf8NjtxaNcVFtdAAnUPvaoNBrc9WG5tNmmfaK. Now creating blockchain... -Error: insufficient authorization -``` - -Therefore the user needs to provide a control key which he has indeed control of, and then it succeeds. The output (assuming the node is running on `localhost` and the API port set to standard `9650`) is going to look something like this: - -```bash -Avalanche L1 has been created with ID: 2b175hLJhGdj3CzgXENso9CmwMgejaCQXhMFzBsm8hXbH2MF7H. Now creating blockchain... -Endpoint for blockchain "2XDnKyAEr1RhhWpTpMXqrjeejN23vETmDykVzkb4PrU1fQjewh" with VM ID "tGBrMADESojmu5Et9CpbGCrmVf9fiAJtZM5ZJ3YVDj5JTu2qw": http://127.0.0.1:9650/ext/bc/2XDnKyAEr1RhhWpTpMXqrjeejN23vETmDykVzkb4PrU1fQjewh/rpc -``` - -Well done. You have just created your own Avalanche L1 with your own Subnet-EVM running on `Fuji`. - -To get your new Avalanche L1 information, visit the [Avalanche L1 Explorer](https://subnets-test.avax.network/). The search best works by blockchain ID, so in this example, enter `2XDnKyAEr1RhhWpTpMXqrjeejN23vETmDykVzkb4PrU1fQjewh` into the search box and you should see your shiny new blockchain information. - -Join an Avalanche L1 as a Validator (LEGACY)[​](#request-to-join-a-avalanche-l1-as-a-validator "Direct link to heading") -------------------------------------------------------------------------------------------------------------- - -The new Avalanche L1 created in the previous steps doesn't have any dedicated validators yet. To request permission to validate an Avalanche L1, the following steps are required: - - -Before a node can be a validator on an Avalanche L1, the node is required to already be tracking the P-Chain. - -If the validator is within 24 hours of expiring on the primary network, it can't be added to the Avalanche L1. - -See [here](/nodes/validate/node-validator#add-a-validator-with-core-extension) on how to become a validator. - - -First, request permission to validate by running the `join` command along with the Avalanche L1 name: - -```bash -avalanche blockchain join testblockchain -``` - -Note: Running `join` does not guarantee that your node is a validator of the Avalanche L1! The owner of the Avalanche L1 must approve your node to be a validator afterwards by calling `addValidator` as described in the next section. - -When you call the `join` command, you are first prompted with the network selection: +We will select `Yes` on using our local machine as a bootstrap validator. Note that since we need to sync our node with Fuji, this process will take around 3 minutes. ```bash +You can use your local machine as a bootstrap validator on the blockchain +This means that you don't have to to set up a remote server on a cloud service (e.g. AWS / GCP) to be a validator on the blockchain. Use the arrow keys to navigate: ↓ ↑ → ← -? Choose a network to validate on (this command only supports public networks): - ▸ Fuji - Mainnet -``` - -Next, there are two setup choices: Automatic and Manual configurations. As mentioned earlier, "Automatic" is going to attempt at editing a config file and setting up your plugin directory, while "Manual" is going to just print the required config to the screen. See what "Automatic" does: - -```bash -✔ Automatic -✔ Path to your existing config file (or where it's going to be generated): config.json -``` - -Provide a path to a config file. If executing this command on the box where your validator is running, then you could point this to the actually used config file, for example `/etc/avalanchego/config.json` - just make sure the tool has **write** access to the file. Or you could just copy the file later. In any case, the tool is going to either try to edit the existing file specified by the given path, or create a new file. Again, set write permissions. - -Next, provide the plugin directory. The beginning of this tutorial contains VMs description [Virtual Machine](#virtual-machine). Each VM runs its own plugin, therefore AvalancheGo needs to be able to access the correspondent plugin binary. As this is the `join` command, which doesn't know yet about the plugin, there is a need to provide the directory where the plugin resides. Make sure to provide the location for your case: - -```bash -✔ Path to your avalanchego plugin dir (likely avalanchego/build/plugins): /home/user/go/src/github.com/ava-labs/avalanchego/build/plugins -``` - -The tool doesn't know where exactly it's located so it requires the full path. With the path given, it's going to copy the VM binary to the provided location: - -```bash -✔ Path to your avalanchego plugin dir (likely avalanchego/build/plugins): /home/user/go/src/github.com/ava-labs/avalanchego/build/plugins█ -VM binary written to /home/user/go/src/github.com/ava-labs/avalanchego/build/plugins/tGBrMADESojmu5Et9CpbGCrmVf9fiAJtZM5ZJ3YVDj5JTu2qw -This is going to edit your existing config file. This edit is nondestructive, -but it's always good to have a backup. -Use the arrow keys to navigate: ↓ ↑ → ← -? Proceed?: +? Do you want to use your local machine as a bootstrap validator?: ▸ Yes No ``` -Hitting `Yes` is going to attempt at writing the config file: - -```bash -✔ Yes -The config file has been edited. To use it, make sure to start the node with the '--config-file' option, e.g. - -./build/avalanchego --config-file config.json +Well done. You have just created your own Avalanche L1 on `Fuji`. -(using your binary location). The node has to be restarted for the changes to take effect. -``` - -It's **required to restart the node**. - -If choosing "Manual" instead, the tool is going to just print _instructions_. The user is going to have to follow these instructions and apply them to the node. Note that the IDs for the VM and Avalanche L1s is going to be different in your case. +You will be able to see information on the deployed L1 at the end of `avalanche blockchain deploy` command: ```bash -✔ Manual - -To setup your node, you must do two things: - -1. Add your VM binary to your node's plugin directory -2. Update your node config to start validating the Avalanche L1 - -To add the VM to your plugin directory, copy or scp from /tmp/tGBrMADESojmu5Et9CpbGCrmVf9fiAJtZM5ZJ3YVDj5JTu2qw - -If you installed avalanchego manually, your plugin directory is likely -avalanchego/build/plugins. - -If you start your node from the command line WITHOUT a config file (e.g. via command -line or systemd script), add the following flag to your node's startup command: - ---track-subnets=2b175hLJhGdj3CzgXENso9CmwMgejaCQXhMFzBsm8hXbH2MF7H -(if the node already has a track-subnets config, append the new value by -comma-separating it). - -For example: -./build/avalanchego --network-id=Fuji --track-subnets=2b175hLJhGdj3CzgXENso9CmwMgejaCQXhMFzBsm8hXbH2MF7H - -If you start the node via a JSON config file, add this to your config file: -track-subnets: 2b175hLJhGdj3CzgXENso9CmwMgejaCQXhMFzBsm8hXbH2MF7H - -TIP: Try this command with the --avalanchego-config flag pointing to your config file, -this tool is going to try to update the file automatically (make sure it can write to it). - -After you update your config, you are going to need to restart your node for the changes to -take effect. ++--------------------+----------------------------------------------------+ +| DEPLOYMENT RESULTS | | ++--------------------+----------------------------------------------------+ +| Chain Name | testblockchain | ++--------------------+----------------------------------------------------+ +| Subnet ID | 2cNuyBhvAd4jH5bFSGndezhB66Z4UHYAsLCMGoCpvhXVhrZfgd | ++--------------------+----------------------------------------------------+ +| VM ID | qcvkEX1zWSz7PtGd7CKvPRBqLVTzA7qyMPvkh5NMDWkuhrcCu | ++--------------------+----------------------------------------------------+ +| Blockchain ID | 2U7vNdB78xTiN6QtZ9aetfKoGtQhfeEPQG6QZC8bpq8QMf4cDx | ++--------------------+ + +| P-Chain TXID | | ++--------------------+----------------------------------------------------+ ``` +To get your new Avalanche L1 information, visit the [Avalanche L1 Explorer](https://subnets-test.avax.network/). The search best works by blockchain ID, so in this example, enter `2U7vNdB78xTiN6QtZ9aetfKoGtQhfeEPQG6QZC8bpq8QMf4cDx` into the search box and you should see your shiny new blockchain information. + Add a Validator[​](#add-a-validator "Direct link to heading") ------------------------------------------------------------- - -If the `join` command isn't successfully completed before `addValidator` is completed, the Avalanche L1 could experience degraded performance or even halt. - - -Now that the node has joined the Avalanche L1, an Avalanche L1 control key holder must call `addValidator` to grant the node permission to be a validator in your Avalanche L1. +Before proceeding to add a validator to our Avalanche L1, we will need to have the validator's NodeID, BLS public key and proof of possession. These can be obtained by ssh into the node itself and run the `getNodeID` API specified [here](https://docs.avax.network/api-reference/info-api#infogetnodeid) -To whitelist a node as a recognized validator on the Avalanche L1, run: +To add a validator to an Avalanche L1, the owner of the key that acts as the controller of ValidatorManager contract specified in `avalanche blockchain create` command above run: ```bash avalanche blockchain addValidator testblockchain ``` -As this operation involves a new transaction, you will need to specify which private key to use: - -```bash -Use the arrow keys to navigate: ↓ ↑ → ← -? Which private key should be used to issue the transaction?: - test - ▸ mytestkey -``` - Choose `Fuji`: ```bash Use the arrow keys to navigate: ↓ ↑ → ← -? Choose a network to deploy on. This command only supports Fuji currently.: +? Choose a network to deploy on: ▸ Fuji - Mainnet ``` -Now use the **NodeID** of the new validator defined at the beginning of this tutorial. For best results make sure the validator is running and synced. - -```bash -What is the NodeID of the validator you'd like to whitelist?: NodeID-BFa1paAAAAAAAAAAAAAAAAAAAAQGjPhUy -``` - -This ID is intentionally modified. The next question requires a bit of thinking. A validator has a weight, which defines how often consensus selects it for decision making. You should think ahead of how many validators you want initially to identify a good value here. The range is 1 to 100, but the minimum for an Avalanche L1 without any validators yet is 20. - -Just select 30 for this one: +You will need to specify which private key to use to pay for the transaction fees: ```bash Use the arrow keys to navigate: ↓ ↑ → ← -? What stake weight would you like to assign to the validator?: - Default (20) - ▸ Custom +? Which key should be used to pay for transaction fees on P-Chain?: + test + ▸ mytestkey ``` -```bash -✔ What stake weight would you like to assign to the validator?: 30 -``` +Next, we will require -Then specify when the validator is going to start validating. The time must be in the future. Custom option is going to require to enter a specific date in `YYYY-MM-DD HH:MM:SS` format. Just take the default this time: +Now enter the **NodeID** of the new validator to be added. For best results make sure the validator is running and synced. ```bash -Use the arrow keys to navigate: ↓ ↑ → ← -? Start time: - ▸ Start in one minute - Custom +What is the NodeID of the validator you'd like to whitelist?: NodeID-BFa1paAAAAAAAAAAAAAAAAAAAAQGjPhUy ``` -Finally, specify how long it's going to be validating: +Next, enter the node's BLS public key and proof of possession. -```bash -✔ Start in one minute -Use the arrow keys to navigate: ↓ ↑ → ← -? How long should your validator validate for?: - ▸ Until primary network validator expires - Custom -``` +Now, enter the amount of AVAX that you would like to allocate to the new validator. -If choosing `Custom` here, the user must enter a **duration**, which is a time span expressed in hours. For example, could say `200 days = 24 \* 200 = 4800 hours` - -```bash -✔ How long should this validator be validating? Enter a duration, e.g. 8760h: 4800h -``` +The 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. -CLI shows an actual date of when that's now: +1 AVAX should last the validator about a month. ```bash -? Your validator is going to finish staking by 2023-02-13 12:26:55: - ▸ Yes - No +What balance would you like to assign to the validator (in AVAX)?: 1 ``` -Confirm if correct. At this point the prompt series is complete and CLI attempts the transaction: +Next, select a key that will receive the leftover AVAX if the validator is removed from the L1: ```bash -NodeID: NodeID-BFa1padLXBj7VHa2JYvYGzcTBPQGjPhUy -Network: Fuji -Start time: 2022-07-28 12:26:55 -End time: 2023-02-13 12:26:55 -Weight: 30 -Inputs complete, issuing transaction to add the provided validator information... -``` - -This might take a couple of seconds, and if successful, it's going to print: - -```bash -Transaction successful, transaction ID :EhZh8PvQyqA9xggxn6EsdemXMnWKyy839NzEJ5DHExTBiXbjV -``` - -This means the node is now a validator on the given Avalanche L1 on `Fuji`! - -Avalanche L1 Export[​](#avalanche-l1-export "Direct link to heading") ---------------------------------------------------------- - -This tool is most useful on the machine where a validator is or is going to be running. In order to allow a VM to run on a different machine, you can export the configuration. Just need to provide a path to where to export the data: - -```bash -avalanche blockchain export testblockchain -✔ Enter file path to write export data to: /tmp/testblockchain-export.dat + Which stored key should be used be set as a change owner for leftover AVAX?: + test + ▸ mytestkey ``` -The file is in text format and you shouldn't change it. You can then use it to import the configuration on a different machine. - -Avalanche L1 Import[​](#avalanche-l1-import "Direct link to heading") ---------------------------------------------------------- - -To import a VM specification exported in the previous section, just issue the `import` command with the path to the file after having copied the file over: +Next, select a key that can remove the validator: ```bash -avalanche blockchain import /tmp/testblockchain-export.dat -Avalanche L1 imported successfully +? Which stored key should be used be able to disable the validator using P-Chain transactions?: + test + ▸ mytestkey ``` -After this the whole Avalanche L1 configuration should be available on the target machine: - -```bash -avalanche blockchain list -+---------------+---------------+----------+-----------+----------+ -| Avalanche L1 | CHAIN | CHAIN ID | TYPE | DEPLOYED | -+---------------+---------------+----------+-----------+----------+ -| testblockchain | testblockchain | 3333 | SubnetEVM | No | -+---------------+---------------+----------+-----------+----------+ -``` +By the end of the command, you would have successfully added a new validator on the given Avalanche L1 on `Fuji`! Appendix[​](#appendix "Direct link to heading") ----------------------------------------------- @@ -712,13 +429,7 @@ To connect Core (or MetaMask) with your blockchain on the new Avalanche L1 runni ```bash - Network Name: testblockchain -- RPC URL: [http://127.0.0.1:9650/ext/bc/2XDnKyAEr1RhhWpTpMXqrjeejN23vETmDykVzkb4PrU1fQjewh/rpc] +- RPC URL: [http://127.0.0.1:9650/ext/bc/2U7vNdB78xTiN6QtZ9aetfKoGtQhfeEPQG6QZC8bpq8QMf4cDx/rpc] - Chain ID: 3333 - Symbol: TST ``` - - -Unless you deploy your Avalanche L1 on other nodes, you aren't going to be able to use other nodes, including the public API server `https://api.avax-test.network/`, to connect to Core. - - -If you want to open up this node for others to access your Avalanche L1, you should set it up properly with `https//node-ip-address` instead of `http://127.0.0.1:9650`, however, it's out of scope for this tutorial on how to do that. diff --git a/package.json b/package.json index 673bb328363..81fcf65b03b 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "tsx": "^4.19.0" }, "devDependencies": { + "@types/dompurify": "^3.2.0", "@types/mdx": "^2.0.13", "@types/node": "20.14.10", "@types/react": "^18.3.3",