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 GasRefundPenalty,
24 MinGasRefundPenalty,
26
27 MainStorageProofSizeSoftLimit,
31 PerReceiptStorageProofSizeLimit,
33 NewTransactionsValidationStateSizeSoftLimit,
35 CombinedTransactionsSizeLimit,
39 OutgoingReceiptsUsualSizeLimit,
43 OutgoingReceiptsBigSizeLimit,
47
48 MinAllowedTopLevelAccountLength,
50 RegistrarAccountId,
51
52 StorageAmountPerByte,
54 StorageNumBytesAccount,
55 StorageNumExtraBytesRecord,
56
57 ActionReceiptCreation,
62 DataReceiptCreationBase,
63 DataReceiptCreationPerByte,
64 ActionCreateAccount,
65 ActionDeleteAccount,
66 ActionDeployContract,
67 ActionDeployContractPerByte,
68 ActionFunctionCall,
69 ActionFunctionCallPerByte,
70 ActionTransfer,
71 ActionStake,
72 ActionAddFullAccessKey,
73 ActionAddFunctionCallKey,
74 ActionAddFunctionCallKeyPerByte,
75 ActionDeleteKey,
76 ActionDelegate,
77 ActionDeterministicStateInit,
78 ActionDeterministicStateInitPerEntry,
79 ActionDeterministicStateInitPerByte,
80
81 WasmRegularOpCost,
83 WasmLinearOpBaseCost,
84 WasmLinearOpUnitCost,
85 WasmGrowMemCost,
86 WasmBase,
88 WasmContractLoadingBase,
89 WasmContractLoadingBytes,
90 WasmReadMemoryBase,
91 WasmReadMemoryByte,
92 WasmWriteMemoryBase,
93 WasmWriteMemoryByte,
94 WasmReadRegisterBase,
95 WasmReadRegisterByte,
96 WasmWriteRegisterBase,
97 WasmWriteRegisterByte,
98 WasmUtf8DecodingBase,
99 WasmUtf8DecodingByte,
100 WasmUtf16DecodingBase,
101 WasmUtf16DecodingByte,
102 WasmSha256Base,
103 WasmSha256Byte,
104 WasmKeccak256Base,
105 WasmKeccak256Byte,
106 WasmKeccak512Base,
107 WasmKeccak512Byte,
108 WasmRipemd160Base,
109 WasmRipemd160Block,
110 WasmEcrecoverBase,
111 WasmEd25519VerifyBase,
112 WasmEd25519VerifyByte,
113 WasmLogBase,
114 WasmLogByte,
115 WasmStorageWriteBase,
116 WasmStorageWriteKeyByte,
117 WasmStorageWriteValueByte,
118 WasmStorageWriteEvictedByte,
119 WasmStorageReadBase,
120 WasmStorageReadKeyByte,
121 WasmStorageReadValueByte,
122 WasmStorageLargeReadOverheadBase,
123 WasmStorageLargeReadOverheadByte,
124 WasmStorageRemoveBase,
125 WasmStorageRemoveKeyByte,
126 WasmStorageRemoveRetValueByte,
127 WasmStorageHasKeyBase,
128 WasmStorageHasKeyByte,
129 WasmStorageIterCreatePrefixBase,
130 WasmStorageIterCreatePrefixByte,
131 WasmStorageIterCreateRangeBase,
132 WasmStorageIterCreateFromByte,
133 WasmStorageIterCreateToByte,
134 WasmStorageIterNextBase,
135 WasmStorageIterNextKeyByte,
136 WasmStorageIterNextValueByte,
137 WasmTouchingTrieNode,
138 WasmReadCachedTrieNode,
139 WasmPromiseAndBase,
140 WasmPromiseAndPerPromise,
141 WasmPromiseReturn,
142 WasmValidatorStakeBase,
143 WasmValidatorTotalStakeBase,
144 WasmAltBn128G1MultiexpBase,
145 WasmAltBn128G1MultiexpElement,
146 WasmAltBn128PairingCheckBase,
147 WasmAltBn128PairingCheckElement,
148 WasmAltBn128G1SumBase,
149 WasmAltBn128G1SumElement,
150 WasmYieldCreateBase,
151 WasmYieldCreateByte,
152 WasmYieldResumeBase,
153 WasmYieldResumeByte,
154 WasmBls12381P1SumBase,
155 WasmBls12381P1SumElement,
156 WasmBls12381P2SumBase,
157 WasmBls12381P2SumElement,
158 WasmBls12381G1MultiexpBase,
159 WasmBls12381G1MultiexpElement,
160 WasmBls12381G2MultiexpBase,
161 WasmBls12381G2MultiexpElement,
162 WasmBls12381MapFpToG1Base,
163 WasmBls12381MapFpToG1Element,
164 WasmBls12381MapFp2ToG2Base,
165 WasmBls12381MapFp2ToG2Element,
166 WasmBls12381PairingBase,
167 WasmBls12381PairingElement,
168 WasmBls12381P1DecompressBase,
169 WasmBls12381P1DecompressElement,
170 WasmBls12381P2DecompressBase,
171 WasmBls12381P2DecompressElement,
172
173 MaxGasBurnt,
175 MaxGasBurntView,
176 MaxStackHeight,
177 InitialMemoryPages,
178 MaxMemoryPages,
179 RegistersMemoryLimit,
180 MaxRegisterSize,
181 MaxNumberRegisters,
182 MaxNumberLogs,
183 MaxTotalLogLength,
184 MaxTotalPrepaidGas,
185 MaxActionsPerReceipt,
186 MaxNumberBytesMethodNames,
187 MaxLengthMethodName,
188 MaxArgumentsLength,
189 MaxLengthReturnedData,
190 MaxContractSize,
191 MaxTransactionSize,
192 MaxReceiptSize,
193 MaxLengthStorageKey,
194 MaxLengthStorageValue,
195 MaxPromisesPerFunctionCallAction,
196 MaxNumberInputDataDependencies,
197 MaxFunctionsNumberPerContract,
198 MaxLocalsPerContract,
199 AccountIdValidityRulesVersion,
200 YieldTimeoutLengthInBlocks,
201 MaxYieldPayloadSize,
202 MaxTablesPerContract,
203 MaxElementsPerContractTable,
204
205 FlatStorageReads,
207 ImplicitAccountCreation,
208 FixContractLoadingCost,
209 VmKind,
210 EthImplicitAccounts,
211 DiscardCustomSections,
212 SaturatingFloatToInt,
213 ReftypesBulkMemory,
214
215 MaxCongestionIncomingGas,
217 MaxCongestionOutgoingGas,
218 MaxCongestionMemoryConsumption,
219 MaxCongestionMissedChunks,
220
221 MaxOutgoingGas,
222 MinOutgoingGas,
223 AllowedShardOutgoingGas,
224 MaxTxGas,
225 MinTxGas,
226 RejectTxCongestionThreshold,
227
228 UseStateStoredReceipt,
230
231 MaxShardBandwidth,
233 MaxSingleGrant,
234 MaxAllowance,
235 MaxBaseBandwidth,
236
237 ActionDeployGlobalContract,
239 ActionDeployGlobalContractPerByte,
240 GlobalContractStorageAmountPerByte,
241
242 ActionUseGlobalContract,
243 ActionUseGlobalContractPerIdentifierByte,
244 GlobalContractHostFns,
245
246 DeterministicAccountIds,
248}
249
250#[derive(
251 Clone,
252 Copy,
253 PartialEq,
254 Eq,
255 PartialOrd,
256 Ord,
257 Debug,
258 strum::Display,
259 strum::EnumString,
260 strum::IntoStaticStr,
261)]
262#[strum(serialize_all = "snake_case")]
263pub enum FeeParameter {
264 ActionReceiptCreation,
265 DataReceiptCreationBase,
266 DataReceiptCreationPerByte,
267 ActionCreateAccount,
268 ActionDeleteAccount,
269 ActionDeployContract,
270 ActionDeployContractPerByte,
271 ActionFunctionCall,
272 ActionFunctionCallPerByte,
273 ActionTransfer,
274 ActionStake,
275 ActionAddFullAccessKey,
276 ActionAddFunctionCallKey,
277 ActionAddFunctionCallKeyPerByte,
278 ActionDeleteKey,
279 ActionDelegate,
280 ActionDeployGlobalContract,
281 ActionDeployGlobalContractPerByte,
282 ActionUseGlobalContract,
283 ActionUseGlobalContractPerIdentifierByte,
284 ActionDeterministicStateInit,
285 ActionDeterministicStateInitPerByte,
286 ActionDeterministicStateInitPerEntry,
287}
288
289impl Parameter {
290 pub fn vm_limits() -> slice::Iter<'static, Parameter> {
293 [
294 Parameter::MaxGasBurnt,
295 Parameter::MaxStackHeight,
296 Parameter::InitialMemoryPages,
297 Parameter::MaxMemoryPages,
298 Parameter::RegistersMemoryLimit,
299 Parameter::MaxRegisterSize,
300 Parameter::MaxNumberRegisters,
301 Parameter::MaxNumberLogs,
302 Parameter::MaxTotalLogLength,
303 Parameter::MaxTotalPrepaidGas,
304 Parameter::MaxActionsPerReceipt,
305 Parameter::MaxNumberBytesMethodNames,
306 Parameter::MaxLengthMethodName,
307 Parameter::MaxArgumentsLength,
308 Parameter::MaxLengthReturnedData,
309 Parameter::MaxContractSize,
310 Parameter::MaxTransactionSize,
311 Parameter::MaxReceiptSize,
312 Parameter::MaxLengthStorageKey,
313 Parameter::MaxLengthStorageValue,
314 Parameter::MaxPromisesPerFunctionCallAction,
315 Parameter::MaxNumberInputDataDependencies,
316 Parameter::MaxFunctionsNumberPerContract,
317 Parameter::MaxLocalsPerContract,
318 Parameter::AccountIdValidityRulesVersion,
319 Parameter::YieldTimeoutLengthInBlocks,
320 Parameter::MaxYieldPayloadSize,
321 Parameter::PerReceiptStorageProofSizeLimit,
322 Parameter::MaxTablesPerContract,
323 Parameter::MaxElementsPerContractTable,
324 ]
325 .iter()
326 }
327}
328
329impl From<ActionCosts> for FeeParameter {
332 fn from(other: ActionCosts) -> Self {
333 match other {
334 ActionCosts::create_account => Self::ActionCreateAccount,
335 ActionCosts::delete_account => Self::ActionDeleteAccount,
336 ActionCosts::delegate => Self::ActionDelegate,
337 ActionCosts::deploy_contract_base => Self::ActionDeployContract,
338 ActionCosts::deploy_contract_byte => Self::ActionDeployContractPerByte,
339 ActionCosts::function_call_base => Self::ActionFunctionCall,
340 ActionCosts::function_call_byte => Self::ActionFunctionCallPerByte,
341 ActionCosts::transfer => Self::ActionTransfer,
342 ActionCosts::stake => Self::ActionStake,
343 ActionCosts::add_full_access_key => Self::ActionAddFullAccessKey,
344 ActionCosts::add_function_call_key_base => Self::ActionAddFunctionCallKey,
345 ActionCosts::add_function_call_key_byte => Self::ActionAddFunctionCallKeyPerByte,
346 ActionCosts::delete_key => Self::ActionDeleteKey,
347 ActionCosts::new_action_receipt => Self::ActionReceiptCreation,
348 ActionCosts::new_data_receipt_base => Self::DataReceiptCreationBase,
349 ActionCosts::new_data_receipt_byte => Self::DataReceiptCreationPerByte,
350 ActionCosts::deploy_global_contract_base => Self::ActionDeployGlobalContract,
351 ActionCosts::deploy_global_contract_byte => Self::ActionDeployGlobalContractPerByte,
352 ActionCosts::use_global_contract_base => Self::ActionUseGlobalContract,
353 ActionCosts::use_global_contract_byte => Self::ActionUseGlobalContractPerIdentifierByte,
354 ActionCosts::deterministic_state_init_base => Self::ActionDeterministicStateInit,
355 ActionCosts::deterministic_state_init_byte => Self::ActionDeterministicStateInitPerByte,
356 ActionCosts::deterministic_state_init_entry => {
357 Self::ActionDeterministicStateInitPerEntry
358 }
359 }
360 }
361}