1
// Copyright 2019-2025 PureStake Inc.
2
// This file is part of Moonbeam.
3

            
4
// Moonbeam is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Moonbeam is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Moonbeam.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
#[macro_export]
18
macro_rules! impl_runtime_apis_plus_common {
19
	{$($custom:tt)*} => {
20

            
21
		#[cfg(feature = "evm-tracing")]
22
		// Helper function to replay the "on_idle" hook for all pallets, we need this for
23
		// evm-tracing because some ethereum-xcm transactions might be executed at on_idle.
24
		//
25
		// We need to make sure that we replay on_idle exactly the same way as the
26
		// original block execution, but unfortunatly frame executive diosn't provide a function
27
		// to replay only on_idle, so we need to copy here some code inside frame executive.
28
20
		fn replay_on_idle() {
29
			use frame_system::pallet_prelude::BlockNumberFor;
30
			use frame_support::traits::OnIdle;
31

            
32
20
			let weight = <frame_system::Pallet<Runtime>>::block_weight();
33
20
			let max_weight = <
34
20
					<Runtime as frame_system::Config>::BlockWeights as
35
20
					frame_support::traits::Get<_>
36
20
				>::get().max_block;
37
20
			let remaining_weight = max_weight.saturating_sub(weight.total());
38
20
			if remaining_weight.all_gt(Weight::zero()) {
39
20
				let _ = <AllPalletsWithSystem as OnIdle<BlockNumberFor<Runtime>>>::on_idle(
40
20
					<frame_system::Pallet<Runtime>>::block_number(),
41
20
					remaining_weight,
42
20
				);
43
20
			}
44
20
		}
45
20

            
46
397856
		impl_runtime_apis! {
47
397856
			$($custom)*
48
397856

            
49
397856
			impl sp_api::Core<Block> for Runtime {
50
397856
				fn version() -> RuntimeVersion {
51
					VERSION
52
				}
53
397856

            
54
397856
				fn execute_block(block: Block) {
55
					Executive::execute_block(block)
56
				}
57
397856

            
58
397856
				fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
59
					Executive::initialize_block(header)
60
				}
61
397856
			}
62
397856

            
63
397856
			impl sp_api::Metadata<Block> for Runtime {
64
397856
				fn metadata() -> OpaqueMetadata {
65
					OpaqueMetadata::new(Runtime::metadata().into())
66
				}
67
397856

            
68
397856
				fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
69
					Runtime::metadata_at_version(version)
70
				}
71
397856

            
72
397856
				fn metadata_versions() -> Vec<u32> {
73
					Runtime::metadata_versions()
74
				}
75
397856
			}
76
397856

            
77
397856
			impl sp_block_builder::BlockBuilder<Block> for Runtime {
78
397856
				fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
79
					Executive::apply_extrinsic(extrinsic)
80
				}
81
397856

            
82
397856
				fn finalize_block() -> <Block as BlockT>::Header {
83
					Executive::finalize_block()
84
				}
85
397856

            
86
397856
				fn inherent_extrinsics(
87
					data: sp_inherents::InherentData,
88
				) -> Vec<<Block as BlockT>::Extrinsic> {
89
					data.create_extrinsics()
90
				}
91
397856

            
92
397856
				fn check_inherents(
93
					block: Block,
94
					data: sp_inherents::InherentData,
95
				) -> sp_inherents::CheckInherentsResult {
96
					data.check_extrinsics(&block)
97
				}
98
397856
			}
99
397856

            
100
397856
			impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
101
397856
				fn offchain_worker(header: &<Block as BlockT>::Header) {
102
					Executive::offchain_worker(header)
103
				}
104
397856
			}
105
397856

            
106
397856
			impl sp_session::SessionKeys<Block> for Runtime {
107
397856
				fn decode_session_keys(
108
					encoded: Vec<u8>,
109
				) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
110
					opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
111
				}
112
397856

            
113
397856
				fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
114
					opaque::SessionKeys::generate(seed)
115
				}
116
397856
			}
117
397856

            
118
397856
			#[cfg(not(feature = "disable-genesis-builder"))]
119
397856
			impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
120
397856
				fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
121
					frame_support::genesis_builder_helper::build_state::<RuntimeGenesisConfig>(config)
122
				}
123
397856

            
124
397856
				fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
125
					frame_support::genesis_builder_helper::get_preset::<RuntimeGenesisConfig>(id, genesis_config_preset::get_preset)
126
				}
127
397856

            
128
397856
				fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
129
					genesis_config_preset::preset_names()
130
				}
131
397856
			}
132
397856

            
133
397856
			impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
134
397856
				fn account_nonce(account: AccountId) -> Index {
135
					System::account_nonce(account)
136
				}
137
397856
			}
