1
// Copyright (C) Moondance Labs Ltd.
2
// This file is part of Tanssi.
3

            
4
// Tanssi 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
// Tanssi 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 Tanssi.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
#![cfg_attr(not(feature = "std"), no_std)]
18
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
19
#![recursion_limit = "256"]
20

            
21
// Make the WASM binary available.
22
#[cfg(feature = "std")]
23
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
24

            
25
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
26
#[cfg(feature = "std")]
27
use sp_version::NativeVersion;
28

            
29
#[cfg(any(feature = "std", test))]
30
pub use sp_runtime::BuildStorage;
31

            
32
pub mod migrations;
33
pub mod weights;
34

            
35
pub use sp_runtime::{MultiAddress, Perbill, Permill};
36
use {
37
    cumulus_primitives_core::AggregateMessageOrigin,
38
    dp_impl_tanssi_pallets_config::impl_tanssi_pallets_config,
39
    frame_support::{
40
        construct_runtime,
41
        dispatch::DispatchClass,
42
        genesis_builder_helper::{build_state, get_preset},
43
        pallet_prelude::DispatchResult,
44
        parameter_types,
45
        traits::{
46
            ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Contains, InsideBoth, InstanceFilter,
47
        },
48
        weights::{
49
            constants::{
50
                BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
51
                WEIGHT_REF_TIME_PER_SECOND,
52
            },
53
            ConstantMultiplier, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
54
            WeightToFeePolynomial,
55
        },
56
    },
57
    frame_system::{
58
        limits::{BlockLength, BlockWeights},
59
        EnsureRoot,
60
    },
61
    nimbus_primitives::{NimbusId, SlotBeacon},
62
    pallet_transaction_payment::FungibleAdapter,
63
    parity_scale_codec::{Decode, Encode},
64
    polkadot_runtime_common::SlowAdjustingFeeUpdate,
65
    scale_info::TypeInfo,
66
    smallvec::smallvec,
67
    sp_api::impl_runtime_apis,
68
    sp_consensus_slots::{Slot, SlotDuration},
69
    sp_core::{MaxEncodedLen, OpaqueMetadata},
70
    sp_runtime::{
71
        create_runtime_str, generic, impl_opaque_keys,
72
        traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify},
73
        transaction_validity::{TransactionSource, TransactionValidity},
74
        ApplyExtrinsicResult, MultiSignature,
75
    },
76
    sp_std::prelude::*,
77
    sp_version::RuntimeVersion,
78
};
79

            
80
pub mod xcm_config;
81

            
82
// Polkadot imports
83
use polkadot_runtime_common::BlockHashCount;
84

            
85
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
86
pub type Signature = MultiSignature;
87

            
88
/// Some way of identifying an account on the chain. We intentionally make it equivalent
89
/// to the public key of our transaction signing scheme.
90
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
91

            
92
/// Balance of an account.
93
pub type Balance = u128;
94

            
95
/// Index of a transaction in the chain.
96
pub type Index = u32;
97

            
98
/// A hash of some data used by the chain.
99
pub type Hash = sp_core::H256;
100

            
101
/// An index to a block.
102
pub type BlockNumber = u32;
103

            
104
/// The address format for describing accounts.
105
pub type Address = MultiAddress<AccountId, ()>;
106

            
107
/// Block header type as expected by this runtime.
108
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
109

            
110
/// Block type as expected by this runtime.
111
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
112

            
113
/// A Block signed with a Justification
114
pub type SignedBlock = generic::SignedBlock<Block>;
115

            
116
/// BlockId type as expected by this runtime.
117
pub type BlockId = generic::BlockId<Block>;
118

            
119
/// The SignedExtension to the basic transaction logic.
120
pub type SignedExtra = (
121
    frame_system::CheckNonZeroSender<Runtime>,
122
    frame_system::CheckSpecVersion<Runtime>,
123
    frame_system::CheckTxVersion<Runtime>,
124
    frame_system::CheckGenesis<Runtime>,
125
    frame_system::CheckEra<Runtime>,
126
    frame_system::CheckNonce<Runtime>,
127
    frame_system::CheckWeight<Runtime>,
128
    pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
129
);
130

            
131
/// Unchecked extrinsic type as expected by this runtime.
132
pub type UncheckedExtrinsic =
133
    generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
134

            
135
/// Extrinsic type that has already been checked.
136
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
137

            
138
/// Executive: handles dispatch to the various modules.
139
pub type Executive = frame_executive::Executive<
140
    Runtime,
141
    Block,
142
    frame_system::ChainContext<Runtime>,
143
    Runtime,
144
    AllPalletsWithSystem,
145
>;
146

            
147
pub mod currency {
148
    use super::Balance;
149

            
150
    pub const MICROUNIT: Balance = 1_000_000;
151
    pub const MILLIUNIT: Balance = 1_000_000_000;
152
    pub const UNIT: Balance = 1_000_000_000_000;
153
    pub const KILOUNIT: Balance = 1_000_000_000_000_000;
154

            
155
    pub const STORAGE_BYTE_FEE: Balance = 100 * MICROUNIT;
156

            
157
    pub const fn deposit(items: u32, bytes: u32) -> Balance {
158
        items as Balance * 100 * MILLIUNIT + (bytes as Balance) * STORAGE_BYTE_FEE
159
    }
160
}
161

            
162
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
163
/// node's balance type.
164
///
165
/// This should typically create a mapping between the following ranges:
166
///   - `[0, MAXIMUM_BLOCK_WEIGHT]`
167
///   - `[Balance::min, Balance::max]`
168
///
169
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being:
170
///   - Setting it to `0` will essentially disable the weight fee.
171
///   - Setting it to `1` will cause the literal `#[weight = x]` values to be charged.
172
pub struct WeightToFee;
173
impl WeightToFeePolynomial for WeightToFee {
174
    type Balance = Balance;
175
38
    fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
176
38
        // in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1 MILLIUNIT:
177
38
        // in our template, we map to 1/10 of that, or 1/10 MILLIUNIT
178
38
        let p = MILLIUNIT / 10;
179
38
        let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
180
38
        smallvec![WeightToFeeCoefficient {
181
            degree: 1,
182
            negative: false,
183
            coeff_frac: Perbill::from_rational(p % q, q),
184
            coeff_integer: p / q,
185
        }]
186
38
    }
