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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
338a9d7
heuristics tests are altered to panic with multiple results
Lazark0x Sep 23, 2024
ec9f02d
weights content have been moved to the tests
Lazark0x Sep 24, 2024
f69e521
fixed source file structure
Lazark0x Sep 24, 2024
2224bcc
Merge branch 'master' into 4248-refactor-tests-improve-ux-of-runtime-…
Lazark0x Sep 24, 2024
89c6432
Merge branch 'master' into 4248-refactor-tests-improve-ux-of-runtime-…
Lazark0x Oct 20, 2024
e1a566c
Merge remote-tracking branch 'origin/master' into 4248-refactor-tests…
Lazark0x Nov 4, 2024
e79d1fa
post-review changes: added test for weights count
Lazark0x Nov 5, 2024
773e82d
Merge remote-tracking branch 'origin/master' into 4248-refactor-tests…
Lazark0x Nov 5, 2024
a3e82e1
Merge remote-tracking branch 'origin/master' into 4248-refactor-tests…
Lazark0x Nov 5, 2024
e825e99
post-review: code structure fix
Lazark0x Nov 5, 2024
9771df9
post-review fixes
Lazark0x Nov 13, 2024
b82d24a
post-review fixes
Lazark0x Nov 26, 2024
5994ee6
Merge remote-tracking branch 'origin/master' into 4248-refactor-tests…
Lazark0x Nov 26, 2024
066fece
Merge remote-tracking branch 'origin/master' into 4248-refactor-tests…
StackOverflowExcept1on Dec 7, 2024
f437ec6
fix submodules
StackOverflowExcept1on Dec 7, 2024
f215874
fix clippy
StackOverflowExcept1on Dec 7, 2024
395b22c
Merge branch 'master' into 4248-refactor-tests-improve-ux-of-runtime-…
Lazark0x Dec 12, 2024
9a20ae7
Merge remote-tracking branch 'origin/master' into 4248-refactor-tests…
Lazark0x Dec 16, 2024
a49a3ae
reduced the amount of text in error messages
Lazark0x Dec 16, 2024
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
21 changes: 21 additions & 0 deletions core/src/gas_metering/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,27 @@ impl From<SyscallWeights> for SyscallCosts {
}
}

impl From<MemoryWeights> for IoCosts {
fn from(val: MemoryWeights) -> Self {
Self {
common: PagesCosts::from(val.clone()),
lazy_pages: LazyPagesCosts::from(val),
}
}
}

impl From<MemoryWeights> for PagesCosts {
fn from(val: MemoryWeights) -> Self {
Self {
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(),
}
}
}

impl From<MemoryWeights> for LazyPagesCosts {
fn from(val: MemoryWeights) -> Self {
Self {
Expand Down
26 changes: 25 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,27 @@ impl<T: Config> Default for MemoryWeights<T> {
}
}

impl<T: Config> From<MemoryWeights<T>> for IoCosts {
fn from(val: MemoryWeights<T>) -> Self {
Self {
common: PagesCosts::from(val.clone()),
lazy_pages: LazyPagesCosts::from(val),
}
}
}

impl<T: Config> From<MemoryWeights<T>> for PagesCosts {
fn from(val: MemoryWeights<T>) -> Self {
Self {
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(),
}
}
}

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
Loading
Loading