scout
scout copied to clipboard
Add support for metering
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".
- The only API would be
useTicks(i64)
. This has been added in 0b9882ef. - As part of that ticks are hardcoded currently to 10_000_000 in
Runtime.
We could consider exposing this to the YAML. - The YAML should be extended with a
ticksCount
orticksUsed
field next to the expected post state.
Lastly, the question is how to inject metering. We could consider:
- Using the sentinel contract as is, but that would require the subset of Ewasm 1.0 API.
- Changing the sentinel contract to have a different wasm API.
- 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.