138
397856

            
139
397856
			impl moonbeam_rpc_primitives_debug::DebugRuntimeApi<Block> for Runtime {
140
397856
				fn trace_transaction(
141
20
					extrinsics: Vec<<Block as BlockT>::Extrinsic>,
142
20
					traced_transaction: &EthereumTransaction,
143
20
					header: &<Block as BlockT>::Header,
144
20
				) -> Result<
145
20
					(),
146
20
					sp_runtime::DispatchError,
147
20
				> {
148
20
					#[cfg(feature = "evm-tracing")]
149
20
					{
150
20
						use moonbeam_evm_tracer::tracer::EvmTracer;
151
20
						use xcm_primitives::{
152
20
							ETHEREUM_XCM_TRACING_STORAGE_KEY,
153
20
							EthereumXcmTracingStatus
154
20
						};
155
20
						use frame_support::storage::unhashed;
156
20
						use frame_system::pallet_prelude::BlockNumberFor;
157
20

            
158
20
						// Tell the CallDispatcher we are tracing a specific Transaction.
159
20
						unhashed::put::<EthereumXcmTracingStatus>(
160
20
							ETHEREUM_XCM_TRACING_STORAGE_KEY,
161
20
							&EthereumXcmTracingStatus::Transaction(traced_transaction.hash()),
162
20
						);
163
20

            
164
20
						// Initialize block: calls the "on_initialize" hook on every pallet
165
20
						// in AllPalletsWithSystem.
166
20
						// After pallet message queue was introduced, this must be done only after
167
20
						// enabling XCM tracing by setting ETHEREUM_XCM_TRACING_STORAGE_KEY
168
20
						// in the storage
169
20
						Executive::initialize_block(header);
170
20

            
171
20
						// Apply the a subset of extrinsics: all the substrate-specific or ethereum
172
20
						// transactions that preceded the requested transaction.
173
40
						for ext in extrinsics.into_iter() {
174
20
							let _ = match &ext.0.function {
175
20
								RuntimeCall::Ethereum(transact { transaction }) => {
176
20

            
177
20
									// Reset the previously consumed weight when tracing ethereum transactions.
178
20
									// This is necessary because EVM tracing introduces additional
179
20
									// (ref_time) overhead, which differs from the production runtime behavior.
180
20
									// Without resetting the block weight, the extra tracing overhead could
181
20
									// leading to some transactions to incorrectly fail during tracing.
182
20
									frame_system::BlockWeight::<Runtime>::kill();
183
20

            
184
20
									if transaction == traced_transaction {
185
20
										EvmTracer::new().trace(|| Executive::apply_extrinsic(ext));
186
20
										return Ok(());
187
20
									} else {
188
20
										Executive::apply_extrinsic(ext)
189
20
									}
190
20
								}
191
20
								_ => Executive::apply_extrinsic(ext),
192
20
							};
193
20
							if let Some(EthereumXcmTracingStatus::TransactionExited) = unhashed::get(
194
20
								ETHEREUM_XCM_TRACING_STORAGE_KEY
195
20
							) {
196
20
								return Ok(());
197
20
							}
198
20
						}
199
20

            
200
20
						if let Some(EthereumXcmTracingStatus::Transaction(_)) = unhashed::get(
201
20
							ETHEREUM_XCM_TRACING_STORAGE_KEY
202
20
						) {
203
							// If the transaction was not found, it might be
204
							// an eth-xcm transaction that was executed at on_idle
205
							replay_on_idle();
206
20
						}
207
20

            
208
20
						if let Some(EthereumXcmTracingStatus::TransactionExited) = unhashed::get(
209
20
							ETHEREUM_XCM_TRACING_STORAGE_KEY
210
20
						) {
211
20
							// The transaction was found
212
20
							Ok(())
213
20
						} else {
214
20
							// The transaction was not-found
215
20
							Err(sp_runtime::DispatchError::Other(
216
								"Failed to find Ethereum transaction among the extrinsics.",
217
							))
218
20
						}
219
20
					}
220
20
					#[cfg(not(feature = "evm-tracing"))]
221
20
					Err(sp_runtime::DispatchError::Other(
222
20
						"Missing `evm-tracing` compile time feature flag.",
223
20
					))
224
20
				}
225
397856

            
226
397856
				fn trace_block(
227
20
					extrinsics: Vec<<Block as BlockT>::Extrinsic>,
228
20
					known_transactions: Vec<H256>,
229
20
					header: &<Block as BlockT>::Header,
230
20
				) -> Result<
231
20
					(),
232
20
					sp_runtime::DispatchError,
233
20
				> {
234
20
					#[cfg(feature = "evm-tracing")]
235
20
					{
236
20
						use moonbeam_evm_tracer::tracer::EvmTracer;
237
20
						use frame_system::pallet_prelude::BlockNumberFor;
238
20
						use xcm_primitives::EthereumXcmTracingStatus;
239
20

            
240
20
						// Tell the CallDispatcher we are tracing a full Block.
241
20
						frame_support::storage::unhashed::put::<EthereumXcmTracingStatus>(
242
20
							xcm_primitives::ETHEREUM_XCM_TRACING_STORAGE_KEY,
243
20
							&EthereumXcmTracingStatus::Block,
244
20
						);
245
20

            
246
20
						let mut config = <Runtime as pallet_evm::Config>::config().clone();
247
20
						config.estimate = true;
248
20

            
249
20
						// Initialize block: calls the "on_initialize" hook on every pallet
250
20
						// in AllPalletsWithSystem.
251
20
						// After pallet message queue was introduced, this must be done only after
252
20
						// enabling XCM tracing by setting ETHEREUM_XCM_TRACING_STORAGE_KEY
253
20
						// in the storage
254
20
						Executive::initialize_block(header);
255
20

            
256
20
						// Apply all extrinsics. Ethereum extrinsics are traced.
257
80
						for ext in extrinsics.into_iter() {
258
40
							match &ext.0.function {
259
40
								RuntimeCall::Ethereum(transact { transaction }) => {
260
40

            
261
40
									// Reset the previously consumed weight when tracing multiple transactions.
262
40
									// This is necessary because EVM tracing introduces additional
263
40
									// (ref_time) overhead, which differs from the production runtime behavior.
264
40
									// Without resetting the block weight, the extra tracing overhead could
265
40
									// leading to some transactions to incorrectly fail during tracing.
266
40
									frame_system::BlockWeight::<Runtime>::kill();
267
40

            
268
40
									let tx_hash = &transaction.hash();
269
40
									if known_transactions.contains(&tx_hash) {
270
40
										// Each known extrinsic is a new call stack.
271
40
										EvmTracer::emit_new();
272
40
										EvmTracer::new().trace(|| {
273
40
											if let Err(err) = Executive::apply_extrinsic(ext) {
274
40
												log::debug!(
275
20
													target: "tracing",
276
													"Could not trace eth transaction (hash: {}): {:?}",
277
													&tx_hash,
278
20
													err
279
20
												);
280
20
											}
281
40
										});
282
40
									} else {
283
20
										if let Err(err) = Executive::apply_extrinsic(ext) {
284
20
											log::debug!(
285
20
												target: "tracing",
286
												"Failed to apply eth extrinsic (hash: {}): {:?}",
287
												&tx_hash,
288
20
												err
289
20
											);
290
20
										}
291
20
									}
292
20
								}
293
20
								_ => {
294
40
									if let Err(err) = Executive::apply_extrinsic(ext) {
295
20
										log::debug!(
296
20
											target: "tracing",
297
											"Failed to apply non-eth extrinsic: {:?}",
298
20
											err
299
20
										);
300
20
									}
301
20
								}
302
20
							};
303
20
						}
304
20

            
305
20
						// Replay on_idle
306
20
						// Some XCM messages with eth-xcm transaction might be executed at on_idle
307
20
						replay_on_idle();
308
20

            
309
20
						Ok(())
310
20
					}
311
20
					#[cfg(not(feature = "evm-tracing"))]
312
20
					Err(sp_runtime::DispatchError::Other(
313
20
						"Missing `evm-tracing` compile time feature flag.",
314
20
					))
315
20
				}
316
397856

            
317
397856
				fn trace_call(
318
20
					header: &<Block as BlockT>::Header,
319
20
					from: H160,
320
20
					to: H160,
321
20
					data: Vec<u8>,
322
20
					value: U256,
323
20
					gas_limit: U256,
324
20
					max_fee_per_gas: Option<U256>,
325
20
					max_priority_fee_per_gas: Option<U256>,
326
20
					nonce: Option<U256>,
327
20
					access_list: Option<Vec<(H160, Vec<H256>)>>,
328
20
				) -> Result<(), sp_runtime::DispatchError> {
329
20
					#[cfg(feature = "evm-tracing")]
330
20
					{
331
20
						use moonbeam_evm_tracer::tracer::EvmTracer;
332
20

            
333
20
						// Initialize block: calls the "on_initialize" hook on every pallet
334
20
						// in AllPalletsWithSystem.
335
20
						Executive::initialize_block(header);
336
20

            
337
20
						EvmTracer::new().trace(|| {
338
20
							let is_transactional = false;
339
20
							let validate = true;
340
20

            
341
20
							let transaction_data = pallet_ethereum::TransactionData::new(
342
20
								pallet_ethereum::TransactionAction::Call(to),
343
20
								data.clone(),
344
20
								nonce.unwrap_or_default(),
345
20
								gas_limit,
346
20
								None,
347
20
								max_fee_per_gas.or(Some(U256::default())),
348
20
								max_priority_fee_per_gas.or(Some(U256::default())),
349
20
								value,
350
20
								Some(<Runtime as pallet_evm::Config>::ChainId::get()),
351
20
								access_list.clone().unwrap_or_default(),
352
20
							);
353
20

            
354
20
							let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();
355
20

            
356
20
							let (weight_limit, proof_size_base_cost) = pallet_ethereum::Pallet::<Runtime>::transaction_weight(&transaction_data);
357
20

            
358
20
							let _ = <Runtime as pallet_evm::Config>::Runner::call(
359
20
								from,
360
20
								to,
361
20
								data,
362
20
								value,
363
20
								gas_limit,
364
20
								max_fee_per_gas,
365
20
								max_priority_fee_per_gas,
366
20
								nonce,
367
20
								access_list.unwrap_or_default(),
368
20
								is_transactional,
369
20
								validate,
370
20
								weight_limit,
371
20
								proof_size_base_cost,
372
20
								<Runtime as pallet_evm::Config>::config(),
373
20
							);
374
20
						});
375
20
						Ok(())
376
20
					}
377
20
					#[cfg(not(feature = "evm-tracing"))]
378
20
					Err(sp_runtime::DispatchError::Other(
379
20
						"Missing `evm-tracing` compile time feature flag.",
380
20
					))
381
20
				}
382
397856
			}
