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
20
		fn replay_on_idle() {
30
			use frame_system::pallet_prelude::BlockNumberFor;
31
			use frame_support::traits::OnIdle;
32

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

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

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

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

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

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

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

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

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

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

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

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

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

            
107
387020
			impl sp_session::SessionKeys<Block> for Runtime {
108
387020
				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
387020

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

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

            
124
387020
				#[cfg(not(feature = "disable-genesis-builder"))]
125
387020
				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
387020
				#[cfg(feature = "disable-genesis-builder")]
129
387020
				fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
130
387020
					None
131
387020
				}
132
387020

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

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

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

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

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

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

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

            
204
20
							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
20

            
210
20
							if let Some(EthereumTracingStatus::TransactionExited) = EthereumTracer::status() {
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
					}
221
20
					#[cfg(not(feature = "evm-tracing"))]
222
20
					Err(sp_runtime::DispatchError::Other(
223
20
						"Missing `evm-tracing` compile time feature flag.",
224
20
					))
225
20
				}
226
387020

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

            
244
20
						// Tell the CallDispatcher we are tracing a full Block.
245
20
						EthereumTracer::block(|| {
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 calling ETHEREUM_TRACING_STATUS::using
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
80
								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
40
										}
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
					}
312
20
					#[cfg(not(feature = "evm-tracing"))]
313
20
					Err(sp_runtime::DispatchError::Other(
314
20
						"Missing `evm-tracing` compile time feature flag.",
315
20
					))
316
20
				}
317
387020

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
571
387020
				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
387020

            
583
387020
				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
387020
						RuntimeCall::Ethereum(transact { transaction }) => Some(transaction),
588
387020
						_ => None
589
387020
					}).collect::<Vec<EthereumTransaction>>()
590
				}
591
387020

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

            
596
387020
				fn gas_limit_multiplier_support() {}
597
387020

            
598
387020
				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
387020
					for ext in xts.into_iter() {
604
						let _ = Executive::apply_extrinsic(ext);
605
					}
606
387020

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

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

            
615
387020
				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
387020
			}
621
387020

            
622
387020
			impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {
623
387020
				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
387020
			}
631
387020

            
632
387020
			impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
633
387020
			for Runtime {
634
387020
				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
387020

            
641
387020
				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
387020

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

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

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

            
665
387060
					let block_number = parent_header.number + 1;
666
387020

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

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

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

            
719
387020
			impl session_keys_primitives::VrfApi<Block> for Runtime {
720
387020
				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
387020
						return None;
724
387020
					}
725
					pallet_randomness::Pallet::<Self>::local_vrf_output()
726
387020
				}
727
387020
				fn vrf_key_lookup(
728
					nimbus_id: nimbus_primitives::NimbusId
729
				) -> Option<session_keys_primitives::VrfId> {
730
387020
					use session_keys_primitives::KeysLookup;
731
387020
					AuthorMapping::lookup_keys(&nimbus_id)
732
				}
733
387020
			}
734
387020

            
735
387020
			impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
736
387020
				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
387020

            
742
387020
				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
387020

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

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

            
759
387020
			impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller>
760
387020
				for Runtime {
761
387020
					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
387020

            
773
387020
					fn dry_run_xcm(
774
						origin_location: VersionedLocation,
775
						xcm: VersionedXcm<RuntimeCall>
776
					) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
777
						PolkadotXcm::dry_run_xcm::<
778
							Runtime,
779
							xcm_config::XcmRouter,
780
							RuntimeCall,
781
							xcm_config::XcmExecutorConfig>(origin_location, xcm)
782
					}
783
387020
				}
784
387020

            
785
387020
			impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
786
387020
				fn convert_location(location: VersionedLocation) -> Result<
787
					AccountId,
788
					xcm_runtime_apis::conversions::Error
789
				> {
790
					xcm_runtime_apis::conversions::LocationToAccountHelper::<
791
						AccountId,
792
						xcm_config::LocationToAccountId,
793
					>::convert_location(location)
794
				}
795
387020
			}
796
387020

            
797
387020
			#[cfg(feature = "runtime-benchmarks")]
798
387020
			impl frame_benchmarking::Benchmark<Block> for Runtime {
799
387020

            
800
387020
				fn benchmark_metadata(extra: bool) -> (
801
387020
					Vec<frame_benchmarking::BenchmarkList>,
802
387020
					Vec<frame_support::traits::StorageInfo>,
803
387020
				) {
804
387020
					use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
805
387020
					use frame_system_benchmarking::Pallet as SystemBench;
806
387020
					use frame_support::traits::StorageInfoTrait;
807
387020

            
808
387020
					use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
809
387020
					use pallet_transaction_payment::benchmarking::Pallet as PalletTransactionPaymentBenchmark;
810
387020

            
811
387020
					let mut list = Vec::<BenchmarkList>::new();
812
387020
					list_benchmarks!(list, extra);
813
387020

            
814
387020
					let storage_info = AllPalletsWithSystem::storage_info();
815
387020

            
816
387020
					return (list, storage_info)
817
387020
				}
818
387020

            
819
387020
				#[allow(non_local_definitions)]
820
387020
				fn dispatch_benchmark(
821
387020
					config: frame_benchmarking::BenchmarkConfig,
822
387020
				) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
823
387020
					use frame_benchmarking::{add_benchmark, BenchmarkBatch, Benchmarking};
824
387020
					use frame_support::traits::TrackedStorageKey;
825
387020
					use cumulus_primitives_core::ParaId;
826
387020

            
827
387020
					use xcm::latest::prelude::{
828
387020
						GeneralIndex, Junction, Junctions, Location, Response, NetworkId, AssetId,
829
387020
						Assets as XcmAssets, Fungible, Asset, ParentThen, Parachain, Parent, WeightLimit
830
387020
					};
831
387020
					use xcm_config::SelfReserve;
832
387020
					use frame_benchmarking::BenchmarkError;
833
387020

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

            
843
387020
						fn verify_set_code() {
844
387020
							System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
845
387020
						}
846
387020
					}
