Struct sp_version::RuntimeVersion
source · pub struct RuntimeVersion {
pub spec_name: RuntimeString,
pub impl_name: RuntimeString,
pub authoring_version: u32,
pub spec_version: u32,
pub impl_version: u32,
pub apis: ApisVec,
pub transaction_version: u32,
pub state_version: u8,
}
Expand description
Runtime version.
This should not be thought of as classic Semver (major/minor/tiny).
This triplet have different semantics and mis-interpretation could cause problems.
In particular: bug fixes should result in an increment of spec_version
and possibly
authoring_version
, absolutely not impl_version
since they change the semantics of the
runtime.
Fields§
§spec_name: RuntimeString
Identifies the different Substrate runtimes. There’ll be at least polkadot and node. A different on-chain spec_name to that of the native runtime would normally result in node not attempting to sync or author blocks.
impl_name: RuntimeString
Name of the implementation of the spec. This is of little consequence for the node
and serves only to differentiate code of different implementation teams. For this
codebase, it will be parity-polkadot. If there were a non-Rust implementation of the
Polkadot runtime (e.g. C++), then it would identify itself with an accordingly different
impl_name
.
authoring_version
is the version of the authorship interface. An authoring node
will not attempt to author blocks unless this is equal to its native runtime.
spec_version: u32
Version of the runtime specification.
A full-node will not attempt to use its native runtime in substitute for the on-chain
Wasm runtime unless all of spec_name
, spec_version
and authoring_version
are the same
between Wasm and native.
This number should never decrease.
impl_version: u32
Version of the implementation of the specification.
Nodes are free to ignore this; it serves only as an indication that the code is different;
as long as the other two versions are the same then while the actual code may be different,
it is nonetheless required to do the same thing. Non-consensus-breaking optimizations are
about the only changes that could be made which would result in only the impl_version
changing.
This number can be reverted to 0
after a spec_version
bump.
apis: ApisVec
List of supported API “features” along with their versions.
transaction_version: u32
All existing calls (dispatchables) are fully compatible when this number doesn’t change. If
this number changes, then spec_version
must change, also.
This number must change when an existing call (pallet index, call index) is changed,
either through an alteration in its user-level semantics, a parameter
added/removed, a parameter type changed, or a call/pallet changing its index. An alteration
of the user level semantics is for example when the call was before transfer
and now is
transfer_all
, the semantics of the call changed completely.
Removing a pallet or a call doesn’t require a bump as long as no pallet or call is put at the same index. Removing doesn’t require a bump as the chain will reject a transaction referencing this removed call/pallet while decoding and thus, the user isn’t at risk to execute any unknown call. FRAME runtime devs have control over the index of a call/pallet to prevent that an index gets reused.
Adding a new pallet or call also doesn’t require a bump as long as they also don’t reuse any previously used index.
This number should never decrease.
state_version: u8
Version of the state implementation used by this runtime. Use of an incorrect version is consensus breaking.
Implementations§
source§impl RuntimeVersion
impl RuntimeVersion
sourcepub fn decode_with_version_hint<I: Input>(
input: &mut I,
core_version: Option<u32>,
) -> Result<RuntimeVersion, Error>
pub fn decode_with_version_hint<I: Input>( input: &mut I, core_version: Option<u32>, ) -> Result<RuntimeVersion, Error>
Decode
while giving a “version hint”
There exists multiple versions of RuntimeVersion
and they are versioned using the Core
runtime api:
Core
version < 3 is a runtime version without a transaction version and state version.Core
version 3 is a runtime version without a state version.Core
version 4 is the latest runtime version.
source§impl RuntimeVersion
impl RuntimeVersion
sourcepub fn can_call_with(&self, other: &RuntimeVersion) -> bool
pub fn can_call_with(&self, other: &RuntimeVersion) -> bool
Check if this version matches other version for calling into runtime.
sourcepub fn has_api_with<P: Fn(u32) -> bool>(&self, id: &ApiId, predicate: P) -> bool
pub fn has_api_with<P: Fn(u32) -> bool>(&self, id: &ApiId, predicate: P) -> bool
Check if the given api with api_id
is implemented and the version passes the given
predicate
.
sourcepub fn api_version(&self, id: &ApiId) -> Option<u32>
pub fn api_version(&self, id: &ApiId) -> Option<u32>
Returns the api version found for api with id
.
source§impl RuntimeVersion
impl RuntimeVersion
sourcepub fn state_version(&self) -> StateVersion
pub fn state_version(&self) -> StateVersion
Returns state version to use for update.
For runtime with core api version less than 4, V0 trie version will be applied to state. Otherwise, V1 trie version will be use.
Trait Implementations§
source§impl Clone for RuntimeVersion
impl Clone for RuntimeVersion
source§fn clone(&self) -> RuntimeVersion
fn clone(&self) -> RuntimeVersion
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RuntimeVersion
impl Debug for RuntimeVersion
source§impl Decode for RuntimeVersion
impl Decode for RuntimeVersion
source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
source§impl Default for RuntimeVersion
impl Default for RuntimeVersion
source§fn default() -> RuntimeVersion
fn default() -> RuntimeVersion
source§impl<'de> Deserialize<'de> for RuntimeVersion
impl<'de> Deserialize<'de> for RuntimeVersion
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for RuntimeVersion
impl Display for RuntimeVersion
source§impl Encode for RuntimeVersion
impl Encode for RuntimeVersion
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl PartialEq for RuntimeVersion
impl PartialEq for RuntimeVersion
source§fn eq(&self, other: &RuntimeVersion) -> bool
fn eq(&self, other: &RuntimeVersion) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for RuntimeVersion
impl Serialize for RuntimeVersion
source§impl TypeInfo for RuntimeVersion
impl TypeInfo for RuntimeVersion
impl EncodeLike for RuntimeVersion
impl Eq for RuntimeVersion
impl StructuralPartialEq for RuntimeVersion
Auto Trait Implementations§
impl Freeze for RuntimeVersion
impl RefUnwindSafe for RuntimeVersion
impl Send for RuntimeVersion
impl Sync for RuntimeVersion
impl Unpin for RuntimeVersion
impl UnwindSafe for RuntimeVersion
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.