187
}
188

            
189
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
190
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
191
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
192
/// to even the core data structures.
193
pub mod opaque {
194
    use {
195
        super::*,
196
        sp_runtime::{generic, traits::BlakeTwo256},
197
    };
198

            
199
    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
200
    /// Opaque block header type.
201
    pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
202
    /// Opaque block type.
203
    pub type Block = generic::Block<Header, UncheckedExtrinsic>;
204
    /// Opaque block identifier type.
205
    pub type BlockId = generic::BlockId<Block>;
206
}
207

            
208
impl_opaque_keys! {
209
    pub struct SessionKeys { }
210
}
211

            
212
#[sp_version::runtime_version]
213
pub const VERSION: RuntimeVersion = RuntimeVersion {
214
    spec_name: create_runtime_str!("container-chain-template"),
215
    impl_name: create_runtime_str!("container-chain-template"),
216
    authoring_version: 1,
217
    spec_version: 700,
218
    impl_version: 0,
219
    apis: RUNTIME_API_VERSIONS,
220
    transaction_version: 1,
221
    state_version: 1,
222
};
223

            
224
/// This determines the average expected block time that we are targeting.
225
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
226
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
227
/// up by `pallet_aura` to implement `fn slot_duration()`.
228
///
229
/// Change this to adjust the block time.
230
pub const MILLISECS_PER_BLOCK: u64 = 6000;
231

            
232
// NOTE: Currently it is not possible to change the slot duration after the chain has started.
233
//       Attempting to do so will brick block production.
234
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
235

            
236
// Time is measured by number of blocks.
237
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
238
pub const HOURS: BlockNumber = MINUTES * 60;
239
pub const DAYS: BlockNumber = HOURS * 24;
240

            
241
pub const SUPPLY_FACTOR: Balance = 100;
242

            
243
// Unit = the base number of indivisible units for balances
244
pub const UNIT: Balance = 1_000_000_000_000;
245
pub const MILLIUNIT: Balance = 1_000_000_000;
246
pub const MICROUNIT: Balance = 1_000_000;
247

            
248
pub const STORAGE_BYTE_FEE: Balance = 100 * MICROUNIT * SUPPLY_FACTOR;
249

            
250
pub const fn deposit(items: u32, bytes: u32) -> Balance {
251
    items as Balance * 100 * MILLIUNIT * SUPPLY_FACTOR + (bytes as Balance) * STORAGE_BYTE_FEE
252
}
253

            
254
/// The existential deposit. Set to 1/10 of the Connected Relay Chain.
255
pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT;
256

            
257
/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is
258
/// used to limit the maximal weight of a single extrinsic.
259
const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
260

            
261
/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by
262
/// `Operational` extrinsics.
263
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
264

            
265
/// We allow for 0.5 of a second of compute with a 12 second average block time.
266
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
267
    WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
268
    cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
