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)*} {$($bench_custom:tt)*}) => {
20
    	use ethereum::AuthorizationList;
21

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

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

            
47
397349
		impl_runtime_apis! {
48
397349
			$($custom)*
49
397349

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

            
55
397349
				fn execute_block(block: Block) {
56
					Executive::execute_block(block)
57
				}
58
397349

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

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

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

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

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

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

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

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

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

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

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

            
119
397349
			impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
120
397349
				fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
121
					frame_support::genesis_builder_helper::build_state::<RuntimeGenesisConfig>(config)
122
				}
123
397349

            
124
397349
				#[cfg(not(feature = "disable-genesis-builder"))]
125
397349
				fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
126
					frame_support::genesis_builder_helper::get_preset::<RuntimeGenesisConfig>(id, genesis_config_preset::get_preset)
127
				}
128
397349
				#[cfg(feature = "disable-genesis-builder")]
129
397349
				fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
130
397349
					None
131
397349
				}
132
397349

            
133
397349
				#[cfg(not(feature = "disable-genesis-builder"))]
134
397349
				fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
135
					genesis_config_preset::preset_names()
136
				}
137
397349
				#[cfg(feature = "disable-genesis-builder")]
138
397349
				fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
139
397349
					Default::default()
140
397349
				}
141
397349
			}
142
397349

            
143
397349
			impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
144
397349
				fn account_nonce(account: AccountId) -> Index {
145
					System::account_nonce(account)
146
				}
147
397349
			}
