-
Notifications
You must be signed in to change notification settings - Fork 2.6k
contracts: Expose rent parameter to contracts #8231
Conversation
/benchmark runtime pallet pallet_contracts |
Finished benchmark for branch: at-rent-params Benchmark: Benchmark Runtime Pallet cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs ResultsPallet: "pallet_contracts", Extrinsic: "on_initialize", Lowest values: [], Highest values: [], Steps: [50], Repeat: 20
|
…/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs
What is the default |
The SCALE encoded size of this struct is 73 bytes. If you look at the weight assigned for calling this function you can see that it is in-line or even below the single value getters. Copying more data to the contract memory is negligible when compared to the overhead of calling an (imported) function. This does not include the decoding time of course. However, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for adding this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bot merge force |
Trying merge. |
Fixes #7533
This PR introduces a new contract callable function named
seal_rent_params
. This function returns information that can be used by contracts to make decisions based on rent related issues. The function returns the following data structure:substrate/frame/contracts/src/exec.rs
Lines 49 to 74 in 8929cba
Those information are collected very efficiently without any additional storage accesses by snapshotting them at the beginning of each contract call. They are grouped together in a struct because the overhead of calling a supervisor function is substantial. More than copying a few more bytes. These should be all the information needed to duplicate rent calculation in contract code (@cmichi please double check) . We expose data rather than some operational function like
seal_rent_projection
to allow the maximum amount of freedom for contracts until a good rent management strategy arises.@jacogr This adds a new field to the
Schedule
.This includes a storage migration to the new
Schedule
data structure. It resets all values to its new defaults and increases the version number to trigger a re-instrumentation.