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
381538
		impl_runtime_apis! {
48
381538
			$($custom)*
49
381538

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
149
381538
			impl moonbeam_rpc_primitives_debug::DebugRuntimeApi<Block> for Runtime {
150
381538
				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
381538

            
227
381538
				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
381538

            
318
381538
				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
381538
			}
387
381538

            
388
381538
			impl moonbeam_rpc_primitives_txpool::TxPoolRuntimeApi<Block> for Runtime {
389
381538
				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
381538
								RuntimeCall::Ethereum(transact { transaction }) => Some(transaction),
398
381538
								_ => None,
399
381558
							})
400
20
							.collect(),
401
20
						future: xts_future
402
20
							.into_iter()
403
40
							.filter_map(|xt| match xt.0.function {
404
381538
								RuntimeCall::Ethereum(transact { transaction }) => Some(transaction),
405
381538
								_ => None,
406
381558
							})
407
20
							.collect(),
408
20
					}
409
20
				}
410
381538
			}
411
381538

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

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

            
422
381538
				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
381538

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

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

            
435
381538
				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
381538

            
440
381538
				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
381538
					let config = if estimate {
454
381538
						let mut config = <Runtime as pallet_evm::Config>::config().clone();
455
						config.estimate = true;
456
						Some(config)
457
381538
					} else {
458
381538
						None
459
381538
					};
460
381538
					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
381538

            
500
381538
				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
381538
					let config = if estimate {
513
381538
						let mut config = <Runtime as pallet_evm::Config>::config().clone();
514
						config.estimate = true;
515
						Some(config)
516
381538
					} else {
517
381538
						None
518
381538
					};
519
381538
					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
381538

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

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

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

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

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

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

            
596
381538
				fn gas_limit_multiplier_support() {}
597
381538

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

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

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

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

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

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

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

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

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

            
657
381538
			impl nimbus_primitives::NimbusApi<Block> for Runtime {
658
381578
				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
381538
					use pallet_parachain_staking::Config as PalletParachainStakingConfig;
664
381538

            
665
381578
					let block_number = parent_header.number + 1;
666
381538

            
667
381538
					// The Moonbeam runtimes use an entropy source that needs to do some accounting
668
381538
					// work during block initialization. Therefore we initialize it here to match
669
381538
					// the state it will be in when the next block is being executed.
670
381538
					use frame_support::traits::OnInitialize;
671
381578
					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
381538
						// get author account id
683
381538
						use nimbus_primitives::AccountLookup;
684
381538
						let author_account_id = if let Some(account) =
685
381538
							pallet_author_mapping::Pallet::<Self>::lookup_account(&author) {
686
381538
							account
687
381538
						} else {
688
381538
							// return false if author mapping not registered like in can_author impl
689
381538
							return false
690
381538
						};
691
381538
						let candidates = pallet_parachain_staking::Pallet::<Self>::compute_top_candidates();
692
						if candidates.is_empty() {
693
381538
							// If there are zero selected candidates, we use the same eligibility
694
381538
							// as the previous round
695
381538
							return AuthorInherent::can_author(&author, &slot);
696
381538
						}
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
381538
					} else {
706
381578
						AuthorInherent::can_author(&author, &slot)
707
381538
					}
708
381578
				}
709
381538
			}
710
381538

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

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

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

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

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

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

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

            
773
381538
					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
381538
				}
784
381538

            
785
381538
			impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
786
381538
				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
381538
			}
796
381538

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
991
381538

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

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

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

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

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

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

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

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

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

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

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

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

            
381538
					$($bench_custom)*
381538

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

            
381538
					];
381538

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

            
381538
					add_benchmarks!(params, batches);
381538

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

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

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