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 ActionDeployGlobalContract,
235 ActionDeployGlobalContractPerByte,
236 GlobalContractStorageAmountPerByte,
237
238 ActionUseGlobalContract,
239 ActionUseGlobalContractPerIdentifierByte,
240}
241
242#[derive(
243 Clone,
244 Copy,
245 PartialEq,
246 Eq,
247 PartialOrd,
248 Ord,
249 Debug,
250 strum::Display,
251 strum::EnumString,
252 strum::IntoStaticStr,
253)]
254#[strum(serialize_all = "snake_case")]
255pub enum FeeParameter {
256 ActionReceiptCreation,
257 DataReceiptCreationBase,
258 DataReceiptCreationPerByte,
259 ActionCreateAccount,
260 ActionDeleteAccount,
261 ActionDeployContract,
262 ActionDeployContractPerByte,
263 ActionFunctionCall,
264 ActionFunctionCallPerByte,
265 ActionTransfer,
266 ActionStake,
267 ActionAddFullAccessKey,
268 ActionAddFunctionCallKey,
269 ActionAddFunctionCallKeyPerByte,
270 ActionDeleteKey,
271 ActionDelegate,
272 ActionDeployGlobalContract,
273 ActionDeployGlobalContractPerByte,
274 ActionUseGlobalContract,
275 ActionUseGlobalContractPerIdentifierByte,
276}
277
278impl Parameter {
279 pub fn vm_limits() -> slice::Iter<'static, Parameter> {
282 [
283 Parameter::MaxGasBurnt,
284 Parameter::MaxStackHeight,
285 Parameter::ContractPrepareVersion,
286 Parameter::InitialMemoryPages,
287 Parameter::MaxMemoryPages,
288 Parameter::RegistersMemoryLimit,
289 Parameter::MaxRegisterSize,
290 Parameter::MaxNumberRegisters,
291 Parameter::MaxNumberLogs,
292 Parameter::MaxTotalLogLength,
293 Parameter::MaxTotalPrepaidGas,
294 Parameter::MaxActionsPerReceipt,
295 Parameter::MaxNumberBytesMethodNames,
296 Parameter::MaxLengthMethodName,
297 Parameter::MaxArgumentsLength,
298 Parameter::MaxLengthReturnedData,
299 Parameter::MaxContractSize,
300 Parameter::MaxTransactionSize,
301 Parameter::MaxReceiptSize,
302 Parameter::MaxLengthStorageKey,
303 Parameter::MaxLengthStorageValue,
304 Parameter::MaxPromisesPerFunctionCallAction,
305 Parameter::MaxNumberInputDataDependencies,
306 Parameter::MaxFunctionsNumberPerContract,
307 Parameter::Wasmer2StackLimit,
308 Parameter::MaxLocalsPerContract,
309 Parameter::AccountIdValidityRulesVersion,
310 Parameter::YieldTimeoutLengthInBlocks,
311 Parameter::MaxYieldPayloadSize,
312 Parameter::PerReceiptStorageProofSizeLimit,
313 ]
314 .iter()
315 }
316}
317
318impl From<ActionCosts> for FeeParameter {
321 fn from(other: ActionCosts) -> Self {
322 match other {
323 ActionCosts::create_account => Self::ActionCreateAccount,
324 ActionCosts::delete_account => Self::ActionDeleteAccount,
325 ActionCosts::delegate => Self::ActionDelegate,
326 ActionCosts::deploy_contract_base => Self::ActionDeployContract,
327 ActionCosts::deploy_contract_byte => Self::ActionDeployContractPerByte,
328 ActionCosts::function_call_base => Self::ActionFunctionCall,
329 ActionCosts::function_call_byte => Self::ActionFunctionCallPerByte,
330 ActionCosts::transfer => Self::ActionTransfer,
331 ActionCosts::stake => Self::ActionStake,
332 ActionCosts::add_full_access_key => Self::ActionAddFullAccessKey,
333 ActionCosts::add_function_call_key_base => Self::ActionAddFunctionCallKey,
334 ActionCosts::add_function_call_key_byte => Self::ActionAddFunctionCallKeyPerByte,
335 ActionCosts::delete_key => Self::ActionDeleteKey,
336 ActionCosts::new_action_receipt => Self::ActionReceiptCreation,
337 ActionCosts::new_data_receipt_base => Self::DataReceiptCreationBase,
338 ActionCosts::new_data_receipt_byte => Self::DataReceiptCreationPerByte,
339 ActionCosts::deploy_global_contract_base => Self::ActionDeployGlobalContract,
340 ActionCosts::deploy_global_contract_byte => Self::ActionDeployGlobalContractPerByte,
341 ActionCosts::use_global_contract_base => Self::ActionUseGlobalContract,
342 ActionCosts::use_global_contract_byte => Self::ActionUseGlobalContractPerIdentifierByte,
343 }
344 }
345}