383
397856

            
384
397856
			impl moonbeam_rpc_primitives_txpool::TxPoolRuntimeApi<Block> for Runtime {
385
397856
				fn extrinsic_filter(
386
20
					xts_ready: Vec<<Block as BlockT>::Extrinsic>,
387
20
					xts_future: Vec<<Block as BlockT>::Extrinsic>,
388
20
				) -> TxPoolResponse {
389
20
					TxPoolResponse {
390
20
						ready: xts_ready
391
20
							.into_iter()
392
397856
							.filter_map(|xt| match xt.0.function {
393
397856
								RuntimeCall::Ethereum(transact { transaction }) => Some(transaction),
394
397856
								_ => None,
395
397856
							})
396
20
							.collect(),
397
20
						future: xts_future
398
20
							.into_iter()
399
397856
							.filter_map(|xt| match xt.0.function {
400
397856
								RuntimeCall::Ethereum(transact { transaction }) => Some(transaction),
401
397856
								_ => None,
402
397856
							})
403
20
							.collect(),
404
20
					}
405
20
				}
406
397856
			}
407
397856

            
408
397856
			impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
409
397856
				fn chain_id() -> u64 {
410
20
					<Runtime as pallet_evm::Config>::ChainId::get()
411
20
				}
412
397856

            
413
397856
				fn account_basic(address: H160) -> EVMAccount {
414
20
					let (account, _) = EVM::account_basic(&address);
415
20
					account
416
20
				}
417
397856

            
418
397856
				fn gas_price() -> U256 {
419
20
					let (gas_price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();
420
20
					gas_price
421
20
				}
422
397856

            
423
397856
				fn account_code_at(address: H160) -> Vec<u8> {
424
20
					pallet_evm::AccountCodes::<Runtime>::get(address)
425
20
				}
426
397856

            
427
397856
				fn author() -> H160 {
428
20
					<pallet_evm::Pallet<Runtime>>::find_author()
429
20
				}
430
397856

            
431
397856
				fn storage_at(address: H160, index: U256) -> H256 {
432
20
					let tmp: [u8; 32] = index.to_big_endian();
433
20
					pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))
434
20
				}
435
397856

            
436
397856
				fn call(
437
20
					from: H160,
438
20
					to: H160,
439
20
					data: Vec<u8>,
440
20
					value: U256,
441
20
					gas_limit: U256,
442
20
					max_fee_per_gas: Option<U256>,
443
20
					max_priority_fee_per_gas: Option<U256>,
444
20
					nonce: Option<U256>,
445
20
					estimate: bool,
446
20
					access_list: Option<Vec<(H160, Vec<H256>)>>,
447
20
				) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
