core_processor/
configs.rs

1// This file is part of Gear.
2
3// Copyright (C) 2021-2025 Gear Technologies Inc.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Configurations.
20
21use alloc::{collections::BTreeSet, vec::Vec};
22use gear_core::{
23    costs::{ExtCosts, LazyPagesCosts, ProcessCosts},
24    pages::WasmPagesAmount,
25};
26
27pub use gear_wasm_instrument::syscalls::SyscallName;
28
29/// Contextual block information.
30#[derive(Clone, Copy, Debug, Default)]
31pub struct BlockInfo {
32    /// Height.
33    pub height: u32,
34    /// Timestamp.
35    pub timestamp: u64,
36}
37
38/// Execution settings for handling messages.
39pub(crate) struct ExecutionSettings {
40    /// Contextual block information.
41    pub block_info: BlockInfo,
42    /// Performance multiplier.
43    pub performance_multiplier: gsys::Percent,
44    /// Execution externalities costs.
45    pub ext_costs: ExtCosts,
46    /// Lazy pages costs.
47    pub lazy_pages_costs: LazyPagesCosts,
48    /// Existential deposit.
49    pub existential_deposit: u128,
50    /// Mailbox threshold.
51    pub mailbox_threshold: u64,
52    /// Max allowed memory size.
53    pub max_pages: WasmPagesAmount,
54    /// Forbidden functions.
55    pub forbidden_funcs: BTreeSet<SyscallName>,
56    /// Reserve for parameter of scheduling.
57    pub reserve_for: u32,
58    /// Most recently determined random seed, along with the time in the past since when it was determinable by chain observers.
59    // TODO: find a way to put a random seed inside block config.
60    pub random_data: (Vec<u8>, u32),
61    /// Gas multiplier.
62    pub gas_multiplier: gsys::GasMultiplier,
63}
64
65/// Stable parameters for the whole block across processing runs.
66#[derive(Clone)]
67pub struct BlockConfig {
68    /// Block info.
69    pub block_info: BlockInfo,
70    /// Performance multiplier.
71    pub performance_multiplier: gsys::Percent,
72    /// Forbidden functions.
73    pub forbidden_funcs: BTreeSet<SyscallName>,
74    /// Reserve for parameter of scheduling.
75    pub reserve_for: u32,
76    /// Gas multiplier.
77    pub gas_multiplier: gsys::GasMultiplier,
78    /// Program processing costs.
79    pub costs: ProcessCosts,
80    /// Existential deposit.
81    pub existential_deposit: u128,
82    /// Mailbox threshold.
83    pub mailbox_threshold: u64,
84    /// Amount of reservations can exist for 1 program.
85    pub max_reservations: u64,
86    /// Max allowed page numbers for wasm program.
87    pub max_pages: WasmPagesAmount,
88    /// Outgoing limit.
89    pub outgoing_limit: u32,
90    /// Outgoing bytes limit.
91    pub outgoing_bytes_limit: u32,
92}