概要

起動中のL1 Blockchainをアップグレードしたい場合があります。 例えば、L1 Blockchainの新しい設定を定義・反映・管理やVMバイナリの更新などです。

bash
avalanche blockchain upgrade [subcommand] [flags]

アップグレードファイルの生成

L1 Blockchainの新しい設定ファイルである upgrade.json ファイルを生成します。 以下のコマンドを実行してください。 「chain name」には、アップグレードファイルを生成したいL1 Blockchainの名前を入力してください。

bash
avalanche blockchain upgrade generate <chain name>

以下のように間違った状態でチェーンの設定ファイルを反映させると、L1 Blockchainが停止する可能性があるという警告文が表示されます。 「Yes」を選択してください。

bash
Any mistakes in configuring network upgrades or coordinating them on validators may cause the network to halt and recovering may be difficult.
Please consult https://docs.avax.network/avalanche-l1s/upgrade/customize-avalanche-l1#network-upgrades-enabledisable-precompiles for more information
Use the arrow keys to navigate: ↓ ↑ → ← 
? Press [Enter] to continue, or abort by choosing 'no': 
  ▸ Yes
    No

アップグレードする項目について確認されます。 1回のアップグレードで1つの項目にすることが推奨されています。 今回は「Native Minting」を選択してみます。

bash
Avalanchego and this tool support configuring multiple precompiles. However, we suggest to only configure one per upgrade.

Use the arrow keys to navigate: ↓ ↑ → ← 
? Select the precompile to configure: 
    Contract Deployment Allow List
    Adjust Fee Settings Post Deploy
  ▸ Native Minting
    Transaction Allow List
    Customize Fees Distribution

いつから反映させるかを確認されています。 「In 5 minutes」を選択してください。

bash
Set parameters for the "Native Minting" precompile
Use the arrow keys to navigate: ↓ ↑ → ← 
? When should the precompile be activated?: 
  ▸ In 5 minutes
    In 1 day
    In 1 week
    In 2 weeks
    Custom

「Allow List」への設定を求めらるので、まずは現在の設定を確認します。 「Preview Allow List」を選択してください。

bash
The chosen block activation time is 2025-09-04 14:32:52
Use the arrow keys to navigate: ↓ ↑ → ← 
? Configure the addresses that are allowed to mint native tokens: 
    Add an address for a role to the allow list
  ▸ Preview Allow List
    Confirm Allow List
    Cancel

現在は以下のように何も設定がされていません。

bash
+---------+-------------+
| Admins  |             |
+---------+-------------+
| Manager |             |
+---------+-------------+
| Enabled |             |
+---------+-------------+

Caution: Allow lists are empty. You will not be able to easily change the precompile settings in the future.

追加するために、「Add an address for a role to the allow list」を選択してください。

bash
? Configure the addresses that are allowed to mint native tokens: 
  ▸ Add an address for a role to the allow list
    Preview Allow List
    Confirm Allow List
    Cancel

管理者権限を追加したいので、「Admin」を選択してください。

bash
? What role should the address have?: 
  ▸ Admin
    Manager
    Enabled
    Explain the difference
    Cancel

以下で管理者に設定するアドレスの入力を求めらるので、任意のアドレスを設定してください。 複数選択する場合は、カンマ区切りでつなげてください。

bash
✔ Enter the address of the account (or multiple comma separated):
  • 例
bash
✔ Enter the address of the account (or multiple comma separated): 0xAe451f1873B4C4D7263631Bf0ea141D54Ba39eEa
bash
✔ Enter the address of the account (or multiple comma separated): 0xCe451f1873B4C4D7263631Bf0ea141D54Ba39eEa,0xDe451f1873B4C4D7263631Bf0ea141D54Ba39eEa

では、再度現在の設定を確認してみます。 「Preview Allow List」を選択してください。

bash
? Configure the addresses that are allowed to mint native tokens: 
    Add an address for a role to the allow list
    Remove address from the allow list
  ▸ Preview Allow List
    Confirm Allow List
    Cancel

以下のように先ほど追加したアドレスが追加されているはずです。

bash
+---------+--------------------------------------------+
| Admins  | 0xAe451f1873B4C4D7263631Bf0ea141D54Ba39eEa |
+---------+--------------------------------------------+
| Manager |                                            |
+---------+--------------------------------------------+
| Enabled |                                            |
+---------+--------------------------------------------+

「Confirm Allow List」を選択して、設定を確定してください。

bash
? Configure the addresses that are allowed to mint native tokens: 
    Add an address for a role to the allow list
    Remove address from the allow list
    Preview Allow List
  ▸ Confirm Allow List
    Cancel

以下のように確認を求められるので、「Yes」を選択してください。

bash
? Confirm?: 
  ▸ Yes
    No, keep editing