448
397856
					let config = if estimate {
449
397856
						let mut config = <Runtime as pallet_evm::Config>::config().clone();
450
						config.estimate = true;
451
						Some(config)
452
397856
					} else {
453
397856
						None
454
397856
					};
455
397856
					let is_transactional = false;
456
20
					let validate = true;
457
20

            
458
20
					let transaction_data = pallet_ethereum::TransactionData::new(
459
20
						pallet_ethereum::TransactionAction::Call(to),
460
20
						data.clone(),
461
20
						nonce.unwrap_or_default(),
462
20
						gas_limit,
463
20
						None,
464
20
						max_fee_per_gas.or(Some(U256::default())),
465
20
						max_priority_fee_per_gas.or(Some(U256::default())),
466
20
						value,
467
20
						Some(<Runtime as pallet_evm::Config>::ChainId::get()),
468
20
						access_list.clone().unwrap_or_default(),
469
20
					);
470
20

            
471
20
					let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();
472
20

            
473
20
					let (weight_limit, proof_size_base_cost) = pallet_ethereum::Pallet::<Runtime>::transaction_weight(&transaction_data);
474
20

            
475
20
					<Runtime as pallet_evm::Config>::Runner::call(
476
20
						from,
477
20
						to,
478
20
						data,
479
20
						value,
480
20
						gas_limit,
481
20
						max_fee_per_gas,
482
20
						max_priority_fee_per_gas,
483
20
						nonce,
484
20
						access_list.unwrap_or_default(),
485
20
						is_transactional,
486
20
						validate,
487
20
						weight_limit,
488
20
						proof_size_base_cost,
489
20
						config.as_ref().unwrap_or(<Runtime as pallet_evm::Config>::config()),
490
20
					).map_err(|err| err.error.into())
491
20
				}
492
397856

            
493
397856
				fn create(
494
20
					from: H160,
495
20
					data: Vec<u8>,
496
20
					value: U256,
497
20
					gas_limit: U256,
498
20
					max_fee_per_gas: Option<U256>,
499
20
					max_priority_fee_per_gas: Option<U256>,
500
20
					nonce: Option<U256>,
501
20
					estimate: bool,
502
20
					access_list: Option<Vec<(H160, Vec<H256>)>>,
503
20
				) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
504
397856
					let config = if estimate {
505
397856
						let mut config = <Runtime as pallet_evm::Config>::config().clone();
506
						config.estimate = true;
507
						Some(config)
508
397856
					} else {
509
397856
						None
510
397856
					};
511
397856
					let is_transactional = false;
512
20
					let validate = true;
513
20

            
514
20
					let transaction_data = pallet_ethereum::TransactionData::new(
515
20
						pallet_ethereum::TransactionAction::Create,
516
20
						data.clone(),
517
20
						nonce.unwrap_or_default(),
518
20
						gas_limit,
519
20
						None,
520
20
						max_fee_per_gas.or(Some(U256::default())),
521
20
						max_priority_fee_per_gas.or(Some(U256::default())),
522
20
						value,
523
20
						Some(<Runtime as pallet_evm::Config>::ChainId::get()),
524
20
						access_list.clone().unwrap_or_default(),
525
20
					);
526
20

            
527
20
					let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();
528
20

            
529
20
					let (weight_limit, proof_size_base_cost) = pallet_ethereum::Pallet::<Runtime>::transaction_weight(&transaction_data);
530
20

            
531
20
					#[allow(clippy::or_fun_call)] // suggestion not helpful here
532
20
					<Runtime as pallet_evm::Config>::Runner::create(
533
20
						from,
534
20
						data,
535
20
						value,
536
20
						gas_limit,
537
20
						max_fee_per_gas,
538
20
						max_priority_fee_per_gas,
539
20
						nonce,
540
20
						access_list.unwrap_or_default(),
541
20
						is_transactional,
542
20
						validate,
543
20
						weight_limit,
544
20
						proof_size_base_cost,
545
20
						config.as_ref().unwrap_or(<Runtime as pallet_evm::Config>::config()),
546
20
					).map_err(|err| err.error.into())
547
20
				}
548
397856

            
549
397856
				fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
550
20
					pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()
551
20
				}
552
397856

            
553
397856
				fn current_block() -> Option<pallet_ethereum::Block> {
554
20
					pallet_ethereum::CurrentBlock::<Runtime>::get()
555
20
				}
556
397856

            
557
397856
				fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
558
20
					pallet_ethereum::CurrentReceipts::<Runtime>::get()
559
20
				}
560
397856

            
561
397856
				fn current_all() -> (
562
					Option<pallet_ethereum::Block>,
563
					Option<Vec<pallet_ethereum::Receipt>>,
564
					Option<Vec<TransactionStatus>>,
565
				) {
566
					(
567
						pallet_ethereum::CurrentBlock::<Runtime>::get(),
568
						pallet_ethereum::CurrentReceipts::<Runtime>::get(),
569
						pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get(),
570
					)
571
				}
572
397856

            
573
397856
				fn extrinsic_filter(
574
					xts: Vec<<Block as BlockT>::Extrinsic>,
575
				) -> Vec<EthereumTransaction> {
576
397856
					xts.into_iter().filter_map(|xt| match xt.0.function {
577
397856
						RuntimeCall::Ethereum(transact { transaction }) => Some(transaction),
578
397856
						_ => None
579
397856
					}).collect::<Vec<EthereumTransaction>>()
580
				}
581
397856

            
582
397856
				fn elasticity() -> Option<Permill> {
583
					None
584
				}
585
397856

            
586
397856
				fn gas_limit_multiplier_support() {}
587
397856

            
588
397856
				fn pending_block(
589
					xts: Vec<<Block as sp_runtime::traits::Block>::Extrinsic>
590
				) -> (
591
					Option<pallet_ethereum::Block>, Option<sp_std::prelude::Vec<TransactionStatus>>
592
				) {
593
397856
					for ext in xts.into_iter() {
594
						let _ = Executive::apply_extrinsic(ext);
595
					}
596
397856

            
597
397856
					Ethereum::on_finalize(System::block_number() + 1);
598

            
599
					(
600
						pallet_ethereum::CurrentBlock::<Runtime>::get(),
601
						pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()
602
					)
603
				 }
