Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RuntimeVerison type and use system_version to derive extrinsics root StateVersion instead of V0 #4257

Merged
merged 26 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f72efc2
rename `state_version` to `system_version` in `RuntimeVersion` type
vedhavyas Apr 23, 2024
17a857f
update extrinsic root to use the state_version dervied from the Runti…
vedhavyas Apr 23, 2024
f7293df
update docs-tests and tests
vedhavyas Apr 23, 2024
246d3f3
Merge branch 'master' into system_version
vedhavyas Jun 24, 2024
d497f25
add prdoc and some fixes
vedhavyas Jun 24, 2024
1ae816c
Update cumulus/parachains/runtimes/starters/seedling/src/lib.rs
vedhavyas Jul 24, 2024
227d68d
Update cumulus/parachains/runtimes/starters/shell/src/lib.rs
vedhavyas Jul 24, 2024
a97a69c
Update prdoc/pr_4257.prdoc
vedhavyas Jul 24, 2024
3f4c79a
Merge branch 'master' into system_version
vedhavyas Jul 25, 2024
2db4305
Merge branch 'master' into system_version
nazar-pc Jul 28, 2024
08ca0c8
Merge branch 'master' into system_version
nazar-pc Aug 6, 2024
a901162
Merge branch 'master' into system_version
vedhavyas Aug 12, 2024
3919d77
add deprecation warning and backward compatibility for older runtime …
vedhavyas Aug 12, 2024
ac6688b
use proc-macro-warning to notify deprecation
vedhavyas Aug 13, 2024
4a836e0
Merge remote-tracking branch 'upstream/master' into system_version
nazar-pc Aug 23, 2024
2925bc6
Apply review suggestions
nazar-pc Aug 23, 2024
da10cf6
Fix prdoc
nazar-pc Aug 23, 2024
4d46886
Merge branch 'master' into system_version
nazar-pc Aug 27, 2024
89b764a
Add `stateVersion` alias to renamed `systemVersion` field
nazar-pc Aug 27, 2024
2d474f4
Manual serde serialization implementation for `RuntimeVersion` to gen…
nazar-pc Aug 29, 2024
5ac52a2
Merge remote-tracking branch 'upstream/master' into system_version
nazar-pc Aug 29, 2024
4248931
Allow both old `stateVersion` and new `systemVersion` to be present a…
nazar-pc Aug 29, 2024
abc1e5f
Check that both `stateVersion` and `systemVersion` when present in se…
nazar-pc Aug 30, 2024
7ad19de
Merge branch 'master' into system_version
nazar-pc Aug 30, 2024
2340a94
Fix no-std compilation
nazar-pc Aug 30, 2024
5b1e88e
Merge remote-tracking branch 'upstream/master' into system_version
nazar-pc Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cumulus/client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl RelayChainInterface for DummyRelayChainInterface {
impl_version: 0,
apis: Cow::Owned(apis),
transaction_version: 5,
state_version: 1,
system_version: 1,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/pov-recovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl RelayChainInterface for Relaychain {
impl_version: 0,
apis: Cow::Owned(apis),
transaction_version: 5,
state_version: 1,
system_version: 1,
})
}

Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/parachain-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ parameter_types! {
impl_version: 1,
apis: sp_version::create_apis_vec!([]),
transaction_version: 1,
state_version: 1,
system_version: 1,
};
pub const ParachainId: ParaId = ParaId::new(200);
pub const ReservedXcmpWeight: Weight = Weight::zero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 16,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 16,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 5,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 5,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 6,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 7,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/starters/seedling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
state_version: 0,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/starters/shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 0,
system_version: 1,
};

/// The version information used to identify this runtime when compiled natively.
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

/// This determines the average expected block time that we are targeting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 6,
state_version: 0,
system_version: 0,
};

pub const MILLISECS_PER_BLOCK: u64 = 6000;
Expand Down
4 changes: 2 additions & 2 deletions cumulus/test/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

#[cfg(feature = "increment-spec-version")]
Expand All @@ -146,7 +146,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

pub const EPOCH_DURATION_IN_BLOCKS: u32 = 10 * MINUTES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

/// The signed extensions that are added to the runtime.
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 26,
state_version: 1,
system_version: 1,
};

/// The BABE epoch configuration at genesis.
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

/// The BABE epoch configuration at genesis.
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 26,
state_version: 1,
system_version: 1,
};

/// The BABE epoch configuration at genesis.
Expand Down
76 changes: 76 additions & 0 deletions prdoc/pr_4257.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Rename `state_version` in `RuntimeVersion` to `system_version`.

doc:
- audience: Runtime Dev
description: |
This PR renames `state_version` in `RuntimeVersion` to `system_version`. `system_version=2` signifies
that extrinsic root derivation uses `StateVersion::V1`.

- audience: Runtime User
description: |
`RuntimeVersion`'s `state_version` is renamed to `system_version`. Applications using that type and its field
must update their code to reflect the changes. For easier migration serde serialization produces both new
`systemVersion` and old `stateVersion` fields and deserialization supports `stateVersion` as an alias as too.

