1use crate::cost::ActionCosts;
2use std::slice;
3
4#[derive(
6 Clone,
7 Copy,
8 PartialEq,
9 Eq,
10 PartialOrd,
11 Ord,
12 Debug,
13 strum::Display,
14 strum::EnumString,
15 strum::IntoStaticStr,
16)]
17#[strum(serialize_all = "snake_case")]
18pub enum Parameter {
19 BurntGasReward,
21 PessimisticGasPriceInflation,
22
23 MinAllowedTopLevelAccountLength,
25 RegistrarAccountId,
26
27 StorageAmountPerByte,
29 StorageNumBytesAccount,
30 StorageNumExtraBytesRecord,
31
32 ActionReceiptCreation,
37 DataReceiptCreationBase,
38 DataReceiptCreationPerByte,
39 ActionCreateAccount,
40 ActionDeleteAccount,
41 ActionDeployContract,
42 ActionDeployContractPerByte,
43 ActionFunctionCall,
44 ActionFunctionCallPerByte,
45 ActionTransfer,
46 ActionPledge,
47 ActionAddFullAccessKey,
48 ActionAddFunctionCallKey,
49 ActionAddFunctionCallKeyPerByte,
50 ActionDeleteKey,
51 ActionDelegate,
52
53 WasmRegularOpCost,
55 WasmGrowMemCost,
56 WasmBase,
58 WasmContractLoadingBase,
59 WasmContractLoadingBytes,
60 WasmReadMemoryBase,
61 WasmReadMemoryByte,
62 WasmWriteMemoryBase,
63 WasmWriteMemoryByte,
64 WasmReadRegisterBase,
65 WasmReadRegisterByte,
66 WasmWriteRegisterBase,
67 WasmWriteRegisterByte,
68 WasmUtf8DecodingBase,
69 WasmUtf8DecodingByte,
70 WasmUtf16DecodingBase,
71 WasmUtf16DecodingByte,
72 WasmSha256Base,
73 WasmSha256Byte,
74 WasmKeccak256Base,
75 WasmKeccak256Byte,
76 WasmKeccak512Base,
77 WasmKeccak512Byte,
78 WasmRipemd160Base,
79 WasmRipemd160Block,
80 WasmEcrecoverBase,
81 WasmEd25519VerifyBase,
82 WasmEd25519VerifyByte,
83 WasmLogBase,
84 WasmLogByte,
85 WasmStorageWriteBase,
86 WasmStorageWriteKeyByte,
87 WasmStorageWriteValueByte,
88 WasmStorageWriteEvictedByte,
89 WasmStorageReadBase,
90 WasmStorageReadKeyByte,
91 WasmStorageReadValueByte,
92 WasmStorageRemoveBase,
93 WasmStorageRemoveKeyByte,
94 WasmStorageRemoveRetValueByte,
95 WasmStorageHasKeyBase,
96 WasmStorageHasKeyByte,
97 WasmStorageIterCreatePrefixBase,
98 WasmStorageIterCreatePrefixByte,
99 WasmStorageIterCreateRangeBase,
100 WasmStorageIterCreateFromByte,
101 WasmStorageIterCreateToByte,
102 WasmStorageIterNextBase,
103 WasmStorageIterNextKeyByte,
104 WasmStorageIterNextValueByte,
105 WasmTouchingTrieNode,
106 WasmReadCachedTrieNode,
107 WasmPromiseAndBase,
108 WasmPromiseAndPerPromise,
109 WasmPromiseReturn,
110 WasmValidatorPledgeBase,
111 WasmValidatorTotalPledgeBase,
112 WasmValidatorPowerBase,
113 WasmValidatorTotalPowerBase,
114 WasmAltBn128G1MultiexpBase,
115 WasmAltBn128G1MultiexpElement,
116 WasmAltBn128PairingCheckBase,
117 WasmAltBn128PairingCheckElement,
118 WasmAltBn128G1SumBase,
119 WasmAltBn128G1SumElement,
120
121 MaxGasBurnt,
123 MaxGasBurntView,
124 MaxStackHeight,
125 ContractPrepareVersion,
126 InitialMemoryPages,
127 MaxMemoryPages,
128 RegistersMemoryLimit,
129 MaxRegisterSize,
130 MaxNumberRegisters,
131 MaxNumberLogs,
132 MaxTotalLogLength,
133 MaxTotalPrepaidGas,
134 MaxActionsPerReceipt,
135 MaxNumberBytesMethodNames,
136 MaxLengthMethodName,
137 MaxArgumentsLength,
138 MaxLengthReturnedData,
139 MaxContractSize,
140 MaxTransactionSize,
141 MaxLengthStorageKey,
142 MaxLengthStorageValue,
143 MaxPromisesPerFunctionCallAction,
144 MaxNumberInputDataDependencies,
145 MaxFunctionsNumberPerContract,
146 Wasmer2StackLimit,
147 MaxLocalsPerContract,
148 AccountIdValidityRulesVersion,
149
150 #[strum(serialize = "disable_9393_fix")]
152 Disable9393Fix,
153 FlatStorageReads,
154 ImplicitAccountCreation,
155 FixContractLoadingCost,
156 MathExtension,
157 Ed25519Verify,
158 AltBn128,
159 FunctionCallWeight,
160 VmKind,
161 EthAccounts,
162
163 ActionRegisterRSA2048Keys,
164 ActionCreateRSA2048Challenge,
165}
166
167#[derive(
168 Clone,
169 Copy,
170 PartialEq,
171 Eq,
172 PartialOrd,
173 Ord,
174 Debug,
175 strum::Display,
176 strum::EnumString,
177 strum::IntoStaticStr,
178)]
179#[strum(serialize_all = "snake_case")]
180pub enum FeeParameter {
181 ActionReceiptCreation,
182 DataReceiptCreationBase,
183 DataReceiptCreationPerByte,
184 ActionCreateAccount,
185 ActionDeleteAccount,
186 ActionDeployContract,
187 ActionDeployContractPerByte,
188 ActionFunctionCall,
189 ActionFunctionCallPerByte,
190 ActionTransfer,
191 ActionPledge,
192 ActionAddFullAccessKey,
193 ActionAddFunctionCallKey,
194 ActionAddFunctionCallKeyPerByte,
195 ActionDeleteKey,
196 ActionDelegate,
197 ActionRegisterRSA2048Keys,
198 ActionCreateRSA2048Challenge,
199}
200
201impl Parameter {
202 pub fn vm_limits() -> slice::Iter<'static, Parameter> {
205 [
206 Parameter::MaxGasBurnt,
207 Parameter::MaxStackHeight,
208 Parameter::ContractPrepareVersion,
209 Parameter::InitialMemoryPages,
210 Parameter::MaxMemoryPages,
211 Parameter::RegistersMemoryLimit,
212 Parameter::MaxRegisterSize,
213 Parameter::MaxNumberRegisters,
214 Parameter::MaxNumberLogs,
215 Parameter::MaxTotalLogLength,
216 Parameter::MaxTotalPrepaidGas,
217 Parameter::MaxActionsPerReceipt,
218 Parameter::MaxNumberBytesMethodNames,
219 Parameter::MaxLengthMethodName,
220 Parameter::MaxArgumentsLength,
221 Parameter::MaxLengthReturnedData,
222 Parameter::MaxContractSize,
223 Parameter::MaxTransactionSize,
224 Parameter::MaxLengthStorageKey,
225 Parameter::MaxLengthStorageValue,
226 Parameter::MaxPromisesPerFunctionCallAction,
227 Parameter::MaxNumberInputDataDependencies,
228 Parameter::MaxFunctionsNumberPerContract,
229 Parameter::Wasmer2StackLimit,
230 Parameter::MaxLocalsPerContract,
231 Parameter::AccountIdValidityRulesVersion,
232 ]
233 .iter()
234 }
235}
236
237impl From<ActionCosts> for FeeParameter {
240 fn from(other: ActionCosts) -> Self {
241 match other {
242 ActionCosts::create_account => Self::ActionCreateAccount,
243 ActionCosts::delete_account => Self::ActionDeleteAccount,
244 ActionCosts::delegate => Self::ActionDelegate,
245 ActionCosts::deploy_contract_base => Self::ActionDeployContract,
246 ActionCosts::deploy_contract_byte => Self::ActionDeployContractPerByte,
247 ActionCosts::function_call_base => Self::ActionFunctionCall,
248 ActionCosts::function_call_byte => Self::ActionFunctionCallPerByte,
249 ActionCosts::transfer => Self::ActionTransfer,
250 ActionCosts::pledge => Self::ActionPledge,
251 ActionCosts::add_full_access_key => Self::ActionAddFullAccessKey,
252 ActionCosts::add_function_call_key_base => Self::ActionAddFunctionCallKey,
253 ActionCosts::add_function_call_key_byte => Self::ActionAddFunctionCallKeyPerByte,
254 ActionCosts::delete_key => Self::ActionDeleteKey,
255 ActionCosts::new_action_receipt => Self::ActionReceiptCreation,
256 ActionCosts::new_data_receipt_base => Self::DataReceiptCreationBase,
257 ActionCosts::new_data_receipt_byte => Self::DataReceiptCreationPerByte,
258 ActionCosts::register_rsa2048_keys => Self::ActionRegisterRSA2048Keys,
259 ActionCosts::create_rsa2048_challenge => Self::ActionCreateRSA2048Challenge,
260 }
261 }
262}