Pre-Charge max size when contracts access storage (#10691)

* Fix seal_get_storage

* Fix seal_take_storage

* Add more benchmarks

* cargo run --quiet --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

* Fix seal_set_storage

* Fix seal_contains_storage and seal_clear_storage

* Fix benchmarks

* cargo run --quiet --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

* Get rid of mem::size_of in benchmarks

* Fix up code loading

* Apply suggestions from code review

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Fix test to call same function twice

* Replaced u32::MAX by SENTINEL const

* Fix seal_contains_storage benchmark

* cargo run --quiet --profile=production  --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

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
This commit is contained in:
Alexander Theißen
2022-01-24 21:14:31 +01:00
committed by GitHub
parent e327b734bc
commit dc45201a64
11 changed files with 1141 additions and 926 deletions
+15 -3
View File
@@ -316,15 +316,24 @@ pub struct HostFnWeights<T: Config> {
/// Weight of calling `seal_set_storage`.
pub set_storage: Weight,
/// Weight per byte of an item stored with `seal_set_storage`.
pub set_storage_per_byte: Weight,
/// Weight per written byten of an item stored with `seal_set_storage`.
pub set_storage_per_new_byte: Weight,
/// Weight per overwritten byte of an item stored with `seal_set_storage`.
pub set_storage_per_old_byte: Weight,
/// Weight of calling `seal_clear_storage`.
pub clear_storage: Weight,
/// Weight of calling `seal_clear_storage` per byte of the stored item.
pub clear_storage_per_byte: Weight,
/// Weight of calling `seal_contains_storage`.
pub contains_storage: Weight,
/// Weight of calling `seal_contains_storage` per byte of the stored item.
pub contains_storage_per_byte: Weight,
/// Weight of calling `seal_get_storage`.
pub get_storage: Weight,
@@ -586,9 +595,12 @@ impl<T: Config> Default for HostFnWeights<T> {
),
debug_message: cost_batched!(seal_debug_message),
set_storage: cost_batched!(seal_set_storage),
set_storage_per_byte: cost_byte_batched!(seal_set_storage_per_kb),
set_storage_per_new_byte: cost_byte_batched!(seal_set_storage_per_new_kb),
set_storage_per_old_byte: cost_byte_batched!(seal_set_storage_per_old_kb),
clear_storage: cost_batched!(seal_clear_storage),
clear_storage_per_byte: cost_byte_batched!(seal_clear_storage_per_kb),
contains_storage: cost_batched!(seal_contains_storage),
contains_storage_per_byte: cost_byte_batched!(seal_contains_storage_per_kb),
get_storage: cost_batched!(seal_get_storage),
get_storage_per_byte: cost_byte_batched!(seal_get_storage_per_kb),
take_storage: cost_batched!(seal_take_storage),