269
);
270

            
271
/// The version information used to identify this runtime when compiled natively.
272
#[cfg(feature = "std")]
273
pub fn native_version() -> NativeVersion {
274
    NativeVersion {
275
        runtime_version: VERSION,
276
        can_author_with: Default::default(),
277
    }
278
}
279

            
280
parameter_types! {
281
    pub const Version: RuntimeVersion = VERSION;
282

            
283
    // This part is copied from Substrate's `bin/node/runtime/src/lib.rs`.
284
    //  The `RuntimeBlockLength` and `RuntimeBlockWeights` exist here because the
285
    // `DeletionWeightLimit` and `DeletionQueueDepth` depend on those to parameterize
286
    // the lazy contract deletion.
287
    pub RuntimeBlockLength: BlockLength =
288
        BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
289
    pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
290
        .base_block(BlockExecutionWeight::get())
291
18
        .for_class(DispatchClass::all(), |weights| {
292
18
            weights.base_extrinsic = ExtrinsicBaseWeight::get();
293
18
        })
294
6
        .for_class(DispatchClass::Normal, |weights| {
295
6
            weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
296
6
        })
297
6
        .for_class(DispatchClass::Operational, |weights| {
298
6
            weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
299
6
            // Operational transactions have some extra reserved space, so that they
300
6
            // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
301
6
            weights.reserved = Some(
302
6
                MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
303
6
            );
304
6
        })
305
        .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
306
        .build_or_panic();
307
    pub const SS58Prefix: u16 = 42;
308
}
309

            
310
// Configure FRAME pallets to include in runtime.
311

            
312
impl frame_system::Config for Runtime {
313
    /// The identifier used to distinguish between accounts.
314
    type AccountId = AccountId;
315
    /// The aggregated dispatch type that is available for extrinsics.
316
    type RuntimeCall = RuntimeCall;
317
    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
318
    type Lookup = AccountIdLookup<AccountId, ()>;
319
    /// The index type for storing how many extrinsics an account has signed.
320
    type Nonce = Index;
321
    /// The index type for blocks.
322
    type Block = Block;
323
    /// The type for hashing blocks and tries.
324
    type Hash = Hash;
325
    /// The hashing algorithm used.
326
    type Hashing = BlakeTwo256;
327
    /// The ubiquitous event type.
328
    type RuntimeEvent = RuntimeEvent;
329
    /// The ubiquitous origin type.
330
    type RuntimeOrigin = RuntimeOrigin;
331
    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
332
    type BlockHashCount = BlockHashCount;
333
    /// Runtime version.
334
    type Version = Version;
335
    /// Converts a module to an index of this module in the runtime.
336
    type PalletInfo = PalletInfo;
337
    /// The data to be stored in an account.
338
    type AccountData = pallet_balances::AccountData<Balance>;
339
    /// What to do if a new account is created.
340
    type OnNewAccount = ();
341
    /// What to do if an account is fully reaped from the system.
342
    type OnKilledAccount = ();
343
    /// The weight of database operations that the runtime can invoke.
344
    type DbWeight = RocksDbWeight;
345
    /// The basic call filter to use in dispatchable.
346
    type BaseCallFilter = InsideBoth<MaintenanceMode, TxPause>;
347
    /// Weight information for the extrinsics of this pallet.
348
    type SystemWeightInfo = weights::frame_system::SubstrateWeight<Runtime>;
349
    /// Block & extrinsics weights: base values and limits.
350
    type BlockWeights = RuntimeBlockWeights;
351
    /// The maximum length of a block (in bytes).
352
    type BlockLength = RuntimeBlockLength;
353
    /// This is used as an identifier of the chain. 42 is the generic substrate prefix.
354
    type SS58Prefix = SS58Prefix;
355
    /// The action to take on a Runtime Upgrade
356
    type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
357
    type MaxConsumers = frame_support::traits::ConstU32<16>;
358
    type RuntimeTask = RuntimeTask;
359
    type SingleBlockMigrations = ();
360
    type MultiBlockMigrator = ();
361
    type PreInherents = ();
362
    type PostInherents = ();
363
    type PostTransactions = ();
364
}
365

            
366
parameter_types! {
367
    pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
368
}
369

            
370
impl pallet_balances::Config for Runtime {
371
    type MaxLocks = ConstU32<50>;
372
    /// The type for recording an account's balance.
373
    type Balance = Balance;
374
    /// The ubiquitous event type.
375
    type RuntimeEvent = RuntimeEvent;
376
    type DustRemoval = ();
377
    type ExistentialDeposit = ExistentialDeposit;
378
    type AccountStore = System;
379
    type MaxReserves = ConstU32<50>;
380
    type ReserveIdentifier = [u8; 8];
381
    type FreezeIdentifier = RuntimeFreezeReason;
382
    type MaxFreezes = ConstU32<0>;
383
    type RuntimeHoldReason = RuntimeHoldReason;
384
    type RuntimeFreezeReason = RuntimeFreezeReason;
385
    type WeightInfo = weights::pallet_balances::SubstrateWeight<Runtime>;
386
}
387

            
388
parameter_types! {
389
    pub const TransactionByteFee: Balance = 1;
390
}
391

            
392
impl pallet_transaction_payment::Config for Runtime {
393
    type RuntimeEvent = RuntimeEvent;
394
    // This will burn the fees
395
    type OnChargeTransaction = FungibleAdapter<Balances, ()>;
396
    type OperationalFeeMultiplier = ConstU8<5>;
397
    type WeightToFee = WeightToFee;
398
    type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
399
    type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
400
}
401

            
402
parameter_types! {
403
    pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
404
    pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
405
    pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
406
}
407

            
408
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
409
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
410
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
411

            
412
type ConsensusHook = pallet_async_backing::consensus_hook::FixedVelocityConsensusHook<
413
    Runtime,
414
    BLOCK_PROCESSING_VELOCITY,
415
    UNINCLUDED_SEGMENT_CAPACITY,
416
>;
417

            
418
impl cumulus_pallet_parachain_system::Config for Runtime {
419
    type WeightInfo = weights::cumulus_pallet_parachain_system::SubstrateWeight<Runtime>;
420
    type RuntimeEvent = RuntimeEvent;
421
    type OnSystemEvent = ();
422
    type OutboundXcmpMessageSource = XcmpQueue;
423
    type SelfParaId = parachain_info::Pallet<Runtime>;
424
    type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
425
    type ReservedDmpWeight = ReservedDmpWeight;
426
    type XcmpMessageHandler = XcmpQueue;
427
    type ReservedXcmpWeight = ReservedXcmpWeight;
428
    type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
429
    type ConsensusHook = ConsensusHook;
430
}
431

            
432
pub struct ParaSlotProvider;
433
impl sp_core::Get<(Slot, SlotDuration)> for ParaSlotProvider {
434
114
    fn get() -> (Slot, SlotDuration) {
435
114
        let slot = u64::from(<Runtime as pallet_author_inherent::Config>::SlotBeacon::slot());
436
114
        (Slot::from(slot), SlotDuration::from_millis(SLOT_DURATION))
437
114
    }
438
}
439

            
440
parameter_types! {
441
    pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK;
442
}
443

            
444
impl pallet_async_backing::Config for Runtime {
445
    type AllowMultipleBlocksPerSlot = ConstBool<true>;
446
    type GetAndVerifySlot =
447
        pallet_async_backing::ParaSlot<RELAY_CHAIN_SLOT_DURATION_MILLIS, ParaSlotProvider>;
448
    type ExpectedBlockTime = ExpectedBlockTime;
449
}
450

            
451
impl parachain_info::Config for Runtime {}
452

            
453
parameter_types! {
454
    pub const Period: u32 = 6 * HOURS;
455
    pub const Offset: u32 = 0;
456
}
457

            
458
impl pallet_sudo::Config for Runtime {
459
    type RuntimeCall = RuntimeCall;
460
    type RuntimeEvent = RuntimeEvent;
461
    type WeightInfo = weights::pallet_sudo::SubstrateWeight<Runtime>;
462
}
463

            
464
impl pallet_utility::Config for Runtime {
465
    type RuntimeEvent = RuntimeEvent;
466
    type RuntimeCall = RuntimeCall;
467
    type PalletsOrigin = OriginCaller;
468
    type WeightInfo = weights::pallet_utility::SubstrateWeight<Runtime>;
469
}
470

            
471
/// The type used to represent the kinds of proxying allowed.
472
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
473
#[derive(
474
    Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, MaxEncodedLen, TypeInfo,