847
387020

            
848
387020
					use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
849
387020
					parameter_types! {
850
387020
						pub const RandomParaId: ParaId = ParaId::new(43211234);
851
387020
					}
852
387020

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

            
868
387020
							(None, None)
869
387020
						}
870
387020
					}
871
387020

            
872
387020
					use pallet_transaction_payment::benchmarking::Pallet as PalletTransactionPaymentBenchmark;
873
387020
					impl pallet_transaction_payment::benchmarking::Config for Runtime {
874
387020
						fn setup_benchmark_environment() {
875
387020
							let alice = AccountId::from(sp_core::hex2array!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"));
876
387020
							pallet_author_inherent::Author::<Runtime>::put(&alice);
877
387020

            
878
387020
							let caller: AccountId = frame_benchmarking::account("caller", 0, 0);
879
387020
							let balance = 1_000_000_000_000_000_000u64.into(); // 1 UNIT
880
387020
							<Balances as frame_support::traits::Currency<_>>::make_free_balance_be(&caller, balance);
881
387020
						}
882
387020
					}
883
387020

            
884
387020
					impl pallet_xcm::benchmarking::Config for Runtime {
885
387020
				        type DeliveryHelper = TestDeliveryHelper;
886
387020

            
887
387020
						fn get_asset() -> Asset {
888
387020
							Asset {
889
387020
								id: AssetId(SelfReserve::get()),
890
387020
								fun: Fungible(ExistentialDeposit::get()),
891
387020
							}
892
387020
						}
893
387020

            
894
387020
						fn reachable_dest() -> Option<Location> {
895
387020
							Some(Parent.into())
896
387020
						}
897
387020

            
898
387020
						fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
899
387020
							None
900
387020
						}
901
387020

            
902
387020
						fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
903
387020
							use xcm_config::SelfReserve;
904
387020

            
905
387020
							ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
906
387020
								RandomParaId::get().into()
907
387020
							);
908
387020

            
909
387020
							Some((
910
387020
								Asset {
911
387020
									fun: Fungible(ExistentialDeposit::get()),
912
387020
									id: AssetId(SelfReserve::get().into())
913
387020
								},
914
387020
								// Moonbeam can reserve transfer native token to
915
387020
								// some random parachain.
916
387020
								ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
917
387020
							))
918
387020
						}
919
387020

            
920
387020
						fn set_up_complex_asset_transfer(
921
387020
						) -> Option<(XcmAssets, u32, Location, Box<dyn FnOnce()>)> {
922
387020
							use xcm_config::SelfReserve;
923
387020

            
924
387020
							let destination: xcm::v5::Location = Parent.into();
925
387020

            
926
387020
							let fee_amount: u128 = <Runtime as pallet_balances::Config>::ExistentialDeposit::get();
927
387020
							let fee_asset: Asset = (SelfReserve::get(), fee_amount).into();
928
387020

            
929
387020
							// Give some multiple of transferred amount
930
387020
							let balance = fee_amount * 1000;
931
387020
							let who = frame_benchmarking::whitelisted_caller();
932
387020
							let _ =
933
387020
								<Balances as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance);
934
387020

            
935
387020
							// verify initial balance
936
387020
							assert_eq!(Balances::free_balance(&who), balance);
937
387020

            
938
387020
							// set up foreign asset
939
387020
							let asset_amount: u128 = 10u128;
940
387020
							let initial_asset_amount: u128 = asset_amount * 10;
941
387020

            
942
387020
							let asset_id = pallet_moonbeam_foreign_assets::default_asset_id::<Runtime>() + 1;
943
387020
							let (_, location, _) = pallet_moonbeam_foreign_assets::create_default_minted_foreign_asset::<Runtime>(
944
387020
								asset_id,
945
387020
								initial_asset_amount,
946
387020
							);
947
387020
							let transfer_asset: Asset = (AssetId(location), asset_amount).into();
948
387020

            
949
387020
							let assets: XcmAssets = vec![fee_asset.clone(), transfer_asset].into();
950
387020
							let fee_index: u32 = 0;
951
387020

            
952
387020
							let verify: Box<dyn FnOnce()> = Box::new(move || {
953
387020
								// verify balance after transfer, decreased by
954
387020
								// transferred amount (and delivery fees)
955
387020
								assert!(Balances::free_balance(&who) <= balance - fee_amount);
956
387020
							});
957
387020

            
958
387020
							Some((assets, fee_index, destination, verify))
959
387020
						}
960
387020
					}
961
387020

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

            
991
387020

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

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

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

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

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

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

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

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

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

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

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

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

            
387020
					$($bench_custom)*
387020

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

            
387020
					];
387020

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

            
387020
					add_benchmarks!(params, batches);
387020

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

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

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