Reference for macros usage (#354)

* Reference for macro usage

update build, fix fmt and tomls

fixed Erc20XcmBridge, updated deps

toml sort &fmt

* fix import

* fix sort

* comment out tests

* fix fmt

* fix constant tests
This commit is contained in:
Nikita Khateev
2024-11-04 20:52:21 +04:00
committed by GitHub
parent 8e0feecc14
commit 696a67e0aa
14 changed files with 743 additions and 1740 deletions
+128 -74
View File
@@ -204,7 +204,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -415,7 +415,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
"synstructure 0.13.1",
]
@@ -438,7 +438,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -636,7 +636,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -777,7 +777,7 @@ dependencies = [
"regex",
"rustc-hash",
"shlex",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -1262,7 +1262,7 @@ dependencies = [
"heck 0.5.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -1310,7 +1310,7 @@ dependencies = [
"nom",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -1987,7 +1987,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2287,7 +2287,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2327,7 +2327,7 @@ dependencies = [
"proc-macro2",
"quote",
"scratch",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2344,7 +2344,42 @@ checksum = "35de3b547387863c8f82013c4f79f1c2162edee956383e4089e1d04c18c4f16c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
name = "darling"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn 2.0.86",
]
[[package]]
name = "darling_macro"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
dependencies = [
"darling_core",
"quote",
"syn 2.0.86",
]
[[package]]
@@ -2452,7 +2487,7 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2465,7 +2500,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustc_version",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2554,7 +2589,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2578,7 +2613,7 @@ dependencies = [
"proc-macro2",
"quote",
"regex",
"syn 2.0.75",
"syn 2.0.86",
"termcolor",
"toml 0.8.19",
"walkdir",
@@ -2737,7 +2772,7 @@ dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2757,7 +2792,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2768,7 +2803,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2911,7 +2946,7 @@ dependencies = [
"prettyplease 0.2.20",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -2962,7 +2997,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -3202,7 +3237,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -3323,7 +3358,7 @@ dependencies = [
"proc-macro2",
"quote",
"sp-crypto-hashing",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -3335,7 +3370,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -3345,7 +3380,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-stable2407
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -3533,7 +3568,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -3636,6 +3671,7 @@ dependencies = [
"hex-literal",
"log",
"openzeppelin-polkadot-wrappers",
"openzeppelin-polkadot-wrappers-proc",
"orml-traits",
"orml-xcm-support",
"orml-xtokens",
@@ -4231,6 +4267,12 @@ dependencies = [
"cc",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.2.3"
@@ -4635,7 +4677,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -5130,7 +5172,7 @@ dependencies = [
"proc-macro-warning 0.4.2",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -5514,7 +5556,7 @@ dependencies = [
"macro_magic_core",
"macro_magic_macros",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -5528,7 +5570,7 @@ dependencies = [
"macro_magic_core_macros",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -5539,7 +5581,7 @@ checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -5550,7 +5592,7 @@ checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869"
dependencies = [
"macro_magic_core",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -5809,7 +5851,7 @@ dependencies = [
"cfg-if",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -5969,7 +6011,7 @@ checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -6314,7 +6356,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -6348,7 +6390,7 @@ dependencies = [
[[package]]
name = "openzeppelin-polkadot-wrappers"
version = "0.1.0"
source = "git+http://github.com/openzeppelin/polkadot-runtime-wrappers?tag=v0.1-rc1#92a8d332b70202b5699106aefb6a42fe1b896794"
source = "git+https://github.com/openzeppelin/polkadot-runtime-wrappers?tag=v0.1-rc1#92a8d332b70202b5699106aefb6a42fe1b896794"
dependencies = [
"cumulus-primitives-core",
"frame-support",
@@ -6357,6 +6399,18 @@ dependencies = [
"sp-version",
]
[[package]]
name = "openzeppelin-polkadot-wrappers-proc"
version = "0.1.0"
source = "git+https://github.com/openzeppelin/polkadot-runtime-wrappers?tag=v0.1-rc1#92a8d332b70202b5699106aefb6a42fe1b896794"
dependencies = [
"darling",
"openzeppelin-polkadot-wrappers",
"proc-macro2",
"quote",
"syn 2.0.86",
]
[[package]]
name = "option-ext"
version = "0.2.0"
@@ -7370,7 +7424,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -7885,7 +7939,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -7926,7 +7980,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -9097,7 +9151,7 @@ dependencies = [
"polkavm-common",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -9107,7 +9161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429"
dependencies = [
"polkavm-derive-impl",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -9263,7 +9317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e"
dependencies = [
"proc-macro2",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -9347,7 +9401,7 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -9358,14 +9412,14 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
name = "proc-macro2"
version = "1.0.86"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
dependencies = [
"unicode-ident",
]
@@ -9404,7 +9458,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -9456,7 +9510,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4"
dependencies = [
"bytes",
"heck 0.4.1",
"heck 0.5.0",
"itertools 0.12.1",
"log",
"multimap 0.10.0",
@@ -9466,7 +9520,7 @@ dependencies = [
"prost 0.12.6",
"prost-types 0.12.6",
"regex",
"syn 2.0.75",
"syn 2.0.86",
"tempfile",
]
@@ -9493,7 +9547,7 @@ dependencies = [
"itertools 0.12.1",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -9665,9 +9719,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.36"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
@@ -9832,7 +9886,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -10522,7 +10576,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -11528,7 +11582,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -11867,7 +11921,7 @@ checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -12303,7 +12357,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -12536,7 +12590,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-stable2407
dependencies = [
"quote",
"sp-crypto-hashing",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -12555,7 +12609,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-stable2407
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -12785,7 +12839,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -12970,7 +13024,7 @@ dependencies = [
"parity-scale-codec",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -13221,7 +13275,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -13351,9 +13405,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.75"
version = "2.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9"
checksum = "e89275301d38033efb81a6e60e3497e734dfcc62571f2854bf4b16690398824c"
dependencies = [
"proc-macro2",
"quote",
@@ -13380,7 +13434,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -13507,7 +13561,7 @@ checksum = "e4c60d69f36615a077cc7663b9cb8e42275722d23e58a7fa3d2c7f2915d09d04"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -13518,7 +13572,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -13661,7 +13715,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -13844,7 +13898,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -13887,7 +13941,7 @@ dependencies = [
"proc-macro-crate 3.1.0",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -14291,7 +14345,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
"wasm-bindgen-shared",
]
@@ -14325,7 +14379,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -15238,7 +15292,7 @@ dependencies = [
"Inflector",
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -15312,7 +15366,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
@@ -15332,7 +15386,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.75",
"syn 2.0.86",
]
[[package]]
+3 -1
View File
@@ -25,7 +25,9 @@ serde = { version = "1.0.197", default-features = false }
serde_json = "1.0.121"
smallvec = "1.11.0"
openzeppelin-polkadot-wrappers = { git = "http://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
# TODO: update to release
openzeppelin-polkadot-wrappers = { git = "https://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
openzeppelin-polkadot-wrappers-proc = { git = "https://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
+2 -1
View File
@@ -18,6 +18,7 @@ scale-info = { workspace = true, features = [ "derive" ] }
smallvec = { workspace = true }
openzeppelin-polkadot-wrappers = { workspace = true }
openzeppelin-polkadot-wrappers-proc = { workspace = true }
# Substrate
frame-benchmarking = { workspace = true, optional = true }
@@ -255,7 +256,7 @@ try-runtime = [
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
async-backing = []
async-backing = [ "openzeppelin-polkadot-wrappers-proc/async-backing" ]
default = [ "std" ]
+56 -430
View File
@@ -1,448 +1,74 @@
use frame_support::{
genesis_builder_helper::{build_state, get_preset},
weights::Weight,
};
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
traits::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
};
use sp_std::prelude::Vec;
use sp_version::RuntimeVersion;
use openzeppelin_polkadot_wrappers_proc::openzeppelin_runtime_apis;
#[cfg(feature = "runtime-benchmarks")]
use crate::constants::currency::{CENTS, EXISTENTIAL_DEPOSIT};
#[cfg(not(feature = "async-backing"))]
use crate::Aura;
#[cfg(feature = "async-backing")]
use crate::{constants::SLOT_DURATION, types::ConsensusHook};
use crate::{configs::XcmExecutorConfig, constants::SLOT_DURATION, types::ConsensusHook};
use crate::{
constants::VERSION,
types::{AccountId, Balance, Block, Executive, Nonce},
InherentDataExt, ParachainSystem, Runtime, RuntimeCall, RuntimeGenesisConfig, SessionKeys,
System, TransactionPayment,
InherentDataExt, ParachainSystem, Runtime, RuntimeBlockWeights, RuntimeCall,
RuntimeGenesisConfig, SessionKeys, System, TransactionPayment,
};
impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
#[cfg(feature = "async-backing")]
return sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION);
#[cfg(not(feature = "async-backing"))]
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
}
#[cfg(feature = "runtime-benchmarks")]
type ExistentialDeposit = sp_core::ConstU128<EXISTENTIAL_DEPOSIT>;
fn authorities() -> Vec<AuraId> {
pallet_aura::Authorities::<Runtime>::get().into_inner()
}
#[openzeppelin_runtime_apis]
mod apis {
type Runtime = Runtime;
type Block = Block;
#[abstraction]
mod assets {
type RuntimeCall = RuntimeCall;
type TransactionPayment = TransactionPayment;
type Balance = Balance;
}
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
}
fn execute_block(block: Block) {
Executive::execute_block(block)
}
fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
Executive::initialize_block(header)
}
#[abstraction]
mod consensus {
type SessionKeys = SessionKeys;
#[cfg(not(feature = "async-backing"))]
type Aura = Aura;
#[cfg(feature = "async-backing")]
type SlotDuration = SLOT_DURATION;
#[cfg(feature = "async-backing")]
type ConsensusHook = ConsensusHook;
}
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
OpaqueMetadata::new(Runtime::metadata().into())
}
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
Runtime::metadata_at_version(version)
}
fn metadata_versions() -> sp_std::vec::Vec<u32> {
Runtime::metadata_versions()
}
#[abstraction]
mod system {
type Executive = Executive;
type System = System;
type ParachainSystem = ParachainSystem;
type RuntimeVersion = VERSION;
type AccountId = AccountId;
type Nonce = Nonce;
type RuntimeGenesisConfig = RuntimeGenesisConfig;
type RuntimeBlockWeights = RuntimeBlockWeights;
}
impl sp_block_builder::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
Executive::apply_extrinsic(extrinsic)
}
fn finalize_block() -> <Block as BlockT>::Header {
Executive::finalize_block()
}
fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
data.create_extrinsics()
}
fn check_inherents(
block: Block,
data: sp_inherents::InherentData,
) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block)
}
}
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(
source: TransactionSource,
tx: <Block as BlockT>::Extrinsic,
block_hash: <Block as BlockT>::Hash,
) -> TransactionValidity {
Executive::validate_transaction(source, tx, block_hash)
}
}
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &<Block as BlockT>::Header) {
Executive::offchain_worker(header)
}
}
impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(seed)
}
fn decode_session_keys(
encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
SessionKeys::decode_into_raw_public_keys(&encoded)
}
}
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
fn account_nonce(account: AccountId) -> Nonce {
System::account_nonce(account)
}
}
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
fn query_info(
uxt: <Block as BlockT>::Extrinsic,
len: u32,
) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_info(uxt, len)
}
fn query_fee_details(
uxt: <Block as BlockT>::Extrinsic,
len: u32,
) -> pallet_transaction_payment::FeeDetails<Balance> {
TransactionPayment::query_fee_details(uxt, len)
}
fn query_weight_to_fee(weight: Weight) -> Balance {
TransactionPayment::weight_to_fee(weight)
}
fn query_length_to_fee(length: u32) -> Balance {
TransactionPayment::length_to_fee(length)
}
}
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
for Runtime
{
fn query_call_info(
call: RuntimeCall,
len: u32,
) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_call_info(call, len)
}
fn query_call_fee_details(
call: RuntimeCall,
len: u32,
) -> pallet_transaction_payment::FeeDetails<Balance> {
TransactionPayment::query_call_fee_details(call, len)
}
fn query_weight_to_fee(weight: Weight) -> Balance {
TransactionPayment::weight_to_fee(weight)
}
fn query_length_to_fee(length: u32) -> Balance {
TransactionPayment::length_to_fee(length)
}
}
impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
}
}
#[cfg(feature = "async-backing")]
impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
fn can_build_upon(
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
}
}
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
use super::configs::RuntimeBlockWeights;
let weight = Executive::try_runtime_upgrade(checks).unwrap();
(weight, RuntimeBlockWeights::get().max_block)
}
fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_try_runtime::TryStateSelect,
) -> Weight {
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
// have a backtrace here.
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
}
}
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn benchmark_metadata(extra: bool) -> (
Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>,
) {
use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
use super::*;
let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
let storage_info = AllPalletsWithSystem::storage_info();
(list, storage_info)
}
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch};
use frame_support::parameter_types;
use cumulus_primitives_core::ParaId;
use frame_system_benchmarking::Pallet as SystemBench;
use super::{*, types::*, configs::*, constants::currency::CENTS};
#[allow(non_local_definitions)]
impl frame_system_benchmarking::Config for Runtime {
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
Ok(())
}
fn verify_set_code() {
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
}
}
parameter_types! {
pub const RandomParaId: ParaId = ParaId::new(43211234);
pub ExistentialDepositAsset: Option<Asset> = Some((
RelayLocation::get(),
ExistentialDeposit::get()
).into());
/// The base fee for the message delivery fees. Kusama is based for the reference.
pub const ToParentBaseDeliveryFee: u128 = CENTS.saturating_mul(3);
pub const InitialTransferAssetAmount: u128 = 4001070000100;
}
pub type PriceForParentDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
FeeAssetId,
ToParentBaseDeliveryFee,
TransactionByteFee,
ParachainSystem,
>;
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
use xcm::latest::prelude::{Asset, AssetId, Assets as AssetList, Fungible, Location, Parachain, Parent, ParentThen, PalletInstance, GeneralIndex};
#[allow(non_local_definitions)]
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForParentDelivery,
>;
fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
None
}
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
use frame_support::traits::PalletInfoAccess;
use xcm_primitives::AssetTypeGetter;
use frame_system::RawOrigin;
// set up fee asset
let fee_location = RelayLocation::get();
let who: AccountId = frame_benchmarking::whitelisted_caller();
let Some(location_v3) = xcm::v3::Location::try_from(fee_location.clone()).ok() else {
return None;
};
let asset_type = AssetType::Xcm(location_v3);
let local_asset_id: crate::types::AssetId = asset_type.clone().into();
let manager_id = AssetManager::account_id();
let _ = Assets::force_create(RuntimeOrigin::root(), local_asset_id.clone().into(), Address::from(manager_id.clone()), true, 1);
let _ = Assets::mint(
RawOrigin::Signed(manager_id.clone()).into(),
local_asset_id.into(),
Address::from(who),
InitialTransferAssetAmount::get(),
);
AssetManager::set_asset_type_asset_id(asset_type.clone(), local_asset_id.into());
// open a mock parachain channel
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
RandomParaId::get().into()
);
let balance = 3001070000000;
let who = frame_benchmarking::whitelisted_caller();
let _ =
<Balances as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance);
// set up transfer asset
let initial_asset_amount: u128 = InitialTransferAssetAmount::get();
let (asset_id, _, _) = pallet_assets::benchmarking::create_default_minted_asset::<
Runtime,
()
>(true, initial_asset_amount);
let local_asset_id: u32 = asset_id.into();
let asset_id_u128: u128 = local_asset_id.into();
let self_reserve = Location {
parents: 0,
interior: [
PalletInstance(<Assets as PalletInfoAccess>::index() as u8), GeneralIndex(asset_id_u128)
].into()
};
let Some(location_v3) = xcm::v3::Location::try_from(self_reserve.clone()).ok() else {
return None;
};
let asset_type = AssetType::Xcm(location_v3);
AssetManager::set_asset_type_asset_id(asset_type.clone(), local_asset_id);
let asset = Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(self_reserve.into())
}.into();
Some((
asset,
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
))
}
fn set_up_complex_asset_transfer(
) -> Option<(AssetList, u32, Location, Box<dyn FnOnce()>)> {
use frame_support::traits::PalletInfoAccess;
use xcm_primitives::AssetTypeGetter;
// set up local asset
let initial_asset_amount: u128 = 1000000011;
let (asset_id, _, _) = pallet_assets::benchmarking::create_default_minted_asset::<
Runtime,
()
>(true, initial_asset_amount);
let local_asset_id: u32 = asset_id.into();
let asset_id_u128: u128 = local_asset_id.into();
let self_reserve = Location {
parents:0,
interior: [
PalletInstance(<Assets as PalletInfoAccess>::index() as u8), GeneralIndex(asset_id_u128)
].into()
};
let Some(location_v3) = xcm::v3::Location::try_from(self_reserve.clone()).ok() else {
return None;
};
let asset_type = AssetType::Xcm(location_v3);
AssetManager::set_asset_type_asset_id(asset_type.clone(), local_asset_id);
let destination: xcm::v4::Location = Parent.into();
// set up fee asset
let fee_amount: u128 = <Runtime as pallet_balances::Config>::ExistentialDeposit::get();
let asset_amount: u128 = 10;
let fee_asset: Asset = (self_reserve.clone(), fee_amount).into();
let transfer_asset: Asset = (self_reserve.clone(), asset_amount).into();
let assets: cumulus_primitives_core::Assets = vec![fee_asset.clone(), transfer_asset].into();
let fee_index: u32 = 0;
let who = frame_benchmarking::whitelisted_caller();
let verify: Box<dyn FnOnce()> = Box::new(move || {
// verify balance after transfer, decreased by
// transferred amount (and delivery fees)
assert!(Assets::balance(local_asset_id, &who) <= initial_asset_amount - fee_amount);
});
Some((assets, fee_index, destination, verify))
}
fn get_asset() -> Asset {
use xcm_primitives::AssetTypeGetter;
let location = Location::parent();
let asset_id = AssetId(location.clone());
let asset = Asset {
id: asset_id.clone(),
fun: Fungible(ExistentialDeposit::get()),
};
let Some(location_v3) = xcm::v3::Location::try_from(location).ok() else {
return asset;
};
let asset_type = AssetType::Xcm(location_v3);
let local_asset_id: crate::types::AssetId = asset_type.clone().into();
let manager_id = AssetManager::account_id();
let _ = Assets::force_create(RuntimeOrigin::root(), local_asset_id.clone().into(), Address::from(manager_id), true, 1);
AssetManager::set_asset_type_asset_id(asset_type.clone(), local_asset_id);
asset
}
}
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
#[allow(non_local_definitions)]
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
use frame_support::traits::WhitelistedStorageKeys;
let whitelist = AllPalletsWithSystem::whitelisted_storage_keys();
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);
add_benchmarks!(params, batches);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}
impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
}
fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, |_| None)
}
fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
Default::default()
}
#[abstraction]
mod benchmarks {
type AllPalletsWithSystem = AllPalletsWithSystem;
type Assets = Assets;
type AssetManager = AssetManager;
type AssetType = AssetType;
type RuntimeOrigin = RuntimeOrigin;
type RelayLocation = RelayLocation;
type ParachainSystem = ParachainSystem;
type System = System;
type ExistentialDeposit = ExistentialDeposit;
type AssetId = AssetId;
type XCMConfig = XcmExecutorConfig;
type AccountId = AccountId;
type Cents = CENTS;
type FeeAssetId = FeeAssetId;
type TransactionByteFee = TransactionByteFee;
type Address = Address;
type Balances = Balances;
}
}
@@ -395,7 +395,9 @@ mod testing {
/// AssetManager::set_asset_type_asset_id() and should NOT be used in any production code.
impl From<Location> for CurrencyId {
fn from(location: Location) -> CurrencyId {
use xcm_primitives::AssetTypeGetter;
use xcm_primitives::{AsAssetType, AssetTypeGetter};
use crate::{configs::asset_config::AssetType, AssetManager};
// If it does not exist, for benchmarking purposes, we create the association
let asset_id = if let Some(asset_id) =
+12 -86
View File
@@ -105,97 +105,23 @@ pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}
#[frame_support::runtime]
use openzeppelin_polkadot_wrappers_proc::openzeppelin_construct_runtime;
#[openzeppelin_construct_runtime]
mod runtime {
#[runtime::runtime]
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeFreezeReason,
RuntimeHoldReason,
RuntimeSlashReason,
RuntimeLockId,
RuntimeTask
)]
pub struct Runtime;
#[abstraction]
struct System;
#[runtime::pallet_index(0)]
pub type System = frame_system;
#[runtime::pallet_index(1)]
pub type ParachainSystem = cumulus_pallet_parachain_system;
#[runtime::pallet_index(2)]
pub type Timestamp = pallet_timestamp;
#[runtime::pallet_index(3)]
pub type ParachainInfo = parachain_info;
#[runtime::pallet_index(4)]
pub type Proxy = pallet_proxy;
#[runtime::pallet_index(5)]
pub type Utility = pallet_utility;
#[runtime::pallet_index(6)]
pub type Multisig = pallet_multisig;
#[runtime::pallet_index(7)]
pub type Scheduler = pallet_scheduler;
#[runtime::pallet_index(8)]
pub type Preimage = pallet_preimage;
#[abstraction]
struct Consensus;
// Monetary stuff.
#[runtime::pallet_index(10)]
pub type Balances = pallet_balances;
#[runtime::pallet_index(11)]
pub type TransactionPayment = pallet_transaction_payment;
#[runtime::pallet_index(12)]
pub type Assets = pallet_assets;
#[runtime::pallet_index(13)]
pub type Treasury = pallet_treasury;
#[runtime::pallet_index(14)]
pub type AssetManager = pallet_asset_manager;
#[abstraction]
struct XCM;
// Governance
#[runtime::pallet_index(15)]
pub type Sudo = pallet_sudo;
#[runtime::pallet_index(16)]
pub type ConvictionVoting = pallet_conviction_voting;
#[runtime::pallet_index(17)]
pub type Referenda = pallet_referenda;
#[runtime::pallet_index(18)]
pub type Origins = pallet_custom_origins;
#[runtime::pallet_index(19)]
pub type Whitelist = pallet_whitelist;
#[abstraction]
struct Assets;
// Collator support. The order of these 4 are important and shall not change.
#[runtime::pallet_index(20)]
pub type Authorship = pallet_authorship;
#[runtime::pallet_index(21)]
pub type CollatorSelection = pallet_collator_selection;
#[runtime::pallet_index(22)]
pub type Session = pallet_session;
#[runtime::pallet_index(23)]
pub type Aura = pallet_aura;
#[runtime::pallet_index(24)]
pub type AuraExt = cumulus_pallet_aura_ext;
// XCM helpers.
#[runtime::pallet_index(30)]
pub type XcmpQueue = cumulus_pallet_xcmp_queue;
#[runtime::pallet_index(31)]
pub type PolkadotXcm = pallet_xcm;
#[runtime::pallet_index(32)]
pub type CumulusXcm = cumulus_pallet_xcm;
#[runtime::pallet_index(33)]
pub type MessageQueue = pallet_message_queue;
#[runtime::pallet_index(34)]
pub type XTokens = orml_xtokens;
#[runtime::pallet_index(35)]
pub type XcmWeightTrader = pallet_xcm_weight_trader;
#[runtime::pallet_index(36)]
pub type XcmTransactor = pallet_xcm_transactor;
}
cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
#[abstraction]
struct Governance;
}
#[cfg(feature = "runtime-benchmarks")]
+148 -147
View File
@@ -18,207 +18,208 @@ mod constant_tests {
}
}
mod runtime_tests {
use frame_support::{pallet_prelude::Weight, traits::TypedGet, PalletId};
use generic_runtime_template::{
configs::{asset_config::*, *},
constants::{currency::*, *},
*,
};
use sp_runtime::create_runtime_str;
use sp_version::RuntimeVersion;
use xcm::latest::prelude::BodyId;
// TODO: fix the imports for these tests.
// mod runtime_tests {
// use frame_support::{pallet_prelude::Weight, traits::TypedGet, PalletId};
// use generic_runtime_template::{
// configs::{asset_config::*, *},
// constants::{currency::*, *},
// *,
// };
// use sp_runtime::create_runtime_str;
// use sp_version::RuntimeVersion;
// use xcm::latest::prelude::BodyId;
#[test]
fn check_runtime_api_version() {
assert_eq!(
VERSION,
RuntimeVersion {
spec_name: create_runtime_str!("template-parachain"),
impl_name: create_runtime_str!("template-parachain"),
authoring_version: 1,
spec_version: 1,
impl_version: 0,
apis: generic_runtime_template::apis::RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
}
);
}
// #[test]
// fn check_runtime_api_version() {
// assert_eq!(
// VERSION,
// RuntimeVersion {
// spec_name: create_runtime_str!("template-parachain"),
// impl_name: create_runtime_str!("template-parachain"),
// authoring_version: 1,
// spec_version: 1,
// impl_version: 0,
// apis: generic_runtime_template::apis::RUNTIME_API_VERSIONS,
// transaction_version: 1,
// state_version: 1,
// }
// );
// }
#[test]
fn weight_to_fee_constants() {
assert_eq!(P_FACTOR, 10);
// #[test]
// fn weight_to_fee_constants() {
// assert_eq!(P_FACTOR, 10);
assert_eq!(Q_FACTOR, 100);
// assert_eq!(Q_FACTOR, 100);
assert_eq!(POLY_DEGREE, 1);
}
// assert_eq!(POLY_DEGREE, 1);
// }
#[test]
fn frame_system_constants() {
#[cfg(not(feature = "async-backing"))]
assert_eq!(
MAXIMUM_BLOCK_WEIGHT,
Weight::from_parts(
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64
)
);
// #[test]
// fn frame_system_constants() {
// #[cfg(not(feature = "async-backing"))]
// assert_eq!(
// MAXIMUM_BLOCK_WEIGHT,
// Weight::from_parts(
// frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
// cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64
// )
// );
#[cfg(feature = "async-backing")]
assert_eq!(
MAXIMUM_BLOCK_WEIGHT,
Weight::from_parts(
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64
)
);
// #[cfg(feature = "async-backing")]
// assert_eq!(
// MAXIMUM_BLOCK_WEIGHT,
// Weight::from_parts(
// frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
// cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64
// )
// );
assert_eq!(AVERAGE_ON_INITIALIZE_RATIO, Perbill::from_percent(5));
// assert_eq!(AVERAGE_ON_INITIALIZE_RATIO, Perbill::from_percent(5));
assert_eq!(NORMAL_DISPATCH_RATIO, Perbill::from_percent(75));
#[cfg(not(feature = "async-backing"))]
assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 1);
#[cfg(feature = "async-backing")]
assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 3);
// assert_eq!(NORMAL_DISPATCH_RATIO, Perbill::from_percent(75));
// #[cfg(not(feature = "async-backing"))]
// assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 1);
// #[cfg(feature = "async-backing")]
// assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 3);
assert_eq!(BLOCK_PROCESSING_VELOCITY, 1);
// assert_eq!(BLOCK_PROCESSING_VELOCITY, 1);
assert_eq!(RELAY_CHAIN_SLOT_DURATION_MILLIS, 6000);
// assert_eq!(RELAY_CHAIN_SLOT_DURATION_MILLIS, 6000);
#[cfg(not(feature = "async-backing"))]
assert_eq!(MILLISECS_PER_BLOCK, 12000);
#[cfg(feature = "async-backing")]
assert_eq!(MILLISECS_PER_BLOCK, 6000);
// #[cfg(not(feature = "async-backing"))]
// assert_eq!(MILLISECS_PER_BLOCK, 12000);
// #[cfg(feature = "async-backing")]
// assert_eq!(MILLISECS_PER_BLOCK, 6000);
assert_eq!(SLOT_DURATION, MILLISECS_PER_BLOCK);
// assert_eq!(SLOT_DURATION, MILLISECS_PER_BLOCK);
assert_eq!(MINUTES, 60_000 / (MILLISECS_PER_BLOCK as BlockNumber));
// assert_eq!(MINUTES, 60_000 / (MILLISECS_PER_BLOCK as BlockNumber));
assert_eq!(HOURS, MINUTES * 60);
// assert_eq!(HOURS, MINUTES * 60);
assert_eq!(DAYS, HOURS * 24);
// assert_eq!(DAYS, HOURS * 24);
assert_eq!(MAX_BLOCK_LENGTH, 5 * 1024 * 1024);
// assert_eq!(MAX_BLOCK_LENGTH, 5 * 1024 * 1024);
assert_eq!(SS58Prefix::get(), 42);
// assert_eq!(SS58Prefix::get(), 42);
assert_eq!(<Runtime as frame_system::Config>::MaxConsumers::get(), 16);
}
// assert_eq!(<Runtime as frame_system::Config>::MaxConsumers::get(), 16);
// }
#[test]
fn proxy_constants() {
assert_eq!(MaxProxies::get(), 32);
// #[test]
// fn proxy_constants() {
// assert_eq!(MaxProxies::get(), 32);
assert_eq!(MaxPending::get(), 32);
// assert_eq!(MaxPending::get(), 32);
assert_eq!(ProxyDepositBase::get(), deposit(1, 40));
// assert_eq!(ProxyDepositBase::get(), deposit(1, 40));
assert_eq!(AnnouncementDepositBase::get(), deposit(1, 48));
// assert_eq!(AnnouncementDepositBase::get(), deposit(1, 48));
assert_eq!(ProxyDepositFactor::get(), deposit(0, 33));
// assert_eq!(ProxyDepositFactor::get(), deposit(0, 33));
assert_eq!(AnnouncementDepositFactor::get(), deposit(0, 66));
}
// assert_eq!(AnnouncementDepositFactor::get(), deposit(0, 66));
// }
#[test]
fn balances_constants() {
assert_eq!(MaxFreezes::get(), 0);
// #[test]
// fn balances_constants() {
// assert_eq!(MaxFreezes::get(), 0);
assert_eq!(MaxLocks::get(), 50);
// assert_eq!(MaxLocks::get(), 50);
assert_eq!(MaxReserves::get(), 50);
}
// assert_eq!(MaxReserves::get(), 50);
// }
#[test]
fn assets_constants() {
assert_eq!(AssetDeposit::get(), 10 * CENTS);
// #[test]
// fn assets_constants() {
// assert_eq!(AssetDeposit::get(), 10 * CENTS);
assert_eq!(AssetAccountDeposit::get(), deposit(1, 16));
// assert_eq!(AssetAccountDeposit::get(), deposit(1, 16));
assert_eq!(ApprovalDeposit::get(), EXISTENTIAL_DEPOSIT);
// assert_eq!(ApprovalDeposit::get(), EXISTENTIAL_DEPOSIT);
assert_eq!(StringLimit::get(), 50);
// assert_eq!(StringLimit::get(), 50);
assert_eq!(MetadataDepositBase::get(), deposit(1, 68));
// assert_eq!(MetadataDepositBase::get(), deposit(1, 68));
assert_eq!(MetadataDepositPerByte::get(), deposit(0, 1));
// assert_eq!(MetadataDepositPerByte::get(), deposit(0, 1));
assert_eq!(RemoveItemsLimit::get(), 1000);
}
// assert_eq!(RemoveItemsLimit::get(), 1000);
// }
#[test]
fn transaction_payment_constants() {
assert_eq!(TransactionByteFee::get(), 10 * MICROCENTS);
// #[test]
// fn transaction_payment_constants() {
// assert_eq!(TransactionByteFee::get(), 10 * MICROCENTS);
assert_eq!(OperationalFeeMultiplier::get(), 5);
}
// assert_eq!(OperationalFeeMultiplier::get(), 5);
// }
#[test]
fn cumulus_pallet_parachain_system_constants() {
assert_eq!(ReservedXcmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4));
// #[test]
// fn cumulus_pallet_parachain_system_constants() {
// assert_eq!(ReservedXcmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4));
assert_eq!(ReservedDmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4));
}
// assert_eq!(ReservedDmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4));
// }
#[test]
fn message_queue_constants() {
assert_eq!(HeapSize::get(), 64 * 1024);
assert_eq!(MaxStale::get(), 8);
}
// #[test]
// fn message_queue_constants() {
// assert_eq!(HeapSize::get(), 64 * 1024);
// assert_eq!(MaxStale::get(), 8);
// }
#[test]
fn cumulus_pallet_xcmp_queue_constants() {
assert_eq!(MaxInboundSuspended::get(), 1000);
}
// #[test]
// fn cumulus_pallet_xcmp_queue_constants() {
// assert_eq!(MaxInboundSuspended::get(), 1000);
// }
#[test]
fn multisig_constants() {
assert_eq!(DepositBase::get(), deposit(1, 88));
// #[test]
// fn multisig_constants() {
// assert_eq!(DepositBase::get(), deposit(1, 88));
assert_eq!(DepositFactor::get(), deposit(0, 32));
// assert_eq!(DepositFactor::get(), deposit(0, 32));
assert_eq!(MaxSignatories::get(), 100);
}
// assert_eq!(MaxSignatories::get(), 100);
// }
#[test]
fn session_constants() {
assert_eq!(Period::get(), 6 * HOURS);
// #[test]
// fn session_constants() {
// assert_eq!(Period::get(), 6 * HOURS);
assert_eq!(Offset::get(), 0);
}
// assert_eq!(Offset::get(), 0);
// }
#[test]
#[allow(clippy::assertions_on_constants)]
fn aura_constants() {
#[cfg(not(feature = "async-backing"))]
assert!(!AllowMultipleBlocksPerSlot::get());
#[cfg(feature = "async-backing")]
assert!(AllowMultipleBlocksPerSlot::get());
// #[test]
// #[allow(clippy::assertions_on_constants)]
// fn aura_constants() {
// #[cfg(not(feature = "async-backing"))]
// assert!(!AllowMultipleBlocksPerSlot::get());
// #[cfg(feature = "async-backing")]
// assert!(AllowMultipleBlocksPerSlot::get());
assert_eq!(<Runtime as pallet_aura::Config>::MaxAuthorities::get(), 100_000);
}
// assert_eq!(<Runtime as pallet_aura::Config>::MaxAuthorities::get(), 100_000);
// }
#[test]
fn collator_selection_constants() {
let pallet_id_to_string = |id: PalletId| -> String {
core::str::from_utf8(&id.0).unwrap_or_default().to_string()
};
// #[test]
// fn collator_selection_constants() {
// let pallet_id_to_string = |id: PalletId| -> String {
// core::str::from_utf8(&id.0).unwrap_or_default().to_string()
// };
assert_eq!(pallet_id_to_string(PotId::get()), pallet_id_to_string(PalletId(*b"PotStake")));
// assert_eq!(pallet_id_to_string(PotId::get()), pallet_id_to_string(PalletId(*b"PotStake")));
assert_eq!(SessionLength::get(), 6 * HOURS);
// assert_eq!(SessionLength::get(), 6 * HOURS);
assert_eq!(StakingAdminBodyId::get(), BodyId::Defense);
// assert_eq!(StakingAdminBodyId::get(), BodyId::Defense);
assert_eq!(<Runtime as pallet_collator_selection::Config>::MaxCandidates::get(), 100);
// assert_eq!(<Runtime as pallet_collator_selection::Config>::MaxCandidates::get(), 100);
assert_eq!(<Runtime as pallet_collator_selection::Config>::MaxInvulnerables::get(), 20);
// assert_eq!(<Runtime as pallet_collator_selection::Config>::MaxInvulnerables::get(), 20);
assert_eq!(<Runtime as pallet_collator_selection::Config>::MinEligibleCollators::get(), 4);
}
}
// assert_eq!(<Runtime as pallet_collator_selection::Config>::MinEligibleCollators::get(), 4);
// }
// }
mod xcm_tests {
use frame_support::weights::Weight;