版本比较

密钥

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

这里以halley的版本号从v4升级到v6为例

背景介绍

starcoin中starcoin-framework中有两个比较重要的版本号,一个是LanguageVersion这里就是Move字节码的版本号,新的字节码版本号一般会添加新的字节码 参考这里https://github.com/starcoinorg/move/blob/dev_v6/language/move-binary-format/src/file_format_common.rs#L404-#L407

...

代码块
StdlibUpgradeScripts::do_upgrade_from_v6_to_v7_with_language_version(&genesis_account, 6);

相关操作

1.查看当前move字节码版本

代码块
starcoin% state get resource 0x1 0x1::Config::Config<0x1::LanguageVersion::LanguageVersion>
{
  "ok": {
    "json": {
      "payload": {
        "major": 4
      }
    },
  }
}

2.发起升级提案

在console下使用如下命令

代码块
account execute-function --function 0x00000000000000000000000000000001::OnChainConfigScripts::propose_update_move_language_version -s 0xed9ea1f3533c14e1b52d9ff6475776ba --arg 6u64 --arg 0u64 -b

...

代码块
    /// global DAO info of the specified token type `Token`.
    struct DaoGlobalInfo<phantom Token: store> has key {
        /// next proposal id.
        next_proposal_id: u64,
        /// proposal creating event.
        proposal_create_event: Event::EventHandle<ProposalCreatedEvent>,
        /// voting event.
        vote_changed_event: Event::EventHandle<VoteChangedEvent>,
    }

3.查看投票状态

使用如下命令

代码块
dev call --function 0x1::Dao::proposal_state -t 0x1::STC::STC -t 0x1::OnChainConfigDao::OnChainConfigUpdate<0x1::LanguageVersion::LanguageVersion> --arg 0xed9ea1f3533c14e1b52d9ff6475776ba --arg 0

...

min_action_delay投票通过后多长时间后可以执行交易, voting_quorum_rate 投票赞成超过多少百分比代表成功,后面回提到这些和状态转换有些关系

4.投票

这里在console中使用基金会账号投票,一定能保证结果超过%4,

...

代码块
    public ( script ) fun cast_vote<Token: copy + drop + store, ActionT: copy + drop + store>(
        signer: signer,
        proposer_address: address,
        proposal_id: u64,
        agree: bool,
        votes: u128,
    )

5. 查看投票结果

使用命令

代码块
dev call --function 0x1::Dao::proposal_info -t 0x1::STC::STC -t 0x1::OnChainConfigDao::OnChainConfigUpdate<0x1::LanguageVersion::LanguageVersion> --arg 0xed9ea1f3533c14e1b52d9ff6475776ba

...

4是AGREE代表成功, 3是DEFEATED代表失败

6.投票成功后将提案加入执行队列

(main使用poll.starcoin.org网页,这步会自动执行)

...

使用查看投票状态命令直到变成6 EXECUTABLE可以执行下一步

7.执行提案

使用命令

代码块
account execute-function -s 0xed9ea1f3533c14e1b52d9ff6475776ba --function 0x1::OnChainConfigScripts::execute_on_chain_config_proposal -t 0x1::LanguageVersion::LanguageVersion --arg 0

...

代码块
    public ( script ) fun execute_on_chain_config_proposal<ConfigT: copy + drop + store>(account: signer, proposal_id: u64) {

8.取回质押的Token

使用下面命令

代码块
account execute-function -s 0x0000000000000000000000000a550c18 --function 0x1::DaoVoteScripts::unstake_vote -t 0x1::STC::STC -t 0x1::OnChainConfigDao::OnChainConfigUpdate<0x1::LanguageVersion::LanguageVersion> --arg 0xed9ea1f3533c14e1b52d9ff6475776ba --arg 0

9.清理完成提案

代码块
account execute-function --function 0x1::Dao::destroy_terminated_proposal -t 0x1::STC::STC -t 0x1::OnChainConfigDao::OnChainConfigUpdate<0x1::LanguageVersion::LanguageVersion> --arg 0xed9ea1f3533c14e1b52d9ff6475776ba --arg 0u64

10.查看move版本字节码

代码块
starcoin% state get resource 0x1 0x1::Config::Config<0x1::LanguageVersion::LanguageVersion>
{
  "ok": {
    "json": {
      "payload": {
        "major": 6
      }
    },
    "raw": "0x0600000000000000"
  }
}

...