use alloc::{collections::BTreeSet, vec::Vec};
use gear_core::{
costs::{BlocksAmount, BytesAmount, CallsAmount, CostOf, SyscallCosts},
pages::WasmPagesAmount,
};
use gear_lazy_pages_common::LazyPagesCosts;
use gear_wasm_instrument::syscalls::SyscallName;
pub const TESTS_MAX_PAGES_NUMBER: u16 = 512;
#[derive(Clone, Copy, Debug, Default)]
pub struct BlockInfo {
pub height: u32,
pub timestamp: u64,
}
#[derive(Debug, Default, Clone)]
pub struct RentCosts {
pub waitlist: CostOf<BlocksAmount>,
pub dispatch_stash: CostOf<BlocksAmount>,
pub reservation: CostOf<BlocksAmount>,
}
#[derive(Debug, Default, Clone)]
pub struct ExtCosts {
pub syscalls: SyscallCosts,
pub rent: RentCosts,
pub mem_grow: CostOf<CallsAmount>,
pub mem_grow_per_page: CostOf<WasmPagesAmount>,
}
#[derive(Debug, Default, Clone)]
pub struct InstantiationCosts {
pub code_section_per_byte: CostOf<BytesAmount>,
pub data_section_per_byte: CostOf<BytesAmount>,
pub global_section_per_byte: CostOf<BytesAmount>,
pub table_section_per_byte: CostOf<BytesAmount>,
pub element_section_per_byte: CostOf<BytesAmount>,
pub type_section_per_byte: CostOf<BytesAmount>,
}
#[derive(Clone, Debug, Default)]
pub struct ProcessCosts {
pub ext: ExtCosts,
pub lazy_pages: LazyPagesCosts,
pub read: CostOf<CallsAmount>,
pub read_per_byte: CostOf<BytesAmount>,
pub write: CostOf<CallsAmount>,
pub instrumentation: CostOf<CallsAmount>,
pub instrumentation_per_byte: CostOf<BytesAmount>,
pub instantiation_costs: InstantiationCosts,
pub load_allocations_per_interval: CostOf<u32>,
}
pub(crate) struct ExecutionSettings {
pub block_info: BlockInfo,
pub performance_multiplier: gsys::Percent,
pub ext_costs: ExtCosts,
pub lazy_pages_costs: LazyPagesCosts,
pub existential_deposit: u128,
pub mailbox_threshold: u64,
pub max_pages: WasmPagesAmount,
pub forbidden_funcs: BTreeSet<SyscallName>,
pub reserve_for: u32,
pub random_data: (Vec<u8>, u32),
pub gas_multiplier: gsys::GasMultiplier,
}
#[derive(Clone)]
pub struct BlockConfig {
pub block_info: BlockInfo,
pub performance_multiplier: gsys::Percent,
pub forbidden_funcs: BTreeSet<SyscallName>,
pub reserve_for: u32,
pub gas_multiplier: gsys::GasMultiplier,
pub costs: ProcessCosts,
pub existential_deposit: u128,
pub mailbox_threshold: u64,
pub max_reservations: u64,
pub max_pages: WasmPagesAmount,
pub outgoing_limit: u32,
pub outgoing_bytes_limit: u32,
}