604
397856

            
605
397856
				fn initialize_pending_block(header: &<Block as BlockT>::Header) {
606
					pallet_randomness::vrf::using_fake_vrf(|| {
607
						let _ = Executive::initialize_block(header);
608
					})
609
				}
610
397856
			}
611
397856

            
612
397856
			impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {
613
397856
				fn convert_transaction(
614
					transaction: pallet_ethereum::Transaction
615
				) -> <Block as BlockT>::Extrinsic {
616
					UncheckedExtrinsic::new_bare(
617
						pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
618
					)
619
				}
620
397856
			}
621
397856

            
622
397856
			impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
623
397856
			for Runtime {
624
397856
				fn query_info(
625
					uxt: <Block as BlockT>::Extrinsic,
626
					len: u32,
627
				) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
628
					TransactionPayment::query_info(uxt, len)
629
				}
630
397856

            
631
397856
				fn query_fee_details(
632
					uxt: <Block as BlockT>::Extrinsic,
633
					len: u32,
634
				) -> pallet_transaction_payment::FeeDetails<Balance> {
635
					TransactionPayment::query_fee_details(uxt, len)
636
				}
637
397856

            
638
397856
				fn query_weight_to_fee(weight: Weight) -> Balance {
639
					TransactionPayment::weight_to_fee(weight)
640
				}
641
397856

            
642
397856
				fn query_length_to_fee(length: u32) -> Balance {
643
					TransactionPayment::length_to_fee(length)
644
				}
645
397856
			}
646
397856

            
647
397856
			impl nimbus_primitives::NimbusApi<Block> for Runtime {
648
397896
				fn can_author(
649
60
					author: nimbus_primitives::NimbusId,
650
60
					slot: u32,
651
60
					parent_header: &<Block as BlockT>::Header
652
60
				) -> bool {
653
397856
					use pallet_parachain_staking::Config as PalletParachainStakingConfig;
654
397856

            
655
397896
					let block_number = parent_header.number + 1;
656
397856

            
657
397856
					// The Moonbeam runtimes use an entropy source that needs to do some accounting
658
397856
					// work during block initialization. Therefore we initialize it here to match
659
397856
					// the state it will be in when the next block is being executed.
660
397856
					use frame_support::traits::OnInitialize;
661
397896
					System::initialize(
662
60
						&block_number,
663
60
						&parent_header.hash(),
664
60
						&parent_header.digest,
665
60
					);
666
60

            
667
60
					// Because the staking solution calculates the next staking set at the beginning
668
60
					// of the first block in the new round, the only way to accurately predict the
669
60
					// authors is to compute the selection during prediction.
670
60
					if pallet_parachain_staking::Pallet::<Self>::round()
671
60
						.should_update(block_number) {
672
397856
						// get author account id
673
397856
						use nimbus_primitives::AccountLookup;
674
397856
						let author_account_id = if let Some(account) =
675
397856
							pallet_author_mapping::Pallet::<Self>::lookup_account(&author) {
676
397856
							account
677
397856
						} else {
678
397856
							// return false if author mapping not registered like in can_author impl
679
397856
							return false
680
397856
						};
681
397856
						let candidates = pallet_parachain_staking::Pallet::<Self>::compute_top_candidates();
682
						if candidates.is_empty() {
683
397856
							// If there are zero selected candidates, we use the same eligibility
684
397856
							// as the previous round
685
397856
							return AuthorInherent::can_author(&author, &slot);
686
397856
						}
687

            
688
						// predict eligibility post-selection by computing selection results now
689
						let (eligible, _) =
690
							pallet_author_slot_filter::compute_pseudo_random_subset::<Self>(
691
								candidates,
692
								&slot
693
							);
694
						eligible.contains(&author_account_id)
695
397856
					} else {
696
397896
						AuthorInherent::can_author(&author, &slot)
697
397856
					}
698
397856
				}
699
397856
			}
700
397856

            
701
397856
			impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
702
397856
				fn collect_collation_info(
703
					header: &<Block as BlockT>::Header
704
				) -> cumulus_primitives_core::CollationInfo {
705
					ParachainSystem::collect_collation_info(header)
706
				}
707
397856
			}
708
397856

            
709
397856
			impl session_keys_primitives::VrfApi<Block> for Runtime {
710
397856
				fn get_last_vrf_output() -> Option<<Block as BlockT>::Hash> {
711
					// TODO: remove in future runtime upgrade along with storage item
712
					if pallet_randomness::Pallet::<Self>::not_first_block().is_none() {
713
397856
						return None;
714
397856
					}
715
					pallet_randomness::Pallet::<Self>::local_vrf_output()
716
397856
				}
717
397856
				fn vrf_key_lookup(
718
					nimbus_id: nimbus_primitives::NimbusId
719
				) -> Option<session_keys_primitives::VrfId> {
720
397856
					use session_keys_primitives::KeysLookup;
721
397856
					AuthorMapping::lookup_keys(&nimbus_id)
722
				}
723
397856
			}
724
397856

            
725
397856
			impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
726
397856
				fn query_acceptable_payment_assets(
727
					xcm_version: xcm::Version
728
				) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
729
					XcmWeightTrader::query_acceptable_payment_assets(xcm_version)
730
				}
731
397856

            
732
397856
				fn query_weight_to_asset_fee(
733
					weight: Weight, asset: VersionedAssetId
734
				) -> Result<u128, XcmPaymentApiError> {
735
					XcmWeightTrader::query_weight_to_asset_fee(weight, asset)
736
				}
737
397856

            
738
397856
				fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
739
					PolkadotXcm::query_xcm_weight(message)
740
				}
741
397856

            
742
397856
				fn query_delivery_fees(
743
					destination: VersionedLocation, message: VersionedXcm<()>
744
				) -> Result<VersionedAssets, XcmPaymentApiError> {
745
					PolkadotXcm::query_delivery_fees(destination, message)
746
				}
