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