mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Transaction versioning in the RuntimeVersion (#5582)
* Add transaction_version * Semantic versioning for runtimes * Move new field to bottom * Versioning * Runtime versioning stuff. * Fix test * Adds tests and fixes bugs * Bump runtime Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -53,7 +53,7 @@ pub use sp_runtime::{
|
||||
Block as BlockT, GetNodeBlockType, GetRuntimeBlockType, HashFor, NumberFor,
|
||||
Header as HeaderT, Hash as HashT,
|
||||
},
|
||||
generic::BlockId, transaction_validity::TransactionValidity,
|
||||
generic::BlockId, transaction_validity::TransactionValidity, RuntimeString,
|
||||
};
|
||||
#[doc(hidden)]
|
||||
pub use sp_core::{offchain, ExecutionContext};
|
||||
@@ -224,6 +224,7 @@ pub use sp_api_proc_macro::decl_runtime_apis;
|
||||
/// impl_version: 0,
|
||||
/// // Here we are exposing the runtime api versions.
|
||||
/// apis: RUNTIME_API_VERSIONS,
|
||||
/// transaction_version: 1,
|
||||
/// };
|
||||
///
|
||||
/// # fn main() {}
|
||||
@@ -520,13 +521,53 @@ pub trait RuntimeApiInfo {
|
||||
#[cfg(feature = "std")]
|
||||
pub type ApiErrorFor<T, Block> = <<T as ProvideRuntimeApi<Block>>::Api as ApiErrorExt>::Error;
|
||||
|
||||
#[derive(codec::Encode, codec::Decode)]
|
||||
pub struct OldRuntimeVersion {
|
||||
pub spec_name: RuntimeString,
|
||||
pub impl_name: RuntimeString,
|
||||
pub authoring_version: u32,
|
||||
pub spec_version: u32,
|
||||
pub impl_version: u32,
|
||||
pub apis: ApisVec,
|
||||
}
|
||||
|
||||
impl From<OldRuntimeVersion> for RuntimeVersion {
|
||||
fn from(x: OldRuntimeVersion) -> Self {
|
||||
Self {
|
||||
spec_name: x.spec_name,
|
||||
impl_name: x.impl_name,
|
||||
authoring_version: x.authoring_version,
|
||||
spec_version: x.spec_version,
|
||||
impl_version: x.impl_version,
|
||||
apis: x.apis,
|
||||
transaction_version: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RuntimeVersion> for OldRuntimeVersion {
|
||||
fn from(x: RuntimeVersion) -> Self {
|
||||
Self {
|
||||
spec_name: x.spec_name,
|
||||
impl_name: x.impl_name,
|
||||
authoring_version: x.authoring_version,
|
||||
spec_version: x.spec_version,
|
||||
impl_version: x.impl_version,
|
||||
apis: x.apis,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
decl_runtime_apis! {
|
||||
/// The `Core` runtime api that every Substrate runtime needs to implement.
|
||||
#[core_trait]
|
||||
#[api_version(2)]
|
||||
#[api_version(3)]
|
||||
pub trait Core {
|
||||
/// Returns the version of the runtime.
|
||||
fn version() -> RuntimeVersion;
|
||||
/// Returns the version of the runtime.
|
||||
#[changed_in(3)]
|
||||
fn version() -> OldRuntimeVersion;
|
||||
/// Execute the given block.
|
||||
#[skip_initialize_block]
|
||||
fn execute_block(block: Block);
|
||||
|
||||
Reference in New Issue
Block a user