部署失败后的recover
在主网和devnet上,部署时经常会失败,提示如下信息:
========================================================================
Recover the intermediate account's ephemeral keypair file with
`solana-keygen recover` and the following 12-word seed phrase:
========================================================================
cry early sweet custom permit myself ride great fitness now two announce <-- 中间账户私钥
========================================================================
To resume a deploy, pass the recovered keypair as the
[BUFFER_SIGNER] to `solana program deploy` or `solana program write-buffer'.
Or to recover the account's lamports, pass it as the
[BUFFER_ACCOUNT_ADDRESS] argument to `solana program close`.
========================================================================
Error: 19 write transactions failed
There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }.
这是因为部署失败,但是SOL被保存到一个中间账户,该账户的私钥已经告知,所以可以按以下步骤操作:
1- 生成中间账户
根据提示,执行以下命令,生成临时中间账户,私钥保存到当前目录的user-keypair.json
文件中。
solana-keygen recover -o user-keypair.json --force
2- 执行以下命令继续部署:
solana program deploy --buffer user-keypair.json ./target/deploy/<程序名>.so
Gas费用消耗记录
- 初次部署前主账户余额:
5.45904024 SOL
- 出错后主账户余额:
3.21873536 SOL
,中间账户中余额:2.23870488 SOL
, 合计:5.45744024 SOL
,消耗了0.0016 SOL
- 使用中间账户再次部署后,中间账户余额:
0 SOL
,主账户余额:3.21758392 SOL
,主账户消耗了0.00115144 SOL
升级了一些功能后,再次部署,如果出错,会再次生成一个新的中间账户,账户变化情况如下:
- 出错后主账户余额:
0.97616544 SOL
, 中间账户中余额:2.23926168 SOL
,合计:3.21542712 SOL
,消耗了0.0021568 SOL
- 使用中间账户再次部署后,中间账户余额:
0 SOL
, 中间账户将所有资金还给了主账户,主账户余额:3.21542212 SOL
, 主账户消耗了0.000005 SOL
原因是在程序升级时,只需要消耗增加的资源消耗。