初期発行するか聞かれるので、「Yes」を選択してください。

bash
? Airdrop more tokens? (`initialMint` section in file): 
  ▸ Yes
    No

どのように初期発行するか聞かれるので、「Add」を選択してください。

bash
? How would you like to distribute your funds: 
  ▸ Add
    Delete
    Preview
    More Info
↓   Done

初期発行先のアドレスの選択を求められるので、任意のアドレスを入力してください。

bash
✗ Address to airdrop to:

発行するトークン量の入力を求められるので、「10000000」など任意の値を入力してください。

bash
✗ Amount to airdrop (in TK01 units):

「Preview」を選択して、現在の設定を確認します。

bash
? How would you like to distribute your funds: 
    Add
    Delete
  ▸ Preview
    More Info
↓   Done

以下のように、先ほど設定したアドレスとトークン量が設定されているはずです。 先ほどの「Add」と同じ手順でアドレスを追加することで、複数アドレスを設定することも可能です。

bash
0. 0xAe451f1873B4C4D7263631Bf0ea141D54Ba39eEa-10000000

「Done」を選択してください。

bash
? How would you like to distribute your funds: 
    Add
    Delete
    Preview
    More Info
↓ ▸ Done

他のプリコンパイルを設定するか聞かれます。 先ほども言ったように、1回のアップグレードでは1つの設定変更が推奨されているため、「No」を選択してください。

bash
? Should we configure another precompile?: 
  ▸ No
    Yes

以下のように出力されていれば実行が成功して、「/Users/<username>/.avalanche-cli/subnets/chain1/upgrade.json」という場所に先ほどの設定が反映されているファイルが保存されます。

bash
Writing upgrade into /Users/<username>/.avalanche-cli/subnets/chain1/upgrade.json

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 chain1-local-node-fuji
  avalanche node local start chain1-local-start-fuji

To apply the change to local validators on Mainnet:
  avalanche node local stop chain1-local-node-mainnet
  avalanche node local start chain1-local-start-mainnet
json
{
	"precompileUpgrades": [
		{
			"contractNativeMinterConfig": {
				"adminAddresses": [
					"0xae451f1873b4c4d7263631bf0ea141d54ba39eea"
				],
				"blockTimestamp": 1756963972,
				"initialMint": {
					"0xae451f1873b4c4d7263631bf0ea141d54ba39eea": "0x989680"
				}
			}
		}
	]
}

実際にファイルとして保存されているかも確認します。 以下のコマンドを実行して、~/.avalanche-cli/subnets/chain1 配下のファイルを確認します。

bash
ls ~/.avalanche-cli/subnets/chain1

以下のように、upgrade.json というファイルが生成されています。

bash
chain.json      genesis.json    sidecar.json    upgrade.json

中身を確認すると以下のようになっているので、ちゃんと先ほどの設定を反映したファイルが生成されています。

bash
{
	"precompileUpgrades": [
		{
			"contractNativeMinterConfig": {
				"adminAddresses": [
					"0xae451f1873b4c4d7263631bf0ea141d54ba39eea"
				],
				"blockTimestamp": 1756963972,
				"initialMint": {
					"0xae451f1873b4c4d7263631bf0ea141d54ba39eea": "0x989680"
				}
			}
		}
	]
}

アップグレードファイルの出力

生成したアップグレードファイルの内容をコンソールに出力して、すぐに内容を確認していきます。 以下のコマンドを実行してください。 「chain name」には、作成したL1 Blockchainの名前を入力してください。

bash
avalanche blockchain upgrade print <chain name>
  • 例
bash
avalanche blockchain upgrade print chain1

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

bash
{
  "precompileUpgrades": [
    {
      "contractNativeMinterConfig": {
        "adminAddresses": [
          "0xae451f1873b4c4d7263631bf0ea141d54ba39eea"
        ],
        "blockTimestamp": 1756963972,
        "initialMint": {
          "0xae451f1873b4c4d7263631bf0ea141d54ba39eea": "0x989680"
        }
      }
    }
  ]
}

アップグレードファイルのexport

生成済みのアップグレードバイトファイルを任意の場所に出力します。 このファイルは他のノードへの配布やバックアップに利用できます。 以下のコマンドを実行してください 「chain name」には、作成したL1 Blockchainの名前を入力してください。

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

そうすると以下のようにどこに保存するかを確認されるので、config.json としてしてください。

bash
Provide a path where we should export the file to:

そうすると、実行したディレクトリの配下に config.json が生成されます。 中身を確認してみると以下のようになっており、先ほど設定した情報が出力されています。