747
397856
			}
748
397856

            
749
397856
			impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller>
750
397856
				for Runtime {
751
397856
					fn dry_run_call(
752
						origin: OriginCaller,
753
						call: RuntimeCall,
754
						result_xcms_version: XcmVersion
755
					) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
756
						PolkadotXcm::dry_run_call::<
757
							Runtime,
758
							xcm_config::XcmRouter,
759
							OriginCaller,
760
							RuntimeCall>(origin, call, result_xcms_version)
761
					}
762
397856

            
763
397856
					fn dry_run_xcm(
764
						origin_location: VersionedLocation,
765
						xcm: VersionedXcm<RuntimeCall>
766
					) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
767
						PolkadotXcm::dry_run_xcm::<
768
							Runtime,
769
							xcm_config::XcmRouter,
770
							RuntimeCall,
771
							xcm_config::XcmExecutorConfig>(origin_location, xcm)
772
					}
773
397856
				}
774
397856

            
775
397856
			impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
776
397856
				fn convert_location(location: VersionedLocation) -> Result<
777
					AccountId,
778
					xcm_runtime_apis::conversions::Error
779
				> {
780
					xcm_runtime_apis::conversions::LocationToAccountHelper::<
781
						AccountId,
782
						xcm_config::LocationToAccountId,
783
					>::convert_location(location)
784
				}
785
397856
			}
786
397856

            
787
397856
			#[cfg(feature = "runtime-benchmarks")]
788
397856
			impl frame_benchmarking::Benchmark<Block> for Runtime {
789
397856

            
790
397856
				fn benchmark_metadata(extra: bool) -> (
791
397856
					Vec<frame_benchmarking::BenchmarkList>,
792
397856
					Vec<frame_support::traits::StorageInfo>,
793
397856
				) {
794
397856
					use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
795
397856
					use frame_system_benchmarking::Pallet as SystemBench;
796
397856
					use frame_support::traits::StorageInfoTrait;
797
397856

            
798
397856
					use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
799
397856
					use pallet_transaction_payment::benchmarking::Pallet as PalletTransactionPaymentBenchmark;
800
397856

            
801
397856
					let mut list = Vec::<BenchmarkList>::new();
802
397856
					list_benchmarks!(list, extra);
803
397856

            
804
397856
					let storage_info = AllPalletsWithSystem::storage_info();
805
397856

            
806
397856
					return (list, storage_info)
807
397856
				}
808
397856

            
809
397856
				fn dispatch_benchmark(
810
397856
					config: frame_benchmarking::BenchmarkConfig,
811
397856
				) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
812
397856
					use frame_benchmarking::{add_benchmark, BenchmarkBatch, Benchmarking};
813
397856
					use frame_support::traits::TrackedStorageKey;
814
397856
					use cumulus_primitives_core::ParaId;
815
397856

            
816
397856
					use xcm::latest::prelude::{
817
397856
						GeneralIndex, Junction, Junctions, Location, Response, NetworkId, AssetId,
818
397856
						Assets as XcmAssets, Fungible, Asset, ParentThen, Parachain, Parent, WeightLimit
819
397856
					};
820
397856
					use xcm_config::SelfReserve;
821
397856
					use frame_benchmarking::BenchmarkError;
822
397856

            
823
397856
					use frame_system_benchmarking::Pallet as SystemBench;
824
397856
					// Needed to run `set_code` and `apply_authorized_upgrade` frame_system benchmarks
825
397856
					// https://github.com/paritytech/cumulus/pull/2766
826
397856
					impl frame_system_benchmarking::Config for Runtime {
827
397856
						fn setup_set_code_requirements(code: &Vec<u8>) -> Result<(), BenchmarkError> {
828
397856
							ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
829
397856
							Ok(())
830
397856
						}
831
397856

            
832
397856
						fn verify_set_code() {
833
397856
							System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
834
397856
						}
835
397856
					}
836
397856

            
837
397856
					use pallet_asset_manager::Config as PalletAssetManagerConfig;
838
397856

            
839
397856
					use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
840
397856
					parameter_types! {
841
397856
						pub const RandomParaId: ParaId = ParaId::new(43211234);
842
397856
					}
843
397856

            
844
397856
					pub struct TestDeliveryHelper;
845
397856
					impl xcm_builder::EnsureDelivery for TestDeliveryHelper {
846
397856
						fn ensure_successful_delivery(
847
397856
							origin_ref: &Location,
848
397856
							_dest: &Location,
849
397856
							_fee_reason: xcm_executor::traits::FeeReason,
850
397856
						) -> (Option<xcm_executor::FeesMode>, Option<XcmAssets>) {
851
397856
							use xcm_executor::traits::ConvertLocation;
852
397856
							let account = xcm_config::LocationToH160::convert_location(origin_ref)
853
397856
								.expect("Invalid location");
854
397856
							// Give the existential deposit at least
855
397856
							let balance = ExistentialDeposit::get();
856
397856
							let _ = <Balances as frame_support::traits::Currency<_>>::
857
397856
								make_free_balance_be(&account.into(), balance);
858
397856

            
859
397856
							(None, None)
860
397856
						}
861
397856
					}
862
397856

            
863
397856
					use pallet_transaction_payment::benchmarking::Pallet as PalletTransactionPaymentBenchmark;
864
397856
					impl pallet_transaction_payment::benchmarking::Config for Runtime {
865
397856
						fn setup_benchmark_environment() {
866
397856
							let alice = AccountId::from(sp_core::hex2array!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"));
867
397856
							pallet_author_inherent::Author::<Runtime>::put(&alice);
868
397856
						}
869
397856
					}
870
397856

            
871
397856
					impl pallet_xcm::benchmarking::Config for Runtime {
872
397856
				        type DeliveryHelper = TestDeliveryHelper;
873
397856

            
874
397856
						fn get_asset() -> Asset {
875
397856
							Asset {
876
397856
								id: AssetId(SelfReserve::get()),
877
397856
								fun: Fungible(ExistentialDeposit::get()),
878
397856
							}
879
397856
						}
880
397856

            
881
397856
						fn reachable_dest() -> Option<Location> {
882
397856
							Some(Parent.into())
883
397856
						}
884
397856

            
885
397856
						fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
886
397856
							None
887
397856
						}
888
397856

            
889
397856
						fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
890
397856
							use xcm_config::SelfReserve;
891
397856

            
892
397856
							ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
893
397856
								RandomParaId::get().into()
894
397856
							);
895
397856

            
896
397856
							Some((
897
397856
								Asset {
898
397856
									fun: Fungible(ExistentialDeposit::get()),
899
397856
									id: AssetId(SelfReserve::get().into())
900
397856
								},
901
397856
								// Moonbeam can reserve transfer native token to
902
397856
								// some random parachain.
903
397856
								ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
904
397856
							))
905
397856
						}
