scout icon indicating copy to clipboard operation
scout copied to clipboard

Add support for metering

Open axic opened this issue 5 years ago • 0 comments

The goal is to be able to meter EEs and store those in the yaml file. It should be possible to try different metering approaches.

Regarding the API I suggest a slightly different one to Ewasm 1.x, to follow the naming planned for Primea: ticks as opposed to gas, where ticks represent "cpu ticks" aka "cpu cycles".

  1. The only API would be useTicks(i64). This has been added in 0b9882ef.
  2. As part of that ticks are hardcoded currently to 10_000_000 in Runtime. We could consider exposing this to the YAML.
  3. The YAML should be extended with a ticksCount or ticksUsed field next to the expected post state.

Lastly, the question is how to inject metering. We could consider:

  1. Using the sentinel contract as is, but that would require the subset of Ewasm 1.0 API.
  2. Changing the sentinel contract to have a different wasm API.
  3. Using sentinel-rs as a Rust crate.

Originally chisel was supposed to have the metering algorithm and sentinel-rs would be the contract version (but this hasn't happened yet) and as such sentinel-rs should not be a library. However probably the easiest we can do is include wasm-utils (with our changes) as a crate from the sentinel-rs git repo. We do need to add useTicks to it though.

axic avatar Dec 03 '19 18:12 axic