148
397349

            
149
397349
			impl moonbeam_rpc_primitives_debug::DebugRuntimeApi<Block> for Runtime {
150
397349
				fn trace_transaction(
151
19
					extrinsics: Vec<<Block as BlockT>::Extrinsic>,
152
19
					traced_transaction: &EthereumTransaction,
153
19
					header: &<Block as BlockT>::Header,
154
19
				) -> Result<
155
19
					(),
156
19
					sp_runtime::DispatchError,
157
19
				> {
158
19
					#[cfg(feature = "evm-tracing")]
159
19
					{
160
19
						use moonbeam_evm_tracer::tracer::{
161
19
							EthereumTracingStatus,
162
19
							EvmTracer,
163
19
							EthereumTracer
164
19
						};
165
19
						use frame_support::storage::unhashed;
166
19
						use frame_system::pallet_prelude::BlockNumberFor;
167
19

            
168
19
						// Tell the CallDispatcher we are tracing a specific Transaction.
169
19
						EthereumTracer::transaction(traced_transaction.hash(), || {
170
19
							// Initialize block: calls the "on_initialize" hook on every pallet
171
19
							// in AllPalletsWithSystem.
172
19
							// After pallet message queue was introduced, this must be done only after
173
19
							// enabling XCM tracing by calling ETHEREUM_TRACING_STATUS::using
174
19
							// in the storage
175
19
							Executive::initialize_block(header);
176
19

            
177
19
							// Apply the a subset of extrinsics: all the substrate-specific or ethereum
178
19
							// transactions that preceded the requested transaction.
179
38
							for ext in extrinsics.into_iter() {
180
38
								let _ = match &ext.0.function {
181
19
									RuntimeCall::Ethereum(transact { transaction }) => {
182
19
										// Reset the previously consumed weight when tracing ethereum transactions.
183
19
										// This is necessary because EVM tracing introduces additional
184
19
										// (ref_time) overhead, which differs from the production runtime behavior.
185
19
										// Without resetting the block weight, the extra tracing overhead could
186
19
										// leading to some transactions to incorrectly fail during tracing.
187
19
										frame_system::BlockWeight::<Runtime>::kill();
188
19

            
189
19
										if transaction == traced_transaction {
190
19
											EvmTracer::new().trace(|| Executive::apply_extrinsic(ext));
191
19
											return Ok(());
192
19
										} else {
193
19
											Executive::apply_extrinsic(ext)
194
19
										}
195
19
									}
196
19
									_ => Executive::apply_extrinsic(ext),
197
19
								};
198
19

            
199
19
								if let Some(EthereumTracingStatus::TransactionExited) = EthereumTracer::status() {
200
19
									return Ok(());
201
19
								}
202
19
							}
203
19

            
204
19
							if let Some(EthereumTracingStatus::Transaction(_)) = EthereumTracer::status() {
205
								// If the transaction was not found, it might be
206
								// an eth-xcm transaction that was executed at on_idle
207
								replay_on_idle();
208
							}
209
19

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

            
227
397349
				fn trace_block(
228
19
					extrinsics: Vec<<Block as BlockT>::Extrinsic>,
229
19
					known_transactions: Vec<H256>,
230
19
					header: &<Block as BlockT>::Header,
231
19
				) -> Result<
232
19
					(),
233
19
					sp_runtime::DispatchError,
234
19
				> {
235
19
					#[cfg(feature = "evm-tracing")]
236
19
					{
237
19
						use moonbeam_evm_tracer::tracer::{
238
19
							EthereumTracingStatus,
239
19
							EvmTracer,
240
19
							EthereumTracer
241
19
						};
242
19
						use frame_system::pallet_prelude::BlockNumberFor;
243
19

            
244
19
						// Tell the CallDispatcher we are tracing a full Block.
245
19
						EthereumTracer::block(|| {
246
19
							let mut config = <Runtime as pallet_evm::Config>::config().clone();
247
19
							config.estimate = true;
248
19

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

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

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

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

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

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

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

            
335
19
						// Initialize block: calls the "on_initialize" hook on every pallet
336
19
						// in AllPalletsWithSystem.
337
19
						Executive::initialize_block(header);
338
19

            
339
19
						EvmTracer::new().trace(|| {
340
19
							let is_transactional = false;
341
19
							let validate = true;
342
19

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

            
357
19
							let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();
358
19

            
359
19
							let (weight_limit, proof_size_base_cost) = pallet_ethereum::Pallet::<Runtime>::transaction_weight(&transaction_data);
360
19

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

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

            
412
397349
			impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
413
397349
				fn chain_id() -> u64 {
414
19
					<Runtime as pallet_evm::Config>::ChainId::get()
415
19
				}
416
397349

            
417
397349
				fn account_basic(address: H160) -> EVMAccount {
418
19
					let (account, _) = EVM::account_basic(&address);
419
19
					account
420
19
				}
421
397349

            
422
397349
				fn gas_price() -> U256 {
423
19
					let (gas_price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();
424
19
					gas_price
425
19
				}
426
397349

            
427
397349
				fn account_code_at(address: H160) -> Vec<u8> {
428
19
					pallet_evm::AccountCodes::<Runtime>::get(address)
429
19
				}
430
397349

            
431
397349
				fn author() -> H160 {
432
19
					<pallet_evm::Pallet<Runtime>>::find_author()
433
19
				}
434
397349

            
435
397349
				fn storage_at(address: H160, index: U256) -> H256 {
436
19
					let tmp: [u8; 32] = index.to_big_endian();
437
19
					pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))
438
19
				}
439
397349

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

            
463
19
					let transaction_data = pallet_ethereum::TransactionData::new(
464
19
						pallet_ethereum::TransactionAction::Call(to),
465
19
						data.clone(),
466
19
						nonce.unwrap_or_default(),
467
19
						gas_limit,
468
19
						None,
469
19
						max_fee_per_gas.or(Some(U256::default())),
470
19
						max_priority_fee_per_gas.or(Some(U256::default())),
471
19
						value,
472
19
						Some(<Runtime as pallet_evm::Config>::ChainId::get()),
473
19
						access_list.clone().unwrap_or_default(),
474
19
						authorization_list.clone().unwrap_or_default(),
475
19
					);
476
19

            
477
19
					let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();
478
19

            
479
19
					let (weight_limit, proof_size_base_cost) = pallet_ethereum::Pallet::<Runtime>::transaction_weight(&transaction_data);
480
19

            
481
19
					<Runtime as pallet_evm::Config>::Runner::call(
482
19
						from,
483
19
						to,
484
19
						data,
485
19
						value,
486
19
						gas_limit,
487
19
						max_fee_per_gas,
488
19
						max_priority_fee_per_gas,
489
19
						nonce,
490
19
						access_list.unwrap_or_default(),
491
19
						authorization_list.unwrap_or_default(),
492
19
						is_transactional,
493
19
						validate,
494
19
						weight_limit,
495
19
						proof_size_base_cost,
496
19
						config.as_ref().unwrap_or(<Runtime as pallet_evm::Config>::config()),
497
19
					).map_err(|err| err.error.into())
498
19
				}
499
397349

            
500
397349
				fn create(
501
19
					from: H160,
502
19
					data: Vec<u8>,
503
19
					value: U256,
504
19
					gas_limit: U256,
505
19
					max_fee_per_gas: Option<U256>,
506
19
					max_priority_fee_per_gas: Option<U256>,
507
19
					nonce: Option<U256>,
508
19
					estimate: bool,
509
19
					access_list: Option<Vec<(H160, Vec<H256>)>>,
510
19
					authorization_list: Option<AuthorizationList>,
511
19
				) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
512
397349
					let config = if estimate {
513
397349
						let mut config = <Runtime as pallet_evm::Config>::config().clone();
514
						config.estimate = true;
515
						Some(config)
516
397349
					} else {
517
397349
						None
518
397349
					};
519
397349
					let is_transactional = false;
520
19
					let validate = true;
521
19

            
522
19
					let transaction_data = pallet_ethereum::TransactionData::new(
523
19
						pallet_ethereum::TransactionAction::Create,
524
19
						data.clone(),
525
19
						nonce.unwrap_or_default(),
526
19
						gas_limit,
527
19
						None,
528
19
						max_fee_per_gas.or(Some(U256::default())),
529
19
						max_priority_fee_per_gas.or(Some(U256::default())),
530
19
						value,
531
19
						Some(<Runtime as pallet_evm::Config>::ChainId::get()),
532
19
						access_list.clone().unwrap_or_default(),
533
19
						authorization_list.clone().unwrap_or_default(),
534
19
					);
535
19

            
536
19
					let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();
537
19

            
538
19
					let (weight_limit, proof_size_base_cost) = pallet_ethereum::Pallet::<Runtime>::transaction_weight(&transaction_data);
539
19

            
540
19
					#[allow(clippy::or_fun_call)] // suggestion not helpful here
541
19
					<Runtime as pallet_evm::Config>::Runner::create(
542
19
						from,
543
19
						data,
544
19
						value,
545
19
						gas_limit,
546
19
						max_fee_per_gas,
547
19
						max_priority_fee_per_gas,
548
19
						nonce,
549
19
						access_list.unwrap_or_default(),
550
19
						authorization_list.unwrap_or_default(),
551
19
						is_transactional,
552
19
						validate,
553
19
						weight_limit,
554
19
						proof_size_base_cost,
555
19
						config.as_ref().unwrap_or(<Runtime as pallet_evm::Config>::config()),
556
19
					).map_err(|err| err.error.into())
557
19
				}
558
397349

            
559
397349
				fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
560
19
					pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()
561
19
				}
562
397349

            
563
397349
				fn current_block() -> Option<pallet_ethereum::Block> {
564
19
					pallet_ethereum::CurrentBlock::<Runtime>::get()
565
19
				}
566
397349

            
567
397349
				fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
568
19
					pallet_ethereum::CurrentReceipts::<Runtime>::get()
569
19
				}
570
397349

            
571
397349
				fn current_all() -> (
572
					Option<pallet_ethereum::Block>,
573
					Option<Vec<pallet_ethereum::Receipt>>,
574
					Option<Vec<TransactionStatus>>,
575
				) {
576
					(
577
						pallet_ethereum::CurrentBlock::<Runtime>::get(),
578
						pallet_ethereum::CurrentReceipts::<Runtime>::get(),
579
						pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get(),
580
					)
581
				}
582
397349

            
583
397349
				fn extrinsic_filter(
584
					xts: Vec<<Block as BlockT>::Extrinsic>,
585
				) -> Vec<EthereumTransaction> {
586
					xts.into_iter().filter_map(|xt| match xt.0.function {
587
397349
						RuntimeCall::Ethereum(transact { transaction }) => Some(transaction),
588
397349
						_ => None
589
397349
					}).collect::<Vec<EthereumTransaction>>()
590
				}
591
397349

            
592
397349
				fn elasticity() -> Option<Permill> {
593
					None
594
				}
595
397349

            
596
397349
				fn gas_limit_multiplier_support() {}
597
397349

            
598
397349
				fn pending_block(
599
					xts: Vec<<Block as sp_runtime::traits::Block>::Extrinsic>
600
				) -> (
601
					Option<pallet_ethereum::Block>, Option<sp_std::prelude::Vec<TransactionStatus>>
602
				) {
603
397349
					for ext in xts.into_iter() {
604
						let _ = Executive::apply_extrinsic(ext);
605
					}
606
397349

            
607
397349
					Ethereum::on_finalize(System::block_number() + 1);
608

            
609
					(
610
						pallet_ethereum::CurrentBlock::<Runtime>::get(),
611
						pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()
612
					)
613
				 }
614
397349

            
615
397349
				fn initialize_pending_block(header: &<Block as BlockT>::Header) {
616
					pallet_randomness::vrf::using_fake_vrf(|| {
617
						let _ = Executive::initialize_block(header);
618
					})
619
				}
620
397349
			}
621
397349

            
622
397349
			impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {
623
397349
				fn convert_transaction(
624
					transaction: pallet_ethereum::Transaction
625
				) -> <Block as BlockT>::Extrinsic {
626
					UncheckedExtrinsic::new_bare(
627
						pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),
628
					)
629
				}
630
397349
			}
631
397349

            
632
397349
			impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
633
397349
			for Runtime {
634
397349
				fn query_info(
635
					uxt: <Block as BlockT>::Extrinsic,
636
					len: u32,
637
				) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
638
					TransactionPayment::query_info(uxt, len)
639
				}
640
397349

            
641
397349
				fn query_fee_details(
642
					uxt: <Block as BlockT>::Extrinsic,
643
					len: u32,
644
				) -> pallet_transaction_payment::FeeDetails<Balance> {
645
					TransactionPayment::query_fee_details(uxt, len)
646
				}
647
397349

            
648
397349
				fn query_weight_to_fee(weight: Weight) -> Balance {
649
					TransactionPayment::weight_to_fee(weight)
650
				}
651
397349

            
652
397349
				fn query_length_to_fee(length: u32) -> Balance {
653
					TransactionPayment::length_to_fee(length)
654
				}
655
397349
			}
656
397349

            
657
397349
			impl nimbus_primitives::NimbusApi<Block> for Runtime {
658
397387
				fn can_author(
659
57
					author: nimbus_primitives::NimbusId,
660
57
					slot: u32,
661
57
					parent_header: &<Block as BlockT>::Header
662
57
				) -> bool {
663
397349
					use pallet_parachain_staking::Config as PalletParachainStakingConfig;
664
397349

            
665
397387
					let block_number = parent_header.number + 1;
666
397349

            
667
397349
					// The Moonbeam runtimes use an entropy source that needs to do some accounting
668
397349
					// work during block initialization. Therefore we initialize it here to match
669
397349
					// the state it will be in when the next block is being executed.
670
397349
					use frame_support::traits::OnInitialize;
671
397387
					System::initialize(
672
57
						&block_number,
673
57
						&parent_header.hash(),
674
57
						&parent_header.digest,
675
57
					);
676
57

            
677
57
					// Because the staking solution calculates the next staking set at the beginning
678
57
					// of the first block in the new round, the only way to accurately predict the
679
57
					// authors is to compute the selection during prediction.
680
57
					if pallet_parachain_staking::Pallet::<Self>::round()
681
57
						.should_update(block_number) {
682
397349
						// get author account id
683
397349
						use nimbus_primitives::AccountLookup;
684
397349
						let author_account_id = if let Some(account) =
685
397349
							pallet_author_mapping::Pallet::<Self>::lookup_account(&author) {
686
397349
							account
687
397349
						} else {
688
397349
							// return false if author mapping not registered like in can_author impl
689
397349
							return false
690
397349
						};
691
397349
						let candidates = pallet_parachain_staking::Pallet::<Self>::compute_top_candidates();
692
						if candidates.is_empty() {
693
397349
							// If there are zero selected candidates, we use the same eligibility
694
397349
							// as the previous round
695
397349
							return AuthorInherent::can_author(&author, &slot);
696
397349
						}
697

            
698
						// predict eligibility post-selection by computing selection results now
699
						let (eligible, _) =
700
							pallet_author_slot_filter::compute_pseudo_random_subset::<Self>(
701
								candidates,
702
								&slot
703
							);
704
						eligible.contains(&author_account_id)
705
397349
					} else {
706
397387
						AuthorInherent::can_author(&author, &slot)
707
397349
					}
708
397387
				}
709
397349
			}
710
397349

            
711
397349
			impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
712
397349
				fn collect_collation_info(
713
					header: &<Block as BlockT>::Header
714
				) -> cumulus_primitives_core::CollationInfo {
715
					ParachainSystem::collect_collation_info(header)
716
				}
717
397349
			}
718
397349

            
719
397349
			impl session_keys_primitives::VrfApi<Block> for Runtime {
720
397349
				fn get_last_vrf_output() -> Option<<Block as BlockT>::Hash> {
721
					// TODO: remove in future runtime upgrade along with storage item
722
					if pallet_randomness::Pallet::<Self>::not_first_block().is_none() {
723
397349
						return None;
724
397349
					}
725
					pallet_randomness::Pallet::<Self>::local_vrf_output()
726
397349
				}
727
397349
				fn vrf_key_lookup(
728
					nimbus_id: nimbus_primitives::NimbusId
729
				) -> Option<session_keys_primitives::VrfId> {
730
397349
					use session_keys_primitives::KeysLookup;
731
397349
					AuthorMapping::lookup_keys(&nimbus_id)
732
				}
733
397349
			}
734
397349

            
735
397349
			impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
736
397349
				fn query_acceptable_payment_assets(
737
					xcm_version: xcm::Version
738
				) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
739
					XcmWeightTrader::query_acceptable_payment_assets(xcm_version)
740
				}
741
397349

            
742
397349
				fn query_weight_to_asset_fee(
743
					weight: Weight, asset: VersionedAssetId
744
				) -> Result<u128, XcmPaymentApiError> {
745
					XcmWeightTrader::query_weight_to_asset_fee(weight, asset)
746
				}
747
397349

            
748
397349
				fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
749
					PolkadotXcm::query_xcm_weight(message)
750
				}