906
397856

            
907
397856
						fn set_up_complex_asset_transfer(
908
397856
						) -> Option<(XcmAssets, u32, Location, Box<dyn FnOnce()>)> {
909
397856
							use xcm_config::SelfReserve;
910
397856

            
911
397856
							let destination: xcm::v5::Location = Parent.into();
912
397856

            
913
397856
							let fee_amount: u128 = <Runtime as pallet_balances::Config>::ExistentialDeposit::get();
914
397856
							let fee_asset: Asset = (SelfReserve::get(), fee_amount).into();
915
397856

            
916
397856
							// Give some multiple of transferred amount
917
397856
							let balance = fee_amount * 1000;
918
397856
							let who = frame_benchmarking::whitelisted_caller();
919
397856
							let _ =
920
397856
								<Balances as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance);
921
397856

            
922
397856
							// verify initial balance
923
397856
							assert_eq!(Balances::free_balance(&who), balance);
924
397856

            
925
397856
							// set up local asset
926
397856
							let asset_amount: u128 = 10u128;
927
397856
							let initial_asset_amount: u128 = asset_amount * 10;
928
397856

            
929
397856
							let (asset_id, _, _) = pallet_assets::benchmarking::create_default_minted_asset::<
930
397856
								Runtime,
931
397856
								()
932
397856
							>(true, initial_asset_amount);
933
397856
							let transfer_asset: Asset = (SelfReserve::get(), asset_amount).into();
934
397856

            
935
397856
							let assets: XcmAssets = vec![fee_asset.clone(), transfer_asset].into();
936
397856
							let fee_index: u32 = 0;
937
397856

            
938
397856
							let verify: Box<dyn FnOnce()> = Box::new(move || {
939
397856
								// verify balance after transfer, decreased by
940
397856
								// transferred amount (and delivery fees)
941
397856
								assert!(Balances::free_balance(&who) <= balance - fee_amount);
942
397856
							});
943
397856

            
944
397856
							Some((assets, fee_index, destination, verify))
945
397856
						}
946
397856
					}
947
397856

            
948
397856
					impl pallet_xcm_benchmarks::Config for Runtime {
949
397856
						type XcmConfig = xcm_config::XcmExecutorConfig;
950
397856
						type AccountIdConverter = xcm_config::LocationToAccountId;
951
397856
						type DeliveryHelper = ();
952
397856
						fn valid_destination() -> Result<Location, BenchmarkError> {
953
397856
							Ok(Location::parent())
954
397856
						}
955
397856
						fn worst_case_holding(_depositable_count: u32) -> XcmAssets {
956
397856
						// 100 fungibles
957
397856
							const HOLDING_FUNGIBLES: u32 = 100;
958
397856
							let fungibles_amount: u128 = 100;
959
397856
							let assets = (0..HOLDING_FUNGIBLES).map(|i| {
960
397856
								let location: Location = GeneralIndex(i as u128).into();
961
397856
								Asset {
962
397856
									id: AssetId(location),
963
397856
									fun: Fungible(fungibles_amount * i as u128),
964
397856
								}
965
397856
								.into()
966
397856
							})
967
397856
							.chain(
968
397856
								core::iter::once(
969
397856
									Asset {
970
397856
										id: AssetId(Location::parent()),
971
397856
										fun: Fungible(u128::MAX)
972
397856
									}
973
397856
								)
974
397856
							)
975
397856
							.collect::<Vec<_>>();
976
397856

            
977
397856

            
978
397856
							for (i, asset) in assets.iter().enumerate() {
979
397856
								if let Asset {
980
397856
									id: AssetId(location),
981
397856
									fun: Fungible(_)
982
397856
								} = asset {
983
397856
									EvmForeignAssets::set_asset(
984
397856
										location.clone(),
985
397856
										i as u128
986
397856
									);
987
397856
									XcmWeightTrader::set_asset_price(
988
397856
										location.clone(),
989
397856
										1u128.pow(18)
990
397856
									);
991
397856
								}
992
397856
							}
993
397856
							assets.into()
994
397856
						}
995
397856
					}
996
397856

            
997
397856
					impl pallet_xcm_benchmarks::generic::Config for Runtime {
998
397856
						type RuntimeCall = RuntimeCall;
999
397856
						type TransactAsset = Balances;
397856

            
397856
						fn worst_case_response() -> (u64, Response) {
397856
							(0u64, Response::Version(Default::default()))
397856
						}
397856

            
397856
						fn worst_case_asset_exchange()
397856
							-> Result<(XcmAssets, XcmAssets), BenchmarkError> {
397856
							Err(BenchmarkError::Skip)
397856
						}
397856

            
397856
						fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
397856
							Err(BenchmarkError::Skip)
397856
						}
397856

            
397856
						fn export_message_origin_and_destination()
397856
							-> Result<(Location, NetworkId, Junctions), BenchmarkError> {
397856
							Err(BenchmarkError::Skip)
397856
						}
397856

            
397856
						fn transact_origin_and_runtime_call()
397856
							-> Result<(Location, RuntimeCall), BenchmarkError> {
397856
							Ok((Location::parent(), frame_system::Call::remark_with_event {
397856
								remark: vec![]
397856
							}.into()))
397856
						}
