概要
事前準備
設定を変更するL1 Blockchainを作成していきます。 以下のコマンドを実行してください。 「chain name」には、作成したいL1 Blockchainの名前を入力してください。
avalanche blockchain create <chain name>- 例
avalanche blockchain create chain3作成するL1 Blockchainの設定は、「L1の作成」の「L1作成」を確認してください。
L1の設定取得
既存のL1 Blockchainのデプロイ情報を指定されたファイルに出力します。 以下のコマンドを実行してください。 「chain name」には、取得したいL1 Blockchainの名前を入力してください。
avalanche blockchain export <chain name>- 例
avalanche blockchain export chain1出力先のファイルパスの指定を求められるので、./chain1_config.json など任意のファイルパスを指定してください。
✔ Enter file path to write export data to: ./chain1_config.json指定したファイルが作成されていたら実行成功です。 以下のようにいくつかオプションがあるので1つずつ簡単に説明します。
--custom-vm-branch string custom vm branch
--custom-vm-build-script string custom vm build-script
--custom-vm-repo-url string custom vm repository url
-o, --output string write the export data to the provided file path--custom-vm-branch stringカスタムVMのGitブランチ名を指定します。 エクスポート情報に、どのブランチ由来のVMかを明示します。--custom-vm-build-script stringカスタムVMをビルドするスクリプトのパス(またはコマンド)を指定します。--custom-vm-repo-url stringカスタムVMのリポジトリURL(例:Git URL)を指定します。 VMの取得元を明示します。-o, --output string書き出し先ファイルパスを指定します。
L1の設定変更
L1 Blockchainのチェーン設定(各ブロックチェーンごとに適用)やノード設定をまとめて指定します。 指定された各設定ファイルを指定されたL1 Blockchainに反映します。
まずは、現在のL1 Blockchainの設定を確認してみます。 以下のコマンドを実行してください。
cat ~/.avalanche-cli/subnets/chain3/sidecar.json以下のように出力されます。
{
"Name": "chain3",
"VM": "Subnet-EVM",
"VMVersion": "v0.7.8",
"RPCVersion": 43,
"Subnet": "chain3",
"ExternalToken": false,
"TokenName": "TK03 Token",
"TokenSymbol": "TK03",
"ChainID": "",
"Version": "1.4.0",
"Networks": null,
"ImportedFromAPM": false,
"ImportedVMID": "",
"CustomVMRepoURL": "",
"CustomVMBranch": "",
"CustomVMBuildScript": "",
"TeleporterReady": true,
"TeleporterKey": "cli-teleporter-deployer",
"TeleporterVersion": "v1.0.0",
"RunRelayer": true,
"SubnetEVMMainnetChainID": 0,
"ValidatorManagement": "Proof Of Authority",
"ValidatorManagerOwner": "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC",
"ProxyContractOwner": "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC",
"Sovereign": true,
"UseACP99": true
}%次にこのL1 Blockchainの設定を変更していきます。 「chain name」には、設定変更したいL1 Blockchainの名前を入力してください。
avalanche blockchain configure <chain name>- 例
avalanche blockchain configure chain3変更する設定ファイルについて聞かれるので、「subnet.json」を選択してください。
? Which configuration file would you like to provide?:
node-config.json
chain.json
▸ subnet.json
per-node-chain.json反映したい設定ファイルについて確認されるので、先ほど保存したファイルを入力してください。
✔ Enter the path to your configuration file: ./chain1_config.jsonchain.json もあるか確認されるので、「Yes」を選択してください。
? Would you like to provide the chain.json file as well?:
No
▸ Yeschain.json は .avalanche-cli/subnets/ 配下に保存されているので、 ~/.avalanche-cli/subnets/chain1/chain.json などのように指定してください。
✔ Enter the path to your configuration file: ~/.avalanche-cli/subnets/chain1/chain.json以下のように出力されていれば実行成功です。
File /Users/<username>/.avalanche-cli/subnets/chain3/subnet.json successfully written
File /Users/<username>/.avalanche-cli/subnets/chain3/chain.json successfully written
To apply the change on Local Network:
avalanche network stop
avalanche network start
To apply the change to local validators on Fuji:
avalanche node local stop chain3-local-node-fuji
avalanche node local start chain3-local-start-fuji
To apply the change to local validators on Mainnet:
avalanche node local stop chain3-local-node-mainnet
avalanche node local start chain3-local-start-mainnetsubnet.json を確認してみます。
以下のようなコマンドで設定ファイルを更新したL1 Blockchainの subnet.json を確認してください。
cat /Users/<username>/.avalanche-cli/subnets/chain3/subnet.json以下のように Name が chain1 になっていれば、chain1 の設定が chain3 に反映できています。
{"Sidecar":{"Name":"chain1","VM":"Subnet-EVM","VMVersion":"v0.7.8","RPCVersion":43,"Subnet":"chain1","ExternalToken":false,"TokenName":"TK01 Token","TokenSymbol":"TK01","ChainID":"","Version":"1.4.0","Networks":{"Local Network":{"SubnetID":"2W9boARgCWL25z6pMFNtkCfNA5v28VGg9PmBgUJfuKndEdhrvw","BlockchainID":"...以下のようにいくつかオプションがあるので1つずつ簡単に説明します。
--chain-config string path to the chain configuration
--node-config string path to avalanchego node configuration
--per-node-chain-config string path to per node chain configuration for local network
--subnet-config string path to the subnet configuration--chain-config string対象チェーン(例: Subnet-EVM)のチェーン設定ファイルのパスを指定します。--node-config stringAvalancheGoのノード設定ファイルのパスを指定します。--per-node-chain-config stringローカルネットワーク用の、ノード単位のチェーン設定ファイルのパスを指定します。--subnet-config string対象Subnet/L1全体に適用されるネットワーク設定ファイルのパスを指定します。
L1設定の読み込み
L1 Blockchainの設定をファイルから読み込んでいきます。
exportしたファイルのL1 Blockchain名を変更していきます。
chain1_config.json などexportしたファイルを開いて、Name の部分を chain4 などに変更してください。
変更できたら設定ファイルを読み込んで、chain4 というL1 Blockchainを作成していきます。
以下のコマンドを実行してください。
avalanche blockchain import fileファイルとGithubリポジトリのどちらから設定を読み込むか選択を求められるので、「File」を選択してください。
? Would you like to import your blockchain from a file or a repository?:
▸ File
Repositoryファイルの選択を求められるので、先ほど更新したファイルである ./chain1_config.json を入力してください。
Select the file to import your blockchain from: ./chain1_config.json以下のように出力されれば chain4 の作成は成功しています。
Blockchain imported successfullychain4 の設定ファイルが存在するか確認するために、以下のコマンドを実行してください。
ls ~/.avalanche-cli/subnets以下のように chain4 が含まれていれば実行は成功しています。
chain1 chain2 chain3 chain4以下のようにいくつかオプションがあるので1つずつ簡単に説明します。
--blockchain string the blockchain configuration to import from the provided repo
--branch string the repo branch to use if downloading a new repo
-f, --force overwrite the existing configuration if one exists
--repo string the repo to import (ex: ava-labs/avalanche-plugins-core) or url to download the repo from--blockchain string指定したGithubリポジトリ内から取り込むブロックチェーン設定名を指定します。--branch string新規にリポジトリをダウンロードする時に使うブランチ名を指定します。-f, --force同じL1 Blockchainの設定が既に存在しても上書きします(デフォルトでは上書きしません)。--repo string取り込み元のGithubリポジトリを指定します。
稼働しているL1設定の読み込み
現在稼働中のL1 Blockchainの設定をローカルに取り込んでいきます。 例えば、TestnetやMainnetで実際に稼働しているL1 Blockchainの設定をローカルに取り込むことができます。 以下のコマンドを実行してください。
avalanche blockchain import public読み込む対象の稼働中のL1 Blockchainのネットワークの選択を求められるので、「Fuji Testnet」を選択してください。
? Choose a network for the operation:
Local Network
Devnet
▸ Fuji Testnet
MainnetRPC URLの入力を求められるので、今回は「Fuji Testnet」上で稼働している「Dispatch」のRPC URLである「https://subnets.avax.network/dispatch/testnet/rpc 」を入力してください。
✔ What is the RPC endpoint?: https://subnets.avax.network/dispatch/testnet/rpcEVMの選択を求められるので、「Subnet-EVM」を選択してください。
? Which Virtual Machine would you like to use?:
▸ Subnet-EVM
Custom VM
Explain the difference「Subnet-EVM」を選択した場合、VMのバージョンを確認されるので、「v0.7.8」を選択してください。
? Pick the version for this VM:
▸ v0.7.8
v0.7.7
v0.7.5
v0.7.4
↓ v0.7.3以下のように出力されていれば実行成功です。
Blockchain "dispatch" imported successfully本当にL1 Blockchainの設定が追加されているか確認していきます。 以下のコマンドを実行してください。
ls ~/.avalanche-cli/subnets 以下のように dispatch という項目が追加されていれば実行が成功しています。
chain1 chain2 chain3 chain4 dispatch以下のようにいくつかオプションがあるので1つずつ簡単に説明します。
--blockchain-id string the blockchain ID
--cluster string operate on the given cluster
--custom use a custom VM template
--devnet operate on a devnet network
--endpoint string use the given endpoint for network operations
--evm import a subnet-evm
--force overwrite the existing configuration if one exists
-f, --fuji testnet operate on fuji (alias to testnet
-l, --local operate on a local network
-m, --mainnet operate on mainnet
--node-url string [optional] URL of an already running validator
-t, --testnet fuji operate on testnet (alias to fuji)--blockchain-id string取り込み対象のブロックチェーンID(CB58 形式のIDなど)を指定します。--cluster string操作対象のクラスタ名(Avalanche CLIで命名したノード集合)を指定します。--customカスタムVMテンプレートを使って取り込みます。--devnetDevnetを対象に処理を実行します。--endpoint stringネットワーク操作に使う制御用エンドポイントURLを指定します。--evmSubnet-EVMのチェーン構成として取り込みます。--force同名の構成が存在しても上書きします(デフォルトは上書きしません)。-f, --fujiFujiを対象に処理を実行します(--testnetのエイリアス)。-l, --localローカルネットワークを対象に処理を実行します。-m, --mainnetMainnetを対象に処理を実行します。--node-url string既に稼働中のバリデータノードのURLを任意で指定します。 そこからメタデータを取得します。-t, --testnetTestnetを対象に処理を実行します(--fujiのエイリアス)。