Skip to main content

gear_core/
costs.rs

1// Copyright (C) Gear Technologies Inc.
2// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
3
4//! Costs module.
5
6use crate::pages::{GearPagesAmount, WasmPagesAmount};
7use core::{fmt::Debug, marker::PhantomData};
8use paste::paste;
9
10/// Gas cost per some type of action or data size.
11#[derive(Clone, Copy, PartialEq, Eq)]
12pub struct CostOf<T> {
13    cost: u64,
14    _phantom: PhantomData<T>,
15}
16
17impl<T> CostOf<T> {
18    /// Const constructor
19    pub const fn new(cost: u64) -> Self {
20        Self {
21            cost,
22            _phantom: PhantomData,
23        }
24    }
25
26    /// Cost for one.
27    pub const fn cost_for_one(&self) -> u64 {
28        self.cost
29    }
30}
31
32impl<T: Into<u32>> CostOf<T> {
33    /// Calculate (saturating mult) cost for `num` amount of `T`.
34    pub fn cost_for(&self, num: T) -> u64 {
35        self.cost.saturating_mul(Into::<u32>::into(num).into())
36    }
37}
38
39impl<T> Debug for CostOf<T> {
40    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
41        f.write_fmt(format_args!("{}", &self.cost))
42    }
43}
44
45impl<T> From<u64> for CostOf<T> {
46    fn from(cost: u64) -> Self {
47        CostOf::new(cost)
48    }
49}
50
51impl<T> From<CostOf<T>> for u64 {
52    fn from(value: CostOf<T>) -> Self {
53        value.cost
54    }
55}
56
57impl<T> Default for CostOf<T> {
58    fn default() -> Self {
59        CostOf::new(0)
60    }
61}
62
63/// Some actions or calls amount.
64#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, derive_more::From, derive_more::Into)]
65pub struct CallsAmount(u32);
66
67impl CostOf<CallsAmount> {
68    /// Calculate (saturating add) cost for `per_byte` amount of `BytesAmount` (saturating mul).
69    pub fn with_bytes(&self, per_byte: CostOf<BytesAmount>, amount: BytesAmount) -> u64 {
70        self.cost_for_one()
71            .saturating_add(per_byte.cost_for(amount))
72    }
73}
74
75/// Bytes amount.
76#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, derive_more::From, derive_more::Into)]
77pub struct BytesAmount(u32);
78
79/// Chain blocks amount.
80#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, derive_more::From, derive_more::Into)]
81pub struct BlocksAmount(u32);
82
83/// Program imported function call (syscall) costs.
84#[derive(Debug, Clone, Default, PartialEq, Eq)]
85pub struct SyscallCosts {
86    /// Cost of calling `alloc`.
87    pub alloc: CostOf<CallsAmount>,
88
89    /// Cost of calling `free`.
90    pub free: CostOf<CallsAmount>,
91
92    /// Cost of calling `free_range`
93    pub free_range: CostOf<CallsAmount>,
94
95    /// Cost of calling `free_range` per page
96    pub free_range_per_page: CostOf<WasmPagesAmount>,
97
98    /// Cost of calling `gr_reserve_gas`.
99    pub gr_reserve_gas: CostOf<CallsAmount>,
100
101    /// Cost of calling `gr_unreserve_gas`
102    pub gr_unreserve_gas: CostOf<CallsAmount>,
103
104    /// Cost of calling `gr_system_reserve_gas`
105    pub gr_system_reserve_gas: CostOf<CallsAmount>,
106
107    /// Cost of calling `gr_gas_available`.
108    pub gr_gas_available: CostOf<CallsAmount>,
109
110    /// Cost of calling `gr_message_id`.
111    pub gr_message_id: CostOf<CallsAmount>,
112
113    /// Cost of calling `gr_program_id`.
114    pub gr_program_id: CostOf<CallsAmount>,
115
116    /// Cost of calling `gr_source`.
117    pub gr_source: CostOf<CallsAmount>,
118
119    /// Cost of calling `gr_value`.
120    pub gr_value: CostOf<CallsAmount>,
121
122    /// Cost of calling `gr_value_available`.
123    pub gr_value_available: CostOf<CallsAmount>,
124
125    /// Cost of calling `gr_size`.
126    pub gr_size: CostOf<CallsAmount>,
127
128    /// Cost of calling `gr_read`.
129    pub gr_read: CostOf<CallsAmount>,
130
131    /// Cost per payload byte for `gr_read`.
132    pub gr_read_per_byte: CostOf<BytesAmount>,
133
134    /// Cost of calling `gr_env_vars`.
135    pub gr_env_vars: CostOf<CallsAmount>,
136
137    /// Cost of calling `gr_block_height`.
138    pub gr_block_height: CostOf<CallsAmount>,
139
140    /// Cost of calling `gr_block_timestamp`.
141    pub gr_block_timestamp: CostOf<CallsAmount>,
142
143    /// Cost of calling `gr_random`.
144    pub gr_random: CostOf<CallsAmount>,
145
146    /// Cost of calling `gr_reply_deposit`.
147    pub gr_reply_deposit: CostOf<CallsAmount>,
148
149    /// Cost of calling `gr_send`
150    pub gr_send: CostOf<CallsAmount>,
151
152    /// Cost per bytes for `gr_send`.
153    pub gr_send_per_byte: CostOf<BytesAmount>,
154
155    /// Cost of calling `gr_send_wgas`.
156    pub gr_send_wgas: CostOf<CallsAmount>,
157
158    /// Cost of calling `gr_send_wgas` per one payload byte.
159    pub gr_send_wgas_per_byte: CostOf<BytesAmount>,
160
161    /// Cost of calling `gr_send_init`.
162    pub gr_send_init: CostOf<CallsAmount>,
163
164    /// Cost of calling `gr_send_push`.
165    pub gr_send_push: CostOf<CallsAmount>,
166
167    /// Cost per payload byte by `gr_send_push`.
168    pub gr_send_push_per_byte: CostOf<BytesAmount>,
169
170    /// Cost of calling `gr_send_commit`.
171    pub gr_send_commit: CostOf<CallsAmount>,
172
173    /// Cost of calling `gr_send_commit_wgas`.
174    pub gr_send_commit_wgas: CostOf<CallsAmount>,
175
176    /// Cost of calling `gr_reservation_send`.
177    pub gr_reservation_send: CostOf<CallsAmount>,
178
179    /// Cost of calling `gr_reservation_send` per one payload byte.
180    pub gr_reservation_send_per_byte: CostOf<BytesAmount>,
181
182    /// Cost of calling `gr_reservation_send_commit`.
183    pub gr_reservation_send_commit: CostOf<CallsAmount>,
184
185    /// Cost of calling `gr_send_init`.
186    pub gr_send_input: CostOf<CallsAmount>,
187
188    /// Cost of calling `gr_send_init_wgas`.
189    pub gr_send_input_wgas: CostOf<CallsAmount>,
190
191    /// Cost of calling `gr_send_push_input`.
192    pub gr_send_push_input: CostOf<CallsAmount>,
193
194    /// Cost per payload byte by `gr_send_push_input`.
195    pub gr_send_push_input_per_byte: CostOf<BytesAmount>,
196
197    /// Cost of calling `gr_reply`.
198    pub gr_reply: CostOf<CallsAmount>,
199
200    /// Cost of calling `gr_reply` per one payload byte.
201    pub gr_reply_per_byte: CostOf<BytesAmount>,
202
203    /// Cost of calling `gr_reply_wgas`.
204    pub gr_reply_wgas: CostOf<CallsAmount>,
205
206    /// Cost of calling `gr_reply_wgas` per one payload byte.
207    pub gr_reply_wgas_per_byte: CostOf<BytesAmount>,
208
209    /// Cost of calling `gr_reply_commit`.
210    pub gr_reply_commit: CostOf<CallsAmount>,
211
212    /// Cost of calling `gr_reply_commit_wgas`.
213    pub gr_reply_commit_wgas: CostOf<CallsAmount>,
214
215    /// Cost of calling `gr_reservation_reply`.
216    pub gr_reservation_reply: CostOf<CallsAmount>,
217
218    /// Cost of calling `gr_reservation_reply` per one payload byte.
219    pub gr_reservation_reply_per_byte: CostOf<BytesAmount>,
220
221    /// Cost of calling `gr_reservation_reply_commit`.
222    pub gr_reservation_reply_commit: CostOf<CallsAmount>,
223
224    /// Cost of calling `gr_reply_push`.
225    pub gr_reply_push: CostOf<CallsAmount>,
226
227    /// Cost per payload byte by `gr_reply_push`.
228    pub gr_reply_push_per_byte: CostOf<BytesAmount>,
229
230    /// Cost of calling `gr_reply_input`.
231    pub gr_reply_input: CostOf<CallsAmount>,
232
233    /// Cost of calling `gr_reply_input_wgas`.
234    pub gr_reply_input_wgas: CostOf<CallsAmount>,
235
236    /// Cost of calling `gr_reply_push_input`.
237    pub gr_reply_push_input: CostOf<CallsAmount>,
238
239    /// Cost per payload byte by `gr_reply_push_input`.
240    pub gr_reply_push_input_per_byte: CostOf<BytesAmount>,
241
242    /// Cost of calling `gr_reply_to`.
243    pub gr_reply_to: CostOf<CallsAmount>,
244
245    /// Cost of calling `gr_signal_code`.
246    pub gr_signal_code: CostOf<CallsAmount>,
247
248    /// Cost of calling `gr_signal_from`.
249    pub gr_signal_from: CostOf<CallsAmount>,
250
251    /// Cost of calling `gr_debug`.
252    pub gr_debug: CostOf<CallsAmount>,
253
254    /// Cost per payload byte by `gr_debug`.
255    pub gr_debug_per_byte: CostOf<BytesAmount>,
256
257    /// Cost of calling `gr_reply_code`.
258    pub gr_reply_code: CostOf<CallsAmount>,
259
260    /// Cost of calling `gr_exit`.
261    pub gr_exit: CostOf<CallsAmount>,
262
263    /// Cost of calling `gr_leave`.
264    pub gr_leave: CostOf<CallsAmount>,
265
266    /// Cost of calling `gr_wait`.
267    pub gr_wait: CostOf<CallsAmount>,
268
269    /// Cost of calling `gr_wait_for`.
270    pub gr_wait_for: CostOf<CallsAmount>,
271
272    /// Cost of calling `gr_wait_up_to`.
273    pub gr_wait_up_to: CostOf<CallsAmount>,
274
275    /// Cost of calling `gr_wake`.
276    pub gr_wake: CostOf<CallsAmount>,
277
278    /// Cost of calling `gr_create_program_wgas`.
279    pub gr_create_program: CostOf<CallsAmount>,
280
281    /// Cost per payload byte by `gr_create_program_wgas`.
282    pub gr_create_program_payload_per_byte: CostOf<BytesAmount>,
283
284    /// Cost per salt byte by `gr_create_program_wgas`.
285    pub gr_create_program_salt_per_byte: CostOf<BytesAmount>,
286
287    /// Cost of calling `gr_create_program_wgas`.
288    pub gr_create_program_wgas: CostOf<CallsAmount>,
289
290    /// Cost per payload byte by `gr_create_program_wgas`.
291    pub gr_create_program_wgas_payload_per_byte: CostOf<BytesAmount>,
292
293    /// Cost per salt byte by `gr_create_program_wgas`.
294    pub gr_create_program_wgas_salt_per_byte: CostOf<BytesAmount>,
295}
296
297/// Enumerates syscalls that can be charged by gas meter.
298#[derive(Debug, Copy, Clone)]
299pub enum CostToken {
300    /// Zero cost.
301    Null,
302    /// Cost of calling `alloc`.
303    Alloc,
304    /// Cost of calling `free`.
305    Free,
306    /// Cost of calling `free_range`
307    FreeRange,
308    /// Cost of calling `gr_reserve_gas`.
309    ReserveGas,
310    /// Cost of calling `gr_unreserve_gas`.
311    UnreserveGas,
312    /// Cost of calling `gr_system_reserve_gas`.
313    SystemReserveGas,
314    /// Cost of calling `gr_gas_available`.
315    GasAvailable,
316    /// Cost of calling `gr_message_id`.
317    MsgId,
318    /// Cost of calling `gr_program_id`.
319    ActorId,
320    /// Cost of calling `gr_source`.
321    Source,
322    /// Cost of calling `gr_value`.
323    Value,
324    /// Cost of calling `gr_value_available`.
325    ValueAvailable,
326    /// Cost of calling `gr_size`.
327    Size,
328    /// Cost of calling `gr_read`.
329    Read,
330    /// Cost of calling `gr_env_vars`.
331    EnvVars,
332    /// Cost of calling `gr_block_height`.
333    BlockHeight,
334    /// Cost of calling `gr_block_timestamp`.
335    BlockTimestamp,
336    /// Cost of calling `gr_random`.
337    Random,
338    /// Cost of calling `gr_reply_deposit`.
339    ReplyDeposit,
340    /// Cost of calling `gr_send`, taking in account payload size.
341    Send(BytesAmount),
342    /// Cost of calling `gr_send_wgas`, taking in account payload size.
343    SendWGas(BytesAmount),
344    /// Cost of calling `gr_send_init`.
345    SendInit,
346    /// Cost of calling `gr_send_push`, taking in account payload size.
347    SendPush(BytesAmount),
348    /// Cost of calling `gr_send_commit`.
349    SendCommit,
350    /// Cost of calling `gr_send_commit_wgas`.
351    SendCommitWGas,
352    /// Cost of calling `gr_reservation_send`, taking in account payload size.
353    ReservationSend(BytesAmount),
354    /// Cost of calling `gr_reservation_send_commit`.
355    ReservationSendCommit,
356    /// Cost of calling `gr_send_input`.
357    SendInput,
358    /// Cost of calling `gr_send_input_wgas`.
359    SendInputWGas,
360    /// Cost of calling `gr_send_push_input`.
361    SendPushInput,
362    /// Cost of calling `gr_reply`, taking in account payload size.
363    Reply(BytesAmount),
364    /// Cost of calling `gr_reply_wgas`, taking in account payload size.
365    ReplyWGas(BytesAmount),
366    /// Cost of calling `gr_reply_push`, taking in account payload size.
367    ReplyPush(BytesAmount),
368    /// Cost of calling `gr_reply_commit`.
369    ReplyCommit,
370    /// Cost of calling `gr_reply_commit_wgas`.
371    ReplyCommitWGas,
372    /// Cost of calling `gr_reservation_reply`, taking in account payload size.
373    ReservationReply(BytesAmount),
374    /// Cost of calling `gr_reservation_reply_commit`.
375    ReservationReplyCommit,
376    /// Cost of calling `gr_reply_input`.
377    ReplyInput,
378    /// Cost of calling `gr_reply_input_wgas`.
379    ReplyInputWGas,
380    /// Cost of calling `gr_reply_push_input`.
381    ReplyPushInput,
382    /// Cost of calling `gr_reply_to`.
383    ReplyTo,
384    /// Cost of calling `gr_signal_code`.
385    SignalCode,
386    /// Cost of calling `gr_signal_from`.
387    SignalFrom,
388    /// Cost of calling `gr_debug`, taking in account payload size.
389    Debug(BytesAmount),
390    /// Cost of calling `gr_reply_code`.
391    ReplyCode,
392    /// Cost of calling `gr_exit`.
393    Exit,
394    /// Cost of calling `gr_leave`.
395    Leave,
396    /// Cost of calling `gr_wait`.
397    Wait,
398    /// Cost of calling `gr_wait_for`.
399    WaitFor,
400    /// Cost of calling `gr_wait_up_to`.
401    WaitUpTo,
402    /// Cost of calling `gr_wake`.
403    Wake,
404    /// Cost of calling `gr_create_program`, taking in account payload and salt size.
405    CreateProgram(BytesAmount, BytesAmount),
406    /// Cost of calling `gr_create_program_wgas`, taking in account payload and salt size.
407    CreateProgramWGas(BytesAmount, BytesAmount),
408}
409
410impl SyscallCosts {
411    /// Get cost for a token.
412    pub fn cost_for_token(&self, token: CostToken) -> u64 {
413        use CostToken::*;
414
415        macro_rules! cost_with_per_byte {
416            ($name:ident, $len:expr) => {
417                paste! {
418                    self.$name.with_bytes(self.[< $name _per_byte >], $len)
419                }
420            };
421        }
422
423        match token {
424            Null => 0,
425            Alloc => self.alloc.cost_for_one(),
426            Free => self.free.cost_for_one(),
427            FreeRange => self.free_range.cost_for_one(),
428            ReserveGas => self.gr_reserve_gas.cost_for_one(),
429            UnreserveGas => self.gr_unreserve_gas.cost_for_one(),
430            SystemReserveGas => self.gr_system_reserve_gas.cost_for_one(),
431            GasAvailable => self.gr_gas_available.cost_for_one(),
432            MsgId => self.gr_message_id.cost_for_one(),
433            ActorId => self.gr_program_id.cost_for_one(),
434            Source => self.gr_source.cost_for_one(),
435            Value => self.gr_value.cost_for_one(),
436            ValueAvailable => self.gr_value_available.cost_for_one(),
437            Size => self.gr_size.cost_for_one(),
438            Read => self.gr_read.cost_for_one(),
439            EnvVars => self.gr_env_vars.cost_for_one(),
440            BlockHeight => self.gr_block_height.cost_for_one(),
441            BlockTimestamp => self.gr_block_timestamp.cost_for_one(),
442            Random => self.gr_random.cost_for_one(),
443            ReplyDeposit => self.gr_reply_deposit.cost_for_one(),
444            Send(len) => cost_with_per_byte!(gr_send, len),
445            SendWGas(len) => cost_with_per_byte!(gr_send_wgas, len),
446            SendInit => self.gr_send_init.cost_for_one(),
447            SendPush(len) => cost_with_per_byte!(gr_send_push, len),
448            SendCommit => self.gr_send_commit.cost_for_one(),
449            SendCommitWGas => self.gr_send_commit_wgas.cost_for_one(),
450            ReservationSend(len) => cost_with_per_byte!(gr_reservation_send, len),
451            ReservationSendCommit => self.gr_reservation_send_commit.cost_for_one(),
452            SendInput => self.gr_send_input.cost_for_one(),
453            SendInputWGas => self.gr_send_input_wgas.cost_for_one(),
454            SendPushInput => self.gr_send_push_input.cost_for_one(),
455            Reply(len) => cost_with_per_byte!(gr_reply, len),
456            ReplyWGas(len) => cost_with_per_byte!(gr_reply_wgas, len),
457            ReplyPush(len) => cost_with_per_byte!(gr_reply_push, len),
458            ReplyCommit => self.gr_reply_commit.cost_for_one(),
459            ReplyCommitWGas => self.gr_reply_commit_wgas.cost_for_one(),
460            ReservationReply(len) => cost_with_per_byte!(gr_reservation_reply, len),
461            ReservationReplyCommit => self.gr_reservation_reply_commit.cost_for_one(),
462            ReplyInput => self.gr_reply_input.cost_for_one(),
463            ReplyInputWGas => self.gr_reply_input_wgas.cost_for_one(),
464            ReplyPushInput => self.gr_reply_push_input.cost_for_one(),
465            ReplyTo => self.gr_reply_to.cost_for_one(),
466            SignalCode => self.gr_signal_code.cost_for_one(),
467            SignalFrom => self.gr_signal_from.cost_for_one(),
468            Debug(len) => cost_with_per_byte!(gr_debug, len),
469            ReplyCode => self.gr_reply_code.cost_for_one(),
470            Exit => self.gr_exit.cost_for_one(),
471            Leave => self.gr_leave.cost_for_one(),
472            Wait => self.gr_wait.cost_for_one(),
473            WaitFor => self.gr_wait_for.cost_for_one(),
474            WaitUpTo => self.gr_wait_up_to.cost_for_one(),
475            Wake => self.gr_wake.cost_for_one(),
476            CreateProgram(payload, salt) => CostOf::from(
477                self.gr_create_program
478                    .with_bytes(self.gr_create_program_payload_per_byte, payload),
479            )
480            .with_bytes(self.gr_create_program_salt_per_byte, salt),
481            CreateProgramWGas(payload, salt) => CostOf::from(
482                self.gr_create_program_wgas
483                    .with_bytes(self.gr_create_program_wgas_payload_per_byte, payload),
484            )
485            .with_bytes(self.gr_create_program_wgas_salt_per_byte, salt),
486        }
487    }
488}
489
490/// Memory pages costs.
491#[derive(Debug, Default, Clone, PartialEq, Eq)]
492pub struct PagesCosts {
493    /// Loading from storage and moving it in program memory cost.
494    pub load_page_data: CostOf<GearPagesAmount>,
495    /// Uploading page data to storage cost.
496    pub upload_page_data: CostOf<GearPagesAmount>,
497    /// Memory grow cost.
498    pub mem_grow: CostOf<GearPagesAmount>,
499    /// Memory grow per page cost.
500    pub mem_grow_per_page: CostOf<GearPagesAmount>,
501    /// Parachain read heuristic cost.
502    pub parachain_read_heuristic: CostOf<GearPagesAmount>,
503}
504
505/// Memory pages lazy access costs.
506#[derive(Debug, Default, Clone, PartialEq, Eq)]
507pub struct LazyPagesCosts {
508    /// First read page access cost.
509    pub signal_read: CostOf<GearPagesAmount>,
510    /// First write page access cost.
511    pub signal_write: CostOf<GearPagesAmount>,
512    /// First write access cost for page, which has been already read accessed.
513    pub signal_write_after_read: CostOf<GearPagesAmount>,
514    /// First read page access cost from host function call.
515    pub host_func_read: CostOf<GearPagesAmount>,
516    /// First write page access cost from host function call.
517    pub host_func_write: CostOf<GearPagesAmount>,
518    /// First write page access cost from host function call.
519    pub host_func_write_after_read: CostOf<GearPagesAmount>,
520    /// Loading page data from storage cost.
521    pub load_page_storage_data: CostOf<GearPagesAmount>,
522}
523
524/// IO costs.
525#[derive(Debug, Default, Clone, PartialEq, Eq)]
526pub struct IoCosts {
527    /// Consts for common pages.
528    pub common: PagesCosts,
529    /// Consts for lazy pages.
530    pub lazy_pages: LazyPagesCosts,
531}
532
533/// Holding in storages rent costs.
534#[derive(Debug, Default, Clone, PartialEq, Eq)]
535pub struct RentCosts {
536    /// Holding message in waitlist cost per block.
537    pub waitlist: CostOf<BlocksAmount>,
538    /// Holding message in dispatch stash cost per block.
539    pub dispatch_stash: CostOf<BlocksAmount>,
540    /// Holding reservation cost per block.
541    pub reservation: CostOf<BlocksAmount>,
542}
543
544/// Execution externalities costs.
545#[derive(Debug, Default, Clone, PartialEq, Eq)]
546pub struct ExtCosts {
547    /// Syscalls costs.
548    pub syscalls: SyscallCosts,
549    /// Rent costs.
550    pub rent: RentCosts,
551    /// Memory grow cost.
552    pub mem_grow: CostOf<CallsAmount>,
553    /// Memory grow per page cost.
554    pub mem_grow_per_page: CostOf<WasmPagesAmount>,
555}
556
557/// Module instantiation costs.
558#[derive(Debug, Default, Clone, PartialEq, Eq)]
559pub struct InstantiationCosts {
560    /// WASM module code section instantiation per byte cost.
561    pub code_section_per_byte: CostOf<BytesAmount>,
562    /// WASM module data section instantiation per byte cost.
563    pub data_section_per_byte: CostOf<BytesAmount>,
564    /// WASM module global section instantiation per byte cost.
565    pub global_section_per_byte: CostOf<BytesAmount>,
566    /// WASM module table section instantiation per byte cost.
567    pub table_section_per_byte: CostOf<BytesAmount>,
568    /// WASM module element section instantiation per byte cost.
569    pub element_section_per_byte: CostOf<BytesAmount>,
570    /// WASM module type section instantiation per byte cost.
571    pub type_section_per_byte: CostOf<BytesAmount>,
572}
573
574/// Database costs.
575#[derive(Clone, Debug, Default, PartialEq, Eq)]
576pub struct DbCosts {
577    /// Storage read cost.
578    pub read: CostOf<CallsAmount>,
579    /// Storage read per byte cost.
580    pub read_per_byte: CostOf<BytesAmount>,
581    /// Storage write cost.
582    pub write: CostOf<CallsAmount>,
583    /// Storage write per byte cost.
584    pub write_per_byte: CostOf<BytesAmount>,
585}
586
587/// Code instrumentation costs.
588#[derive(Clone, Debug, Default, PartialEq, Eq)]
589pub struct InstrumentationCosts {
590    /// Code instrumentation cost.
591    pub base: CostOf<CallsAmount>,
592    /// Code instrumentation per byte cost.
593    pub per_byte: CostOf<BytesAmount>,
594}
595
596/// Costs for message processing
597#[derive(Clone, Debug, Default, PartialEq, Eq)]
598pub struct ProcessCosts {
599    /// Execution externalities costs.
600    pub ext: ExtCosts,
601    /// Lazy pages costs.
602    pub lazy_pages: LazyPagesCosts,
603    /// Module instantiation costs.
604    pub instantiation: InstantiationCosts,
605    /// DB costs.
606    pub db: DbCosts,
607    /// Instrumentation costs.
608    pub instrumentation: InstrumentationCosts,
609    /// Load program allocations cost per interval.
610    pub load_allocations_per_interval: CostOf<u32>,
611}