475
)]
476
#[allow(clippy::unnecessary_cast)]
477
pub enum ProxyType {
478
    /// All calls can be proxied. This is the trivial/most permissive filter.
479
    Any = 0,
480
    /// Only extrinsics that do not transfer funds.
481
    NonTransfer = 1,
482
    /// Only extrinsics related to governance (democracy and collectives).
483
    Governance = 2,
484
    /// Allow to veto an announced proxy call.
485
    CancelProxy = 3,
486
    /// Allow extrinsic related to Balances.
487
    Balances = 4,
488
}
489

            
490
impl Default for ProxyType {
491
    fn default() -> Self {
492
        Self::Any
493
    }
494
}
495

            
496
impl InstanceFilter<RuntimeCall> for ProxyType {
497
    fn filter(&self, c: &RuntimeCall) -> bool {
498
        // Since proxy filters are respected in all dispatches of the Utility
499
        // pallet, it should never need to be filtered by any proxy.
500
        if let RuntimeCall::Utility(..) = c {
501
            return true;
502
        }
503

            
504
        match self {
505
            ProxyType::Any => true,
506
            ProxyType::NonTransfer => {
507
                matches!(
508
                    c,
509
                    RuntimeCall::System(..)
510
                        | RuntimeCall::ParachainSystem(..)
511
                        | RuntimeCall::Timestamp(..)
512
                        | RuntimeCall::Proxy(..)
513
                )
514
            }
515
            // We don't have governance yet
516
            ProxyType::Governance => false,
517
            ProxyType::CancelProxy => matches!(
518
                c,
519
                RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })
520
            ),
521
            ProxyType::Balances => {
522
                matches!(c, RuntimeCall::Balances(..))
523
            }
524
        }
525
    }
526

            
527
    fn is_superset(&self, o: &Self) -> bool {
528
        match (self, o) {
529
            (x, y) if x == y => true,
530
            (ProxyType::Any, _) => true,
531
            (_, ProxyType::Any) => false,
532
            _ => false,
533
        }
534
    }
535
}
536

            
537
impl pallet_proxy::Config for Runtime {
538
    type RuntimeEvent = RuntimeEvent;
539
    type RuntimeCall = RuntimeCall;
540
    type Currency = Balances;
541
    type ProxyType = ProxyType;
542
    // One storage item; key size 32, value size 8
543
    type ProxyDepositBase = ConstU128<{ deposit(1, 8) }>;
544
    // Additional storage item size of 33 bytes (32 bytes AccountId + 1 byte sizeof(ProxyType)).
545
    type ProxyDepositFactor = ConstU128<{ deposit(0, 33) }>;
546
    type MaxProxies = ConstU32<32>;
547
    type MaxPending = ConstU32<32>;
548
    type CallHasher = BlakeTwo256;
549
    type AnnouncementDepositBase = ConstU128<{ deposit(1, 8) }>;
550
    // Additional storage item size of 68 bytes:
551
    // - 32 bytes AccountId
552
    // - 32 bytes Hasher (Blake2256)
553
    // - 4 bytes BlockNumber (u32)
554
    type AnnouncementDepositFactor = ConstU128<{ deposit(0, 68) }>;
555
    type WeightInfo = weights::pallet_proxy::SubstrateWeight<Runtime>;
556
}
557

            
558
pub struct XcmExecutionManager;
559
impl xcm_primitives::PauseXcmExecution for XcmExecutionManager {
560
    fn suspend_xcm_execution() -> DispatchResult {
561
        XcmpQueue::suspend_xcm_execution(RuntimeOrigin::root())
562
    }
563
    fn resume_xcm_execution() -> DispatchResult {
564
        XcmpQueue::resume_xcm_execution(RuntimeOrigin::root())
565
    }
566
}
567

            
568
impl pallet_migrations::Config for Runtime {
569
    type RuntimeEvent = RuntimeEvent;
570
    type MigrationsList = (migrations::TemplateMigrations<Runtime, XcmpQueue, PolkadotXcm>,);
571
    type XcmExecutionManager = XcmExecutionManager;
572
}
573

            
574
/// Maintenance mode Call filter
575
pub struct MaintenanceFilter;
576
impl Contains<RuntimeCall> for MaintenanceFilter {
577
    fn contains(c: &RuntimeCall) -> bool {
578
        !matches!(c, RuntimeCall::Balances(_) | RuntimeCall::PolkadotXcm(_))
579
    }
580
}
581

            
582
/// Normal Call Filter
583
/// We dont allow to create nor mint assets, this for now is disabled
584
/// We only allow transfers. For now creation of assets will go through
585
/// asset-manager, while minting/burning only happens through xcm messages
586
/// This can change in the future
587
pub struct NormalFilter;
588
impl Contains<RuntimeCall> for NormalFilter {
589
    fn contains(_c: &RuntimeCall) -> bool {
590
        true
591
    }
592
}
593

            
594
impl pallet_maintenance_mode::Config for Runtime {
595
    type RuntimeEvent = RuntimeEvent;
596
    type NormalCallFilter = NormalFilter;
597
    type MaintenanceCallFilter = MaintenanceFilter;
598
    type MaintenanceOrigin = EnsureRoot<AccountId>;
599
    type XcmExecutionManager = XcmExecutionManager;
600
}
601

            
602
impl pallet_root_testing::Config for Runtime {
603
    type RuntimeEvent = RuntimeEvent;
604
}
605

            
606
impl pallet_tx_pause::Config for Runtime {
607
    type RuntimeEvent = RuntimeEvent;
608
    type RuntimeCall = RuntimeCall;
609
    type PauseOrigin = EnsureRoot<AccountId>;
610
    type UnpauseOrigin = EnsureRoot<AccountId>;
611
    type WhitelistedCalls = ();
612
    type MaxNameLen = ConstU32<256>;
613
    type WeightInfo = weights::pallet_tx_pause::SubstrateWeight<Runtime>;
614
}
615

            
616
impl dp_impl_tanssi_pallets_config::Config for Runtime {
617
    const SLOT_DURATION: u64 = SLOT_DURATION;
618
    type TimestampWeights = weights::pallet_timestamp::SubstrateWeight<Runtime>;
619
    type AuthorInherentWeights = weights::pallet_author_inherent::SubstrateWeight<Runtime>;
620
    type AuthoritiesNotingWeights = weights::pallet_cc_authorities_noting::SubstrateWeight<Runtime>;
621
}
622

            
623
parameter_types! {
624
    // One storage item; key size 32; value is size 4+4+16+32. Total = 1 * (32 + 56)
625
    pub const DepositBase: Balance = currency::deposit(1, 88);
626
    // Additional storage item size of 32 bytes.
627
    pub const DepositFactor: Balance = currency::deposit(0, 32);
628
    pub const MaxSignatories: u32 = 100;
629
}
630

            
631
impl pallet_multisig::Config for Runtime {
632
    type RuntimeEvent = RuntimeEvent;
633
    type RuntimeCall = RuntimeCall;
634
    type Currency = Balances;
635
    type DepositBase = DepositBase;
636
    type DepositFactor = DepositFactor;
637
    type MaxSignatories = MaxSignatories;
638
    type WeightInfo = weights::pallet_multisig::SubstrateWeight<Runtime>;
639
}
640

            
641
impl_tanssi_pallets_config!(Runtime);
642

            
643
// Create the runtime by composing the FRAME pallets that were previously configured.
644
22492
construct_runtime!(
645
3284
    pub enum Runtime
646
3284
    {
647
3284
        // System support stuff.
648
3284
        System: frame_system = 0,
649
3284
        ParachainSystem: cumulus_pallet_parachain_system = 1,
650
3284
        Timestamp: pallet_timestamp = 2,
651
3284
        ParachainInfo: parachain_info = 3,
652
3284
        Sudo: pallet_sudo = 4,
653
3284
        Utility: pallet_utility = 5,
654
3284
        Proxy: pallet_proxy = 6,
655
3284
        Migrations: pallet_migrations = 7,
656
3284
        MaintenanceMode: pallet_maintenance_mode = 8,
657
3284
        TxPause: pallet_tx_pause = 9,
658
3284

            
659
3284
        // Monetary stuff.
660
3284
        Balances: pallet_balances = 10,
661
3284
        TransactionPayment: pallet_transaction_payment = 11,
662
3284

            
663
3284
        // Other utilities
664
3284
        Multisig: pallet_multisig = 16,
665
3284

            
666
3284
        // ContainerChain Author Verification
667
3284
        AuthoritiesNoting: pallet_cc_authorities_noting = 50,
668
3284
        AuthorInherent: pallet_author_inherent = 51,
669
3284

            
670
3284
        // XCM
671
3284
        XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Storage, Event<T>} = 70,
672
3284
        CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 71,
673
3284
        DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 72,
674
3284
        PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 73,
675
3284
        MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 74,
676
3284
        ForeignAssets: pallet_assets::<Instance1>::{Pallet, Call, Storage, Event<T>} = 75,
677
3284
        ForeignAssetsCreator: pallet_foreign_asset_creator::{Pallet, Call, Storage, Event<T>} = 76,
678
3284
        AssetRate: pallet_asset_rate::{Pallet, Call, Storage, Event<T>} = 77,
679
3284
        XcmExecutorUtils: pallet_xcm_executor_utils::{Pallet, Call, Storage, Event<T>} = 78,
680
3284

            
681
3284
        RootTesting: pallet_root_testing = 100,
682
3284
        AsyncBacking: pallet_async_backing::{Pallet, Storage} = 110,
683
3284

            
684
3284
    }
685
22492
);
686

            
687
#[cfg(feature = "runtime-benchmarks")]
688
mod benches {
689
    frame_benchmarking::define_benchmarks!(
690
        [frame_system, frame_system_benchmarking::Pallet::<Runtime>]
691
        [cumulus_pallet_parachain_system, ParachainSystem]
692
        [pallet_timestamp, Timestamp]
693
        [pallet_sudo, Sudo]
694
        [pallet_utility, Utility]
695
        [pallet_proxy, Proxy]
696
        [pallet_tx_pause, TxPause]
697
        [pallet_balances, Balances]
698
        [pallet_multisig, Multisig]
699
        [pallet_cc_authorities_noting, AuthoritiesNoting]
700
        [pallet_author_inherent, AuthorInherent]
701
        [cumulus_pallet_xcmp_queue, XcmpQueue]
702
        [cumulus_pallet_dmp_queue, DmpQueue]
703
        [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
704
        [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
705
        [pallet_message_queue, MessageQueue]
706
        [pallet_assets, ForeignAssets]
707
        [pallet_foreign_asset_creator, ForeignAssetsCreator]
708
        [pallet_asset_rate, AssetRate]
709
        [pallet_xcm_executor_utils, XcmExecutorUtils]
710
    );
711
}
712

            
713
6532
impl_runtime_apis! {
714
4450
    impl sp_api::Core<Block> for Runtime {
715
4450
        fn version() -> RuntimeVersion {
716
            VERSION
717
        }
718
4450

            
719
4450
        fn execute_block(block: Block) {
720
            Executive::execute_block(block)
721
        }
722
4450

            
723
4450
        fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
724
            Executive::initialize_block(header)
725
        }
726
4450
    }
727
4450

            
728
4450
    impl sp_api::Metadata<Block> for Runtime {
729
4450
        fn metadata() -> OpaqueMetadata {
730
            OpaqueMetadata::new(Runtime::metadata().into())
731
        }
732
4450

            
733
4450
        fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
734
            Runtime::metadata_at_version(version)
735
        }
736
4450

            
737
4450
        fn metadata_versions() -> Vec<u32> {
738
            Runtime::metadata_versions()
739
        }
740
4450
    }
741
4450

            
742
4450
    impl sp_block_builder::BlockBuilder<Block> for Runtime {
743
4450
        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
744
            Executive::apply_extrinsic(extrinsic)
745
        }
746
4450

            
747
4450
        fn finalize_block() -> <Block as BlockT>::Header {
748
            Executive::finalize_block()
749
        }
750
4450

            
751
4450
        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
752
            data.create_extrinsics()
753
        }
754
4450

            
755
4450
        fn check_inherents(
756
            block: Block,
757
            data: sp_inherents::InherentData,
758
        ) -> sp_inherents::CheckInherentsResult {
759
            data.check_extrinsics(&block)
760
        }
761
4450
    }
762
4450

            
763
4450
    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
764
4450
        fn validate_transaction(
765
            source: TransactionSource,
766
            tx: <Block as BlockT>::Extrinsic,
767
            block_hash: <Block as BlockT>::Hash,
768
        ) -> TransactionValidity {
769
            Executive::validate_transaction(source, tx, block_hash)
770
        }
771
4450
    }
772
4450

            
773
4450
    impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
774
4450
        fn offchain_worker(header: &<Block as BlockT>::Header) {
775
            Executive::offchain_worker(header)
776
        }
777
4450
    }
778
4450

            
779
4450
    impl sp_session::SessionKeys<Block> for Runtime {
780
4450
        fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
781
            SessionKeys::generate(seed)
782
        }
783
4450

            
784
4450
        fn decode_session_keys(
785
            encoded: Vec<u8>,
786
        ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
787
            SessionKeys::decode_into_raw_public_keys(&encoded)
788
        }
789
4450
    }
790
4450

            
791
4450
    impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
792
4450
        fn account_nonce(account: AccountId) -> Index {
793
            System::account_nonce(account)
794
        }
795
4450
    }
796
4450

            
797
4450
    impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
798
4450
        fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
799
            ParachainSystem::collect_collation_info(header)
800
        }
801
4450
    }
802
4450

            
803
4450
    impl async_backing_primitives::UnincludedSegmentApi<Block> for Runtime {
804
4450
        fn can_build_upon(
805
            included_hash: <Block as BlockT>::Hash,
806
            slot: async_backing_primitives::Slot,
807
        ) -> bool {
808
            ConsensusHook::can_build_upon(included_hash, slot)
809
        }
810
4450
    }
811
4450

            
812
4450
    impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
813
4450
        fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
814
            build_state::<RuntimeGenesisConfig>(config)
815
        }
816
4450

            
817
4450
        fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
818
            get_preset::<RuntimeGenesisConfig>(id, |_| None)
819
        }
820
4450
        fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
821
            vec![]
822
        }
823
4450
    }
824
4450

            
825
4450
    #[cfg(feature = "runtime-benchmarks")]
