diff --git a/.github/workflows/comparison-table.yml b/.github/workflows/comparison-table.yml index a77660b5ac7..6474a4a9a7a 100644 --- a/.github/workflows/comparison-table.yml +++ b/.github/workflows/comparison-table.yml @@ -8,7 +8,6 @@ on: required: true type: choice options: - - gear - vara env: diff --git a/.maintain/frame-weight-template.hbs b/.maintain/frame-weight-template.hbs index 4c3e92bd390..765cf477abc 100644 --- a/.maintain/frame-weight-template.hbs +++ b/.maintain/frame-weight-template.hbs @@ -45,10 +45,6 @@ pub trait WeightInfo { ) -> Weight; {{/each}} {{#if (eq pallet "pallet_gear")}} - fn allocation_cost() -> Weight; - fn grow_cost() -> Weight; - fn initial_cost() -> Weight; - fn load_cost() -> Weight; fn instr_i64const(r: u32, ) -> Weight; {{/if}} } @@ -59,22 +55,6 @@ pub struct SubstrateWeight(PhantomData); impl frame_system::WeightInfo for SubstrateWeight { {{else}} impl {{pallet}}::WeightInfo for SubstrateWeight { -{{/if}} -{{#if (eq pallet "pallet_gear")}} - fn allocation_cost() -> Weight { - // To be changed with the proper value. - T::DbWeight::get().writes(1) - } - fn grow_cost() -> Weight { - // To be changed with the proper value. - T::DbWeight::get().writes(1) - } - fn initial_cost() -> Weight { - T::DbWeight::get().writes(1) - } - fn load_cost() -> Weight { - T::DbWeight::get().reads(1) - } {{/if}} {{#each benchmarks as |benchmark|}} {{#if (eq benchmark.name "instr_call")}} @@ -128,22 +108,6 @@ impl {{pallet}}::WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - {{#if (eq pallet "pallet_gear")}} - fn allocation_cost() -> Weight { - // To be changed with the proper value. - RocksDbWeight::get().writes(1) - } - fn grow_cost() -> Weight { - // To be changed with the proper value. - RocksDbWeight::get().writes(1) - } - fn initial_cost() -> Weight { - RocksDbWeight::get().writes(1) - } - fn load_cost() -> Weight { - RocksDbWeight::get().reads(1) - } - {{/if}} {{#each benchmarks as |benchmark|}} {{#if (eq benchmark.name "instr_call")}} {{#each benchmark.component_weight as |cw|}} diff --git a/common/src/benchmarking.rs b/common/src/benchmarking.rs index 0419ab70bb5..170666d415a 100644 --- a/common/src/benchmarking.rs +++ b/common/src/benchmarking.rs @@ -19,7 +19,7 @@ use super::*; use gear_core::{ - pages::{PageNumber, PageU32Size, WasmPage}, + pages::{PageNumber, WasmPage}, program::MemoryInfix, }; use gear_wasm_instrument::parity_wasm::{self, elements::*}; @@ -115,39 +115,27 @@ pub fn generate_wasm(num_pages: WasmPage) -> Result, &'static str> { Ok(code) } -pub fn set_program< - ProgramStorage: super::ProgramStorage, - BlockNumber: Zero + Copy + Saturating, ->( +pub fn set_program( program_id: ProgramId, code: Vec, static_pages: WasmPage, -) { - let code_id = CodeId::generate(&code).into_origin(); - let allocations: BTreeSet = static_pages.iter_from_zero().collect(); - let persistent_pages_data: BTreeMap = allocations - .iter() - .flat_map(|p| p.to_pages_iter()) - .map(|p| (p, PageBuf::new_zeroed())) - .collect(); - let pages_with_data = persistent_pages_data.keys().copied().collect(); - - let memory_infix = MemoryInfix::new(1u32); - let program = ActiveProgram { - allocations, - pages_with_data, - code_hash: code_id, - code_exports: Default::default(), - static_pages, - state: ProgramState::Initialized, - gas_reservation_map: GasReservationMap::default(), - expiration_block: Zero::zero(), - memory_infix, - }; - for (page, page_buf) in persistent_pages_data { - ProgramStorage::set_program_page_data(program_id, memory_infix, page, page_buf); - } - - ProgramStorage::add_program(program_id, program) - .expect("benchmarking; program duplicates should not exist"); +) where + ProgramStorage: super::ProgramStorage, + BlockNumber: Zero + Copy + Saturating, +{ + ProgramStorage::add_program( + program_id, + ActiveProgram { + allocations: Default::default(), + pages_with_data: Default::default(), + code_hash: CodeId::generate(&code).into_origin(), + code_exports: Default::default(), + static_pages, + state: ProgramState::Initialized, + gas_reservation_map: GasReservationMap::default(), + expiration_block: Zero::zero(), + memory_infix: MemoryInfix::new(1u32), + }, + ) + .expect("benchmarking; program duplicates should not exist"); } diff --git a/pallets/gear/src/weights.rs b/pallets/gear/src/weights.rs index a414e539b0a..8b28e02be0c 100644 --- a/pallets/gear/src/weights.rs +++ b/pallets/gear/src/weights.rs @@ -220,10 +220,6 @@ pub trait WeightInfo { fn tasks_wake_message_no_wake() -> Weight; fn tasks_remove_from_waitlist() -> Weight; fn tasks_remove_from_mailbox() -> Weight; - fn allocation_cost() -> Weight; - fn grow_cost() -> Weight; - fn initial_cost() -> Weight; - fn load_cost() -> Weight; fn instr_i64const(r: u32, ) -> Weight; } @@ -358,20 +354,6 @@ impl WeightInfo for SubstrateWeight { // Standard Error: 2_260_663 .saturating_add(Weight::from_parts(188_425_504, 0).saturating_mul(r.into())) } - fn allocation_cost() -> Weight { - // To be changed with the proper value. - T::DbWeight::get().writes(1) - } - fn grow_cost() -> Weight { - // To be changed with the proper value. - T::DbWeight::get().writes(1) - } - fn initial_cost() -> Weight { - T::DbWeight::get().writes(1) - } - fn load_cost() -> Weight { - T::DbWeight::get().reads(1) - } /// The range of component `c` is `[0, 512]`. fn db_write_per_kb(c: u32, ) -> Weight { // Proof Size summary in bytes: @@ -2234,20 +2216,6 @@ impl WeightInfo for () { // Standard Error: 2_260_663 .saturating_add(Weight::from_parts(188_425_504, 0).saturating_mul(r.into())) } - fn allocation_cost() -> Weight { - // To be changed with the proper value. - RocksDbWeight::get().writes(1) - } - fn grow_cost() -> Weight { - // To be changed with the proper value. - RocksDbWeight::get().writes(1) - } - fn initial_cost() -> Weight { - RocksDbWeight::get().writes(1) - } - fn load_cost() -> Weight { - RocksDbWeight::get().reads(1) - } /// The range of component `c` is `[0, 512]`. fn db_write_per_kb(c: u32, ) -> Weight { // Proof Size summary in bytes: diff --git a/runtime/vara/src/weights/pallet_gear.rs b/runtime/vara/src/weights/pallet_gear.rs index f885e41f3d9..14dcc02facc 100644 --- a/runtime/vara/src/weights/pallet_gear.rs +++ b/runtime/vara/src/weights/pallet_gear.rs @@ -220,10 +220,6 @@ pub trait WeightInfo { fn tasks_wake_message_no_wake() -> Weight; fn tasks_remove_from_waitlist() -> Weight; fn tasks_remove_from_mailbox() -> Weight; - fn allocation_cost() -> Weight; - fn grow_cost() -> Weight; - fn initial_cost() -> Weight; - fn load_cost() -> Weight; fn instr_i64const(r: u32, ) -> Weight; } @@ -358,20 +354,6 @@ impl pallet_gear::WeightInfo for SubstrateWeight { // Standard Error: 2_260_663 .saturating_add(Weight::from_parts(188_425_504, 0).saturating_mul(r.into())) } - fn allocation_cost() -> Weight { - // To be changed with the proper value. - T::DbWeight::get().writes(1) - } - fn grow_cost() -> Weight { - // To be changed with the proper value. - T::DbWeight::get().writes(1) - } - fn initial_cost() -> Weight { - T::DbWeight::get().writes(1) - } - fn load_cost() -> Weight { - T::DbWeight::get().reads(1) - } /// The range of component `c` is `[0, 512]`. fn db_write_per_kb(c: u32, ) -> Weight { // Proof Size summary in bytes: @@ -2234,20 +2216,6 @@ impl WeightInfo for () { // Standard Error: 2_260_663 .saturating_add(Weight::from_parts(188_425_504, 0).saturating_mul(r.into())) } - fn allocation_cost() -> Weight { - // To be changed with the proper value. - RocksDbWeight::get().writes(1) - } - fn grow_cost() -> Weight { - // To be changed with the proper value. - RocksDbWeight::get().writes(1) - } - fn initial_cost() -> Weight { - RocksDbWeight::get().writes(1) - } - fn load_cost() -> Weight { - RocksDbWeight::get().reads(1) - } /// The range of component `c` is `[0, 512]`. fn db_write_per_kb(c: u32, ) -> Weight { // Proof Size summary in bytes: