1use crate::{
4 BTreeMap, BandersnatchPublic, BlsPublic, Ed25519Public, EntropyBuffer, Gas, OpaqueHash,
5 ServiceId, String, TimeSlot, ValidatorMetadata, Vec,
6 service::{Privileges, ServiceAccount, WorkPackage},
7 vm::{DeferredTransfer, Operand},
8};
9use serde::{Deserialize, Serialize};
10#[cfg(feature = "json")]
11use spacejson::Json;
12
13pub type ValidatorsData = [ValidatorData; 6];
15
16pub type Accounts = BTreeMap<ServiceId, ServiceAccount>;
18
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
21pub struct AuthorizeArgs {
22 pub package: WorkPackage,
24 pub core_idx: u16,
26 pub accounts: Accounts,
28 pub timeslot: TimeSlot,
30}
31
32#[derive(Serialize, Deserialize)]
34pub struct RefineArgs {
35 pub core: u16,
37 pub index: usize,
39 pub package: WorkPackage,
41 pub auth_output: Vec<u8>,
43 pub all_imports: Vec<Vec<Segment>>,
45 pub export_offset: u16,
47 pub accounts: Accounts,
49 pub timeslot: TimeSlot,
51}
52
53#[derive(Serialize, Deserialize)]
55pub struct Segment(#[serde(with = "codec::bytes")] pub [u8; 4104]);
56
57#[derive(Serialize, Deserialize)]
59pub struct AccumulateArgs {
60 pub context: AccumulateState,
62 pub timeslot: TimeSlot,
64 pub service: ServiceId,
66 pub gas: Gas,
68 pub operands: Vec<Operand>,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
74pub struct AccumulateState {
75 pub accounts: Accounts,
77
78 pub validators: ValidatorsData,
80
81 pub authorization: [Vec<OpaqueHash>; crate::CORES_COUNT],
83
84 pub privileges: Privileges,
86
87 pub entropy: EntropyBuffer,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
93pub struct Accumulated {
94 pub context: AccumulateState,
96
97 pub transfers: Vec<DeferredTransfer>,
99
100 pub hash: Option<OpaqueHash>,
102
103 pub gas: Gas,
105
106 pub reason: Reason,
108}
109
110#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Copy)]
112#[cfg_attr(feature = "json", derive(Json))]
113pub struct ValidatorData {
114 #[cfg_attr(feature = "json", json(hex))]
116 pub bandersnatch: BandersnatchPublic,
117 #[cfg_attr(feature = "json", json(hex))]
119 pub ed25519: Ed25519Public,
120 #[cfg_attr(feature = "json", json(hex))]
122 #[serde(with = "codec::bytes")]
123 pub bls: BlsPublic,
124 #[cfg_attr(feature = "json", json(hex))]
126 #[serde(with = "codec::bytes")]
127 pub metadata: ValidatorMetadata,
128}
129
130#[derive(Debug, Default, PartialEq, Eq, Clone, Serialize, Deserialize)]
134pub enum Reason {
135 Halt,
137
138 Panic(String),
140
141 Fault {
143 page: u32,
145 },
146
147 HostCall(u32),
149
150 OOG,
152
153 #[default]
155 Continue,
156}