826
4450
    impl frame_benchmarking::Benchmark<Block> for Runtime {
827
4450
        fn benchmark_metadata(
828
4450
            extra: bool,
829
4450
        ) -> (
830
4450
            Vec<frame_benchmarking::BenchmarkList>,
831
4450
            Vec<frame_support::traits::StorageInfo>,
832
4450
        ) {
833
4450
            use frame_benchmarking::{Benchmarking, BenchmarkList};
834
4450
            use frame_support::traits::StorageInfoTrait;
835
4450
            use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
836
4450

            
837
4450
            let mut list = Vec::<BenchmarkList>::new();
838
4450
            list_benchmarks!(list, extra);
839
4450

            
840
4450
            let storage_info = AllPalletsWithSystem::storage_info();
841
4450
            (list, storage_info)
842
4450
        }
843
4450

            
844
4450
        fn dispatch_benchmark(
845
4450
            config: frame_benchmarking::BenchmarkConfig,
846
4450
        ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
847
4450
            use frame_benchmarking::{BenchmarkBatch, Benchmarking, BenchmarkError};
848
4450
            use sp_core::storage::TrackedStorageKey;
849
4450
            use staging_xcm::latest::prelude::*;
850
4450
            impl frame_system_benchmarking::Config for Runtime {
851
4450
                fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
852
4450
                    ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
853
4450
                    Ok(())
854
4450
                }
855
4450

            
856
4450
                fn verify_set_code() {
857
4450
                    System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
858
4450
                }
859
4450
            }
860
4450
            use crate::xcm_config::SelfReserve;
861
4450
            parameter_types! {
862
4450
                pub ExistentialDepositAsset: Option<Asset> = Some((
863
4450
                    SelfReserve::get(),
864
4450
                    ExistentialDeposit::get()
865
4450
                ).into());
866
4450
            }
867
4450

            
868
4450
            impl pallet_xcm_benchmarks::Config for Runtime {
869
4450
                type XcmConfig = xcm_config::XcmConfig;
870
4450
                type AccountIdConverter = xcm_config::LocationToAccountId;
871
4450
                type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
872
4450
                xcm_config::XcmConfig,
873
4450
                ExistentialDepositAsset,
874
4450
                xcm_config::PriceForParentDelivery,
875
4450
                >;
876
4450
                fn valid_destination() -> Result<Location, BenchmarkError> {
877
4450
                    Ok(Location::parent())
878
4450
                }
879
4450
                fn worst_case_holding(_depositable_count: u32) -> Assets {
880
4450
                    // We only care for native asset until we support others
881
4450
                    // TODO: refactor this case once other assets are supported
882
4450
                    vec![Asset{
883
4450
                        id: AssetId(SelfReserve::get()),
884
4450
                        fun: Fungible(u128::MAX),
885
4450
                    }].into()
886
4450
                }
887
4450
            }
888
4450

            
889
4450
            impl pallet_xcm_benchmarks::generic::Config for Runtime {
890
4450
                type TransactAsset = Balances;
891
4450
                type RuntimeCall = RuntimeCall;
892
4450

            
893
4450
                fn worst_case_response() -> (u64, Response) {
894
4450
                    (0u64, Response::Version(Default::default()))
895
4450
                }
896
4450

            
897
4450
                fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
898
4450
                    Err(BenchmarkError::Skip)
899
4450
                }
900
4450

            
901
4450
                fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
902
4450
                    Err(BenchmarkError::Skip)
903
4450
                }
904
4450

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

            
909
4450
                fn subscribe_origin() -> Result<Location, BenchmarkError> {
910
4450
                    Ok(Location::parent())
911
4450
                }
912
4450

            
913
4450
                fn fee_asset() -> Result<Asset, BenchmarkError> {
914
4450
                    Ok(Asset {
915
4450
                        id: AssetId(SelfReserve::get()),
916
4450
                        fun: Fungible(ExistentialDeposit::get()*100),
917
4450
                    })
918
4450
                }
919
4450

            
920
4450
                fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
921
4450
                    let origin = Location::parent();
922
4450
                    let assets: Assets = (Location::parent(), 1_000u128).into();
923
4450
                    let ticket = Location { parents: 0, interior: Here };
924
4450
                    Ok((origin, ticket, assets))
925
4450
                }
926
4450

            
927
4450
                fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
928
4450
                    Err(BenchmarkError::Skip)
929
4450
                }
930
4450

            
931
4450
                fn export_message_origin_and_destination(
932
4450
                ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
933
4450
                    Err(BenchmarkError::Skip)
934
4450
                }
935
4450

            
936
4450
                fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
937
4450
                    Err(BenchmarkError::Skip)
938
4450
                }
939
4450
            }
940
4450

            
941
4450
            use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
942
4450
            impl pallet_xcm::benchmarking::Config for Runtime {
943
4450
                type DeliveryHelper = ();
944
4450
                fn get_asset() -> Asset {
945
4450
                    Asset {
946
4450
                        id: AssetId(SelfReserve::get()),
947
4450
                        fun: Fungible(ExistentialDeposit::get()),
948
4450
                    }
949
4450
                }
950
4450

            
951
4450
                fn reachable_dest() -> Option<Location> {
952
4450
                    Some(Parent.into())
953
4450
                }
954
4450

            
955
4450
                fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
956
4450
                    // Relay/native token can be teleported between AH and Relay.
957
4450
                    Some((
958
4450
                        Asset {
959
4450
                            fun: Fungible(EXISTENTIAL_DEPOSIT),
960
4450
                            id: Parent.into()
961
4450
                        },
962
4450
                        Parent.into(),
963
4450
                    ))
964
4450
                }
965
4450

            
966
4450
                fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
967
4450
                    use xcm_config::SelfReserve;
968
4450
                    // AH can reserve transfer native token to some random parachain.
969
4450
                    let random_para_id = 43211234;
970
4450
                    ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
971
4450
                        random_para_id.into()
972
4450
                    );
973
4450
                    let who = frame_benchmarking::whitelisted_caller();
974
4450
                    // Give some multiple of the existential deposit
975
4450
                    let balance = EXISTENTIAL_DEPOSIT * 1000;
976
4450
                    let _ = <Balances as frame_support::traits::Currency<_>>::make_free_balance_be(
977
4450
                        &who, balance,
978
4450
                    );
979
4450
                    Some((
980
4450
                        Asset {
981
4450
                            fun: Fungible(EXISTENTIAL_DEPOSIT*10),
982
4450
                            id: SelfReserve::get().into()
983
4450
                        },
984
4450
                        ParentThen(Parachain(random_para_id).into()).into(),
985
4450
                    ))
986
4450
                }
987
4450

            
988
4450
                fn set_up_complex_asset_transfer(
989
4450
                ) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
990
4450
                    use xcm_config::SelfReserve;
991
4450
                    // Transfer to Relay some local AH asset (local-reserve-transfer) while paying
992
4450
                    // fees using teleported native token.
993
4450
                    // (We don't care that Relay doesn't accept incoming unknown AH local asset)
