public-awesome / cw-nfts

Examples and helpers to build NFT contracts on CosmWasm
Apache License 2.0
185 stars 181 forks source link

Add CosmOrc test for NFT mint, transfer, and instantiate gas usage. #84

Open 0xekez opened 1 year ago

0xekez commented 1 year ago

This adds @de-husk's amazing cosmwasm orc library to this repository which allows us to run contract tests against a real local chan and measure gas usage while we're at it. It currently tests a simple instantiate, mint, and transfer flow and captures gas usage in ci/integration-tests/gas_reports.

Here is an example gas report showing the gas usage of each operation:

{
  "cw721_base": {
    "Execute__cw721_base_mint": {
      "file_name": "ci/integration-tests/src/tests/cw721_base_test.rs",
      "gas_used": 140453,
      "gas_wanted": 186171,
      "line_number": 39
    },
    "Execute__cw721_base_transfer": {
      "file_name": "ci/integration-tests/src/tests/cw721_base_test.rs",
      "gas_used": 137331,
      "gas_wanted": 181488,
      "line_number": 55
    },
    "Instantiate__cw721_base_init": {
      "file_name": "ci/integration-tests/src/tests/cw721_base_test.rs",
      "gas_used": 165333,
      "gas_wanted": 223490,
      "line_number": 21
    }
  }
}

Merging this will cause the associated GitHub action to make a comment on new changes describing how gas usage changed for its tests:

image
mikedotexe commented 1 year ago

Extremely useful, thanks Ekez

ethanfrey commented 1 year ago

This orc things looks cool.

Is it ready for larger use? Can you link it here? https://github.com/CosmWasm/cw-plus/issues/507

We had been discussing some way to benchmark gas better, but in the end it needs a chain, not just a local vm, to do this proper.

JakeHartnell commented 1 year ago

This orc things looks cool.

Is it ready for larger use? Can you link it here? CosmWasm/cw-plus#507

We had been discussing some way to benchmark gas better, but in the end it needs a chain, not just a local vm, to do this proper.

Done. I think it's ready?