mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 09:37:55 +00:00
contracts: Consider contract size in weights (#8086)
* contracts: Consider contract size in weights * Bump spec version * Whitespace fix Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Correct pre-charged code weight even in the error case * Use the instrumented code size in weight calculation * Charge the cost of re-instrumentation from the gas meter * Fix benchmark * 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 * Better documentation of return types Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
This commit is contained in:
committed by
GitHub
parent
fbd3148bba
commit
84071d6d49
@@ -104,10 +104,6 @@ pub struct Limits {
|
||||
|
||||
/// The maximum length of a subject in bytes used for PRNG generation.
|
||||
pub subject_len: u32,
|
||||
|
||||
/// The maximum length of a contract code in bytes. This limit applies to the uninstrumented
|
||||
/// and pristine form of the code as supplied to `instantiate_with_code`.
|
||||
pub code_size: u32,
|
||||
}
|
||||
|
||||
impl Limits {
|
||||
@@ -250,9 +246,18 @@ pub struct HostFnWeights<T: Config> {
|
||||
/// Weight of calling `seal_terminate`.
|
||||
pub terminate: Weight,
|
||||
|
||||
/// Weight per byte of the terminated contract.
|
||||
pub terminate_per_code_byte: Weight,
|
||||
|
||||
/// Weight of calling `seal_restore_to`.
|
||||
pub restore_to: Weight,
|
||||
|
||||
/// Weight per byte of the restoring contract.
|
||||
pub restore_to_per_caller_code_byte: Weight,
|
||||
|
||||
/// Weight per byte of the restored contract.
|
||||
pub restore_to_per_tombstone_code_byte: Weight,
|
||||
|
||||
/// Weight per delta key supplied to `seal_restore_to`.
|
||||
pub restore_to_per_delta: Weight,
|
||||
|
||||
@@ -292,6 +297,9 @@ pub struct HostFnWeights<T: Config> {
|
||||
/// Weight of calling `seal_call`.
|
||||
pub call: Weight,
|
||||
|
||||
/// Weight per byte of the called contract.
|
||||
pub call_per_code_byte: Weight,
|
||||
|
||||
/// Weight surcharge that is claimed if `seal_call` does a balance transfer.
|
||||
pub call_transfer_surcharge: Weight,
|
||||
|
||||
@@ -304,6 +312,9 @@ pub struct HostFnWeights<T: Config> {
|
||||
/// Weight of calling `seal_instantiate`.
|
||||
pub instantiate: Weight,
|
||||
|
||||
/// Weight per byte of the instantiated contract.
|
||||
pub instantiate_per_code_byte: Weight,
|
||||
|
||||
/// Weight per input byte supplied to `seal_instantiate`.
|
||||
pub instantiate_per_input_byte: Weight,
|
||||
|
||||
@@ -443,7 +454,6 @@ impl Default for Limits {
|
||||
table_size: 4096,
|
||||
br_table_size: 256,
|
||||
subject_len: 32,
|
||||
code_size: 512 * 1024,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -528,8 +538,11 @@ impl<T: Config> Default for HostFnWeights<T> {
|
||||
r#return: cost!(seal_return),
|
||||
return_per_byte: cost_byte!(seal_return_per_kb),
|
||||
terminate: cost!(seal_terminate),
|
||||
terminate_per_code_byte: cost_byte!(seal_terminate_per_code_kb),
|
||||
restore_to: cost!(seal_restore_to),
|
||||
restore_to_per_delta: cost_batched!(seal_restore_to_per_delta),
|
||||
restore_to_per_caller_code_byte: cost_byte_args!(seal_restore_to_per_code_kb_delta, 1, 0, 0),
|
||||
restore_to_per_tombstone_code_byte: cost_byte_args!(seal_restore_to_per_code_kb_delta, 0, 1, 0),
|
||||
restore_to_per_delta: cost_batched_args!(seal_restore_to_per_code_kb_delta, 0, 0, 1),
|
||||
random: cost_batched!(seal_random),
|
||||
deposit_event: cost_batched!(seal_deposit_event),
|
||||
deposit_event_per_topic: cost_batched_args!(seal_deposit_event_per_topic_and_kb, 1, 0),
|
||||
@@ -542,13 +555,15 @@ impl<T: Config> Default for HostFnWeights<T> {
|
||||
get_storage_per_byte: cost_byte_batched!(seal_get_storage_per_kb),
|
||||
transfer: cost_batched!(seal_transfer),
|
||||
call: cost_batched!(seal_call),
|
||||
call_transfer_surcharge: cost_batched_args!(seal_call_per_transfer_input_output_kb, 1, 0, 0),
|
||||
call_per_input_byte: cost_byte_batched_args!(seal_call_per_transfer_input_output_kb, 0, 1, 0),
|
||||
call_per_output_byte: cost_byte_batched_args!(seal_call_per_transfer_input_output_kb, 0, 0, 1),
|
||||
call_per_code_byte: cost_byte_batched_args!(seal_call_per_code_transfer_input_output_kb, 1, 0, 0, 0),
|
||||
call_transfer_surcharge: cost_batched_args!(seal_call_per_code_transfer_input_output_kb, 0, 1, 0, 0),
|
||||
call_per_input_byte: cost_byte_batched_args!(seal_call_per_code_transfer_input_output_kb, 0, 0, 1, 0),
|
||||
call_per_output_byte: cost_byte_batched_args!(seal_call_per_code_transfer_input_output_kb, 0, 0, 0, 1),
|
||||
instantiate: cost_batched!(seal_instantiate),
|
||||
instantiate_per_input_byte: cost_byte_batched_args!(seal_instantiate_per_input_output_salt_kb, 1, 0, 0),
|
||||
instantiate_per_output_byte: cost_byte_batched_args!(seal_instantiate_per_input_output_salt_kb, 0, 1, 0),
|
||||
instantiate_per_salt_byte: cost_byte_batched_args!(seal_instantiate_per_input_output_salt_kb, 0, 0, 1),
|
||||
instantiate_per_code_byte: cost_byte_batched_args!(seal_instantiate_per_code_input_output_salt_kb, 1, 0, 0, 0),
|
||||
instantiate_per_input_byte: cost_byte_batched_args!(seal_instantiate_per_code_input_output_salt_kb, 0, 1, 0, 0),
|
||||
instantiate_per_output_byte: cost_byte_batched_args!(seal_instantiate_per_code_input_output_salt_kb, 0, 0, 1, 0),
|
||||
instantiate_per_salt_byte: cost_byte_batched_args!(seal_instantiate_per_code_input_output_salt_kb, 0, 0, 0, 1),
|
||||
hash_sha2_256: cost_batched!(seal_hash_sha2_256),
|
||||
hash_sha2_256_per_byte: cost_byte_batched!(seal_hash_sha2_256_per_kb),
|
||||
hash_keccak_256: cost_batched!(seal_hash_keccak_256),
|
||||
|
||||
Reference in New Issue
Block a user