751
397349

            
752
397349
				fn query_delivery_fees(
753
					destination: VersionedLocation, message: VersionedXcm<()>
754
				) -> Result<VersionedAssets, XcmPaymentApiError> {
755
					PolkadotXcm::query_delivery_fees(destination, message)
756
				}
757
397349
			}
758
397349

            
759
397349
			impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller>
760
397349
				for Runtime {
761
397349
					fn dry_run_call(
762
						origin: OriginCaller,
763
						call: RuntimeCall,
764
						result_xcms_version: XcmVersion
765
					) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
766
						PolkadotXcm::dry_run_call::<
767
							Runtime,
768
							xcm_config::XcmRouter,
769
							OriginCaller,
770
							RuntimeCall>(origin, call, result_xcms_version)
771
					}
772
397349

            
773
397349
					fn dry_run_xcm(
774
						origin_location: VersionedLocation,
775
						xcm: VersionedXcm<RuntimeCall>
776
					) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
777
						PolkadotXcm::dry_run_xcm::<xcm_config::XcmRouter>(origin_location, xcm)
778
					}
779
397349
				}
780
397349

            
781
397349
			impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
782
397349
				fn convert_location(location: VersionedLocation) -> Result<
783
					AccountId,
784
					xcm_runtime_apis::conversions::Error