crates:
- name: frame-system
bump: major
- name: sp-api
bump: none
- name: sp-version
bump: major
- name: sp-storage
bump: minor
- name: sp-version-proc-macro
bump: minor
- name: sc-block-builder
bump: major
- name: sc-executor
bump: major
- name: sc-rpc
bump: none
- name: sc-rpc-spec-v2
bump: none
- name: cumulus-pallet-parachain-system
bump: none
- name: cumulus-client-pov-recovery
bump: none
- name: cumulus-client-network
bump: none
- name: rococo-runtime
bump: major
- name: westend-runtime
bump: major
- name: asset-hub-rococo-runtime
bump: major
- name: asset-hub-westend-runtime
bump: major
- name: bridge-hub-rococo-runtime
bump: major
- name: bridge-hub-westend-runtime
bump: major
- name: collectives-westend-runtime
bump: major
- name: coretime-rococo-runtime
bump: major
- name: coretime-westend-runtime
bump: major
- name: people-rococo-runtime
bump: major
- name: people-westend-runtime
bump: major
- name: penpal-runtime
bump: major
- name: contracts-rococo-runtime
bump: major
- name: glutton-westend-runtime
bump: major
- name: seedling-runtime
bump: major
- name: shell-runtime
bump: major
- name: rococo-parachain-runtime
bump: major
2 changes: 1 addition & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
state_version: 1,
system_version: 1,
};

/// The BABE epoch configuration at genesis.
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/block-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ where
header.extrinsics_root().clone(),
HashingFor::<Block>::ordered_trie_root(
self.extrinsics.iter().map(Encode::encode).collect(),
sp_runtime::StateVersion::V0,
self.api.version(self.parent_hash)?.extrinsics_root_state_version(),
),
);

Expand Down
12 changes: 6 additions & 6 deletions substrate/client/executor/src/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ mod tests {

let version = decode_version(&old_runtime_version.encode()).unwrap();
assert_eq!(1, version.transaction_version);
assert_eq!(0, version.state_version);
assert_eq!(0, version.system_version);
}

#[test]
Expand All @@ -507,12 +507,12 @@ mod tests {
impl_version: 1,
apis: create_apis_vec!([(<dyn Core::<Block>>::ID, 3)]),
transaction_version: 3,
state_version: 4,
system_version: 4,
};

let version = decode_version(&old_runtime_version.encode()).unwrap();
assert_eq!(3, version.transaction_version);
assert_eq!(0, version.state_version);
assert_eq!(0, version.system_version);

let old_runtime_version = RuntimeVersion {
spec_name: "test".into(),
Expand All @@ -522,12 +522,12 @@ mod tests {
impl_version: 1,
apis: create_apis_vec!([(<dyn Core::<Block>>::ID, 4)]),
transaction_version: 3,
state_version: 4,
system_version: 4,
};

let version = decode_version(&old_runtime_version.encode()).unwrap();
assert_eq!(3, version.transaction_version);
assert_eq!(4, version.state_version);
assert_eq!(4, version.system_version);
}

#[test]
Expand All @@ -545,7 +545,7 @@ mod tests {
impl_version: 100,
apis: create_apis_vec!([(<dyn Core::<Block>>::ID, 4)]),
transaction_version: 100,
state_version: 1,
system_version: 1,
};

let embedded = sp_version::embed::embed_runtime_version(&wasm, runtime_version.clone())
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/rpc-spec-v2/src/chain_head/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ async fn follow_with_runtime() {
[\"0x37e397fc7c91f5e4\",2],[\"0xd2bc9897eed08f15\",3],[\"0x40fe3ad401f8959a\",6],\
[\"0xbc9d89904f5b923f\",1],[\"0xc6e9a76309f39b09\",2],[\"0xdd718d5cc53262d4\",1],\
[\"0xcbca25e39f142387\",2],[\"0xf78b278be53f454c\",2],[\"0xab3c0572291feb8b\",1],\
[\"0xed99c5acb25eedf5\",3],[\"0xfbc577b9d747efd6\",1]],\"transactionVersion\":1,\"stateVersion\":1}";
[\"0xed99c5acb25eedf5\",3],[\"0xfbc577b9d747efd6\",1]],\"transactionVersion\":1,\"systemVersion\":1}";

let runtime: RuntimeVersion = serde_json::from_str(runtime_str).unwrap();

Expand Down
3 changes: 2 additions & 1 deletion substrate/client/rpc/src/state/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ async fn should_return_runtime_version() {
[\"0x37e397fc7c91f5e4\",2],[\"0xd2bc9897eed08f15\",3],[\"0x40fe3ad401f8959a\",6],\
[\"0xbc9d89904f5b923f\",1],[\"0xc6e9a76309f39b09\",2],[\"0xdd718d5cc53262d4\",1],\
[\"0xcbca25e39f142387\",2],[\"0xf78b278be53f454c\",2],[\"0xab3c0572291feb8b\",1],\
[\"0xed99c5acb25eedf5\",3],[\"0xfbc577b9d747efd6\",1]],\"transactionVersion\":1,\"stateVersion\":1}";
[\"0xed99c5acb25eedf5\",3],[\"0xfbc577b9d747efd6\",1]],\"transactionVersion\":1,\"systemVersion\":1,\
\"stateVersion\":1}";

let runtime_version = api.runtime_version(None.into()).unwrap();
let serialized = serde_json::to_string(&runtime_version).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/support/test/compile_pass/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: sp_version::create_apis_vec!([]),
transaction_version: 0,
state_version: 0,
system_version: 0,
};

pub type Signature = sr25519::Signature;
Expand Down
Loading
Loading