json
{
	"precompileUpgrades": [
		{
			"contractNativeMinterConfig": {
				"adminAddresses": [
					"0xae451f1873b4c4d7263631bf0ea141d54ba39eea"
				],
				"blockTimestamp": 1756963972,
				"initialMint": {
					"0xae451f1873b4c4d7263631bf0ea141d54ba39eea": "0x989680"
				}
			}
		}
	]
}

upgrade.json の内容が出力されるため、upgrade.json がない場合は以下のようなエラーが出ます。

bash
Error: open /Users/cardene/.avalanche-cli/subnets/chain2/upgrade.json: no such file or directory

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

bash
--force                      If true, overwrite a possibly existing file without prompting
--upgrade-filepath string    Export upgrade bytes file to location of choice on disk
  • --force エクスポート先に同名のファイルが既に存在する場合でも、確認なしで上書き保存します。
  • --upgrade-filepath string アップグレードバイトファイルを出力するパスを指定します。 任意のディレクトリ・ファイル名を設定可能です。

アップグレードファイルのimport

exportされたアップグレードファイルをローカル環境に取り込みます。 このコマンドを利用することで、他ノードから共有されたアップグレードファイルを自身の作成したL1 Blockchainに適用することができます。

まずは別のL1 Blockchainを作成する必要があるため、chain2 というチェーンを作成します。 以下のコマンドを実行してください。

bash
avalanche blockchain create chain2

詳細は「L1の作成」を参考にしてください。 デプロイはしなくて良いので、以下のコマンドで chain1 のアップグレード設定を chain2 に反映させます。 以下のコマンドを実行してください。 「chain name」には、先ほど作成したL1 Blockchainの名前を入力してください。

bash
avalanche blockchain upgrade import <chain name>
  • 例
bash
avalanche blockchain upgrade import chain2

どのファイルをimportするか聞かれるので、先ほどexportしたファイルのパスである config.json を入力してください。

bash
✗ Provide the path to the upgrade file to import:

以下のように出力されていれば、chain2 に chain1 のアップグレード設定を反映できています。

bash
Writing upgrade into /Users/cardene/.avalanche-cli/subnets/chain2/upgrade.json

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 chain2-local-node-fuji
  avalanche node local start chain2-local-start-fuji

To apply the change to local validators on Mainnet:
  avalanche node local stop chain2-local-node-mainnet
  avalanche node local start chain2-local-start-mainnet

念の為、print コマンドで確認してみます。 以下のコマンドを実行してください。 「chain name」には、先ほど作成したL1 Blockchainの名前を入力してください。

bash
avalanche blockchain upgrade import <chain name>
  • 例
bash
avalanche blockchain upgrade print chain2

以下のように出力されていれば、chain1 のアップグレード設定が適切に chain2 にも反映されています。

json
{
  "precompileUpgrades": [
    {
      "contractNativeMinterConfig": {
        "adminAddresses": [
          "0xae451f1873b4c4d7263631bf0ea141d54ba39eea"
        ],
        "blockTimestamp": 1756963972,
        "initialMint": {
          "0xae451f1873b4c4d7263631bf0ea141d54ba39eea": "0x989680"
        }
      }
    }
  ]
}

以下のようなオプションがあるので簡単に説明します。

bash
--upgrade-filepath string    Import upgrade bytes file into local environment
  • --upgrade-filepath string importするアップグレードバイトファイルのパスを指定します。 エクスポート済みファイルを取り込む際に必須のオプションです。

VMバイナリのアップグレード

ブロックチェーンのVM(仮想マシン)バイナリをアップグレードするために利用します。 対象はローカル環境のブロックチェーンかFuji / Mainnetにデプロイされたブロックチェーンの両方です。 以下のコマンドを実行してください。 「chain name」には、先ほど作成したL1 Blockchainの名前を入力してください。

bash
avalanche blockchain upgrade vm <chain name>
  • 例
bash
avalanche blockchain upgrade vm chain2

変更するVMの設定について確認されますが、現在は1つしかないのでそのまま選択してください。

bash
 What deployment would you like to upgrade: 
  ▸ Update config for future deployments

どのようにVMを更新するか確認されます。 今回は別バージョンのVMを設定したので、「Update to a specific version」を選択してください。

bash
? How would you like to update your subnet's virtual machine: 
    Update to latest version
  ▸ Update to a specific version
    Update to a custom binary

更新するバージョンを幾つにするか確認されるので、「v0.7.5」と入力してください。 Subnet EVMのバージョンについては以下から確認できます。 https://github.com/ava-labs/subnet-evm/releases

bash
Enter version:

以下のように出力されれば、VMの設定完了です。 次回のアップグレード反映時に適用されるようになります。

bash
VM updated for future deployments. Update will apply next time subnet is deployed.

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

