contracts: Expose rent parameter to contracts (#8231)

* contracts: Expose rent parameter to contracts

* 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

* Fix typos

* Improve comments

* Add rent parameter weights

* Allow deploying a new schedule with the same version

* Add storage migration for new schedule

* Only decode the schedule version in storage migration

* Remove confusing docs

* Replace original_code_len() by aggregate_code_len()

Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
This commit is contained in:
Alexander Theißen
2021-03-12 12:21:08 +01:00
committed by GitHub
parent 3743cec9bd
commit a4e8875897
11 changed files with 1129 additions and 698 deletions
+19
View File
@@ -45,6 +45,14 @@ pub const INSTR_BENCHMARK_BATCH_SIZE: u32 = 1_000;
#[derive(Clone, Encode, Decode, PartialEq, Eq, ScheduleDebug)]
pub struct Schedule<T: Config> {
/// Version of the schedule.
///
/// # Note
///
/// Must be incremented whenever the [`self.instruction_weights`] are changed. The
/// reason is that changes to instruction weights require a re-instrumentation
/// of all contracts which are triggered by a version comparison on call.
/// Changes to other parts of the schedule should not increment the version in
/// order to avoid unnecessary re-instrumentations.
pub version: u32,
/// Whether the `seal_println` function is allowed to be used contracts.
@@ -62,6 +70,11 @@ pub struct Schedule<T: Config> {
}
/// Describes the upper limits on various metrics.
///
/// # Note
///
/// The values in this struct should only ever be increased for a deployed chain. The reason
/// is that decreasing those values will break existing contracts which are above the new limits.
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug)]
pub struct Limits {
@@ -188,6 +201,7 @@ pub struct InstructionWeights<T: Config> {
pub i64rotl: u32,
pub i64rotr: u32,
/// The type parameter is used in the default implementation.
#[codec(skip)]
pub _phantom: PhantomData<T>,
}
@@ -348,7 +362,11 @@ pub struct HostFnWeights<T: Config> {
/// Weight per byte hashed by `seal_hash_blake2_128`.
pub hash_blake2_128_per_byte: Weight,
/// Weight of calling `seal_rent_params`.
pub rent_params: Weight,
/// The type parameter is used in the default implementation.
#[codec(skip)]
pub _phantom: PhantomData<T>
}
@@ -572,6 +590,7 @@ impl<T: Config> Default for HostFnWeights<T> {
hash_blake2_256_per_byte: cost_byte_batched!(seal_hash_blake2_256_per_kb),
hash_blake2_128: cost_batched!(seal_hash_blake2_128),
hash_blake2_128_per_byte: cost_byte_batched!(seal_hash_blake2_128_per_kb),
rent_params: cost_batched!(seal_rent_params),
_phantom: PhantomData,
}
}