版本比较

密钥

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

...

代码块
//# init --rpc <http://barnard.seed.starcoin.org>  --block-number 6487000

//# faucet --addr creator --amount 100000000000

//# block

//# call-api chain.get_block_by_number [6487001]

//# run --signers creator --args {{$.call-api[0].header.number}}u64  --args {{$.call-api[0].header.block_hash}}
script{
    use StarcoinFramework::Vector;
    use StarcoinFramework::Debug;
    fun main(_sender: signer, block_number: u64, block_hash: vector<u8>){
        
        Debug::print(&block_hash);
        assert!(block_number == 6487001, 100);
        assert!(Vector::length(&block_hash) == 32, 101);
        // 0x2e12...fc8e is the block hash of number 6487001 on barnard network.
        assert!(x"2e121adfe4bacb96de73e8b1afa5a67b8276bc4319fc3b4c0f346d12751ffc8e" != block_hash, 1002);
    }
}
  • During initialization, the state tree will be updated, and dozens of state tree nodes need to be read. These nodes must be obtained remotely through rpc. If the network is slow, the initialization process will be longer, up to 2-3 minutes.

4. Added package and deploy commands

In version 1.11, the publish command can be used to publish the module, which automatically compiles the Move module and builds the package transaction.

But sometimes, we need to know the Package hash in an integration test, such as a two-phase upgrade. The new package and deploy commands meet this need.

Example of use:

代码块
//# init -n dev

//# faucet --addr creator --amount 100000000000

//# package
module creator::test {
    public fun hello(){}   
}

//# deploy {{$.package[0].file}}

//# run --signers creator
script{
    use creator::test;
    fun main(_sender: signer){
        test::hello();
    }
} 

CLI

1. Command output and template variables

The output results of the command will be saved in the running environment, and subsequent commands can obtain these results, and use template variables to use some fields in the results as input parameters of subsequent commands.

This feature can meet the requirement that some tests need to rely on the output result of the pre-order command as the input parameter.

Example of use:

代码块
starcoin% chain list-block
starcoin% chain get-block {{$.chain[0].ok[0].block_hash}}

2. dry-run mode

It supports dry-run mode, which can obtain the status from remote nodes, and then execute dry-run locally, which is convenient for debugging.

dry-run mode reads the latest state from the remote node, and then executes transactions based on the latest state of the node, but does not change at the same time

Example of use:

Connect to the remote node through the command starcoin --connect ws://barnard.seed.starcoin.org:9870 --local-account-dir ~/.starcoin/barnard/account_vaults consoleand enter the command line mode, then in the command line Just add the --dry-run option when executing a transaction.

代码块
account transfer --receiver 0x662ba5a1a1da0f1c70a9762c7eeb7aaf -v 2998645035 --dry-run

Transaction result:

代码块
{
  "ok": {
    "dry_run_output": {
      "events": [
        ...
      ],
      "explained_status": "Executed",
      "gas_used": "284531",
      "status": "Executed",
      "write_set": [
        ...
      ]
    },
    "execute_output": null,
    "raw_txn": {
      "chain_id": 251,
      "decoded_payload": {
        "ScriptFunction": {
          "args": [
            "0x662ba5a1a1da0f1c70a9762c7eeb7aaf",
            2998645035
          ],
          "function": "peer_to_peer_v2",
          "module": "0x00000000000000000000000000000001::TransferScripts",
          "ty_args": [
            "0x00000000000000000000000000000001::STC::STC"
          ]
        }
      },
      "expiration_timestamp_secs": "1661695240",
      "gas_token_code": "0x1::STC::STC",
      "gas_unit_price": "1",
      "max_gas_amount": "10000000",
      "payload": "0x...",
      "sender": "0x13ef2286ebcb79d268415660221de46a",
      "sequence_number": "3"
    },
    "raw_txn_hex": "0x..."
  }
}

The execution and result of the transaction can be checked in this way, but the modified state is not updated to the blockchain.

3. Resource paging query and filtering

The state list resource can be paged and queried, and can be filtered by resource_type and event.

When there are too many resources under the account, using paging query can improve the query speed, reduce the content displayed on the terminal, and make it more convenient to display.

Using resource_type, you can quickly query the specified resource and reduce unnecessary information display.

Command line arguments:

代码块
starcoin% state list resource -h
state-list-resource 

USAGE:
    state list resource [OPTIONS] <ADDRESS>

ARGS:
    <ADDRESS>    account address

OPTIONS:
    -h, --help                             Print help information
    -i, --start-index <START_INDEX>        
    -n, --block-number <BLOCK_NUMBER>      Get state at a special block height
    -s, --max-size <MAX_SIZE>              
    -t, --resource-type <RESOURCE_TYPE>    
  • Paging query:
    state list resource <address> -i <start index> -s <number of resources>

  • Filter based on resource_type:
    state list resource <address> -t <resouce type>

Example of use:

Query the Token balance, the resource type is 0x1::Account::Balance

代码块
starcoin% state list resource 0xa2e5e803294a89e8a627f85729444c7f -t 0x1::Account::Balance
{
  "ok": {
    "resources": {
      "0x00000000000000000000000000000001::Account::Balance<0x00000000000000000000000000000001::STC::STC>": {
        "json": {
          "token": {
            "value": 12000108858
          }
        },
        "raw": "0x3a2143cb020000000000000000000000"
      }
    }
  }
}

Major Changes Pull Request

[mpm]

[rpc]

[cli]

  • Change the default devnet data dir by @YusongWang in #3570

  • cli: dev get-coin don't check account by @YusongWang in #3589

  • [cli] dry run at cli side and print warn log when transaction execute failed by @jolestar in #3597

  • [scmd]Support jpst template expression in command line and starcoin testsuit by @jolestar in #3583

  • provide install script for the latest starcoin and mpm by @yuliyu123 in #3610

  • [cli]list resource support filter struct_type and start_idx max_size by @YusongWang in #3639

[StarcoinFramework]

StarcoinFramework 最新版,包含 DAOSpacke 的逻辑,升级并部署到 Halley 测试网。

 

完整的变更请查看:(TODO 等正式的 release 版本)

感谢贡献者:(列表)