785
				> {
786
					xcm_runtime_apis::conversions::LocationToAccountHelper::<
787
						AccountId,
788
						xcm_config::LocationToAccountId,
789
					>::convert_location(location)
790
				}
791
397349
			}
792
397349

            
793
397349
			#[cfg(feature = "runtime-benchmarks")]
794
397349
			impl frame_benchmarking::Benchmark<Block> for Runtime {
795
397349

            
796
397349
				fn benchmark_metadata(extra: bool) -> (
797
397349
					Vec<frame_benchmarking::BenchmarkList>,
798
397349
					Vec<frame_support::traits::StorageInfo>,
799
397349
				) {
800
397349
					use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
801
397349
					use frame_system_benchmarking::Pallet as SystemBench;
802
397349
					use frame_support::traits::StorageInfoTrait;
803
397349

            
804
397349
					use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
805
397349
					use pallet_transaction_payment::benchmarking::Pallet as PalletTransactionPaymentBenchmark;
806
397349

            
807
397349
					let mut list = Vec::<BenchmarkList>::new();
808
397349
					list_benchmarks!(list, extra);
809
397349

            
810
397349
					let storage_info = AllPalletsWithSystem::storage_info();
811
397349

            
812
397349
					return (list, storage_info)
813
397349
				}
814
397349

            
815
397349
				#[allow(non_local_definitions)]
816
397349
				fn dispatch_benchmark(
817
397349
					config: frame_benchmarking::BenchmarkConfig,
818
397349
				) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
819
397349
					use frame_benchmarking::{add_benchmark, BenchmarkBatch, Benchmarking};
820
397349
					use frame_support::traits::TrackedStorageKey;
821
397349
					use cumulus_primitives_core::ParaId;
822
397349

            
823
397349
					use xcm::latest::prelude::{
824
397349
						GeneralIndex, Junction, Junctions, Location, Response, NetworkId, AssetId,
825
397349
						Assets as XcmAssets, Fungible, Asset, ParentThen, Parachain, Parent, WeightLimit
826
397349
					};
827
397349
					use xcm_config::SelfReserve;
828
397349
					use frame_benchmarking::BenchmarkError;
829
397349

            
830
397349
					use frame_system_benchmarking::Pallet as SystemBench;
831
397349
					// Needed to run `set_code` and `apply_authorized_upgrade` frame_system benchmarks
832
397349
					// https://github.com/paritytech/cumulus/pull/2766
833
397349
					impl frame_system_benchmarking::Config for Runtime {
834
397349
						fn setup_set_code_requirements(code: &Vec<u8>) -> Result<(), BenchmarkError> {
835
397349
							ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
836
397349
							Ok(())
837
397349
						}
838
397349

            
839
397349
						fn verify_set_code() {
840
397349
							System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
841
397349
						}
842
397349
					}
843
397349

            
844
397349
					use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
845
397349
					parameter_types! {
846
397349
						pub const RandomParaId: ParaId = ParaId::new(43211234);
847
397349
					}
848
397349

            
849
397349
					pub struct TestDeliveryHelper;
850
397349
					impl xcm_builder::EnsureDelivery for TestDeliveryHelper {
851
397349
						fn ensure_successful_delivery(
852
397349
							origin_ref: &Location,
853
397349
							_dest: &Location,
854
397349
							_fee_reason: xcm_executor::traits::FeeReason,
855
397349
						) -> (Option<xcm_executor::FeesMode>, Option<XcmAssets>) {
856
397349
							use xcm_executor::traits::ConvertLocation;
857
397349
							if let Some(account) = xcm_config::LocationToH160::convert_location(origin_ref) {
858
397349
								// Give the existential deposit at least
859
397349
								let balance = ExistentialDeposit::get();
860
397349
								let _ = <Balances as frame_support::traits::Currency<_>>::
861
397349
									make_free_balance_be(&account.into(), balance);
862
397349
							}
863
397349

            
864
397349
							(None, None)
865
397349
						}
866
397349
					}
867
397349

            
868
397349
					use pallet_transaction_payment::benchmarking::Pallet as PalletTransactionPaymentBenchmark;
869
397349
					impl pallet_transaction_payment::benchmarking::Config for Runtime {
870
397349
						fn setup_benchmark_environment() {
871
397349
							let alice = AccountId::from(sp_core::hex2array!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"));
872
397349
							pallet_author_inherent::Author::<Runtime>::put(&alice);
873
397349

            
874
397349
							let caller: AccountId = frame_benchmarking::account("caller", 0, 0);
875
397349
							let balance = 1_000_000_000_000_000_000u64.into(); // 1 UNIT
876
397349
							<Balances as frame_support::traits::Currency<_>>::make_free_balance_be(&caller, balance);
877
397349
						}
878
397349
					}
879
397349

            
880
397349
					impl pallet_xcm::benchmarking::Config for Runtime {
881
397349
				        type DeliveryHelper = TestDeliveryHelper;
882
397349

            
883
397349
						fn get_asset() -> Asset {
884
397349
							Asset {
885
397349
								id: AssetId(SelfReserve::get()),
886
397349
								fun: Fungible(ExistentialDeposit::get()),
887
397349
							}
888
397349
						}
889
397349

            
890
397349
						fn reachable_dest() -> Option<Location> {
891
397349
							Some(Parent.into())
892
397349
						}
893
397349

            
894
397349
						fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
895
397349
							None
896
397349
						}
897
397349

            
898
397349
						fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
899
397349
							use xcm_config::SelfReserve;
900
397349

            
901
397349
							ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
902
397349
								RandomParaId::get().into()
903
397349
							);
904
397349

            
905
397349
							Some((
906
397349
								Asset {
907
397349
									fun: Fungible(ExistentialDeposit::get()),
908
397349
									id: AssetId(SelfReserve::get().into())
909
397349
								},
910
397349
								// Moonbeam can reserve transfer native token to
911
397349
								// some random parachain.
912
397349
								ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
913
397349
							))
914
397349
						}
