diff --git a/core-backend/src/env.rs b/core-backend/src/env.rs index 625eec6e8b0..0e67f3e161d 100644 --- a/core-backend/src/env.rs +++ b/core-backend/src/env.rs @@ -277,6 +277,7 @@ where { #[rustfmt::skip] fn bind_funcs(builder: &mut EnvBuilder) { + builder.add_func(ExecSettings, wrap_common_func!(FuncsHandler::exec_settings, (3) -> ())); builder.add_func(BlockHeight, wrap_common_func!(FuncsHandler::block_height, (2) -> ())); builder.add_func(BlockTimestamp,wrap_common_func!(FuncsHandler::block_timestamp, (2) -> ())); builder.add_func(CreateProgram, wrap_common_func!(FuncsHandler::create_program, (8) -> ())); diff --git a/core-backend/src/error.rs b/core-backend/src/error.rs index baabe2bba54..d344b1efffa 100644 --- a/core-backend/src/error.rs +++ b/core-backend/src/error.rs @@ -127,6 +127,8 @@ pub enum UnrecoverableExecutionError { TooBigReadLen, #[display(fmt = "Cannot take data in payload range from message with size")] ReadWrongRange, + #[display(fmt = "Unexpected version of execution settings encountered ")] + UnexpectedExecSettingsVersion, } /// Memory error in infallible sys-call. diff --git a/core-backend/src/funcs.rs b/core-backend/src/funcs.rs index 3b064431d60..fc3ab1f3a71 100644 --- a/core-backend/src/funcs.rs +++ b/core-backend/src/funcs.rs @@ -354,6 +354,22 @@ where Ok(res.is_err() as i32) } + #[host(cost = RuntimeCosts::ExecSettings)] + pub fn exec_settings( + ctx: &mut CallerWrap<'_, '_, Ext>, + gas: u64, + settings_ptr: u32, + settings_ver: u32, + ) -> Result<(u64, ()), HostError> { + let settings = ctx.ext_mut().exec_settings(settings_ver)?; + let settings_bytes = settings.to_bytes(); + let settings_write = ctx + .manager + .register_write(settings_ptr, settings_bytes.len() as u32); + ctx.write(settings_write, settings_bytes) + .map_err(Into::into) + } + #[host(cost = RuntimeCosts::BlockHeight)] pub fn block_height( ctx: &mut CallerWrap<'_, '_, Ext>, diff --git a/core-backend/src/mock.rs b/core-backend/src/mock.rs index e1b8177b407..514c656e4ec 100644 --- a/core-backend/src/mock.rs +++ b/core-backend/src/mock.rs @@ -28,12 +28,12 @@ use core::{cell::Cell, fmt, fmt::Debug}; use gear_core::{ costs::RuntimeCosts, env::{Externalities, PayloadSliceLock, UnlockPayloadBound}, + exec_settings::{ExecSettings, ExecSettingsV1}, gas::{ChargeError, CounterType, CountersOwner, GasAmount, GasCounter, GasLeft}, ids::{MessageId, ProgramId, ReservationId}, memory::{Memory, MemoryError, MemoryInterval}, message::{HandlePacket, InitPacket, ReplyPacket}, pages::{PageNumber, PageU32Size, WasmPage, WASM_PAGE_SIZE}, - percent::Percent, }; use gear_core_errors::{ReplyCode, SignalCode}; use gear_lazy_pages_common::ProcessAccessError; @@ -115,15 +115,23 @@ impl Externalities for MockExt { fn free(&mut self, _page: WasmPage) -> Result<(), Self::AllocError> { Err(Error) } + fn exec_settings(&self, version: u32) -> Result { + match version { + 1 => Ok(ExecSettings::V1(ExecSettingsV1 { + performance_multiplier_percent: 100, + existential_deposit: 10, + mailbox_threshold: 20, + gas_to_value_multiplier: 30, + })), + _ => unreachable!("Unexpected version of execution settings"), + } + } fn block_height(&self) -> Result { Ok(0) } fn block_timestamp(&self) -> Result { Ok(0) } - fn performance_multiplier(&self) -> Result { - Ok(Percent::new(100)) - } fn send_init(&mut self) -> Result { Ok(0) } diff --git a/core-processor/src/configs.rs b/core-processor/src/configs.rs index 153d7fc23af..1f9e6ca47ca 100644 --- a/core-processor/src/configs.rs +++ b/core-processor/src/configs.rs @@ -172,6 +172,8 @@ pub struct ExecutionSettings { pub random_data: (Vec, u32), /// Rent cost per block. pub rent_cost: u128, + /// Value per gas multiplier. + pub gas_to_value_multiplier: u128, } /// Stable parameters for the whole block across processing runs. @@ -221,4 +223,6 @@ pub struct BlockConfig { pub code_instrumentation_byte_cost: u64, /// Rent cost per block. pub rent_cost: u128, + /// Value per gas multiplier. + pub gas_to_value_multiplier: u128, } diff --git a/core-processor/src/executor.rs b/core-processor/src/executor.rs index 05099bf8997..81602c92995 100644 --- a/core-processor/src/executor.rs +++ b/core-processor/src/executor.rs @@ -222,6 +222,7 @@ where reservation: settings.reservation, random_data: settings.random_data, rent_cost: settings.rent_cost, + gas_to_value_multiplier: settings.gas_to_value_multiplier, }; let lazy_pages_weights = context.page_costs.lazy_pages_weights(); @@ -418,6 +419,7 @@ where random_data: Default::default(), system_reservation: Default::default(), rent_cost: Default::default(), + gas_to_value_multiplier: Default::default(), }; let lazy_pages_weights = context.page_costs.lazy_pages_weights(); diff --git a/core-processor/src/ext.rs b/core-processor/src/ext.rs index b1af302f147..1912a715d87 100644 --- a/core-processor/src/ext.rs +++ b/core-processor/src/ext.rs @@ -27,6 +27,7 @@ use alloc::{ use gear_core::{ costs::{HostFnWeights, RuntimeCosts}, env::{Externalities, PayloadSliceLock, UnlockPayloadBound}, + exec_settings::{ExecSettings, ExecSettingsV1}, gas::{ ChargeError, ChargeResult, CounterType, CountersOwner, GasAllowanceCounter, GasAmount, GasCounter, GasLeft, Token, ValueCounter, @@ -109,6 +110,8 @@ pub struct ProcessorContext { pub random_data: (Vec, u32), /// Rent cost per block. pub rent_cost: u128, + /// Gas to value multiplier. + pub gas_to_value_multiplier: u128, } #[cfg(any(feature = "mock", test))] @@ -154,6 +157,7 @@ impl ProcessorContext { reservation: 0, random_data: ([0u8; 32].to_vec(), 0), rent_cost: 0, + gas_to_value_multiplier: Default::default(), } } } @@ -721,6 +725,18 @@ impl Externalities for Ext { .map_err(Into::into) } + fn exec_settings(&self, version: u32) -> Result { + match version { + 1 => Ok(ExecSettings::V1(ExecSettingsV1 { + performance_multiplier_percent: self.context.performance_multiplier.value(), + existential_deposit: self.context.existential_deposit, + mailbox_threshold: self.context.mailbox_threshold, + gas_to_value_multiplier: self.context.gas_to_value_multiplier, + })), + _ => Err(UnrecoverableExecutionError::UnexpectedExecSettingsVersion.into()), + } + } + fn block_height(&self) -> Result { Ok(self.context.block_info.height) } @@ -729,10 +745,6 @@ impl Externalities for Ext { Ok(self.context.block_info.timestamp) } - fn performance_multiplier(&self) -> Result { - Ok(self.context.performance_multiplier) - } - fn send_init(&mut self) -> Result { let handle = self.context.message_context.send_init()?; Ok(handle) diff --git a/core-processor/src/processing.rs b/core-processor/src/processing.rs index befb3685610..6b05ff64213 100644 --- a/core-processor/src/processing.rs +++ b/core-processor/src/processing.rs @@ -71,6 +71,7 @@ where reservation, write_cost, rent_cost, + gas_to_value_multiplier, .. } = block_config.clone(); @@ -89,6 +90,7 @@ where reservation, random_data, rent_cost, + gas_to_value_multiplier, }; let dispatch = execution_context.dispatch; diff --git a/core/src/costs.rs b/core/src/costs.rs index f0fe50c4fe7..5c159543c50 100644 --- a/core/src/costs.rs +++ b/core/src/costs.rs @@ -136,6 +136,9 @@ pub struct HostFnWeights { /// Weight per payload byte by `gr_read`. pub gr_read_per_byte: u64, + /// Weight of calling `gr_exec_settings`. + pub gr_exec_settings: u64, + /// Weight of calling `gr_block_height`. pub gr_block_height: u64, @@ -349,6 +352,8 @@ pub enum RuntimeCosts { Read, /// Weight of calling `gr_read` per read buffer bytes number. ReadPerByte(u32), + /// Weight of calling `gr_exec_settings`. + ExecSettings, /// Weight of calling `gr_block_height`. BlockHeight, /// Weight of calling `gr_block_timestamp`. @@ -475,6 +480,7 @@ impl RuntimeCosts { Size => s.gr_size, Read => s.gr_read, ReadPerByte(len) => cost_per_byte(s.gr_read_per_byte, len), + ExecSettings => s.gr_exec_settings, BlockHeight => s.gr_block_height, BlockTimestamp => s.gr_block_timestamp, Random => s.gr_random, diff --git a/core/src/env.rs b/core/src/env.rs index f05993aae27..f9353a3bd28 100644 --- a/core/src/env.rs +++ b/core/src/env.rs @@ -19,11 +19,11 @@ //! Environment for running a module. use crate::{ + exec_settings::ExecSettings, ids::{MessageId, ProgramId, ReservationId}, memory::Memory, message::{HandlePacket, InitPacket, MessageContext, Payload, ReplyPacket}, pages::WasmPage, - percent::Percent, }; use alloc::collections::BTreeSet; use core::{fmt::Display, mem}; @@ -198,15 +198,16 @@ pub trait Externalities { /// should be `free`-d separately. fn free(&mut self, page: WasmPage) -> Result<(), Self::AllocError>; + /// Get execution settings currently set in the system and in the form + /// corresponded to the requested version. + fn exec_settings(&self, version: u32) -> Result; + /// Get the current block height. fn block_height(&self) -> Result; /// Get the current block timestamp. fn block_timestamp(&self) -> Result; - /// Get current performance multiplier. - fn performance_multiplier(&self) -> Result; - /// Initialize a new incomplete message for another program and return its handle. fn send_init(&mut self) -> Result; diff --git a/core/src/exec_settings.rs b/core/src/exec_settings.rs new file mode 100644 index 00000000000..f00af03ac0c --- /dev/null +++ b/core/src/exec_settings.rs @@ -0,0 +1,53 @@ +// This file is part of Gear. + +// Copyright (C) 2021-2023 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Execution settings + +use core::{mem, slice}; + +/// All supported versions of execution settings +pub enum ExecSettings { + /// Values of execution settings V1 + V1(ExecSettingsV1), +} + +impl ExecSettings { + /// Returns byte representation of execution settings + pub fn to_bytes(&self) -> &[u8] { + match self { + ExecSettings::V1(v1) => { + let ptr = v1 as *const ExecSettingsV1 as *const u8; + unsafe { slice::from_raw_parts(ptr, mem::size_of::()) } + } + } + } +} + +/// Values of execution settings V1 +#[repr(C, packed)] +#[derive(Debug, Clone, Copy)] +pub struct ExecSettingsV1 { + /// Performance multiplier percentage + pub performance_multiplier_percent: u32, + /// Existential deposit + pub existential_deposit: u128, + /// Mailbox threshold + pub mailbox_threshold: u64, + /// Multiplier for converting gas into value + pub gas_to_value_multiplier: u128, +} diff --git a/core/src/lib.rs b/core/src/lib.rs index 47e982393ec..8901b26fa81 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -30,6 +30,7 @@ extern crate alloc; pub mod code; pub mod costs; pub mod env; +pub mod exec_settings; pub mod gas; pub mod ids; pub mod memory; diff --git a/core/src/percent.rs b/core/src/percent.rs index e63f218fd95..48aaf7640f5 100644 --- a/core/src/percent.rs +++ b/core/src/percent.rs @@ -34,7 +34,7 @@ impl Percent { Self(value) } - /// Returns the inner `u16` value. + /// Returns the inner `u32` value. pub fn value(self) -> u32 { self.0 } diff --git a/examples/sys-calls/src/lib.rs b/examples/sys-calls/src/lib.rs index ea6d8473761..531c5888109 100644 --- a/examples/sys-calls/src/lib.rs +++ b/examples/sys-calls/src/lib.rs @@ -76,6 +76,13 @@ pub enum Kind { ReplyDetails(MessageId, [u8; 4]), SignalDetails, SignalDetailsWake, + // Expected values + ExecSettings { + performance_multiplier: u32, + existential_deposit: u128, + mailbox_threshold: u64, + gas_to_value_multiplier: u128, + }, // Expected(block height) BlockHeight(u32), // Expected(block timestamp) diff --git a/examples/sys-calls/src/wasm.rs b/examples/sys-calls/src/wasm.rs index 171e989a7e3..c0c0a7a2c47 100644 --- a/examples/sys-calls/src/wasm.rs +++ b/examples/sys-calls/src/wasm.rs @@ -264,6 +264,34 @@ fn process(syscall_kind: Kind) { Kind::SignalDetailsWake => { panic!("must be called in handle_reply"); } + Kind::ExecSettings { + performance_multiplier: expected_performance_multiplier_percent, + existential_deposit: expected_existential_deposit, + mailbox_threshold: expected_mailbox_threshold, + gas_to_value_multiplier: expected_gas_to_value_multiplier, + } => { + let settings = exec::settings(); + let actual_performance_multiplier_percent = settings.performance_multiplier_percent; + assert_eq!( + actual_performance_multiplier_percent, expected_performance_multiplier_percent, + "Kind::ExecSettings: performance_multiplier test failed" + ); + let actual_existential_deposit = settings.existential_deposit; + assert_eq!( + actual_existential_deposit, expected_existential_deposit, + "Kind::ExecSettings: existential_deposit test failed" + ); + let actual_mailbox_threshold = settings.mailbox_threshold; + assert_eq!( + actual_mailbox_threshold, expected_mailbox_threshold, + "Kind::ExecSettings: mailbox_threshold test failed" + ); + let actual_gas_to_value_multiplier = settings.gas_to_value_multiplier; + assert_eq!( + actual_gas_to_value_multiplier, expected_gas_to_value_multiplier, + "Kind::ExecSettings: gas_to_value_multiplier test failed" + ); + } Kind::BlockHeight(expected_height) => { let actual_height = exec::block_height(); assert_eq!( diff --git a/gcore/src/exec.rs b/gcore/src/exec.rs index 84e1c65d7f1..ebde8f32717 100644 --- a/gcore/src/exec.rs +++ b/gcore/src/exec.rs @@ -26,9 +26,35 @@ use crate::{ ActorId, MessageId, ReservationId, }; use gsys::{ - BlockNumberWithHash, ErrorWithBlockNumberAndValue, ErrorWithGas, ErrorWithHash, HashWithValue, + BlockNumberWithHash, ErrorWithBlockNumberAndValue, ErrorWithGas, ErrorWithHash, Gas, + HashWithValue, Value, }; +/// Current version of execution settings. +/// +/// Backend maintains backward compatibility with previous versions of execution +/// settings. This structure matches to the most recent version of execution +/// settings supported by backend. +#[repr(C, packed)] +#[derive(Debug, Default, Clone, Copy)] +pub struct Settings { + /// Current value of performance multiplier in percents. + pub performance_multiplier_percent: u32, + /// Current value of existential deposit. + pub existential_deposit: Value, + /// Current value of mailbox threshold. + pub mailbox_threshold: Gas, + /// Current value of value per gas multiplier. + pub gas_to_value_multiplier: Value, +} + +/// Get current version of execution settings. +pub fn settings() -> Settings { + let mut settings = Settings::default(); + unsafe { gsys::gr_exec_settings(&mut settings as *mut _ as *mut u8, 1) }; + settings +} + /// Get the current block height. /// /// The block height serves to identify a particular block. diff --git a/gstd/src/exec/mod.rs b/gstd/src/exec/mod.rs index 76405fbd0bd..5f02dd28e77 100644 --- a/gstd/src/exec/mod.rs +++ b/gstd/src/exec/mod.rs @@ -24,8 +24,8 @@ pub use basic::*; pub use gcore::exec::{ - block_height, block_timestamp, gas_available, leave, random, system_reserve_gas, - value_available, wait, wait_for, wait_up_to, + block_height, block_timestamp, gas_available, leave, random, settings, system_reserve_gas, + value_available, wait, wait_for, wait_up_to, Settings, }; pub use r#async::*; diff --git a/gsys/src/lib.rs b/gsys/src/lib.rs index 1ed2e672116..e4e79c6e2a3 100644 --- a/gsys/src/lib.rs +++ b/gsys/src/lib.rs @@ -331,6 +331,13 @@ impl TwoHashesWithValue { #[allow(improper_ctypes)] extern "C" { + /// Infallible `gr_exec_settings` get syscall. + /// + /// Arguments type: + /// - `settings`: `mut ptr` for buffer to store requested version of settings. + /// - `version`: `u32` defining version of settings to get. + pub fn gr_exec_settings(settings: *mut BufferStart, version: u32); + /// Infallible `gr_block_height` get syscall. /// /// Arguments type: diff --git a/gtest/src/lib.rs b/gtest/src/lib.rs index 0fe769f8b12..b2a21973708 100644 --- a/gtest/src/lib.rs +++ b/gtest/src/lib.rs @@ -46,3 +46,4 @@ pub const MODULE_INSTRUMENTATION_BYTE_COST: u64 = 13; pub const MODULE_INSTRUMENTATION_COST: u64 = 297; pub const DISPATCH_HOLD_COST: u64 = 200; pub const RENT_COST: u128 = 330; +pub const VALUE_PER_GAS: u128 = 25; diff --git a/gtest/src/manager.rs b/gtest/src/manager.rs index 7563b5ded54..a25acafbbb1 100644 --- a/gtest/src/manager.rs +++ b/gtest/src/manager.rs @@ -22,7 +22,8 @@ use crate::{ Result, System, TestError, DISPATCH_HOLD_COST, EPOCH_DURATION_IN_BLOCKS, EXISTENTIAL_DEPOSIT, INITIAL_RANDOM_SEED, MAILBOX_THRESHOLD, MAX_RESERVATIONS, MODULE_INSTANTIATION_BYTE_COST, MODULE_INSTRUMENTATION_BYTE_COST, MODULE_INSTRUMENTATION_COST, READ_COST, READ_PER_BYTE_COST, - RENT_COST, RESERVATION_COST, RESERVE_FOR, WAITLIST_COST, WRITE_COST, WRITE_PER_BYTE_COST, + RENT_COST, RESERVATION_COST, RESERVE_FOR, VALUE_PER_GAS, WAITLIST_COST, WRITE_COST, + WRITE_PER_BYTE_COST, }; use core_processor::{ common::*, @@ -839,6 +840,7 @@ impl ExtManager { code_instrumentation_cost: MODULE_INSTRUMENTATION_COST, code_instrumentation_byte_cost: MODULE_INSTRUMENTATION_BYTE_COST, rent_cost: RENT_COST, + gas_to_value_multiplier: VALUE_PER_GAS, }; let (actor_data, code) = match data { diff --git a/pallets/gear/src/benchmarking/mod.rs b/pallets/gear/src/benchmarking/mod.rs index 71fde344dfd..98c360084d1 100644 --- a/pallets/gear/src/benchmarking/mod.rs +++ b/pallets/gear/src/benchmarking/mod.rs @@ -204,6 +204,7 @@ fn default_processor_context() -> ProcessorContext { reservation: 0, random_data: ([0u8; 32].to_vec(), 0), rent_cost: 0, + gas_to_value_multiplier: Default::default(), } } @@ -960,6 +961,17 @@ benchmarks! { verify_process(res.unwrap()); } + gr_exec_settings { + let r in 0 .. API_BENCHMARK_BATCHES; + let mut res = None; + let exec = Benches::::gr_exec_settings(r)?; + }: { + res.replace(run_process(exec)); + } + verify { + verify_process(res.unwrap()); + } + gr_block_height { let r in 0 .. API_BENCHMARK_BATCHES; let mut res = None; diff --git a/pallets/gear/src/benchmarking/syscalls.rs b/pallets/gear/src/benchmarking/syscalls.rs index 600eebdaeb5..6fa10de5568 100644 --- a/pallets/gear/src/benchmarking/syscalls.rs +++ b/pallets/gear/src/benchmarking/syscalls.rs @@ -363,6 +363,28 @@ where Self::prepare_handle(module, 0) } + pub fn gr_exec_settings(r: u32) -> Result, &'static str> { + let repetitions = r * API_BENCHMARK_BATCH_SIZE; + let settings_offset = COMMON_OFFSET; + + let module = ModuleDefinition { + memory: Some(ImportedMemory::new(SMALL_MEM_SIZE)), + imported_functions: vec![SysCallName::ExecSettings], + handle_body: Some(body::syscall( + repetitions, + &[ + // offset where to write settings + InstrI32Const(settings_offset), + // version. TODO: Should it be benched based on version? + InstrI32Const(1), + ], + )), + ..Default::default() + }; + + Self::prepare_handle(module, 0) + } + pub fn gr_read(r: u32) -> Result, &'static str> { let repetitions = r * API_BENCHMARK_BATCH_SIZE; let buffer_offset = COMMON_OFFSET; diff --git a/pallets/gear/src/benchmarking/tests/syscalls_integrity.rs b/pallets/gear/src/benchmarking/tests/syscalls_integrity.rs index 90957ba093f..d9629805bb1 100644 --- a/pallets/gear/src/benchmarking/tests/syscalls_integrity.rs +++ b/pallets/gear/src/benchmarking/tests/syscalls_integrity.rs @@ -155,6 +155,7 @@ where SysCallName::ProgramId => check_gr_program_id::(), SysCallName::Source => check_gr_source::(), SysCallName::Value => check_gr_value::(), + SysCallName::ExecSettings => check_gr_exec_settings::(), SysCallName::BlockHeight => check_gr_block_height::(), SysCallName::BlockTimestamp => check_gr_block_timestamp::(), SysCallName::GasAvailable => check_gr_gas_available::(), @@ -828,6 +829,31 @@ where }); } +fn check_gr_exec_settings() +where + T: Config, + T::AccountId: Origin, +{ + run_tester::(|_, _| { + let performance_multiplier = T::PerformanceMultiplier::get().value(); + let existential_deposit = T::Currency::minimum_balance().unique_saturated_into(); + let mailbox_threshold = T::MailboxThreshold::get(); + let gas_to_value_multiplier = ::GasMultiplier::get() + .gas_to_value(1) + .unique_saturated_into(); + let mp = vec![Kind::ExecSettings { + performance_multiplier, + existential_deposit, + mailbox_threshold, + gas_to_value_multiplier, + }] + .encode() + .into(); + + (TestCall::send_message(mp), None::) + }) +} + fn check_gr_block_height() where T: Config, diff --git a/pallets/gear/src/benchmarking/utils.rs b/pallets/gear/src/benchmarking/utils.rs index a6df303d2ac..503ec45eae0 100644 --- a/pallets/gear/src/benchmarking/utils.rs +++ b/pallets/gear/src/benchmarking/utils.rs @@ -84,6 +84,9 @@ where code_instrumentation_cost: schedule.code_instrumentation_cost.ref_time(), code_instrumentation_byte_cost: schedule.code_instrumentation_byte_cost.ref_time(), rent_cost: RentCostPerBlockOf::::get().unique_saturated_into(), + gas_to_value_multiplier: ::GasMultiplier::get() + .gas_to_value(1) + .unique_saturated_into(), } } diff --git a/pallets/gear/src/lib.rs b/pallets/gear/src/lib.rs index 5bef97c2c9c..65a8b677357 100644 --- a/pallets/gear/src/lib.rs +++ b/pallets/gear/src/lib.rs @@ -1054,6 +1054,9 @@ pub mod pallet { code_instrumentation_cost: schedule.code_instrumentation_cost.ref_time(), code_instrumentation_byte_cost: schedule.code_instrumentation_byte_cost.ref_time(), rent_cost: RentCostPerBlockOf::::get().unique_saturated_into(), + gas_to_value_multiplier: ::GasMultiplier::get() + .gas_to_value(1) + .unique_saturated_into(), } } diff --git a/pallets/gear/src/schedule.rs b/pallets/gear/src/schedule.rs index b2010a58961..827f0bb2a3a 100644 --- a/pallets/gear/src/schedule.rs +++ b/pallets/gear/src/schedule.rs @@ -376,6 +376,9 @@ pub struct HostFnWeights { /// Weight per payload byte by `gr_read`. pub gr_read_per_byte: Weight, + /// Weight of calling `gr_exec_settings`. + pub gr_exec_settings: Weight, + /// Weight of calling `gr_block_height`. pub gr_block_height: Weight, @@ -868,6 +871,7 @@ impl HostFnWeights { gr_size: self.gr_size.ref_time(), gr_read: self.gr_read.ref_time(), gr_read_per_byte: self.gr_read_per_byte.ref_time(), + gr_exec_settings: self.gr_exec_settings.ref_time(), gr_block_height: self.gr_block_height.ref_time(), gr_block_timestamp: self.gr_block_timestamp.ref_time(), gr_random: self.gr_random.ref_time(), @@ -989,6 +993,7 @@ impl Default for HostFnWeights { gr_size: to_weight!(cost_batched!(gr_size)), gr_read: to_weight!(cost_batched!(gr_read)), gr_read_per_byte: to_weight!(cost_byte_batched!(gr_read_per_kb)), + gr_exec_settings: to_weight!(cost_batched!(gr_exec_settings)), gr_block_height: to_weight!(cost_batched!(gr_block_height)), gr_block_timestamp: to_weight!(cost_batched!(gr_block_timestamp)), gr_random: to_weight!(cost_batched!(gr_random)), diff --git a/pallets/gear/src/weights.rs b/pallets/gear/src/weights.rs index 477c7f3bd54..f822f94f8fa 100644 --- a/pallets/gear/src/weights.rs +++ b/pallets/gear/src/weights.rs @@ -25,7 +25,7 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("gear-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/gear benchmark pallet --chain=gear-dev --steps=50 --repeat=20 --pallet=pallet_gear --extrinsic=alloc,alloc_in_handle,alloc_per_page,claim_value,create_program,db_read_per_kb,db_write_per_kb,free,gr_block_height,gr_block_timestamp,gr_create_program,gr_create_program_per_kb,gr_create_program_wgas,gr_create_program_wgas_per_kb,gr_debug,gr_debug_per_kb,gr_gas_available,gr_message_id,gr_pay_program_rent,gr_program_id,gr_random,gr_read,gr_read_per_kb,gr_reply_code,gr_reply_deposit,gr_reply_per_kb,gr_reply_push,gr_reply_push_input,gr_reply_push_input_per_kb,gr_reply_push_per_kb,gr_reply_to,gr_reply_wgas_per_kb,gr_reservation_reply_commit_per_kb,gr_reservation_reply_per_kb,gr_reservation_send,gr_reservation_send_commit,gr_reservation_send_per_kb,gr_reserve_gas,gr_send,gr_send_commit,gr_send_commit_wgas,gr_send_init,gr_send_input,gr_send_input_wgas,gr_send_per_kb,gr_send_push,gr_send_push_input,gr_send_push_input_per_kb,gr_send_push_per_kb,gr_send_wgas,gr_send_wgas_per_kb,gr_signal_code,gr_signal_from,gr_size,gr_source,gr_system_reserve_gas,gr_unreserve_gas,gr_value,gr_value_available,gr_wake,initial_allocation,instantiate_module_per_kb,instr_br,instr_br_if,instr_br_table,instr_br_table_per_entry,instr_call,instr_call_const,instr_call_indirect,instr_call_indirect_per_param,instr_call_per_local,instr_global_get,instr_global_set,instr_i32add,instr_i32and,instr_i32clz,instr_i32ctz,instr_i32divs,instr_i32divu,instr_i32eq,instr_i32eqz,instr_i32extend16s,instr_i32extend8s,instr_i32ges,instr_i32geu,instr_i32gts,instr_i32gtu,instr_i32les,instr_i32leu,instr_i32load,instr_i32lts,instr_i32ltu,instr_i32mul,instr_i32ne,instr_i32or,instr_i32popcnt,instr_i32rems,instr_i32remu,instr_i32rotl,instr_i32rotr,instr_i32shl,instr_i32shrs,instr_i32shru,instr_i32store,instr_i32sub,instr_i32wrapi64,instr_i32xor,instr_i64add,instr_i64and,instr_i64clz,instr_i64ctz,instr_i64divs,instr_i64divu,instr_i64eq,instr_i64eqz,instr_i64extend16s,instr_i64extend32s,instr_i64extend8s,instr_i64extendsi32,instr_i64extendui32,instr_i64ges,instr_i64geu,instr_i64gts,instr_i64gtu,instr_i64les,instr_i64leu,instr_i64load,instr_i64lts,instr_i64ltu,instr_i64mul,instr_i64ne,instr_i64or,instr_i64popcnt,instr_i64rems,instr_i64remu,instr_i64rotl,instr_i64rotr,instr_i64shl,instr_i64shrs,instr_i64shru,instr_i64store,instr_i64sub,instr_i64xor,instr_if,instr_local_get,instr_local_set,instr_local_tee,instr_memory_current,instr_select,lazy_pages_host_func_read,lazy_pages_host_func_write,lazy_pages_host_func_write_after_read,lazy_pages_load_page_storage_data,lazy_pages_signal_read,lazy_pages_signal_write,lazy_pages_signal_write_after_read,mem_grow,pay_program_rent,reinstrument_per_kb,resume_session_commit,resume_session_init,resume_session_push,send_message,send_reply,tasks_pause_program,tasks_pause_program_uninited,tasks_remove_from_mailbox,tasks_remove_from_waitlist,tasks_remove_gas_reservation,tasks_remove_resume_session,tasks_send_dispatch,tasks_send_user_message,tasks_send_user_message_to_mailbox,tasks_wake_message,tasks_wake_message_no_wake,upload_code,upload_program --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./scripts/benchmarking/weights-output/pallet_gear.rs --template=.maintain/frame-weight-template.hbs +// ./target/production/gear benchmark pallet --chain=gear-dev --steps=50 --repeat=20 --pallet=pallet_gear --extrinsic=alloc,alloc_in_handle,alloc_per_page,claim_value,create_program,db_read_per_kb,db_write_per_kb,free,gr_block_height,gr_block_timestamp,gr_create_program,gr_create_program_per_kb,gr_create_program_wgas,gr_create_program_wgas_per_kb,gr_debug,gr_debug_per_kb,gr_gas_available,gr_message_id,gr_pay_program_rent,gr_program_id,gr_random,gr_read,gr_read_per_kb,gr_reply_code,gr_reply_deposit,gr_reply_per_kb,gr_reply_push,gr_reply_push_input,gr_reply_push_input_per_kb,gr_reply_push_per_kb,gr_reply_to,gr_reply_wgas_per_kb,gr_reservation_reply_commit_per_kb,gr_reservation_reply_per_kb,gr_reservation_send,gr_reservation_send_commit,gr_reservation_send_per_kb,gr_reserve_gas,gr_send,gr_send_commit,gr_send_commit_wgas,gr_send_init,gr_send_input,gr_send_input_wgas,gr_send_per_kb,gr_send_push,gr_send_push_input,gr_send_push_input_per_kb,gr_send_push_per_kb,gr_send_wgas,gr_send_wgas_per_kb,gr_signal_code,gr_signal_from,gr_size,gr_source,gr_system_reserve_gas,gr_unreserve_gas,gr_value,gr_value_available,gr_wake,initial_allocation,instantiate_module_per_kb,instr_br,instr_br_if,instr_br_table,instr_br_table_per_entry,instr_call,instr_call_const,instr_call_indirect,instr_call_indirect_per_param,instr_call_per_local,instr_global_get,instr_global_set,instr_i32add,instr_i32and,instr_i32clz,instr_i32ctz,instr_i32divs,instr_i32divu,instr_i32eq,instr_i32eqz,instr_i32extend16s,instr_i32extend8s,instr_i32ges,instr_i32geu,instr_i32gts,instr_i32gtu,instr_i32les,instr_i32leu,instr_i32load,instr_i32lts,instr_i32ltu,instr_i32mul,instr_i32ne,instr_i32or,instr_i32popcnt,instr_i32rems,instr_i32remu,instr_i32rotl,instr_i32rotr,instr_i32shl,instr_i32shrs,instr_i32shru,instr_i32store,instr_i32sub,instr_i32wrapi64,instr_i32xor,instr_i64add,instr_i64and,instr_i64clz,instr_i64ctz,instr_i64divs,instr_i64divu,instr_i64eq,instr_i64eqz,instr_i64extend16s,instr_i64extend32s,instr_i64extend8s,instr_i64extendsi32,instr_i64extendui32,instr_i64ges,instr_i64geu,instr_i64gts,instr_i64gtu,instr_i64les,instr_i64leu,instr_i64load,instr_i64lts,instr_i64ltu,instr_i64mul,instr_i64ne,instr_i64or,instr_i64popcnt,instr_i64rems,instr_i64remu,instr_i64rotl,instr_i64rotr,instr_i64shl,instr_i64shrs,instr_i64shru,instr_i64store,instr_i64sub,instr_i64xor,instr_if,instr_local_get,instr_local_set,instr_local_tee,instr_memory_current,instr_select,lazy_pages_host_func_read,lazy_pages_host_func_write,lazy_pages_host_func_write_after_read,lazy_pages_load_page_storage_data,lazy_pages_signal_read,lazy_pages_signal_write,lazy_pages_signal_write_after_read,mem_grow,pay_program_rent,reinstrument_per_kb,resume_session_commit,resume_session_init,resume_session_push,send_message,send_reply,tasks_pause_program,tasks_pause_program_uninited,tasks_remove_from_mailbox,tasks_remove_from_waitlist,tasks_remove_gas_reservation,tasks_remove_resume_session,tasks_send_dispatch,tasks_send_user_message,tasks_send_user_message_to_mailbox,tasks_wake_message,tasks_wake_message_no_wake,upload_code,upload_program,gr_exec_settings --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./scripts/benchmarking/weights-output/pallet_gear.rs --template=.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -81,6 +81,7 @@ pub trait WeightInfo { fn gr_size(r: u32, ) -> Weight; fn gr_read(r: u32, ) -> Weight; fn gr_read_per_kb(n: u32, ) -> Weight; + fn gr_exec_settings(r: u32, ) -> Weight; fn gr_block_height(r: u32, ) -> Weight; fn gr_block_timestamp(r: u32, ) -> Weight; fn gr_random(n: u32, ) -> Weight; @@ -716,6 +717,16 @@ impl WeightInfo for SubstrateWeight { .saturating_add(Weight::from_parts(13_068_816, 0).saturating_mul(n.into())) } /// The range of component `r` is `[0, 20]`. + fn gr_exec_settings(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 221_823_000 picoseconds. + Weight::from_parts(924_157_395, 0) + // Standard Error: 3_073_388 + .saturating_add(Weight::from_parts(143_835_127, 0).saturating_mul(r.into())) + } + /// The range of component `r` is `[0, 20]`. fn gr_block_height(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` @@ -2679,6 +2690,16 @@ impl WeightInfo for () { .saturating_add(Weight::from_parts(13_068_816, 0).saturating_mul(n.into())) } /// The range of component `r` is `[0, 20]`. + fn gr_exec_settings(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 221_823_000 picoseconds. + Weight::from_parts(924_157_395, 0) + // Standard Error: 3_073_388 + .saturating_add(Weight::from_parts(143_835_127, 0).saturating_mul(r.into())) + } + /// The range of component `r` is `[0, 20]`. fn gr_block_height(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` diff --git a/runtime/gear/src/weights/pallet_gear.rs b/runtime/gear/src/weights/pallet_gear.rs index b86b0c49d63..92479891dbe 100644 --- a/runtime/gear/src/weights/pallet_gear.rs +++ b/runtime/gear/src/weights/pallet_gear.rs @@ -25,7 +25,7 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("gear-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/gear benchmark pallet --chain=gear-dev --steps=50 --repeat=20 --pallet=pallet_gear --extrinsic=alloc,alloc_in_handle,alloc_per_page,claim_value,create_program,db_read_per_kb,db_write_per_kb,free,gr_block_height,gr_block_timestamp,gr_create_program,gr_create_program_per_kb,gr_create_program_wgas,gr_create_program_wgas_per_kb,gr_debug,gr_debug_per_kb,gr_gas_available,gr_message_id,gr_pay_program_rent,gr_program_id,gr_random,gr_read,gr_read_per_kb,gr_reply_code,gr_reply_deposit,gr_reply_per_kb,gr_reply_push,gr_reply_push_input,gr_reply_push_input_per_kb,gr_reply_push_per_kb,gr_reply_to,gr_reply_wgas_per_kb,gr_reservation_reply_commit_per_kb,gr_reservation_reply_per_kb,gr_reservation_send,gr_reservation_send_commit,gr_reservation_send_per_kb,gr_reserve_gas,gr_send,gr_send_commit,gr_send_commit_wgas,gr_send_init,gr_send_input,gr_send_input_wgas,gr_send_per_kb,gr_send_push,gr_send_push_input,gr_send_push_input_per_kb,gr_send_push_per_kb,gr_send_wgas,gr_send_wgas_per_kb,gr_signal_code,gr_signal_from,gr_size,gr_source,gr_system_reserve_gas,gr_unreserve_gas,gr_value,gr_value_available,gr_wake,initial_allocation,instantiate_module_per_kb,instr_br,instr_br_if,instr_br_table,instr_br_table_per_entry,instr_call,instr_call_const,instr_call_indirect,instr_call_indirect_per_param,instr_call_per_local,instr_global_get,instr_global_set,instr_i32add,instr_i32and,instr_i32clz,instr_i32ctz,instr_i32divs,instr_i32divu,instr_i32eq,instr_i32eqz,instr_i32extend16s,instr_i32extend8s,instr_i32ges,instr_i32geu,instr_i32gts,instr_i32gtu,instr_i32les,instr_i32leu,instr_i32load,instr_i32lts,instr_i32ltu,instr_i32mul,instr_i32ne,instr_i32or,instr_i32popcnt,instr_i32rems,instr_i32remu,instr_i32rotl,instr_i32rotr,instr_i32shl,instr_i32shrs,instr_i32shru,instr_i32store,instr_i32sub,instr_i32wrapi64,instr_i32xor,instr_i64add,instr_i64and,instr_i64clz,instr_i64ctz,instr_i64divs,instr_i64divu,instr_i64eq,instr_i64eqz,instr_i64extend16s,instr_i64extend32s,instr_i64extend8s,instr_i64extendsi32,instr_i64extendui32,instr_i64ges,instr_i64geu,instr_i64gts,instr_i64gtu,instr_i64les,instr_i64leu,instr_i64load,instr_i64lts,instr_i64ltu,instr_i64mul,instr_i64ne,instr_i64or,instr_i64popcnt,instr_i64rems,instr_i64remu,instr_i64rotl,instr_i64rotr,instr_i64shl,instr_i64shrs,instr_i64shru,instr_i64store,instr_i64sub,instr_i64xor,instr_if,instr_local_get,instr_local_set,instr_local_tee,instr_memory_current,instr_select,lazy_pages_host_func_read,lazy_pages_host_func_write,lazy_pages_host_func_write_after_read,lazy_pages_load_page_storage_data,lazy_pages_signal_read,lazy_pages_signal_write,lazy_pages_signal_write_after_read,mem_grow,pay_program_rent,reinstrument_per_kb,resume_session_commit,resume_session_init,resume_session_push,send_message,send_reply,tasks_pause_program,tasks_pause_program_uninited,tasks_remove_from_mailbox,tasks_remove_from_waitlist,tasks_remove_gas_reservation,tasks_remove_resume_session,tasks_send_dispatch,tasks_send_user_message,tasks_send_user_message_to_mailbox,tasks_wake_message,tasks_wake_message_no_wake,upload_code,upload_program --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./scripts/benchmarking/weights-output/pallet_gear.rs --template=.maintain/frame-weight-template.hbs +// ./target/production/gear benchmark pallet --chain=gear-dev --steps=50 --repeat=20 --pallet=pallet_gear --extrinsic=alloc,alloc_in_handle,alloc_per_page,claim_value,create_program,db_read_per_kb,db_write_per_kb,free,gr_block_height,gr_block_timestamp,gr_create_program,gr_create_program_per_kb,gr_create_program_wgas,gr_create_program_wgas_per_kb,gr_debug,gr_debug_per_kb,gr_gas_available,gr_message_id,gr_pay_program_rent,gr_program_id,gr_random,gr_read,gr_read_per_kb,gr_reply_code,gr_reply_deposit,gr_reply_per_kb,gr_reply_push,gr_reply_push_input,gr_reply_push_input_per_kb,gr_reply_push_per_kb,gr_reply_to,gr_reply_wgas_per_kb,gr_reservation_reply_commit_per_kb,gr_reservation_reply_per_kb,gr_reservation_send,gr_reservation_send_commit,gr_reservation_send_per_kb,gr_reserve_gas,gr_send,gr_send_commit,gr_send_commit_wgas,gr_send_init,gr_send_input,gr_send_input_wgas,gr_send_per_kb,gr_send_push,gr_send_push_input,gr_send_push_input_per_kb,gr_send_push_per_kb,gr_send_wgas,gr_send_wgas_per_kb,gr_signal_code,gr_signal_from,gr_size,gr_source,gr_system_reserve_gas,gr_unreserve_gas,gr_value,gr_value_available,gr_wake,initial_allocation,instantiate_module_per_kb,instr_br,instr_br_if,instr_br_table,instr_br_table_per_entry,instr_call,instr_call_const,instr_call_indirect,instr_call_indirect_per_param,instr_call_per_local,instr_global_get,instr_global_set,instr_i32add,instr_i32and,instr_i32clz,instr_i32ctz,instr_i32divs,instr_i32divu,instr_i32eq,instr_i32eqz,instr_i32extend16s,instr_i32extend8s,instr_i32ges,instr_i32geu,instr_i32gts,instr_i32gtu,instr_i32les,instr_i32leu,instr_i32load,instr_i32lts,instr_i32ltu,instr_i32mul,instr_i32ne,instr_i32or,instr_i32popcnt,instr_i32rems,instr_i32remu,instr_i32rotl,instr_i32rotr,instr_i32shl,instr_i32shrs,instr_i32shru,instr_i32store,instr_i32sub,instr_i32wrapi64,instr_i32xor,instr_i64add,instr_i64and,instr_i64clz,instr_i64ctz,instr_i64divs,instr_i64divu,instr_i64eq,instr_i64eqz,instr_i64extend16s,instr_i64extend32s,instr_i64extend8s,instr_i64extendsi32,instr_i64extendui32,instr_i64ges,instr_i64geu,instr_i64gts,instr_i64gtu,instr_i64les,instr_i64leu,instr_i64load,instr_i64lts,instr_i64ltu,instr_i64mul,instr_i64ne,instr_i64or,instr_i64popcnt,instr_i64rems,instr_i64remu,instr_i64rotl,instr_i64rotr,instr_i64shl,instr_i64shrs,instr_i64shru,instr_i64store,instr_i64sub,instr_i64xor,instr_if,instr_local_get,instr_local_set,instr_local_tee,instr_memory_current,instr_select,lazy_pages_host_func_read,lazy_pages_host_func_write,lazy_pages_host_func_write_after_read,lazy_pages_load_page_storage_data,lazy_pages_signal_read,lazy_pages_signal_write,lazy_pages_signal_write_after_read,mem_grow,pay_program_rent,reinstrument_per_kb,resume_session_commit,resume_session_init,resume_session_push,send_message,send_reply,tasks_pause_program,tasks_pause_program_uninited,tasks_remove_from_mailbox,tasks_remove_from_waitlist,tasks_remove_gas_reservation,tasks_remove_resume_session,tasks_send_dispatch,tasks_send_user_message,tasks_send_user_message_to_mailbox,tasks_wake_message,tasks_wake_message_no_wake,upload_code,upload_program,gr_exec_settings --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./scripts/benchmarking/weights-output/pallet_gear.rs --template=.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -81,6 +81,7 @@ pub trait WeightInfo { fn gr_size(r: u32, ) -> Weight; fn gr_read(r: u32, ) -> Weight; fn gr_read_per_kb(n: u32, ) -> Weight; + fn gr_exec_settings(r: u32, ) -> Weight; fn gr_block_height(r: u32, ) -> Weight; fn gr_block_timestamp(r: u32, ) -> Weight; fn gr_random(n: u32, ) -> Weight; @@ -716,6 +717,16 @@ impl pallet_gear::WeightInfo for SubstrateWeight { .saturating_add(Weight::from_parts(13_068_816, 0).saturating_mul(n.into())) } /// The range of component `r` is `[0, 20]`. + fn gr_exec_settings(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 221_823_000 picoseconds. + Weight::from_parts(924_157_395, 0) + // Standard Error: 3_073_388 + .saturating_add(Weight::from_parts(143_835_127, 0).saturating_mul(r.into())) + } + /// The range of component `r` is `[0, 20]`. fn gr_block_height(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` @@ -2679,6 +2690,16 @@ impl WeightInfo for () { .saturating_add(Weight::from_parts(13_068_816, 0).saturating_mul(n.into())) } /// The range of component `r` is `[0, 20]`. + fn gr_exec_settings(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 221_823_000 picoseconds. + Weight::from_parts(924_157_395, 0) + // Standard Error: 3_073_388 + .saturating_add(Weight::from_parts(143_835_127, 0).saturating_mul(r.into())) + } + /// The range of component `r` is `[0, 20]`. fn gr_block_height(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` diff --git a/runtime/vara/src/weights/pallet_gear.rs b/runtime/vara/src/weights/pallet_gear.rs index c7939a1f341..721f283a8e8 100644 --- a/runtime/vara/src/weights/pallet_gear.rs +++ b/runtime/vara/src/weights/pallet_gear.rs @@ -25,7 +25,7 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vara-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/gear benchmark pallet --chain=vara-dev --steps=50 --repeat=20 --pallet=pallet_gear --extrinsic=alloc,alloc_in_handle,alloc_per_page,claim_value,create_program,db_read_per_kb,db_write_per_kb,free,gr_block_height,gr_block_timestamp,gr_create_program,gr_create_program_per_kb,gr_create_program_wgas,gr_create_program_wgas_per_kb,gr_debug,gr_debug_per_kb,gr_gas_available,gr_message_id,gr_pay_program_rent,gr_program_id,gr_random,gr_read,gr_read_per_kb,gr_reply_code,gr_reply_deposit,gr_reply_per_kb,gr_reply_push,gr_reply_push_input,gr_reply_push_input_per_kb,gr_reply_push_per_kb,gr_reply_to,gr_reply_wgas_per_kb,gr_reservation_reply_commit_per_kb,gr_reservation_reply_per_kb,gr_reservation_send,gr_reservation_send_commit,gr_reservation_send_per_kb,gr_reserve_gas,gr_send,gr_send_commit,gr_send_commit_wgas,gr_send_init,gr_send_input,gr_send_input_wgas,gr_send_per_kb,gr_send_push,gr_send_push_input,gr_send_push_input_per_kb,gr_send_push_per_kb,gr_send_wgas,gr_send_wgas_per_kb,gr_signal_code,gr_signal_from,gr_size,gr_source,gr_system_reserve_gas,gr_unreserve_gas,gr_value,gr_value_available,gr_wake,initial_allocation,instantiate_module_per_kb,instr_br,instr_br_if,instr_br_table,instr_br_table_per_entry,instr_call,instr_call_const,instr_call_indirect,instr_call_indirect_per_param,instr_call_per_local,instr_global_get,instr_global_set,instr_i32add,instr_i32and,instr_i32clz,instr_i32ctz,instr_i32divs,instr_i32divu,instr_i32eq,instr_i32eqz,instr_i32extend16s,instr_i32extend8s,instr_i32ges,instr_i32geu,instr_i32gts,instr_i32gtu,instr_i32les,instr_i32leu,instr_i32load,instr_i32lts,instr_i32ltu,instr_i32mul,instr_i32ne,instr_i32or,instr_i32popcnt,instr_i32rems,instr_i32remu,instr_i32rotl,instr_i32rotr,instr_i32shl,instr_i32shrs,instr_i32shru,instr_i32store,instr_i32sub,instr_i32wrapi64,instr_i32xor,instr_i64add,instr_i64and,instr_i64clz,instr_i64ctz,instr_i64divs,instr_i64divu,instr_i64eq,instr_i64eqz,instr_i64extend16s,instr_i64extend32s,instr_i64extend8s,instr_i64extendsi32,instr_i64extendui32,instr_i64ges,instr_i64geu,instr_i64gts,instr_i64gtu,instr_i64les,instr_i64leu,instr_i64load,instr_i64lts,instr_i64ltu,instr_i64mul,instr_i64ne,instr_i64or,instr_i64popcnt,instr_i64rems,instr_i64remu,instr_i64rotl,instr_i64rotr,instr_i64shl,instr_i64shrs,instr_i64shru,instr_i64store,instr_i64sub,instr_i64xor,instr_if,instr_local_get,instr_local_set,instr_local_tee,instr_memory_current,instr_select,lazy_pages_host_func_read,lazy_pages_host_func_write,lazy_pages_host_func_write_after_read,lazy_pages_load_page_storage_data,lazy_pages_signal_read,lazy_pages_signal_write,lazy_pages_signal_write_after_read,mem_grow,pay_program_rent,reinstrument_per_kb,resume_session_commit,resume_session_init,resume_session_push,send_message,send_reply,tasks_pause_program,tasks_pause_program_uninited,tasks_remove_from_mailbox,tasks_remove_from_waitlist,tasks_remove_gas_reservation,tasks_remove_resume_session,tasks_send_dispatch,tasks_send_user_message,tasks_send_user_message_to_mailbox,tasks_wake_message,tasks_wake_message_no_wake,upload_code,upload_program --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./scripts/benchmarking/weights-output/pallet_gear.rs --template=.maintain/frame-weight-template.hbs +// ./target/production/gear benchmark pallet --chain=vara-dev --steps=50 --repeat=20 --pallet=pallet_gear --extrinsic=alloc,alloc_in_handle,alloc_per_page,claim_value,create_program,db_read_per_kb,db_write_per_kb,free,gr_block_height,gr_block_timestamp,gr_create_program,gr_create_program_per_kb,gr_create_program_wgas,gr_create_program_wgas_per_kb,gr_debug,gr_debug_per_kb,gr_gas_available,gr_message_id,gr_pay_program_rent,gr_program_id,gr_random,gr_read,gr_read_per_kb,gr_reply_code,gr_reply_deposit,gr_reply_per_kb,gr_reply_push,gr_reply_push_input,gr_reply_push_input_per_kb,gr_reply_push_per_kb,gr_reply_to,gr_reply_wgas_per_kb,gr_reservation_reply_commit_per_kb,gr_reservation_reply_per_kb,gr_reservation_send,gr_reservation_send_commit,gr_reservation_send_per_kb,gr_reserve_gas,gr_send,gr_send_commit,gr_send_commit_wgas,gr_send_init,gr_send_input,gr_send_input_wgas,gr_send_per_kb,gr_send_push,gr_send_push_input,gr_send_push_input_per_kb,gr_send_push_per_kb,gr_send_wgas,gr_send_wgas_per_kb,gr_signal_code,gr_signal_from,gr_size,gr_source,gr_system_reserve_gas,gr_unreserve_gas,gr_value,gr_value_available,gr_wake,initial_allocation,instantiate_module_per_kb,instr_br,instr_br_if,instr_br_table,instr_br_table_per_entry,instr_call,instr_call_const,instr_call_indirect,instr_call_indirect_per_param,instr_call_per_local,instr_global_get,instr_global_set,instr_i32add,instr_i32and,instr_i32clz,instr_i32ctz,instr_i32divs,instr_i32divu,instr_i32eq,instr_i32eqz,instr_i32extend16s,instr_i32extend8s,instr_i32ges,instr_i32geu,instr_i32gts,instr_i32gtu,instr_i32les,instr_i32leu,instr_i32load,instr_i32lts,instr_i32ltu,instr_i32mul,instr_i32ne,instr_i32or,instr_i32popcnt,instr_i32rems,instr_i32remu,instr_i32rotl,instr_i32rotr,instr_i32shl,instr_i32shrs,instr_i32shru,instr_i32store,instr_i32sub,instr_i32wrapi64,instr_i32xor,instr_i64add,instr_i64and,instr_i64clz,instr_i64ctz,instr_i64divs,instr_i64divu,instr_i64eq,instr_i64eqz,instr_i64extend16s,instr_i64extend32s,instr_i64extend8s,instr_i64extendsi32,instr_i64extendui32,instr_i64ges,instr_i64geu,instr_i64gts,instr_i64gtu,instr_i64les,instr_i64leu,instr_i64load,instr_i64lts,instr_i64ltu,instr_i64mul,instr_i64ne,instr_i64or,instr_i64popcnt,instr_i64rems,instr_i64remu,instr_i64rotl,instr_i64rotr,instr_i64shl,instr_i64shrs,instr_i64shru,instr_i64store,instr_i64sub,instr_i64xor,instr_if,instr_local_get,instr_local_set,instr_local_tee,instr_memory_current,instr_select,lazy_pages_host_func_read,lazy_pages_host_func_write,lazy_pages_host_func_write_after_read,lazy_pages_load_page_storage_data,lazy_pages_signal_read,lazy_pages_signal_write,lazy_pages_signal_write_after_read,mem_grow,pay_program_rent,reinstrument_per_kb,resume_session_commit,resume_session_init,resume_session_push,send_message,send_reply,tasks_pause_program,tasks_pause_program_uninited,tasks_remove_from_mailbox,tasks_remove_from_waitlist,tasks_remove_gas_reservation,tasks_remove_resume_session,tasks_send_dispatch,tasks_send_user_message,tasks_send_user_message_to_mailbox,tasks_wake_message,tasks_wake_message_no_wake,upload_code,upload_program,gr_exec_settings --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./scripts/benchmarking/weights-output/pallet_gear.rs --template=.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -81,6 +81,7 @@ pub trait WeightInfo { fn gr_size(r: u32, ) -> Weight; fn gr_read(r: u32, ) -> Weight; fn gr_read_per_kb(n: u32, ) -> Weight; + fn gr_exec_settings(r: u32, ) -> Weight; fn gr_block_height(r: u32, ) -> Weight; fn gr_block_timestamp(r: u32, ) -> Weight; fn gr_random(n: u32, ) -> Weight; @@ -716,6 +717,16 @@ impl pallet_gear::WeightInfo for SubstrateWeight { .saturating_add(Weight::from_parts(13_214_277, 0).saturating_mul(n.into())) } /// The range of component `r` is `[0, 20]`. + fn gr_exec_settings(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 219_398_000 picoseconds. + Weight::from_parts(675_408_801, 0) + // Standard Error: 1_772_109 + .saturating_add(Weight::from_parts(151_363_102, 0).saturating_mul(r.into())) + } + /// The range of component `r` is `[0, 20]`. fn gr_block_height(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` @@ -2679,6 +2690,16 @@ impl WeightInfo for () { .saturating_add(Weight::from_parts(13_214_277, 0).saturating_mul(n.into())) } /// The range of component `r` is `[0, 20]`. + fn gr_exec_settings(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 219_398_000 picoseconds. + Weight::from_parts(675_408_801, 0) + // Standard Error: 1_772_109 + .saturating_add(Weight::from_parts(151_363_102, 0).saturating_mul(r.into())) + } + /// The range of component `r` is `[0, 20]`. fn gr_block_height(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` diff --git a/utils/regression-analysis/src/main.rs b/utils/regression-analysis/src/main.rs index 9f52ad593f4..a751ed5fe72 100644 --- a/utils/regression-analysis/src/main.rs +++ b/utils/regression-analysis/src/main.rs @@ -319,6 +319,7 @@ fn weights(kind: WeightsKind, input_file: PathBuf, output_file: PathBuf) { gr_size, gr_read, gr_read_per_byte, + gr_exec_settings, gr_block_height, gr_block_timestamp, gr_random, diff --git a/utils/wasm-gen/src/generator/syscalls.rs b/utils/wasm-gen/src/generator/syscalls.rs index 8e2d34b857d..d5a0efb3b6b 100644 --- a/utils/wasm-gen/src/generator/syscalls.rs +++ b/utils/wasm-gen/src/generator/syscalls.rs @@ -205,7 +205,8 @@ impl InvocableSysCall { }; match underlying_syscall { - SysCallName::BlockHeight + SysCallName::ExecSettings + | SysCallName::BlockHeight | SysCallName::BlockTimestamp | SysCallName::Debug | SysCallName::Panic diff --git a/utils/wasm-instrument/src/syscalls.rs b/utils/wasm-instrument/src/syscalls.rs index 6d1667a3002..bc291fb2ff2 100644 --- a/utils/wasm-instrument/src/syscalls.rs +++ b/utils/wasm-instrument/src/syscalls.rs @@ -74,6 +74,7 @@ pub enum SysCallName { // Program execution related // -- // Execution environmental data + ExecSettings, BlockHeight, BlockTimestamp, GasAvailable, @@ -108,6 +109,7 @@ impl SysCallName { pub fn to_str(&self) -> &'static str { match self { SysCallName::Alloc => "alloc", + SysCallName::ExecSettings => "gr_exec_settings", SysCallName::BlockHeight => "gr_block_height", SysCallName::BlockTimestamp => "gr_block_timestamp", SysCallName::CreateProgram => "gr_create_program", @@ -285,6 +287,12 @@ impl SysCallName { SysCallSignature::gr([Ptr(PtrInfo::new_mutable(PtrType::ErrorWithSignalCode))]) } Self::MessageId => SysCallSignature::gr([Ptr(PtrInfo::new_mutable(PtrType::Hash))]), + Self::ExecSettings => SysCallSignature::gr([ + // The PtrType::BufferStart doesn't work here as it requires length_param_idx + // Should we introduce something like PtrType::Buffer + Ptr(PtrInfo::new_mutable(PtrType::BlockNumber)), + Size, + ]), Self::Read => SysCallSignature::gr([ MessagePosition, Size,