概要

事前準備

設定を変更するL1 Blockchainを作成していきます。 以下のコマンドを実行してください。 「chain name」には、作成したいL1 Blockchainの名前を入力してください。

bash
avalanche blockchain create <chain name>
  • 例
bash
avalanche blockchain create chain3

作成するL1 Blockchainの設定は、「L1の作成」の「L1作成」を確認してください。

L1の設定取得

既存のL1 Blockchainのデプロイ情報を指定されたファイルに出力します。 以下のコマンドを実行してください。 「chain name」には、取得したいL1 Blockchainの名前を入力してください。

bash
avalanche blockchain export <chain name>
  • 例
bash
avalanche blockchain export chain1

出力先のファイルパスの指定を求められるので、./chain1_config.json など任意のファイルパスを指定してください。

bash
✔ Enter file path to write export data to: ./chain1_config.json

指定したファイルが作成されていたら実行成功です。 以下のようにいくつかオプションがあるので1つずつ簡単に説明します。

bash
--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の設定を確認してみます。 以下のコマンドを実行してください。

bash
cat ~/.avalanche-cli/subnets/chain3/sidecar.json

以下のように出力されます。

bash
{
    "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の名前を入力してください。

bash
avalanche blockchain configure <chain name>
  • 例
bash
avalanche blockchain configure chain3

変更する設定ファイルについて聞かれるので、「subnet.json」を選択してください。

bash
? Which configuration file would you like to provide?: 
    node-config.json
    chain.json
  ▸ subnet.json
    per-node-chain.json

反映したい設定ファイルについて確認されるので、先ほど保存したファイルを入力してください。

bash
✔ Enter the path to your configuration file: ./chain1_config.json

chain.json もあるか確認されるので、「Yes」を選択してください。

bash
? Would you like to provide the chain.json file as well?: 
    No
  ▸ Yes

chain.json は .avalanche-cli/subnets/ 配下に保存されているので、 ~/.avalanche-cli/subnets/chain1/chain.json などのように指定してください。

bash
✔ Enter the path to your configuration file: ~/.avalanche-cli/subnets/chain1/chain.json

以下のように出力されていれば実行成功です。

bash
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-mainnet

subnet.json を確認してみます。 以下のようなコマンドで設定ファイルを更新したL1 Blockchainの subnet.json を確認してください。

bash
cat /Users/<username>/.avalanche-cli/subnets/chain3/subnet.json

以下のように Name が chain1 になっていれば、chain1 の設定が chain3 に反映できています。

bash
{"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つずつ簡単に説明します。

bash
--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 string AvalancheGoのノード設定ファイルのパスを指定します。
  • --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を作成していきます。 以下のコマンドを実行してください。

bash
avalanche blockchain import file

ファイルとGithubリポジトリのどちらから設定を読み込むか選択を求められるので、「File」を選択してください。

bash
? Would you like to import your blockchain from a file or a repository?: 
  ▸ File
    Repository

ファイルの選択を求められるので、先ほど更新したファイルである ./chain1_config.json を入力してください。

bash
Select the file to import your blockchain from: ./chain1_config.json

以下のように出力されれば chain4 の作成は成功しています。

bash
Blockchain imported successfully

chain4 の設定ファイルが存在するか確認するために、以下のコマンドを実行してください。

bash
ls ~/.avalanche-cli/subnets

以下のように chain4 が含まれていれば実行は成功しています。

bash
chain1  chain2  chain3  chain4

以下のようにいくつかオプションがあるので1つずつ簡単に説明します。

bash
--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の設定をローカルに取り込むことができます。 以下のコマンドを実行してください。

bash
avalanche blockchain import public

読み込む対象の稼働中のL1 Blockchainのネットワークの選択を求められるので、「Fuji Testnet」を選択してください。

bash
? Choose a network for the operation: 
    Local Network
    Devnet
  ▸ Fuji Testnet
    Mainnet

RPC URLの入力を求められるので、今回は「Fuji Testnet」上で稼働している「Dispatch」のRPC URLである「https://subnets.avax.network/dispatch/testnet/rpc 」を入力してください。

bash
✔ What is the RPC endpoint?: https://subnets.avax.network/dispatch/testnet/rpc

EVMの選択を求められるので、「Subnet-EVM」を選択してください。

bash
? Which Virtual Machine would you like to use?: 
  ▸ Subnet-EVM
    Custom VM
    Explain the difference

「Subnet-EVM」を選択した場合、VMのバージョンを確認されるので、「v0.7.8」を選択してください。

bash
? Pick the version for this VM: 
  ▸ v0.7.8
    v0.7.7
    v0.7.5
    v0.7.4
↓   v0.7.3

以下のように出力されていれば実行成功です。

bash
Blockchain "dispatch" imported successfully

本当にL1 Blockchainの設定が追加されているか確認していきます。 以下のコマンドを実行してください。

bash
ls ~/.avalanche-cli/subnets 

以下のように dispatch という項目が追加されていれば実行が成功しています。

bash
chain1          chain2          chain3          chain4          dispatch

以下のようにいくつかオプションがあるので1つずつ簡単に説明します。

bash
--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テンプレートを使って取り込みます。
  • --devnet Devnetを対象に処理を実行します。
  • --endpoint string ネットワーク操作に使う制御用エンドポイントURLを指定します。
  • --evm Subnet-EVMのチェーン構成として取り込みます。
  • --force 同名の構成が存在しても上書きします(デフォルトは上書きしません)。
  • -f, --fuji Fujiを対象に処理を実行します(--testnet のエイリアス)。
  • -l, --local ローカルネットワークを対象に処理を実行します。
  • -m, --mainnet Mainnetを対象に処理を実行します。
  • --node-url string 既に稼働中のバリデータノードのURLを任意で指定します。 そこからメタデータを取得します。
  • -t, --testnet Testnetを対象に処理を実行します(--fuji のエイリアス)。