994
4450
                    let dest = Parent.into();
995
4450

            
996
4450
                    let fee_amount = EXISTENTIAL_DEPOSIT;
997
4450
                    let fee_asset: Asset = (SelfReserve::get(), fee_amount).into();
998
4450

            
999
4450
                    let who = frame_benchmarking::whitelisted_caller();
4450
                    // Give some multiple of the existential deposit
4450
                    let balance = fee_amount + EXISTENTIAL_DEPOSIT * 1000;
4450
                    let _ = <Balances as frame_support::traits::Currency<_>>::make_free_balance_be(
4450
                        &who, balance,
4450
                    );
4450

            
4450
                    // verify initial balance
4450
                    assert_eq!(Balances::free_balance(&who), balance);
4450

            
4450
                    // set up local asset
4450
                    let asset_amount = 10u128;
4450
                    let initial_asset_amount = asset_amount * 10;
4450

            
4450
                    let (asset_id, asset_location) = pallet_foreign_asset_creator::benchmarks::create_default_minted_asset::<Runtime>(
4450
                        initial_asset_amount,
4450
                        who.clone()
4450
                    );
4450

            
4450
                    let transfer_asset: Asset = (asset_location, asset_amount).into();
4450

            
4450
                    let assets: Assets = vec![fee_asset.clone(), transfer_asset].into();
4450
                    let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 };
4450

            
4450
                    // verify transferred successfully
4450
                    let verify = Box::new(move || {
4450
                        // verify native balance after transfer, decreased by transferred fee amount
4450
                        // (plus transport fees)
4450
                        assert!(Balances::free_balance(&who) <= balance - fee_amount);
4450
                        // verify asset balance decreased by exactly transferred amount
4450
                        assert_eq!(
4450
                            ForeignAssets::balance(asset_id, &who),
4450
                            initial_asset_amount - asset_amount,
4450
                        );
4450
                    });
4450
                    Some((assets, fee_index as u32, dest, verify))
4450
                }
4450
            }
4450

            
4450
            let whitelist: Vec<TrackedStorageKey> = vec![
4450
                // Block Number
4450
                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
4450
                    .to_vec()
4450
                    .into(),
4450
                // Total Issuance
4450
                hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80")
4450
                    .to_vec()
4450
                    .into(),
4450
                // Execution Phase
4450
                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a")
4450
                    .to_vec()
4450
                    .into(),
4450
                // Event Count
4450
                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850")
4450
                    .to_vec()
4450
                    .into(),
4450
                // System Events
4450
                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7")
4450
                    .to_vec()
4450
                    .into(),
4450
                // The transactional storage limit.
4450
                hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a")
4450
                    .to_vec()
4450
                    .into(),
4450

            
4450
                // ParachainInfo ParachainId
4450
                hex_literal::hex!(  "0d715f2646c8f85767b5d2764bb2782604a74d81251e398fd8a0a4d55023bb3f")
4450
                    .to_vec()
4450
                    .into(),
4450
            ];
4450

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

            
4450
            add_benchmarks!(params, batches);
4450

            
4450
            Ok(batches)
4450
        }
4450
    }
4450

            
4450
    #[cfg(feature = "try-runtime")]
4450
    impl frame_try_runtime::TryRuntime<Block> for Runtime {
4450
        fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
4450
            let weight = Executive::try_runtime_upgrade(checks).unwrap();
4450
            (weight, RuntimeBlockWeights::get().max_block)
4450
        }
4450

            
4450
        fn execute_block(
4450
            block: Block,
4450
            state_root_check: bool,
4450
            signature_check: bool,
4450
            select: frame_try_runtime::TryStateSelect,
4450
        ) -> Weight {
4450
            // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
4450
            // have a backtrace here.
4450
            Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
4450
        }
4450
    }
4450

            
4450
    impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
4450
    for Runtime {
4450
        fn query_info(
            uxt: <Block as BlockT>::Extrinsic,
            len: u32,
        ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
            TransactionPayment::query_info(uxt, len)
        }
4450

            
4450
        fn query_fee_details(
            uxt: <Block as BlockT>::Extrinsic,
            len: u32,
        ) -> pallet_transaction_payment::FeeDetails<Balance> {
            TransactionPayment::query_fee_details(uxt, len)
        }
4450

            
4450
        fn query_weight_to_fee(weight: Weight) -> Balance {
            TransactionPayment::weight_to_fee(weight)
        }
4450

            
4450
        fn query_length_to_fee(length: u32) -> Balance {
            TransactionPayment::length_to_fee(length)
        }
4450
    }
4450

            
4450
    impl dp_slot_duration_runtime_api::TanssiSlotDurationApi<Block> for Runtime {
4450
        fn slot_duration() -> u64 {
            SLOT_DURATION
        }
4450
    }
6532
}
#[allow(dead_code)]
struct CheckInherents;
#[allow(deprecated)]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
    fn check_inherents(
        block: &Block,
        relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
    ) -> sp_inherents::CheckInherentsResult {
        let relay_chain_slot = relay_state_proof
            .read_slot()
            .expect("Could not read the relay chain slot from the proof");
        let inherent_data =
            cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(
                relay_chain_slot,
                sp_std::time::Duration::from_secs(6),
            )
            .create_inherent_data()
            .expect("Could not create the timestamp inherent data");
        inherent_data.check_extrinsics(block)
    }
}
cumulus_pallet_parachain_system::register_validate_block! {
    Runtime = Runtime,
    CheckInherents = CheckInherents,
    BlockExecutor = pallet_author_inherent::BlockExecutor::<Runtime, Executive>,
}