bash
--binary string        Upgrade to custom binary
--fuji                 fuji           upgrade existing fuji deployment (alias for `testnet`)
--latest               upgrade to latest version
--local                local         upgrade existing local deployment
--mainnet              mainnet     upgrade existing mainnet deployment
--plugin-dir string    plugin directory to automatically upgrade VM
--print                print instructions for upgrading
--testnet              testnet     upgrade existing testnet deployment (alias for `fuji`)
--version string       Upgrade to custom version
  • --binary string カスタムのVMバイナリファイルを指定してアップグレードを行います。
  • --fuji Fuji Testnet上にデプロイ済みのブロックチェーンをアップグレードします。 --testnet のエイリアスです。
  • --latest 利用可能な最新のVMバージョンにアップグレードします。
  • --local ローカル環境にデプロイ済みのブロックチェーンをアップグレードします。
  • --mainnet Mainnet上にデプロイ済みのブロックチェーンをアップグレードします。
  • --plugin-dir string 指定したプラグインディレクトリを利用してVMを自動的にアップグレードします。
  • --print 実際の適用は行わず、アップグレード手順を出力します。 Publicネットワーク上での手動作業の参考に使えます。
  • --testnet Testnet(Fuji)上のブロックチェーンをアップグレードします。 --fuji と同義です。
  • --version string 特定のバージョンを指定してアップグレードを実行します。

アップグレードの反映

生成済みのアップグレードファイルを現在稼働中のL1 Blockchainノードに適用します。 Publicネットワーク(Fuji Testnet または Mainnet)で利用する場合は、対象のバリデータにアクセスできる必要があります。 Avalanche CLIが同一マシンで動作している場合はノード設定を自動で変更しますが、別マシンから実行する場合は手動で行うための設定手順を出力します。

設定を更新した後は必ずバリデータを手動で再起動** してください。 また --avalanchego-chain-config-dir を指定すると、アップグレードファイルをそのディレクトリに書き込みます。 以下のコマンドを実行してください。 「chain name」には、先ほど作成したL1 Blockchainの名前を入力してください。

bash
avalanche blockchain upgrade apply <chain name>
  • 例
bash
avalanche blockchain upgrade apply chain1

どの設定を適用させるか確認されますが、1つしかないのでそのまま選択してください。

bash
? What deployment would you like to upgrade: 
  ▸ Existing local deployment

アップグレードの確認を求めらるので、「Yes」を選択してください。

bash
Warning: one or more of your upgrades is set to happen in the past.
If you've already upgraded your network, the configuration is likely correct and will not cause problems.
If this is a new upgrade, this configuration could cause unpredictable behavior and irrecoverable damage to your Subnet.
The config MUST be removed. Use caution before proceeding
Use the arrow keys to navigate: ↓ ↑ → ← 
? Do you want to continue (use --force to skip prompting)?:   ▸ Yes
    No

ただ、なぜか以下のようにうまくいかないので、原因がわかったらこの部分を修正します。

bash
No local network running. Please start the network first.
Error: timed out trying to contact backend controller, it is most probably not running

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

bash
--avalanchego-chain-config-dir string    avalanchego's chain config file directory (default "/home/runner/.avalanchego/chains")
--config                                 create upgrade config for future subnet deployments (same as generate)
--force                                  If true, don't prompt for confirmation of timestamps in the past
--fuji                                   fuji           apply upgrade existing fuji deployment (alias for `testnet`)
-h, --help                               help for apply
--local                                  local          apply upgrade existing local deployment
--mainnet                                mainnet        apply upgrade existing mainnet deployment
--print                                  if true, print the manual config without prompting (for public networks only)
--testnet                                testnet        apply upgrade existing testnet deployment (alias for `fuji`)
--log-level string                       log level for the application (default "ERROR")
--skip-update-check                      skip check for new versions
  • --avalanchego-chain-config-dir string AvalancheGoのチェーン設定ファイルを配置するディレクトリを指定します。 デフォルトは、 /home/runner/.avalanchego/chains です。
  • --config 将来のサブネットデプロイ用にアップグレード設定を生成します。 upgrade generate と同等の動作を行います。
  • --force 過去のタイムスタンプに関する確認を行わず、強制的に適用します。
  • --fuji Fuji Testnet上の既存デプロイにアップグレードを適用します。 --testnet のエイリアスです。
  • --local ローカル環境にデプロイされたブロックチェーンにアップグレードを適用します。
  • --mainnet Mainnet上の既存デプロイにアップグレードを適用します。
  • --print Publicネットワークで利用する時に、アップグレード手順を実行せずに表示します。 手動設定を行いたい場合に有効です。
  • --testnet Testnet(Fuji)上の既存デプロイにアップグレードを適用します。 --fuji のエイリアスです。
  • --log-level string ログ出力の詳細度を指定します。 デフォルトは "ERROR" です。 例: "INFO", "DEBUG", "WARN"