915
397349

            
916
397349
						fn set_up_complex_asset_transfer(
917
397349
						) -> Option<(XcmAssets, u32, Location, Box<dyn FnOnce()>)> {
918
397349
							use xcm_config::SelfReserve;
919
397349

            
920
397349
							let destination: xcm::v5::Location = Parent.into();
921
397349

            
922
397349
							let fee_amount: u128 = <Runtime as pallet_balances::Config>::ExistentialDeposit::get();
923
397349
							let fee_asset: Asset = (SelfReserve::get(), fee_amount).into();
924
397349

            
925
397349
							// Give some multiple of transferred amount
926
397349
							let balance = fee_amount * 1000;
927
397349
							let who = frame_benchmarking::whitelisted_caller();
928
397349
							let _ =
929
397349
								<Balances as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance);
930
397349

            
931
397349
							// verify initial balance
932
397349
							assert_eq!(Balances::free_balance(&who), balance);
933
397349

            
934
397349
							// set up foreign asset
935
397349
							let asset_amount: u128 = 10u128;
936
397349
							let initial_asset_amount: u128 = asset_amount * 10;
937
397349

            
938
397349
							let asset_id = pallet_moonbeam_foreign_assets::default_asset_id::<Runtime>() + 1;
939
397349
							let (_, location, _) = pallet_moonbeam_foreign_assets::create_default_minted_foreign_asset::<Runtime>(
940
397349
								asset_id,
941
397349
								initial_asset_amount,
942
397349
							);
