From dfd3def67640d66d75b5a232b98b886e39f7cc86 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Sun, 11 Aug 2024 17:30:01 +0200 Subject: [PATCH] add teerdays pallet --- Cargo.lock | 83 +- Cargo.toml | 3 + polkadot-parachains/common/src/lib.rs | 170 +-- .../integritee-runtime/Cargo.toml | 3 + .../integritee-runtime/src/lib.rs | 1059 +++++++++-------- .../integritee-runtime/src/weights/mod.rs | 1 + .../src/weights/pallet_teerdays.rs | 105 ++ 7 files changed, 797 insertions(+), 627 deletions(-) create mode 100644 polkadot-parachains/integritee-runtime/src/weights/pallet_teerdays.rs diff --git a/Cargo.lock b/Cargo.lock index a56d19f4..9d547690 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1193,7 +1193,7 @@ dependencies = [ [[package]] name = "claims-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "parity-scale-codec", "rustc-hex", @@ -1335,7 +1335,7 @@ checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" [[package]] name = "common-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "derive_more", "parity-scale-codec", @@ -2841,7 +2841,7 @@ dependencies = [ [[package]] name = "enclave-bridge-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "common-primitives", "log", @@ -4288,7 +4288,7 @@ dependencies = [ [[package]] name = "integritee-collator" -version = "1.13.0" +version = "1.13.1" dependencies = [ "assert_cmd", "async-trait", @@ -4395,7 +4395,7 @@ dependencies = [ [[package]] name = "integritee-runtime" -version = "1.13.530" +version = "1.13.540" dependencies = [ "assets-common", "cumulus-pallet-aura-ext", @@ -4446,6 +4446,7 @@ dependencies = [ "pallet-session", "pallet-sidechain", "pallet-teeracle", + "pallet-teerdays", "pallet-teerex", "pallet-timestamp", "pallet-transaction-payment", @@ -6551,7 +6552,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" version = "0.0.1" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "frame-benchmarking", "frame-support", @@ -6826,7 +6827,7 @@ dependencies = [ [[package]] name = "pallet-claims" version = "0.9.12" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "claims-primitives", "frame-benchmarking", @@ -6996,7 +6997,7 @@ dependencies = [ [[package]] name = "pallet-enclave-bridge" version = "0.12.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "enclave-bridge-primitives", "frame-benchmarking", @@ -7496,7 +7497,7 @@ dependencies = [ [[package]] name = "pallet-sidechain" version = "0.11.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "enclave-bridge-primitives", "frame-benchmarking", @@ -7634,17 +7635,19 @@ dependencies = [ [[package]] name = "pallet-teeracle" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "hex-literal", "log", + "pallet-aura", "pallet-teerex", "pallet-timestamp", "parity-scale-codec", "scale-info", + "sp-consensus-aura", "sp-core", "sp-io", "sp-runtime", @@ -7655,10 +7658,32 @@ dependencies = [ "test-utils", ] +[[package]] +name = "pallet-teerdays" +version = "0.1.0" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "hex-literal", + "log", + "pallet-balances", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "teerdays-primitives", +] + [[package]] name = "pallet-teerex" version = "0.10.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "frame-benchmarking", "frame-support", @@ -7666,6 +7691,7 @@ dependencies = [ "hex", "hex-literal", "log", + "pallet-aura", "pallet-balances", "pallet-timestamp", "parity-scale-codec", @@ -7673,6 +7699,7 @@ dependencies = [ "scale-info", "serde", "sgx-verify", + "sp-consensus-aura", "sp-core", "sp-io", "sp-runtime", @@ -7886,7 +7913,7 @@ dependencies = [ [[package]] name = "pallet-xcm-transactor" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "cumulus-primitives-core", "frame-benchmarking", @@ -7942,8 +7969,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e69bf016dc406eff7d53a7d3f7cf1c2e72c82b9088aac1118591e36dd2cd3e9" dependencies = [ "bitcoin_hashes 0.13.0", - "rand 0.8.5", - "rand_core 0.6.4", + "rand 0.7.3", + "rand_core 0.5.1", "serde", "unicode-normalization", ] @@ -12283,7 +12310,7 @@ dependencies = [ [[package]] name = "sgx-verify" version = "0.1.4" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "base64 0.13.1", "chrono", @@ -12462,7 +12489,7 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "sidechain-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "parity-scale-codec", "scale-info", @@ -14004,17 +14031,29 @@ checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" [[package]] name = "teeracle-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "common-primitives", "sp-std", "substrate-fixed", ] +[[package]] +name = "teerdays-primitives" +version = "0.1.0" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-runtime", +] + [[package]] name = "teerex-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "common-primitives", "derive_more", @@ -14068,7 +14107,7 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test-utils" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "log", "sgx-verify", @@ -14721,7 +14760,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] @@ -15913,7 +15952,7 @@ dependencies = [ [[package]] name = "xcm-primitives" version = "0.0.1" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "frame-support", "sp-runtime", @@ -15937,7 +15976,7 @@ dependencies = [ [[package]] name = "xcm-transactor-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#98389472ef524fa9cacb57f9e9095e1fb67b9216" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.13.0#6df6036090dcc1d6513e3cfcb6e16cc5a6b74613" dependencies = [ "common-primitives", "cumulus-primitives-core", diff --git a/Cargo.toml b/Cargo.toml index 079693fc..af89e293 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ pallet-claims = { default-features = false, git = "https://github.com/integritee pallet-enclave-bridge = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.13.0" } pallet-sidechain = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.13.0" } pallet-teeracle = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.13.0" } +pallet-teerdays = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.13.0" } pallet-teerex = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.13.0" } pallet-xcm-transactor = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.13.0" } xcm-primitives = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.13.0" } @@ -178,10 +179,12 @@ substrate-wasm-builder = "23.0.0" #pallet-enclave-bridge = { path = '../pallets/enclave-bridge' } #pallet-sidechain = { path = '../pallets/sidechain' } #pallet-teeracle = { path = '../pallets/teeracle' } +#pallet-teerdays = { path = '../pallets/teerdays' } #pallet-teerex = { path = '../pallets/teerex' } #pallet-xcm-transactor = { path = '../pallets/xcm-transactor' } #sgx-verify = { path = '../pallets/teerex/sgx-verify' } #teeracle-primitives = { path = '../pallets/primitives/teeracle' } +#teerdays-primitives = { path = '../pallets/primitives/teerdays' } #teerex-primitives = { path = '../pallets/primitives/teerex' } #test-utils = { path = '../pallets/test-utils' } #xcm-primitives = { path = '../pallets/primitives/xcm' } diff --git a/polkadot-parachains/common/src/lib.rs b/polkadot-parachains/common/src/lib.rs index 085497d3..70f4e2f1 100644 --- a/polkadot-parachains/common/src/lib.rs +++ b/polkadot-parachains/common/src/lib.rs @@ -29,89 +29,95 @@ pub use types::*; /// Common types of parachains. mod types { - use sp_runtime::{ - generic, - traits::{BlakeTwo256, IdentifyAccount, Verify}, - }; + use sp_runtime::{ + generic, + traits::{BlakeTwo256, IdentifyAccount, Verify}, + }; - /// An index to a block. - pub type BlockNumber = u32; + /// An index to a block. + pub type BlockNumber = u32; - /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. - pub type Signature = sp_runtime::MultiSignature; + /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. + pub type Signature = sp_runtime::MultiSignature; - /// Some way of identifying an account on the chain. We intentionally make it equivalent - /// to the public key of our transaction signing scheme. - pub type AccountId = <::Signer as IdentifyAccount>::AccountId; + /// Some way of identifying an account on the chain. We intentionally make it equivalent + /// to the public key of our transaction signing scheme. + pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - /// The type for looking up accounts. We don't expect more than 4 billion of them, but you - /// never know... - pub type AccountIndex = u32; + /// The type for looking up accounts. We don't expect more than 4 billion of them, but you + /// never know... + pub type AccountIndex = u32; - /// Balance of an account. - pub type Balance = u128; + /// Balance of an account. + pub type Balance = u128; - /// Nonce of a transaction in the chain. - pub type Nonce = u32; + /// Nonce of a transaction in the chain. + pub type Nonce = u32; - /// A hash of some data used by the chain. - pub type Hash = sp_core::H256; + /// A hash of some data used by the chain. + pub type Hash = sp_core::H256; - /// Digest item type. - pub type DigestItem = sp_runtime::generic::DigestItem; + /// Digest item type. + pub type DigestItem = sp_runtime::generic::DigestItem; - // Aura consensus authority. - pub type AuraId = sp_consensus_aura::sr25519::AuthorityId; + // Aura consensus authority. + pub type AuraId = sp_consensus_aura::sr25519::AuthorityId; - // Id used for identifying assets. - pub type AssetIdForTrustBackedAssets = u32; + // Id used for identifying assets. + pub type AssetIdForTrustBackedAssets = u32; - /// The address format for describing accounts. - pub type Address = sp_runtime::MultiAddress; - /// Block header type as expected by this runtime. - pub type Header = generic::Header; + /// The address format for describing accounts. + pub type Address = sp_runtime::MultiAddress; + /// Block header type as expected by this runtime. + pub type Header = generic::Header; } /// Common constants of parachains. mod constants { - use super::types::BlockNumber; - use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}; - use sp_runtime::Perbill; - /// This determines the average expected block time that we are targeting. Blocks will be - /// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by - /// `pallet_timestamp` which is in turn picked up by `pallet_aura` to implement `fn - /// slot_duration()`. - /// - /// Change this to adjust the block time. - pub const MILLISECS_PER_BLOCK: u64 = 12000; - pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; - - // Time is measured by number of blocks. - pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); - pub const HOURS: BlockNumber = MINUTES * 60; - pub const DAYS: BlockNumber = HOURS * 24; - - /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is - /// used to limit the maximal weight of a single extrinsic. - pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); - /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by - /// Operational extrinsics. - pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); - - /// We allow for 0.5 seconds of compute with a 6 second average block time. - pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( - WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), - polkadot_primitives::MAX_POV_SIZE as u64, - ); - - /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included - /// into the relay chain. - pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; - /// How many parachain blocks are processed by the relay chain per parent. Limits the - /// number of blocks authored per slot. - pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; - /// Relay chain slot duration, in milliseconds. - pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; + use super::types::BlockNumber; + use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}; + use polkadot_core_primitives::Moment; + use sp_runtime::Perbill; + /// This determines the average expected block time that we are targeting. Blocks will be + /// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by + /// `pallet_timestamp` which is in turn picked up by `pallet_aura` to implement `fn + /// slot_duration()`. + /// + /// Change this to adjust the block time. + pub const MILLISECS_PER_BLOCK: u64 = 12000; + pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; + + // Time is measured by number of blocks. + pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); + pub const HOURS: BlockNumber = MINUTES * 60; + pub const DAYS: BlockNumber = HOURS * 24; + + // Time helpers in milliseconds. + pub const MS_PER_MINUTE: Moment = 60_000; + pub const MS_PER_HOUR: Moment = crate::MS_PER_MINUTE * 60; + pub const MS_PER_DAY: Moment = crate::MS_PER_HOUR * 24; + + /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is + /// used to limit the maximal weight of a single extrinsic. + pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); + /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by + /// Operational extrinsics. + pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + + /// We allow for 0.5 seconds of compute with a 6 second average block time. + pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( + WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + polkadot_primitives::MAX_POV_SIZE as u64, + ); + + /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included + /// into the relay chain. + pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; + /// How many parachain blocks are processed by the relay chain per parent. Limits the + /// number of blocks authored per slot. + pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; + /// Relay chain slot duration, in milliseconds. + pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; } /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know @@ -119,18 +125,18 @@ mod constants { /// of data like extrinsics, allowing for them to continue syncing the network through upgrades /// to even the core data structures. pub mod opaque { - use super::*; - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - use sp_runtime::{ - generic, - traits::{BlakeTwo256, Hash as HashT}, - }; - /// Opaque block header type. - pub type Header = generic::Header; - /// Opaque block type. - pub type Block = generic::Block; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId; - /// Opaque block hash type. - pub type Hash = ::Output; + use super::*; + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; + use sp_runtime::{ + generic, + traits::{BlakeTwo256, Hash as HashT}, + }; + /// Opaque block header type. + pub type Header = generic::Header; + /// Opaque block type. + pub type Block = generic::Block; + /// Opaque block identifier type. + pub type BlockId = generic::BlockId; + /// Opaque block hash type. + pub type Hash = ::Output; } diff --git a/polkadot-parachains/integritee-runtime/Cargo.toml b/polkadot-parachains/integritee-runtime/Cargo.toml index 0e2089af..d837ff82 100644 --- a/polkadot-parachains/integritee-runtime/Cargo.toml +++ b/polkadot-parachains/integritee-runtime/Cargo.toml @@ -62,6 +62,7 @@ pallet-session = { workspace = true } pallet-sidechain = { workspace = true } pallet-teeracle = { workspace = true } pallet-teerex = { workspace = true } +pallet-teerdays = { workspace = true } pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } @@ -157,6 +158,7 @@ std = [ "pallet-session/std", "pallet-sidechain/std", "pallet-teeracle/std", + "pallet-teerdays/std", "pallet-teerex/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", @@ -222,6 +224,7 @@ runtime-benchmarks = [ "pallet-scheduler/runtime-benchmarks", "pallet-sidechain/runtime-benchmarks", "pallet-teeracle/runtime-benchmarks", + "pallet-teerdays/runtime-benchmarks", "pallet-teerex/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", diff --git a/polkadot-parachains/integritee-runtime/src/lib.rs b/polkadot-parachains/integritee-runtime/src/lib.rs index caea883b..990ff0fa 100644 --- a/polkadot-parachains/integritee-runtime/src/lib.rs +++ b/polkadot-parachains/integritee-runtime/src/lib.rs @@ -26,43 +26,43 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use cumulus_primitives_core::AggregateMessageOrigin; pub use frame_support::{ - construct_runtime, - dispatch::DispatchClass, - genesis_builder_helper::{build_state, get_preset}, - pallet_prelude::Get, - parameter_types, - traits::{ - EitherOfDiverse, Everything, IsInVec, Nothing, PalletInfoAccess, Randomness, - WithdrawReasons, - }, - weights::{ - constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, - IdentityFee, Weight, - }, - PalletId, StorageValue, + construct_runtime, + dispatch::DispatchClass, + genesis_builder_helper::{build_state, get_preset}, + pallet_prelude::Get, + parameter_types, + traits::{ + EitherOfDiverse, Everything, IsInVec, Nothing, PalletInfoAccess, Randomness, + WithdrawReasons, + }, + weights::{ + constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, + IdentityFee, Weight, + }, + PalletId, StorageValue, }; use frame_support::{ - derive_impl, ord_parameter_types, - traits::{ - fungible::{HoldConsideration, NativeFromLeft, NativeOrWithId, UnionOf}, - tokens::{imbalance::ResolveAssetTo, ConversionFromAssetBalance, PayFromAccount}, - AsEnsureOriginWithArg, ConstBool, EnsureOriginWithArg, EqualPrivilegeOnly, Imbalance, - InstanceFilter, LinearStoragePrice, OnUnbalanced, - }, - weights::ConstantMultiplier, + derive_impl, ord_parameter_types, + traits::{ + fungible::{HoldConsideration, NativeFromLeft, NativeOrWithId, UnionOf}, + tokens::{imbalance::ResolveAssetTo, ConversionFromAssetBalance, PayFromAccount}, + AsEnsureOriginWithArg, ConstBool, EnsureOriginWithArg, EqualPrivilegeOnly, Imbalance, + InstanceFilter, LinearStoragePrice, OnUnbalanced, + }, + weights::ConstantMultiplier, }; use frame_system::{ - limits::{BlockLength, BlockWeights}, - EnsureRoot, EnsureSignedBy, EnsureWithSuccess, + limits::{BlockLength, BlockWeights}, + EnsureRoot, EnsureSignedBy, EnsureWithSuccess, }; use integritee_parachains_common::{ - fee::{SlowAdjustingFeeUpdate, WeightToFee}, - AuraId, AVERAGE_ON_INITIALIZE_RATIO, BLOCK_PROCESSING_VELOCITY, DAYS, HOURS, - MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO, RELAY_CHAIN_SLOT_DURATION_MILLIS, - SLOT_DURATION, UNINCLUDED_SEGMENT_CAPACITY, + fee::{SlowAdjustingFeeUpdate, WeightToFee}, + AuraId, AVERAGE_ON_INITIALIZE_RATIO, BLOCK_PROCESSING_VELOCITY, DAYS, HOURS, + MAXIMUM_BLOCK_WEIGHT, MINUTES, MS_PER_DAY, NORMAL_DISPATCH_RATIO, + RELAY_CHAIN_SLOT_DURATION_MILLIS, SLOT_DURATION, UNINCLUDED_SEGMENT_CAPACITY, }; pub use integritee_parachains_common::{ - AccountId, Address, Balance, BlockNumber, Hash, Header, Nonce, Signature, MILLISECS_PER_BLOCK, + AccountId, Address, Balance, BlockNumber, Hash, Header, Nonce, Signature, MILLISECS_PER_BLOCK, }; use pallet_asset_conversion::{Ascending, Chain, WithFirstAsset}; pub use pallet_balances::Call as BalancesCall; @@ -81,10 +81,10 @@ use sp_core::{crypto::KeyTypeId, ConstU128, ConstU32, OpaqueMetadata}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, IdentityLookup}, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, RuntimeDebug, + create_runtime_str, generic, impl_opaque_keys, + traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, IdentityLookup}, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, RuntimeDebug, }; pub use sp_runtime::{Perbill, Permill}; use sp_std::prelude::*; @@ -105,7 +105,7 @@ pub type SessionHandlers = (); /// of data like extrinsics, allowing for them to continue syncing the network through upgrades /// to even the core data structures. pub mod opaque { - pub use integritee_parachains_common::opaque::*; + pub use integritee_parachains_common::opaque::*; } impl_opaque_keys! { @@ -116,14 +116,14 @@ impl_opaque_keys! { #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("integritee-parachain"), - impl_name: create_runtime_str!("integritee-full"), - authoring_version: 2, - spec_version: 540, - impl_version: 1, - apis: RUNTIME_API_VERSIONS, - transaction_version: 8, - state_version: 0, + spec_name: create_runtime_str!("integritee-parachain"), + impl_name: create_runtime_str!("integritee-full"), + authoring_version: 2, + spec_version: 540, + impl_version: 1, + apis: RUNTIME_API_VERSIONS, + transaction_version: 8, + state_version: 0, }; pub const TEER: Balance = 1_000_000_000_000; @@ -132,7 +132,7 @@ pub const MICROTEER: Balance = 1_000_000; // Logic from Polkadot/Kusama. pub const fn deposit(items: u32, bytes: u32) -> Balance { - items as Balance * 20 * TEER + (bytes as Balance) * 1_000 * MICROTEER + items as Balance * 20 * TEER + (bytes as Balance) * 1_000 * MICROTEER } /// A timestamp: milliseconds since the unix epoch. @@ -141,28 +141,28 @@ pub type Moment = u64; /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } + NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } pub struct DealWithFees; impl OnUnbalanced> for DealWithFees { - fn on_unbalanceds( - mut fees_then_tips: impl Iterator>, - ) { - if let Some(fees) = fees_then_tips.next() { - // for fees, 1% to treasury, 99% burned - // TODO: apply burning function based on cumulative number of extrinsics (#32) - let mut split = fees.ration(1, 99); - - // tips (voluntary extra fees) go to the treasury entirely. no burning - if let Some(tips) = fees_then_tips.next() { - tips.merge_into(&mut split.0); - } - Treasury::on_unbalanced(split.0); - // burn remainder by not assigning imbalance to someone - } - } + fn on_unbalanceds( + mut fees_then_tips: impl Iterator>, + ) { + if let Some(fees) = fees_then_tips.next() { + // for fees, 1% to treasury, 99% burned + // TODO: apply burning function based on cumulative number of extrinsics (#32) + let mut split = fees.ration(1, 99); + + // tips (voluntary extra fees) go to the treasury entirely. no burning + if let Some(tips) = fees_then_tips.next() { + tips.merge_into(&mut split.0); + } + Treasury::on_unbalanced(split.0); + // burn remainder by not assigning imbalance to someone + } + } } parameter_types! { @@ -196,21 +196,21 @@ parameter_types! { /// but overridden as needed. #[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Runtime { - type BaseCallFilter = Everything; - type BlockWeights = RuntimeBlockWeights; - type BlockLength = RuntimeBlockLength; - type Block = Block; - type AccountId = AccountId; - type Nonce = Nonce; - type Hash = Hash; - type BlockHashCount = BlockHashCount; - type DbWeight = RocksDbWeight; - type Version = Version; - type AccountData = pallet_balances::AccountData; - type SystemWeightInfo = weights::frame_system::WeightInfo; - type SS58Prefix = SS58Prefix; - type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; - type MaxConsumers = frame_support::traits::ConstU32<16>; + type BaseCallFilter = Everything; + type BlockWeights = RuntimeBlockWeights; + type BlockLength = RuntimeBlockLength; + type Block = Block; + type AccountId = AccountId; + type Nonce = Nonce; + type Hash = Hash; + type BlockHashCount = BlockHashCount; + type DbWeight = RocksDbWeight; + type Version = Version; + type AccountData = pallet_balances::AccountData; + type SystemWeightInfo = weights::frame_system::WeightInfo; + type SS58Prefix = SS58Prefix; + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; + type MaxConsumers = frame_support::traits::ConstU32<16>; } parameter_types! { @@ -218,11 +218,11 @@ parameter_types! { } impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the unix epoch. - type Moment = Moment; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = weights::pallet_timestamp::WeightInfo; + /// A timestamp: milliseconds since the unix epoch. + type Moment = Moment; + type OnTimestampSet = (); + type MinimumPeriod = MinimumPeriod; + type WeightInfo = weights::pallet_timestamp::WeightInfo; } parameter_types! { @@ -236,30 +236,30 @@ parameter_types! { } impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = weights::pallet_balances::WeightInfo; - type MaxReserves = MaxReserves; - type ReserveIdentifier = [u8; 8]; - type RuntimeHoldReason = RuntimeHoldReason; - type RuntimeFreezeReason = (); - type FreezeIdentifier = (); - type MaxFreezes = (); + type MaxLocks = MaxLocks; + /// The type for recording an account's balance. + type Balance = Balance; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = weights::pallet_balances::WeightInfo; + type MaxReserves = MaxReserves; + type ReserveIdentifier = [u8; 8]; + type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = (); + type FreezeIdentifier = (); + type MaxFreezes = (); } impl pallet_transaction_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; - type WeightToFee = WeightToFee; - type LengthToFee = ConstantMultiplier; - type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type RuntimeEvent = RuntimeEvent; + type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; + type WeightToFee = WeightToFee; + type LengthToFee = ConstantMultiplier; + type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; + type OperationalFeeMultiplier = OperationalFeeMultiplier; } parameter_types! { @@ -271,13 +271,13 @@ parameter_types! { } impl pallet_multisig::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; - type WeightInfo = weights::pallet_multisig::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = weights::pallet_multisig::WeightInfo; } parameter_types! { @@ -293,39 +293,39 @@ parameter_types! { /// The type used to represent the kinds of proxying allowed. #[derive( - Copy, - Clone, - Eq, - PartialEq, - Ord, - PartialOrd, - Encode, - Decode, - RuntimeDebug, - MaxEncodedLen, - TypeInfo, + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Encode, + Decode, + RuntimeDebug, + MaxEncodedLen, + TypeInfo, )] pub enum ProxyType { - Any, // Any transactions. - NonTransfer, // Any type of transaction except balance transfers (including vested transfers) - Governance, - // Staking = 3, - // IdentityJudgement = 4, - CancelProxy, - // Auction, + Any, // Any transactions. + NonTransfer, // Any type of transaction except balance transfers (including vested transfers) + Governance, + // Staking = 3, + // IdentityJudgement = 4, + CancelProxy, + // Auction, } impl Default for ProxyType { - fn default() -> Self { - Self::Any - } + fn default() -> Self { + Self::Any + } } impl InstanceFilter for ProxyType { - fn filter(&self, c: &RuntimeCall) -> bool { - match self { - ProxyType::Any => true, - ProxyType::NonTransfer => matches!( + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => matches!( c, RuntimeCall::System {..} | RuntimeCall::Timestamp {..} | @@ -344,43 +344,43 @@ impl InstanceFilter for ProxyType { RuntimeCall::Proxy {..} | RuntimeCall::Multisig {..} ), - ProxyType::Governance => { - matches!( + ProxyType::Governance => { + matches!( c, RuntimeCall::Treasury { .. } | RuntimeCall::Bounties(..) | RuntimeCall::ChildBounties(..) ) - } - ProxyType::CancelProxy => { - matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) - } - } - } - fn is_superset(&self, o: &Self) -> bool { - match (self, o) { - (x, y) if x == y => true, - (ProxyType::Any, _) => true, - (_, ProxyType::Any) => false, - (ProxyType::NonTransfer, _) => true, - _ => false, - } - } + }, + ProxyType::CancelProxy => { + matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) + }, + } + } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + (ProxyType::NonTransfer, _) => true, + _ => false, + } + } } impl pallet_proxy::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Currency = Balances; - type ProxyType = ProxyType; - type ProxyDepositBase = ProxyDepositBase; - type ProxyDepositFactor = ProxyDepositFactor; - type MaxProxies = MaxProxies; - type WeightInfo = weights::pallet_proxy::WeightInfo; - type MaxPending = MaxPending; - type CallHasher = BlakeTwo256; - type AnnouncementDepositBase = AnnouncementDepositBase; - type AnnouncementDepositFactor = AnnouncementDepositFactor; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = MaxProxies; + type WeightInfo = weights::pallet_proxy::WeightInfo; + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; } parameter_types! { @@ -390,14 +390,14 @@ parameter_types! { } impl pallet_vesting::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type BlockNumberToBalance = ConvertInto; - type BlockNumberProvider = System; - type MinVestedTransfer = MinVestedTransfer; - type WeightInfo = weights::pallet_vesting::WeightInfo; - type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; - const MAX_VESTING_SCHEDULES: u32 = 28; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BlockNumberToBalance = ConvertInto; + type BlockNumberProvider = System; + type MinVestedTransfer = MinVestedTransfer; + type WeightInfo = weights::pallet_vesting::WeightInfo; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; + const MAX_VESTING_SCHEDULES: u32 = 28; } parameter_types! { @@ -407,24 +407,24 @@ parameter_types! { } impl pallet_scheduler::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type PalletsOrigin = OriginCaller; - type RuntimeCall = RuntimeCall; - type MaximumWeight = MaximumSchedulerWeight; - // one schedule is the founder allocation. We only allow RootOrigin here such that it takes a democracy proposal to change this schedule - type ScheduleOrigin = EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = weights::pallet_scheduler::WeightInfo; - type OriginPrivilegeCmp = EqualPrivilegeOnly; - type Preimages = Preimage; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type PalletsOrigin = OriginCaller; + type RuntimeCall = RuntimeCall; + type MaximumWeight = MaximumSchedulerWeight; + // one schedule is the founder allocation. We only allow RootOrigin here such that it takes a democracy proposal to change this schedule + type ScheduleOrigin = EnsureRoot; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = weights::pallet_scheduler::WeightInfo; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type Preimages = Preimage; } impl pallet_utility::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type PalletsOrigin = OriginCaller; - type WeightInfo = weights::pallet_utility::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type PalletsOrigin = OriginCaller; + type WeightInfo = weights::pallet_utility::WeightInfo; } parameter_types! { @@ -435,16 +435,16 @@ parameter_types! { } impl pallet_preimage::Config for Runtime { - type WeightInfo = weights::pallet_preimage::WeightInfo; - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type ManagerOrigin = EnsureRoot; - type Consideration = HoldConsideration< - AccountId, - Balances, - PreimageHoldReason, - LinearStoragePrice, - >; + type WeightInfo = weights::pallet_preimage::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type Consideration = HoldConsideration< + AccountId, + Balances, + PreimageHoldReason, + LinearStoragePrice, + >; } parameter_types! { @@ -454,24 +454,24 @@ parameter_types! { } type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook< - Runtime, - RELAY_CHAIN_SLOT_DURATION_MILLIS, - BLOCK_PROCESSING_VELOCITY, - UNINCLUDED_SEGMENT_CAPACITY, + Runtime, + RELAY_CHAIN_SLOT_DURATION_MILLIS, + BLOCK_PROCESSING_VELOCITY, + UNINCLUDED_SEGMENT_CAPACITY, >; impl cumulus_pallet_parachain_system::Config for Runtime { - type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo; - type RuntimeEvent = RuntimeEvent; - type OnSystemEvent = (); - type SelfParaId = staging_parachain_info::Pallet; - type DmpQueue = frame_support::traits::EnqueueWithOrigin; - type ReservedDmpWeight = ReservedDmpWeight; - type OutboundXcmpMessageSource = XcmpQueue; - type XcmpMessageHandler = XcmpQueue; - type ReservedXcmpWeight = ReservedXcmpWeight; - type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; - type ConsensusHook = ConsensusHook; + type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type OnSystemEvent = (); + type SelfParaId = staging_parachain_info::Pallet; + type DmpQueue = frame_support::traits::EnqueueWithOrigin; + type ReservedDmpWeight = ReservedDmpWeight; + type OutboundXcmpMessageSource = XcmpQueue; + type XcmpMessageHandler = XcmpQueue; + type ReservedXcmpWeight = ReservedXcmpWeight; + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; + type ConsensusHook = ConsensusHook; } impl staging_parachain_info::Config for Runtime {} @@ -483,26 +483,26 @@ parameter_types! { } impl pallet_message_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::pallet_message_queue::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor< - cumulus_primitives_core::AggregateMessageOrigin, - >; - #[cfg(not(feature = "runtime-benchmarks"))] - type MessageProcessor = staging_xcm_builder::ProcessXcmMessage< - AggregateMessageOrigin, - staging_xcm_executor::XcmExecutor, - RuntimeCall, - >; - type Size = u32; - // The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin: - type QueueChangeHandler = NarrowOriginToSibling; - type QueuePausedQuery = NarrowOriginToSibling; - type HeapSize = sp_core::ConstU32<{ 64 * 1024 }>; - type MaxStale = sp_core::ConstU32<8>; - type ServiceWeight = MessageQueueServiceWeight; - type IdleMaxServiceWeight = (); + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_message_queue::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor< + cumulus_primitives_core::AggregateMessageOrigin, + >; + #[cfg(not(feature = "runtime-benchmarks"))] + type MessageProcessor = staging_xcm_builder::ProcessXcmMessage< + AggregateMessageOrigin, + staging_xcm_executor::XcmExecutor, + RuntimeCall, + >; + type Size = u32; + // The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin: + type QueueChangeHandler = NarrowOriginToSibling; + type QueuePausedQuery = NarrowOriginToSibling; + type HeapSize = sp_core::ConstU32<{ 64 * 1024 }>; + type MaxStale = sp_core::ConstU32<8>; + type ServiceWeight = MessageQueueServiceWeight; + type IdleMaxServiceWeight = (); } parameter_types! { @@ -516,11 +516,11 @@ parameter_types! { } impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; - type DisabledValidators = (); - type MaxAuthorities = MaxAuthorities; - type AllowMultipleBlocksPerSlot = ConstBool; - type SlotDuration = pallet_aura::MinimumPeriodTimesTwo; + type AuthorityId = AuraId; + type DisabledValidators = (); + type MaxAuthorities = MaxAuthorities; + type AllowMultipleBlocksPerSlot = ConstBool; + type SlotDuration = pallet_aura::MinimumPeriodTimesTwo; } // Integritee pallet @@ -530,16 +530,16 @@ parameter_types! { } impl pallet_teerex::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MomentsPerDay = MomentsPerDay; - type MaxAttestationRenewalPeriod = MaxAttestationRenewalPeriod; - type WeightInfo = weights::pallet_teerex::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type MomentsPerDay = MomentsPerDay; + type MaxAttestationRenewalPeriod = MaxAttestationRenewalPeriod; + type WeightInfo = weights::pallet_teerex::WeightInfo; } impl pallet_enclave_bridge::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = pallet_balances::Pallet; - type WeightInfo = weights::pallet_enclave_bridge::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type Currency = pallet_balances::Pallet; + type WeightInfo = weights::pallet_enclave_bridge::WeightInfo; } // Integritee pallet @@ -548,8 +548,19 @@ parameter_types! { } impl pallet_sidechain::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::pallet_sidechain::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_sidechain::WeightInfo; +} +// added by Integritee +parameter_types! { + pub const UnlockPeriod: Moment = 7 * MS_PER_DAY; +} +impl pallet_teerdays::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_teerdays::WeightInfo; + type Currency = Balances; + type CurrencyBalance = Balance; + type UnlockPeriod = UnlockPeriod; } parameter_types! { @@ -558,11 +569,11 @@ parameter_types! { // Integritee pallet impl pallet_claims::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type VestingSchedule = Vesting; - type Prefix = Prefix; - type MoveClaimOrigin = EnsureRoot; - type WeightInfo = weights::pallet_claims::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type VestingSchedule = Vesting; + type Prefix = Prefix; + type MoveClaimOrigin = EnsureRoot; + type WeightInfo = weights::pallet_claims::WeightInfo; } parameter_types! { pub const MaxWhitelistedReleases: u32 = 10; @@ -571,10 +582,10 @@ parameter_types! { // Integritee pallet impl pallet_teeracle::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::pallet_teeracle::WeightInfo; - type MaxWhitelistedReleases = MaxWhitelistedReleases; - type MaxOracleBlobLen = MaxOracleBlobLen; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_teeracle::WeightInfo; + type MaxWhitelistedReleases = MaxWhitelistedReleases; + type MaxOracleBlobLen = MaxOracleBlobLen; } parameter_types! { @@ -594,39 +605,39 @@ parameter_types! { pub struct NoConversion; impl ConversionFromAssetBalance for NoConversion { - type Error = (); - fn from_asset_balance(balance: Balance, _asset_id: ()) -> Result { - Ok(balance) - } - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(_: ()) {} + type Error = (); + fn from_asset_balance(balance: Balance, _asset_id: ()) -> Result { + Ok(balance) + } + #[cfg(feature = "runtime-benchmarks")] + fn ensure_successful(_: ()) {} } impl pallet_treasury::Config for Runtime { - type PalletId = TreasuryPalletId; - type Currency = pallet_balances::Pallet; - type ApproveOrigin = EnsureRootOrMoreThanHalfCouncil; - type RejectOrigin = EnsureRootOrMoreThanHalfCouncil; - type RuntimeEvent = RuntimeEvent; - type OnSlash = (); // No Proposal - type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type ProposalBondMaximum = ProposalBondMaximum; - type SpendPeriod = SpendPeriod; //Cannot be 0: Error: Thread 'tokio-runtime-worker' panicked at 'attempt to calculate the remainder with a divisor of zero - type Burn = (); //No burn - type BurnDestination = (); //No burn - type SpendFunds = Bounties; - type SpendOrigin = EnsureWithSuccess, AccountId, MaxBalance>; - type MaxApprovals = MaxApprovals; //0:cannot approve any proposal - type WeightInfo = weights::pallet_treasury::WeightInfo; - type AssetKind = (); - type Beneficiary = AccountId; - type BeneficiaryLookup = IdentityLookup; - type Paymaster = PayFromAccount; - type BalanceConverter = NoConversion; - type PayoutPeriod = PayoutSpendPeriod; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); + type PalletId = TreasuryPalletId; + type Currency = pallet_balances::Pallet; + type ApproveOrigin = EnsureRootOrMoreThanHalfCouncil; + type RejectOrigin = EnsureRootOrMoreThanHalfCouncil; + type RuntimeEvent = RuntimeEvent; + type OnSlash = (); // No Proposal + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = ProposalBondMaximum; + type SpendPeriod = SpendPeriod; //Cannot be 0: Error: Thread 'tokio-runtime-worker' panicked at 'attempt to calculate the remainder with a divisor of zero + type Burn = (); //No burn + type BurnDestination = (); //No burn + type SpendFunds = Bounties; + type SpendOrigin = EnsureWithSuccess, AccountId, MaxBalance>; + type MaxApprovals = MaxApprovals; //0:cannot approve any proposal + type WeightInfo = weights::pallet_treasury::WeightInfo; + type AssetKind = (); + type Beneficiary = AccountId; + type BeneficiaryLookup = IdentityLookup; + type Paymaster = PayFromAccount; + type BalanceConverter = NoConversion; + type PayoutPeriod = PayoutSpendPeriod; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } parameter_types! { @@ -641,18 +652,18 @@ parameter_types! { } impl pallet_bounties::Config for Runtime { - type BountyDepositBase = BountyDepositBase; - type BountyDepositPayoutDelay = BountyDepositPayoutDelay; - type BountyUpdatePeriod = BountyUpdatePeriod; - type CuratorDepositMultiplier = CuratorDepositMultiplier; - type CuratorDepositMin = CuratorDepositMin; - type CuratorDepositMax = CuratorDepositMax; - type BountyValueMinimum = BountyValueMinimum; - type ChildBountyManager = ChildBounties; - type DataDepositPerByte = DataDepositPerByte; - type RuntimeEvent = RuntimeEvent; - type MaximumReasonLength = MaximumReasonLength; - type WeightInfo = weights::pallet_bounties::WeightInfo; + type BountyDepositBase = BountyDepositBase; + type BountyDepositPayoutDelay = BountyDepositPayoutDelay; + type BountyUpdatePeriod = BountyUpdatePeriod; + type CuratorDepositMultiplier = CuratorDepositMultiplier; + type CuratorDepositMin = CuratorDepositMin; + type CuratorDepositMax = CuratorDepositMax; + type BountyValueMinimum = BountyValueMinimum; + type ChildBountyManager = ChildBounties; + type DataDepositPerByte = DataDepositPerByte; + type RuntimeEvent = RuntimeEvent; + type MaximumReasonLength = MaximumReasonLength; + type WeightInfo = weights::pallet_bounties::WeightInfo; } parameter_types! { @@ -661,10 +672,10 @@ parameter_types! { } impl pallet_child_bounties::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MaxActiveChildBountyCount = MaxActiveChildBountyCount; - type ChildBountyValueMinimum = ChildBountyValueMinimum; - type WeightInfo = weights::pallet_child_bounties::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type MaxActiveChildBountyCount = MaxActiveChildBountyCount; + type ChildBountyValueMinimum = ChildBountyValueMinimum; + type WeightInfo = weights::pallet_child_bounties::WeightInfo; } /// Council collective instance declaration. @@ -680,21 +691,21 @@ parameter_types! { } impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type Proposal = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type MotionDuration = CouncilMotionDuration; - type MaxProposals = CouncilMaxProposals; - type MaxMembers = CouncilMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = weights::pallet_collective::WeightInfo; - type SetMembersOrigin = EnsureRootOrMoreThanHalfCouncil; - type MaxProposalWeight = MaxProposalWeight; + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = weights::pallet_collective::WeightInfo; + type SetMembersOrigin = EnsureRootOrMoreThanHalfCouncil; + type MaxProposalWeight = MaxProposalWeight; } pub type EnsureRootOrMoreThanHalfCouncil = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionMoreThan, + EnsureRoot, + pallet_collective::EnsureProportionMoreThan, >; /// Technical committee collective instance declaration. @@ -709,30 +720,30 @@ parameter_types! { } impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type RuntimeEvent = RuntimeEvent; - type Proposal = RuntimeCall; - /// The maximum amount of time (in blocks) for technical committee members to vote on motions. - /// Motions may end in fewer blocks if enough votes are cast to determine the result. - type MotionDuration = TechnicalMotionDuration; - /// The maximum number of Proposlas that can be open in the technical committee at once. - type MaxProposals = TechnicalMaxProposals; - /// The maximum number of technical committee members. - type MaxMembers = TechnicalMaxMembers; - type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote; - type WeightInfo = weights::pallet_collective::WeightInfo; - type SetMembersOrigin = EnsureRootOrMoreThanHalfCouncil; - type MaxProposalWeight = MaxProposalWeight; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; + type Proposal = RuntimeCall; + /// The maximum amount of time (in blocks) for technical committee members to vote on motions. + /// Motions may end in fewer blocks if enough votes are cast to determine the result. + type MotionDuration = TechnicalMotionDuration; + /// The maximum number of Proposlas that can be open in the technical committee at once. + type MaxProposals = TechnicalMaxProposals; + /// The maximum number of technical committee members. + type MaxMembers = TechnicalMaxMembers; + type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote; + type WeightInfo = weights::pallet_collective::WeightInfo; + type SetMembersOrigin = EnsureRootOrMoreThanHalfCouncil; + type MaxProposalWeight = MaxProposalWeight; } pub type EnsureRootOrMoreThanHalfTechnicalCommittee = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, >; pub type EnsureRootOrAllTechnicalCommittee = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, >; parameter_types! { @@ -748,53 +759,53 @@ parameter_types! { } impl pallet_democracy::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type EnactmentPeriod = EnactmentPeriod; - type LaunchPeriod = LaunchPeriod; - type VotingPeriod = VotingPeriod; - type VoteLockingPeriod = EnactmentPeriod; - type MinimumDeposit = MinimumDeposit; - //// Origin allowed to schedule a SuperMajorityApprove (default decline) - /// referendum once it is is legal for an externally proposed referendum - type ExternalOrigin = EnsureRootOrMoreThanHalfCouncil; - /// Origin allowed to schedule a majority-carries (Simple Majority) - /// referendum once it is legal for an externally proposed referendum - type ExternalMajorityOrigin = EnsureRootOrMoreThanHalfCouncil; - /// Origin allowed to schedule a SuperMajorityAgainst (default accept) - /// referendum once it is legal for an externally proposed referendum - type ExternalDefaultOrigin = EnsureRootOrMoreThanHalfCouncil; - /// Majority of the technical committee can have an ExternalMajority/ExternalDefault vote - /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = EnsureRootOrMoreThanHalfTechnicalCommittee; - type InstantOrigin = EnsureRootOrMoreThanHalfTechnicalCommittee; - type InstantAllowed = InstantAllowed; - type FastTrackVotingPeriod = FastTrackVotingPeriod; - // To cancel a proposal which has been passed. - type CancellationOrigin = EnsureRoot; - type BlacklistOrigin = EnsureRootOrMoreThanHalfCouncil; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = EnsureRootOrAllTechnicalCommittee; - // Any single technical committee member may veto a coming council proposal, however they can - // only do it once and it lasts only for the cooloff period. - type VetoOrigin = pallet_collective::EnsureMember; - type CooloffPeriod = CooloffPeriod; - type Slash = Treasury; - type Scheduler = Scheduler; - type PalletsOrigin = OriginCaller; - type MaxVotes = MaxVotes; - type WeightInfo = weights::pallet_democracy::WeightInfo; - type MaxProposals = MaxProposals; - type Preimages = Preimage; - type MaxDeposits = ConstU32<100>; - type MaxBlacklisted = ConstU32<100>; - type SubmitOrigin = frame_system::EnsureSigned; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type EnactmentPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type VoteLockingPeriod = EnactmentPeriod; + type MinimumDeposit = MinimumDeposit; + //// Origin allowed to schedule a SuperMajorityApprove (default decline) + /// referendum once it is is legal for an externally proposed referendum + type ExternalOrigin = EnsureRootOrMoreThanHalfCouncil; + /// Origin allowed to schedule a majority-carries (Simple Majority) + /// referendum once it is legal for an externally proposed referendum + type ExternalMajorityOrigin = EnsureRootOrMoreThanHalfCouncil; + /// Origin allowed to schedule a SuperMajorityAgainst (default accept) + /// referendum once it is legal for an externally proposed referendum + type ExternalDefaultOrigin = EnsureRootOrMoreThanHalfCouncil; + /// Majority of the technical committee can have an ExternalMajority/ExternalDefault vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = EnsureRootOrMoreThanHalfTechnicalCommittee; + type InstantOrigin = EnsureRootOrMoreThanHalfTechnicalCommittee; + type InstantAllowed = InstantAllowed; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed. + type CancellationOrigin = EnsureRoot; + type BlacklistOrigin = EnsureRootOrMoreThanHalfCouncil; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EnsureRootOrAllTechnicalCommittee; + // Any single technical committee member may veto a coming council proposal, however they can + // only do it once and it lasts only for the cooloff period. + type VetoOrigin = pallet_collective::EnsureMember; + type CooloffPeriod = CooloffPeriod; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; + type WeightInfo = weights::pallet_democracy::WeightInfo; + type MaxProposals = MaxProposals; + type Preimages = Preimage; + type MaxDeposits = ConstU32<100>; + type MaxBlacklisted = ConstU32<100>; + type SubmitOrigin = frame_system::EnsureSigned; } impl orml_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SovereignOrigin = EnsureRoot; + type RuntimeEvent = RuntimeEvent; + type SovereignOrigin = EnsureRoot; } pub type AssetBalance = Balance; @@ -803,44 +814,44 @@ pub type AssetBalance = Balance; pub struct NoAssetCreators; impl EnsureOriginWithArg for NoAssetCreators { - type Success = AccountId; + type Success = AccountId; - fn try_origin( - o: RuntimeOrigin, - _a: &AssetIdForTrustBackedAssets, - ) -> sp_std::result::Result { - Err(o) - } + fn try_origin( + o: RuntimeOrigin, + _a: &AssetIdForTrustBackedAssets, + ) -> sp_std::result::Result { + Err(o) + } - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin(_a: &AssetIdForTrustBackedAssets) -> Result { - Err(()) - } + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin(_a: &AssetIdForTrustBackedAssets) -> Result { + Err(()) + } } pub type MainAssetsInstance = pallet_assets::Instance1; impl pallet_assets::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = AssetBalance; - type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; - type AssetId = AssetIdForTrustBackedAssets; - type AssetIdParameter = parity_scale_codec::Compact; - type Currency = Balances; - type CreateOrigin = NoAssetCreators; //assets can only be created by root - type ForceOrigin = EnsureRoot; - type AssetDeposit = ConstU128<{ TEER }>; - type AssetAccountDeposit = ConstU128<{ TEER }>; - type MetadataDepositBase = ConstU128<{ TEER }>; - type MetadataDepositPerByte = ConstU128<{ 10 * MILLITEER }>; - type ApprovalDeposit = ConstU128<{ 10 * MILLITEER }>; - type StringLimit = ConstU32<50>; - type Freezer = (); - type Extra = (); - type CallbackHandle = (); - type WeightInfo = weights::pallet_assets::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); + type RuntimeEvent = RuntimeEvent; + type Balance = AssetBalance; + type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type AssetId = AssetIdForTrustBackedAssets; + type AssetIdParameter = parity_scale_codec::Compact; + type Currency = Balances; + type CreateOrigin = NoAssetCreators; //assets can only be created by root + type ForceOrigin = EnsureRoot; + type AssetDeposit = ConstU128<{ TEER }>; + type AssetAccountDeposit = ConstU128<{ TEER }>; + type MetadataDepositBase = ConstU128<{ TEER }>; + type MetadataDepositPerByte = ConstU128<{ 10 * MILLITEER }>; + type ApprovalDeposit = ConstU128<{ 10 * MILLITEER }>; + type StringLimit = ConstU32<50>; + type Freezer = (); + type Extra = (); + type CallbackHandle = (); + type WeightInfo = weights::pallet_assets::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } #[cfg(feature = "runtime-benchmarks")] @@ -848,74 +859,74 @@ pub struct AssetRegistryBenchmarkHelper; #[cfg(feature = "runtime-benchmarks")] impl pallet_asset_registry::BenchmarkHelper -for AssetRegistryBenchmarkHelper + for AssetRegistryBenchmarkHelper { - fn get_registered_asset() -> AssetIdForTrustBackedAssets { - use sp_runtime::traits::StaticLookup; - - let root = frame_system::RawOrigin::Root.into(); - let asset_id = 1; - let caller = frame_benchmarking::whitelisted_caller(); - let caller_lookup = ::Lookup::unlookup(caller); - Assets::force_create(root, asset_id.into(), caller_lookup, true, 1) - .expect("Should have been able to force create asset"); - asset_id - } + fn get_registered_asset() -> AssetIdForTrustBackedAssets { + use sp_runtime::traits::StaticLookup; + + let root = frame_system::RawOrigin::Root.into(); + let asset_id = 1; + let caller = frame_benchmarking::whitelisted_caller(); + let caller_lookup = ::Lookup::unlookup(caller); + Assets::force_create(root, asset_id.into(), caller_lookup, true, 1) + .expect("Should have been able to force create asset"); + asset_id + } } impl pallet_asset_registry::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ReserveAssetModifierOrigin = EnsureRoot; - type Assets = Assets; - type WeightInfo = weights::pallet_asset_registry::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetRegistryBenchmarkHelper; + type RuntimeEvent = RuntimeEvent; + type ReserveAssetModifierOrigin = EnsureRoot; + type Assets = Assets; + type WeightInfo = weights::pallet_asset_registry::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = AssetRegistryBenchmarkHelper; } pub type NativeAndAssets = UnionOf< - Balances, - Assets, - NativeFromLeft, - NativeOrWithId, - AccountId, + Balances, + Assets, + NativeFromLeft, + NativeOrWithId, + AccountId, >; pub type PoolIdToAccountId = pallet_asset_conversion::AccountIdConverter< - AssetConversionPalletId, - (NativeOrWithId, NativeOrWithId), + AssetConversionPalletId, + (NativeOrWithId, NativeOrWithId), >; pub type AscendingLocator = -Ascending, PoolIdToAccountId>; + Ascending, PoolIdToAccountId>; pub type WithFirstAssetLocator = WithFirstAsset< - Native, - AccountId, - NativeOrWithId, - PoolIdToAccountId, + Native, + AccountId, + NativeOrWithId, + PoolIdToAccountId, >; impl pallet_asset_conversion::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type HigherPrecisionBalance = sp_core::U256; - type AssetKind = NativeOrWithId; - type Assets = NativeAndAssets; - type PoolId = (Self::AssetKind, Self::AssetKind); - type PoolLocator = Chain; - type PoolAssetId = u32; - type PoolAssets = PoolAssets; - type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam - type PoolSetupFeeAsset = Native; - type PoolSetupFeeTarget = ResolveAssetTo; - type LiquidityWithdrawalFee = LiquidityWithdrawalFee; - type LPFee = ConstU32<3>; // 0.3% swap fee - type PalletId = AssetConversionPalletId; - type MaxSwapPathLength = ConstU32<3>; - type MintMinLiquidity = ConstU128<100>; - type WeightInfo = weights::pallet_asset_conversion::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type HigherPrecisionBalance = sp_core::U256; + type AssetKind = NativeOrWithId; + type Assets = NativeAndAssets; + type PoolId = (Self::AssetKind, Self::AssetKind); + type PoolLocator = Chain; + type PoolAssetId = u32; + type PoolAssets = PoolAssets; + type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam + type PoolSetupFeeAsset = Native; + type PoolSetupFeeTarget = ResolveAssetTo; + type LiquidityWithdrawalFee = LiquidityWithdrawalFee; + type LPFee = ConstU32<3>; // 0.3% swap fee + type PalletId = AssetConversionPalletId; + type MaxSwapPathLength = ConstU32<3>; + type MintMinLiquidity = ConstU128<100>; + type WeightInfo = weights::pallet_asset_conversion::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } parameter_types! { @@ -933,33 +944,33 @@ ord_parameter_types! { pub type PoolAssetsInstance = pallet_assets::Instance2; impl pallet_assets::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type RemoveItemsLimit = ConstU32<1000>; - type AssetId = u32; - type AssetIdParameter = u32; - type Currency = Balances; - type CreateOrigin = - AsEnsureOriginWithArg>; - type ForceOrigin = EnsureRoot; - // Deposits are zero because creation/admin is limited to Asset Conversion pallet. - type AssetDeposit = ConstU128<0>; - type AssetAccountDeposit = ConstU128<0>; - type MetadataDepositBase = ConstU128<0>; - type MetadataDepositPerByte = ConstU128<0>; - type ApprovalDeposit = ApprovalDeposit; - type StringLimit = ConstU32<50>; - type Freezer = (); - type Extra = (); - type WeightInfo = weights::pallet_assets::WeightInfo; - type CallbackHandle = (); - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type RemoveItemsLimit = ConstU32<1000>; + type AssetId = u32; + type AssetIdParameter = u32; + type Currency = Balances; + type CreateOrigin = + AsEnsureOriginWithArg>; + type ForceOrigin = EnsureRoot; + // Deposits are zero because creation/admin is limited to Asset Conversion pallet. + type AssetDeposit = ConstU128<0>; + type AssetAccountDeposit = ConstU128<0>; + type MetadataDepositBase = ConstU128<0>; + type MetadataDepositPerByte = ConstU128<0>; + type ApprovalDeposit = ApprovalDeposit; + type StringLimit = ConstU32<50>; + type Freezer = (); + type Extra = (); + type WeightInfo = weights::pallet_assets::WeightInfo; + type CallbackHandle = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type EventHandler = (CollatorSelection,); + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; + type EventHandler = (CollatorSelection,); } parameter_types! { @@ -967,17 +978,17 @@ parameter_types! { pub const Offset: u32 = 0; } impl pallet_session::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ValidatorId = ::AccountId; - // we don't have stash and controller, thus we don't need the convert as well. - type ValidatorIdOf = pallet_collator_selection::IdentityCollator; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = CollatorSelection; - // Essentially just Aura, but let's be pedantic. - type SessionHandler = ::KeyTypeIdProviders; - type Keys = SessionKeys; - type WeightInfo = weights::pallet_session::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type ValidatorId = ::AccountId; + // we don't have stash and controller, thus we don't need the convert as well. + type ValidatorIdOf = pallet_collator_selection::IdentityCollator; + type ShouldEndSession = pallet_session::PeriodicSessions; + type NextSessionRotation = pallet_session::PeriodicSessions; + type SessionManager = CollatorSelection; + // Essentially just Aura, but let's be pedantic. + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; + type WeightInfo = weights::pallet_session::WeightInfo; } parameter_types! { @@ -986,19 +997,19 @@ parameter_types! { } impl pallet_collator_selection::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type UpdateOrigin = EnsureRootOrMoreThanHalfCouncil; - type PotId = PotId; - type MaxCandidates = ConstU32<100>; - type MinEligibleCollators = ConstU32<4>; - type MaxInvulnerables = ConstU32<20>; - // should be a multiple of session or things will get inconsistent - type KickThreshold = Period; - type ValidatorId = ::AccountId; - type ValidatorIdOf = pallet_collator_selection::IdentityCollator; - type ValidatorRegistration = Session; - type WeightInfo = weights::pallet_collator_selection::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type UpdateOrigin = EnsureRootOrMoreThanHalfCouncil; + type PotId = PotId; + type MaxCandidates = ConstU32<100>; + type MinEligibleCollators = ConstU32<4>; + type MaxInvulnerables = ConstU32<20>; + // should be a multiple of session or things will get inconsistent + type KickThreshold = Period; + type ValidatorId = ::AccountId; + type ValidatorIdOf = pallet_collator_selection::IdentityCollator; + type ValidatorRegistration = Session; + type WeightInfo = weights::pallet_collator_selection::WeightInfo; } construct_runtime!( @@ -1058,24 +1069,25 @@ construct_runtime!( Teeracle: pallet_teeracle = 52, Sidechain: pallet_sidechain= 53, EnclaveBridge: pallet_enclave_bridge = 54, + TeerDays: pallet_teerdays = 55, } ); /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( - frame_system::CheckNonZeroSender, - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, - frame_metadata_hash_extension::CheckMetadataHash, + frame_system::CheckNonZeroSender, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = -generic::UncheckedExtrinsic; + generic::UncheckedExtrinsic; /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Block type as expected by this runtime. @@ -1087,20 +1099,20 @@ pub type BlockId = generic::BlockId; /// Migrations to apply on runtime upgrade. pub type Migrations = ( - migrations::scheduler::v4::PurgeV4Agenda, - migrations::collator_selection_init::v0::InitInvulnerables, - cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, + migrations::scheduler::v4::PurgeV4Agenda, + migrations::collator_selection_init::v0::InitInvulnerables, + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, + cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, ); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, // Solochain: AllPalletsReversedWithSystemFirst, Statemint: AllPallets. Which one to take? - Migrations, + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, // Solochain: AllPalletsReversedWithSystemFirst, Statemint: AllPallets. Which one to take? + Migrations, >; #[cfg(feature = "runtime-benchmarks")] @@ -1109,7 +1121,7 @@ extern crate frame_benchmarking; #[cfg(feature = "runtime-benchmarks")] mod benches { - define_benchmarks!( + define_benchmarks!( [frame_system, SystemBench::] [pallet_asset_conversion, AssetConversion] [pallet_asset_registry, AssetRegistry] @@ -1129,6 +1141,7 @@ mod benches { [pallet_session, SessionBench::] [pallet_sidechain, Sidechain] [pallet_teeracle, Teeracle] + [pallet_teerdays, TeerDays] [pallet_teerex, Teerex] [pallet_enclave_bridge, EnclaveBridge] [pallet_timestamp, Timestamp] diff --git a/polkadot-parachains/integritee-runtime/src/weights/mod.rs b/polkadot-parachains/integritee-runtime/src/weights/mod.rs index 5d7db66a..553e33ad 100644 --- a/polkadot-parachains/integritee-runtime/src/weights/mod.rs +++ b/polkadot-parachains/integritee-runtime/src/weights/mod.rs @@ -24,6 +24,7 @@ pub mod pallet_scheduler; pub mod pallet_session; pub mod pallet_sidechain; pub mod pallet_teeracle; +pub mod pallet_teerdays; pub mod pallet_teerex; pub mod pallet_timestamp; pub mod pallet_treasury; diff --git a/polkadot-parachains/integritee-runtime/src/weights/pallet_teerdays.rs b/polkadot-parachains/integritee-runtime/src/weights/pallet_teerdays.rs new file mode 100644 index 00000000..5385424e --- /dev/null +++ b/polkadot-parachains/integritee-runtime/src/weights/pallet_teerdays.rs @@ -0,0 +1,105 @@ + +//! Autogenerated weights for `pallet_teerdays` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 39.0.0 +//! DATE: 2024-07-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `caribe`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("integritee-solo-fresh")`, DB CACHE: 1024 + +// Executed Command: +// target/release/integritee-node +// benchmark +// pallet +// --chain=integritee-solo-fresh +// --steps=50 +// --repeat=20 +// --pallet=pallet_teerdays +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=runtime/src/weights/pallet_teerdays.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_teerdays`. +pub struct WeightInfo(PhantomData); +impl pallet_teerdays::WeightInfo for WeightInfo { + /// Storage: `TeerDays::TeerDayBonds` (r:1 w:1) + /// Proof: `TeerDays::TeerDayBonds` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `240` + // Estimated: `4764` + // Minimum execution time: 53_157_000 picoseconds. + Weight::from_parts(54_869_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `TeerDays::PendingUnlock` (r:1 w:1) + /// Proof: `TeerDays::PendingUnlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `TeerDays::TeerDayBonds` (r:1 w:1) + /// Proof: `TeerDays::TeerDayBonds` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn unbond() -> Weight { + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `3718` + // Minimum execution time: 32_747_000 picoseconds. + Weight::from_parts(35_019_000, 0) + .saturating_add(Weight::from_parts(0, 3718)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `TeerDays::TeerDayBonds` (r:1 w:1) + /// Proof: `TeerDays::TeerDayBonds` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn update_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `3718` + // Minimum execution time: 22_243_000 picoseconds. + Weight::from_parts(22_940_000, 0) + .saturating_add(Weight::from_parts(0, 3718)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `TeerDays::PendingUnlock` (r:1 w:1) + /// Proof: `TeerDays::PendingUnlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn withdraw_unbonded() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `4764` + // Minimum execution time: 49_889_000 picoseconds. + Weight::from_parts(51_522_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) + } +}