Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heuristics tests are altered to panic with multiple results #4252

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions core/src/costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,21 @@ impl SyscallCosts {
}
}

/// Memory pages costs.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct PagesCosts {
StackOverflowExcept1on marked this conversation as resolved.
Show resolved Hide resolved
/// Loading from storage and moving it in program memory cost.
pub load_page_data: CostOf<GearPagesAmount>,
/// Uploading page data to storage cost.
pub upload_page_data: CostOf<GearPagesAmount>,
/// Memory grow cost.
pub mem_grow: CostOf<GearPagesAmount>,
/// Memory grow per page cost.
pub mem_grow_per_page: CostOf<GearPagesAmount>,
/// Parachain read heuristic cost.
pub parachain_read_heuristic: CostOf<GearPagesAmount>,
}

/// Memory pages lazy access costs.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct LazyPagesCosts {
Expand All @@ -521,6 +536,15 @@ pub struct LazyPagesCosts {
pub load_page_storage_data: CostOf<GearPagesAmount>,
}

/// IO costs.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct IoCosts {
/// Consts for common pages.
pub common: PagesCosts,
/// Consts for lazy pages.
pub lazy_pages: LazyPagesCosts,
}

/// Holding in storages rent costs.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct RentCosts {
Expand Down
20 changes: 19 additions & 1 deletion pallets/gear/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ use common::scheduler::SchedulingCostsPerBlock;
use frame_support::{traits::Get, weights::Weight};
use gear_core::{
code::MAX_WASM_PAGES_AMOUNT,
costs::{ExtCosts, InstantiationCosts, LazyPagesCosts, ProcessCosts, RentCosts, SyscallCosts},
costs::{
ExtCosts, InstantiationCosts, IoCosts, LazyPagesCosts, PagesCosts, ProcessCosts, RentCosts,
SyscallCosts,
},
message,
pages::{GearPage, WasmPage},
};
Expand Down Expand Up @@ -1301,6 +1304,21 @@ impl<T: Config> Default for MemoryWeights<T> {
}
}

impl<T: Config> From<MemoryWeights<T>> for IoCosts {
fn from(val: MemoryWeights<T>) -> Self {
Self {
common: PagesCosts {
load_page_data: val.load_page_data.ref_time().into(),
upload_page_data: val.upload_page_data.ref_time().into(),
mem_grow: val.mem_grow.ref_time().into(),
mem_grow_per_page: val.mem_grow_per_page.ref_time().into(),
parachain_read_heuristic: val.parachain_read_heuristic.ref_time().into(),
},
lazy_pages: LazyPagesCosts::from(val),
}
}
}

impl<T: Config> From<MemoryWeights<T>> for LazyPagesCosts {
fn from(val: MemoryWeights<T>) -> Self {
Self {
Expand Down
1 change: 0 additions & 1 deletion runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

mod apis;
pub mod constants;
pub mod weights;

use sp_runtime::traits::Get;

Expand Down
308 changes: 0 additions & 308 deletions runtime/common/src/weights.rs

This file was deleted.

Loading
Loading