Slap runtime_version macro everywhere (#444)

* Slap runtime_version macro everywhere

* Update Substrate

This includes the fix of compilation for macOS platforms.
This commit is contained in:
Sergei Shulepov
2021-05-19 12:34:02 +02:00
committed by GitHub
parent d458d2622b
commit 093b574d13
4 changed files with 185 additions and 162 deletions
+156 -156
View File
File diff suppressed because it is too large Load Diff
@@ -76,6 +76,7 @@ impl_opaque_keys! {
} }
/// This runtime version. /// This runtime version.
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion { pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("test-parachain"), spec_name: create_runtime_str!("test-parachain"),
impl_name: create_runtime_str!("test-parachain"), impl_name: create_runtime_str!("test-parachain"),
@@ -59,6 +59,7 @@ use xcm_builder::{
use xcm_executor::{Config, XcmExecutor}; use xcm_executor::{Config, XcmExecutor};
/// This runtime version. /// This runtime version.
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion { pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("shell"), spec_name: create_runtime_str!("shell"),
impl_name: create_runtime_str!("shell"), impl_name: create_runtime_str!("shell"),
+27 -6
View File
@@ -59,17 +59,38 @@ impl_opaque_keys! {
pub struct SessionKeys {} pub struct SessionKeys {}
} }
const SPEC_VERSION: u32 = 3; // The only difference between the two declarations below is the `spec_version`. With the
// `upgrade` feature enabled `spec_version` should be greater than the one of without the
// `upgrade` feature.
//
// The duplication here is unfortunate necessity.
//
// runtime_version macro is dumb. It accepts a const item declaration, passes it through and
// also emits runtime version custom section. It parses the expressions to extract the version
// details. Since macro kicks in early, it operates on AST. Thus you cannot use constants.
// Macros are expanded top to bottom, meaning we also cannot use `cfg` here.
/// This runtime version. #[cfg(feature = "upgrade")]
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion { pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("cumulus-test-parachain"), spec_name: create_runtime_str!("cumulus-test-parachain"),
impl_name: create_runtime_str!("cumulus-test-parachain"), impl_name: create_runtime_str!("cumulus-test-parachain"),
authoring_version: 1, authoring_version: 1,
#[cfg(feature = "upgrade")] // Read the note above.
spec_version: SPEC_VERSION + 1, spec_version: 4,
#[cfg(not(feature = "upgrade"))] impl_version: 1,
spec_version: SPEC_VERSION, apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};
#[cfg(not(feature = "upgrade"))]
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("cumulus-test-parachain"),
impl_name: create_runtime_str!("cumulus-test-parachain"),
authoring_version: 1,
// Read the note above.
spec_version: 3,
impl_version: 1, impl_version: 1,
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
transaction_version: 1, transaction_version: 1,