revive: Limit the amount of static memory a contract can use (#5726)
This will make sure that when uploading new code that the declared
static memory fits within a defined limit. We apply different limits to
code and data. Reason is that code will consume much more memory per
byte once decoded during lazy execution.
This PR:
1) Remove the MaxCodeLen from the `Config` to we maintain tight control
over it.
2) Defines a single `STATIC_MEMORY_BYTES` knob that limits the maximum
decoded size.
3) Enforces them only on upload but not on execution so we can raise
them later.
4) Adapt the worst case calculation in `integrity_check`.
5) Bumps the max stack depth from 5 to 10 as this will still fit within
our memory envelope.
6) The memory limit per contract is now a cool 1MB that can be spent on
data or code.
7) Bump PolkaVM for good measure
8) The blob is limited to 256kb which is just a sanity check to not even
try parsing very big inputs.
---------
Co-authored-by:
Cyrill Leutwiler <cyrill@parity.io>
parent
08d171e3
Showing
- Cargo.lock 31 additions, 31 deletionsCargo.lock
- prdoc/pr_5726.prdoc 14 additions, 0 deletionsprdoc/pr_5726.prdoc
- substrate/bin/node/runtime/src/lib.rs 0 additions, 1 deletionsubstrate/bin/node/runtime/src/lib.rs
- substrate/frame/revive/Cargo.toml 1 addition, 1 deletionsubstrate/frame/revive/Cargo.toml
- substrate/frame/revive/fixtures/Cargo.toml 1 addition, 1 deletionsubstrate/frame/revive/fixtures/Cargo.toml
- substrate/frame/revive/fixtures/build/Cargo.toml 1 addition, 1 deletionsubstrate/frame/revive/fixtures/build/Cargo.toml
- substrate/frame/revive/fixtures/contracts/oom_ro.rs 44 additions, 0 deletionssubstrate/frame/revive/fixtures/contracts/oom_ro.rs
- substrate/frame/revive/fixtures/contracts/oom_rw_included.rs 44 additions, 0 deletionssubstrate/frame/revive/fixtures/contracts/oom_rw_included.rs
- substrate/frame/revive/fixtures/contracts/oom_rw_trailing.rs 44 additions, 0 deletionssubstrate/frame/revive/fixtures/contracts/oom_rw_trailing.rs
- substrate/frame/revive/src/benchmarking/mod.rs 15 additions, 15 deletionssubstrate/frame/revive/src/benchmarking/mod.rs
- substrate/frame/revive/src/lib.rs 34 additions, 66 deletionssubstrate/frame/revive/src/lib.rs
- substrate/frame/revive/src/limits.rs 93 additions, 8 deletionssubstrate/frame/revive/src/limits.rs
- substrate/frame/revive/src/tests.rs 38 additions, 0 deletionssubstrate/frame/revive/src/tests.rs
- substrate/frame/revive/src/wasm/mod.rs 10 additions, 10 deletionssubstrate/frame/revive/src/wasm/mod.rs
- substrate/frame/revive/uapi/Cargo.toml 1 addition, 1 deletionsubstrate/frame/revive/uapi/Cargo.toml
Please register or sign in to comment