943
397349
							let transfer_asset: Asset = (AssetId(location), asset_amount).into();
944
397349

            
945
397349
							let assets: XcmAssets = vec![fee_asset.clone(), transfer_asset].into();
946
397349
							let fee_index: u32 = 0;
947
397349

            
948
397349
							let verify: Box<dyn FnOnce()> = Box::new(move || {
949
397349
								// verify balance after transfer, decreased by
950
397349
								// transferred amount (and delivery fees)
951
397349
								assert!(Balances::free_balance(&who) <= balance - fee_amount);
952
397349
							});
953
397349

            
954
397349
							Some((assets, fee_index, destination, verify))
955
397349
						}
956
397349
					}
957
397349

            
958
397349
					impl pallet_xcm_benchmarks::Config for Runtime {
959
397349
						type XcmConfig = xcm_config::XcmExecutorConfig;
960
397349
						type AccountIdConverter = xcm_config::LocationToAccountId;
961
397349
						type DeliveryHelper = ();
962
397349
						fn valid_destination() -> Result<Location, BenchmarkError> {
963
397349
							Ok(Location::parent())
964
397349
						}
965
397349
						fn worst_case_holding(_depositable_count: u32) -> XcmAssets {
966
397349
						// 100 fungibles
967
397349
							const HOLDING_FUNGIBLES: u32 = 100;
968
397349
							let fungibles_amount: u128 = 100;
969
397349
							let assets = (0..HOLDING_FUNGIBLES).map(|i| {
970
397349
								let location: Location = GeneralIndex(i as u128).into();
971
397349
								Asset {
972
397349
									id: AssetId(location),
973
397349
									fun: Fungible(fungibles_amount * i as u128),
974
397349
								}
975
397349
								.into()
976
397349
							})
977
397349
							.chain(
978
397349
								core::iter::once(
979
397349
									Asset {
980
397349
										id: AssetId(Location::parent()),
981
397349
										fun: Fungible(u128::MAX)
982
397349
									}
983
397349
								)
984
397349
							)
985
397349
							.collect::<Vec<_>>();
986
397349

            
987
397349

            
988
397349
							for (i, asset) in assets.iter().enumerate() {
989
397349
								if let Asset {
990
397349
									id: AssetId(location),
991
397349
									fun: Fungible(_)
992
397349
								} = asset {
993
397349
									EvmForeignAssets::set_asset(
994
397349
										location.clone(),
995
397349
										i as u128
996
397349
									);
997
397349
									XcmWeightTrader::set_asset_price(
998
397349
										location.clone(),
999
397349
										1u128.pow(18)
397349
									);
397349
								}
397349
							}
397349
							assets.into()
397349
						}
397349
					}
397349

            
397349
					impl pallet_xcm_benchmarks::generic::Config for Runtime {
397349
						type RuntimeCall = RuntimeCall;
397349
						type TransactAsset = Balances;
397349

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

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

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

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

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

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

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

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

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

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

            
397349
					$($bench_custom)*
397349

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

            
397349
					];
397349

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

            
397349
					add_benchmarks!(params, batches);
397349

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

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

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