397856

            
397856
						fn subscribe_origin() -> Result<Location, BenchmarkError> {
397856
							Ok(Location::parent())
397856
						}
397856

            
397856
						fn claimable_asset()
397856
							-> Result<(Location, Location, XcmAssets), BenchmarkError> {
397856
							let origin = Location::parent();
397856
							let assets: XcmAssets = (AssetId(Location::parent()), 1_000u128)
397856
								.into();
397856
							let ticket = Location { parents: 0, interior: [].into() /* Here */ };
397856
							Ok((origin, ticket, assets))
397856
						}
397856

            
397856
						fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
397856
							Err(BenchmarkError::Skip)
397856
						}
397856

            
397856
						fn unlockable_asset()
397856
							-> Result<(Location, Location, Asset), BenchmarkError> {
397856
							Err(BenchmarkError::Skip)
397856
						}
397856

            
397856
						fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
397856
							Err(BenchmarkError::Skip)
397856
						}
397856
					}
397856

            
397856
					let whitelist: Vec<TrackedStorageKey> = vec![
397856
						// Block Number
397856
						hex_literal::hex!(  "26aa394eea5630e07c48ae0c9558cef7"
397856
											"02a5c1b19ab7a04f536c519aca4983ac")
397856
							.to_vec().into(),
397856
						// Total Issuance
397856
						hex_literal::hex!(  "c2261276cc9d1f8598ea4b6a74b15c2f"
397856
											"57c875e4cff74148e4628f264b974c80")
397856
							.to_vec().into(),
397856
						// Execution Phase
397856
						hex_literal::hex!(  "26aa394eea5630e07c48ae0c9558cef7"
397856
											"ff553b5a9862a516939d82b3d3d8661a")
397856
							.to_vec().into(),
397856
						// Event Count
397856
						hex_literal::hex!(  "26aa394eea5630e07c48ae0c9558cef7"
397856
											"0a98fdbe9ce6c55837576c60c7af3850")
397856
							.to_vec().into(),
397856
						// System Events
397856
						hex_literal::hex!(  "26aa394eea5630e07c48ae0c9558cef7"
397856
											"80d41e5e16056765bc8461851072c9d7")
397856
							.to_vec().into(),
397856
						// System BlockWeight
397856
						hex_literal::hex!(  "26aa394eea5630e07c48ae0c9558cef7"
397856
											"34abf5cb34d6244378cddbf18e849d96")
397856
							.to_vec().into(),
397856
						// ParachainStaking Round
397856
						hex_literal::hex!(  "a686a3043d0adcf2fa655e57bc595a78"
397856
											"13792e785168f725b60e2969c7fc2552")
397856
							.to_vec().into(),
397856
						// Treasury Account (py/trsry)
397856
						hex_literal::hex!(  "26aa394eea5630e07c48ae0c9558cef7"
397856
											"b99d880ec681799c0cf30e8886371da9"
397856
											"7be2919ac397ba499ea5e57132180ec6"
397856
											"6d6f646c70792f747273727900000000"
397856
											"00000000"
397856
						).to_vec().into(),
397856
						// Treasury Account (pc/trsry)
397856
						hex_literal::hex!(  "26aa394eea5630e07c48ae0c9558cef7"
397856
											"b99d880ec681799c0cf30e8886371da9"
397856
											"7be2919ac397ba499ea5e57132180ec6"
397856
											"6d6f646c70632f747273727900000000"
397856
											"00000000"
397856
						).to_vec().into(),
397856
						// ParachainInfo ParachainId
397856
						hex_literal::hex!(  "0d715f2646c8f85767b5d2764bb27826"
397856
											"04a74d81251e398fd8a0a4d55023bb3f")
397856
							.to_vec().into(),
397856
						// Parameters Parameters
397856
						hex_literal::hex!(  "c63bdd4a39095ccf55623a6f2872bf8a" // Pallet: "Parameters"
397856
											"c63bdd4a39095ccf55623a6f2872bf8a" // Storage Prefix: "Parameters"
397856
											// MoonbaseRuntimeRuntimeParamsRuntimeParametersKey(FeesTreasuryProportion)
397856
											"71d0aacb690b61280d0c97c6b6a666640000"
397856
										)
397856
							.to_vec().into(),
397856

            
397856
					];
397856

            
397856
					let mut batches = Vec::<BenchmarkBatch>::new();
397856
					let params = (&config, &whitelist);
397856

            
397856
					add_benchmarks!(params, batches);
397856

            
397856
					if batches.is_empty() {
397856
						return Err("Benchmark not found for this pallet.".into());
397856
					}
397856
					Ok(batches)
397856
				}
397856
			}
397856

            
397856
			#[cfg(feature = "try-runtime")]
397856
			impl frame_try_runtime::TryRuntime<Block> for Runtime {
397856
				fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
397856
					log::info!("try-runtime::on_runtime_upgrade()");
397856
					// NOTE: intentional expect: we don't want to propagate the error backwards,
397856
					// and want to have a backtrace here. If any of the pre/post migration checks
397856
					// fail, we shall stop right here and right now.
397856
					let weight = Executive::try_runtime_upgrade(checks)
397856
						.expect("runtime upgrade logic *must* be infallible");
397856
					(weight, RuntimeBlockWeights::get().max_block)
397856
				}
397856

            
397856
				fn execute_block(
397856
					block: Block,
397856
					state_root_check: bool,
397856
					signature_check: bool,
397856
					select: frame_try_runtime::TryStateSelect
397856
				) -> Weight {
397856
					log::info!(
397856
						"try-runtime: executing block {:?} / root checks: {:?} / try-state-select: {:?}",
397856
						block.header.hash(),
397856
						state_root_check,
397856
						select,
397856
					);
397856
					// NOTE: intentional unwrap: we don't want to propagate the error backwards,
397856
					// and want to have a backtrace here.
397856
					Executive::try_execute_block(
397856
						block,
397856
						state_root_check,
397856
						signature_check,
397856
						select,
397856
					).expect("execute-block failed")
397856
				}
397856
			}
397856
		}
	};
}