From 67c0395b2ca6bd8e2f168b738fef5499c14fa756 Mon Sep 17 00:00:00 2001 From: Gregory Sobol Date: Thu, 23 May 2024 12:41:01 +0200 Subject: [PATCH] refactor(pallet): remove loaded pages from pallet manager (#3981) --- pallets/gear/src/manager/mod.rs | 15 --------------- pallets/gear/src/queue.rs | 6 ------ pallets/gear/src/runtime_api.rs | 1 - 3 files changed, 22 deletions(-) diff --git a/pallets/gear/src/manager/mod.rs b/pallets/gear/src/manager/mod.rs index acc2a972da1..f12f5d7e275 100644 --- a/pallets/gear/src/manager/mod.rs +++ b/pallets/gear/src/manager/mod.rs @@ -138,8 +138,6 @@ pub struct ExtManager { users: BTreeSet, /// Ids checked that they are programs. programs: BTreeSet, - /// Ids of programs which memory pages have been loaded earlier during processing a block. - program_loaded_pages: BTreeSet, /// Messages dispatches. dispatch_statuses: BTreeMap, /// Programs, which state changed. @@ -178,7 +176,6 @@ where _phantom: PhantomData, users: Default::default(), programs: Default::default(), - program_loaded_pages: Default::default(), dispatch_statuses: Default::default(), state_changes: Default::default(), builtins, @@ -210,18 +207,6 @@ where !self.check_program_id(id) } - /// Checks if memory pages of a program were loaded. - pub fn program_pages_loaded(&self, id: &ProgramId) -> bool { - self.program_loaded_pages.contains(id) - } - - /// Adds program's id to the collection of programs with - /// loaded memory pages. - pub fn insert_program_id_loaded_pages(&mut self, id: ProgramId) { - debug_assert!(self.check_program_id(&id)); - - self.program_loaded_pages.insert(id); - } /// NOTE: By calling this function we can't differ whether `None` returned, because /// program with `id` doesn't exist or it's terminated pub fn get_actor(&self, id: ProgramId) -> Option { diff --git a/pallets/gear/src/queue.rs b/pallets/gear/src/queue.rs index 85e83000a4f..50eb9158d4a 100644 --- a/pallets/gear/src/queue.rs +++ b/pallets/gear/src/queue.rs @@ -21,7 +21,6 @@ use core_processor::ContextChargedForInstrumentation; pub(crate) struct QueueStep<'a, T: Config> { pub block_config: &'a BlockConfig, - pub ext_manager: &'a mut ExtManager, pub gas_limit: GasBalanceOf, pub dispatch: StoredDispatch, pub balance: u128, @@ -34,7 +33,6 @@ where pub(crate) fn run_queue_step(queue_step: QueueStep<'_, T>) -> Vec { let QueueStep { block_config, - ext_manager, gas_limit, dispatch, balance, @@ -161,9 +159,6 @@ where Err(journal) => return journal, }; - // Load program memory pages. - ext_manager.insert_program_id_loaded_pages(destination_id); - let (random, bn) = T::Randomness::random(dispatch_id.as_ref()); core_processor::process::( @@ -233,7 +228,6 @@ where let journal = Self::run_queue_step(QueueStep { block_config: &block_config, - ext_manager: &mut ext_manager, gas_limit, dispatch, balance: balance.unique_saturated_into(), diff --git a/pallets/gear/src/runtime_api.rs b/pallets/gear/src/runtime_api.rs index 894156fdba6..c1f5217abeb 100644 --- a/pallets/gear/src/runtime_api.rs +++ b/pallets/gear/src/runtime_api.rs @@ -631,7 +631,6 @@ where // Processing of the message, if destination is common program. let journal = Self::run_queue_step(QueueStep { block_config: &block_config, - ext_manager, gas_limit, dispatch, balance: CurrencyOf::::free_balance(&destination.cast()).unique_saturated_into(),