pub struct StatelessRuntime<CBlock, Block, Executor> { /* private fields */ }
Expand description

Stateless runtime api based on the runtime code and partial state if provided.

NOTE:

  • This is only supposed to be used when no domain client available, i.e., when the caller does not own the entire domain state.
  • This perfectly fits the runtime APIs that are purely stateless, but it’s also usable for the stateful APIs. If some states are used inside a runtime api, these states must be provided and set before dispatching otherwise StatelessRuntime may give invalid output.

Implementations§

source§

impl<CBlock, Block, Executor> StatelessRuntime<CBlock, Block, Executor>
where CBlock: BlockT, Block: BlockT, Executor: CodeExecutor + RuntimeVersionOf,

source

pub fn new(executor: Arc<Executor>, runtime_code: Cow<'static, [u8]>) -> Self

Create a new instance of StatelessRuntime with empty storage.

source

pub fn set_storage(&mut self, storage: Storage)

Set the storage.

Inject the state necessary for calling stateful runtime APIs.

source

pub fn set_extension_factory( &mut self, extension_factory: Box<dyn ExtensionsFactory<Block>>, )

Set the extensions.

Inject the necessary extensions for Domain.

source

pub fn outbox_storage_key( &self, message_key: MessageKey, ) -> Result<Vec<u8>, ApiError>

source

pub fn inbox_response_storage_key( &self, message_key: MessageKey, ) -> Result<Vec<u8>, ApiError>

source

pub fn channel_storage_key( &self, chain_id: ChainId, channel_id: ChannelId, ) -> Result<Vec<u8>, ApiError>

source

pub fn extract_signer( &self, extrinsics: Vec<<Block as BlockT>::Extrinsic>, ) -> Result<ExtractSignerResult<Block>, ApiError>

source

pub fn construct_set_code_extrinsic( &self, runtime_code: Vec<u8>, ) -> Result<Vec<u8>, ApiError>

source

pub fn construct_timestamp_extrinsic( &self, moment: Moment, ) -> Result<Block::Extrinsic, ApiError>

source

pub fn construct_consensus_chain_byte_fee_extrinsic( &self, consensus_chain_byte_fee: Balance, ) -> Result<Block::Extrinsic, ApiError>

source

pub fn construct_domain_update_chain_allowlist_extrinsic( &self, updates: DomainAllowlistUpdates, ) -> Result<Block::Extrinsic, ApiError>

source

pub fn is_inherent_extrinsic( &self, extrinsic: &<Block as BlockT>::Extrinsic, ) -> Result<bool, ApiError>

source

pub fn is_xdm_mmr_proof_valid( &self, extrinsic: &<Block as BlockT>::Extrinsic, ) -> Result<Option<bool>, ApiError>

source

pub fn extract_xdm_mmr_proof( &self, extrinsic: &<Block as BlockT>::Extrinsic, ) -> Result<Option<Vec<u8>>, ApiError>

source

pub fn decode_extrinsic( &self, opaque_extrinsic: OpaqueExtrinsic, ) -> Result<Result<<Block as BlockT>::Extrinsic, DecodeExtrinsicError>, ApiError>

source

pub fn is_within_tx_range( &self, extrinsic: &<Block as BlockT>::Extrinsic, bundle_vrf_hash: &U256, tx_range: &U256, ) -> Result<bool, ApiError>

source

pub fn check_extrinsics_and_do_pre_dispatch( &self, uxts: Vec<<Block as BlockT>::Extrinsic>, block_number: NumberFor<Block>, block_hash: <Block as BlockT>::Hash, ) -> Result<Result<(), CheckExtrinsicsValidityError>, ApiError>

This is stateful runtime api call and require setting of storage keys.

source

pub fn transfers_storage_key(&self) -> Result<Vec<u8>, ApiError>

source

pub fn block_fees_storage_key(&self) -> Result<Vec<u8>, ApiError>

source

pub fn extrinsic_weight( &self, extrinsic: &<Block as BlockT>::Extrinsic, ) -> Result<Weight, ApiError>

source

pub fn is_valid_sudo_call(&self, extrinsic: Vec<u8>) -> Result<bool, ApiError>

source

pub fn construct_domain_sudo_extrinsic( &self, inner_call: Vec<u8>, ) -> Result<Block::Extrinsic, ApiError>

Trait Implementations§

source§

impl<CBlock, Block, Executor> Core<Block> for StatelessRuntime<CBlock, Block, Executor>
where CBlock: BlockT, Block: BlockT, Executor: CodeExecutor + RuntimeVersionOf,

§

fn version( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<RuntimeVersion, ApiError>

Returns the version of the runtime.
§

fn execute_block( &self, __runtime_api_at_param__: <Block as Block>::Hash, block: Block, ) -> Result<(), ApiError>

Execute the given block.
§

fn initialize_block_before_version_5( &self, __runtime_api_at_param__: <Block as Block>::Hash, header: &<Block as Block>::Header, ) -> Result<(), ApiError>

👎Deprecated
Initialize a block with the given header.
§

fn initialize_block( &self, __runtime_api_at_param__: <Block as Block>::Hash, header: &<Block as Block>::Header, ) -> Result<ExtrinsicInclusionMode, ApiError>

Initialize a block with the given header and return the runtime executive mode.
source§

impl<CBlock, Block, Executor> DomainCoreApi<Block> for StatelessRuntime<CBlock, Block, Executor>
where CBlock: BlockT, Block: BlockT, Executor: CodeExecutor + RuntimeVersionOf,

§

fn extract_signer( &self, __runtime_api_at_param__: <Block as Block>::Hash, extrinsics: Vec<<Block as Block>::Extrinsic>, ) -> Result<Vec<(Option<Vec<u8>>, <Block as Block>::Extrinsic)>, ApiError>

Extracts the optional signer per extrinsic.
§

fn is_within_tx_range( &self, __runtime_api_at_param__: <Block as Block>::Hash, extrinsic: &<Block as Block>::Extrinsic, bundle_vrf_hash: &U256, tx_range: &U256, ) -> Result<bool, ApiError>

§

fn intermediate_roots( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<Vec<[u8; 32]>, ApiError>

Returns the intermediate storage roots in an encoded form.
§

fn initialize_block_with_post_state_root( &self, __runtime_api_at_param__: <Block as Block>::Hash, header: &<Block as Block>::Header, ) -> Result<Vec<u8>, ApiError>

Returns the storage root after initializing the block.
§

fn apply_extrinsic_with_post_state_root( &self, __runtime_api_at_param__: <Block as Block>::Hash, extrinsic: <Block as Block>::Extrinsic, ) -> Result<Vec<u8>, ApiError>

Returns the storage root after applying the extrinsic.
§

fn construct_set_code_extrinsic( &self, __runtime_api_at_param__: <Block as Block>::Hash, code: Vec<u8>, ) -> Result<Vec<u8>, ApiError>

Returns an encoded extrinsic aiming to upgrade the runtime using given code.
§

fn construct_timestamp_extrinsic( &self, __runtime_api_at_param__: <Block as Block>::Hash, moment: u64, ) -> Result<<Block as Block>::Extrinsic, ApiError>

Returns an encoded extrinsic to set timestamp.
§

fn construct_consensus_chain_byte_fee_extrinsic( &self, __runtime_api_at_param__: <Block as Block>::Hash, consensus_chain_byte_fee: u128, ) -> Result<<Block as Block>::Extrinsic, ApiError>

Returns an encoded extrinsic to set domain transaction byte fee.
§

fn construct_domain_update_chain_allowlist_extrinsic( &self, __runtime_api_at_param__: <Block as Block>::Hash, updates: DomainAllowlistUpdates, ) -> Result<<Block as Block>::Extrinsic, ApiError>

Returns an extrinsic to update chain allowlist.
§

fn is_inherent_extrinsic( &self, __runtime_api_at_param__: <Block as Block>::Hash, extrinsic: &<Block as Block>::Extrinsic, ) -> Result<bool, ApiError>

Returns true if the extrinsic is an inherent extrinsic.
§

fn check_extrinsics_and_do_pre_dispatch( &self, __runtime_api_at_param__: <Block as Block>::Hash, uxts: Vec<<Block as Block>::Extrinsic>, block_number: <<Block as Block>::Header as Header>::Number, block_hash: <Block as Block>::Hash, ) -> Result<Result<(), CheckExtrinsicsValidityError>, ApiError>

Checks the validity of array of extrinsics + pre_dispatch returning failure on first extrinsic that fails runtime call. IMPORTANT: Change CHECK_EXTRINSICS_AND_DO_PRE_DISPATCH_METHOD_NAME constant when this method name is changed
§

fn decode_extrinsic( &self, __runtime_api_at_param__: <Block as Block>::Hash, opaque_extrinsic: OpaqueExtrinsic, ) -> Result<Result<<Block as Block>::Extrinsic, DecodeExtrinsicError>, ApiError>

Decodes the domain specific extrinsic from the opaque extrinsic.
§

fn extrinsic_era( &self, __runtime_api_at_param__: <Block as Block>::Hash, extrinsic: &<Block as Block>::Extrinsic, ) -> Result<Option<Era>, ApiError>

Returns extrinsic Era if present.
§

fn extrinsic_weight( &self, __runtime_api_at_param__: <Block as Block>::Hash, ext: &<Block as Block>::Extrinsic, ) -> Result<Weight, ApiError>

Returns the extrinsic weight.
§

fn block_fees( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<BlockFees<u128>, ApiError>

The accumulated transaction fee of all transactions included in the block.
§

fn block_digest( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<Digest, ApiError>

Returns the block digest.
§

fn block_weight( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<Weight, ApiError>

Returns the consumed weight of the block.
§

fn transfers( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<Transfers<u128>, ApiError>

Returns the transfers for this domain in the block.
§

fn transfers_storage_key( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<Vec<u8>, ApiError>

Returns the storage key for the Transfers on Domain.
§

fn block_fees_storage_key( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<Vec<u8>, ApiError>

Returns the storage key for the CollectedBlockFees on Domain.
source§

impl<CBlock, Block, Executor> DomainSudoApi<Block> for StatelessRuntime<CBlock, Block, Executor>
where CBlock: BlockT, Block: BlockT, NumberFor<Block>: Codec, Executor: CodeExecutor + RuntimeVersionOf,

§

fn is_valid_sudo_call( &self, __runtime_api_at_param__: <Block as Block>::Hash, extrinsic: Vec<u8>, ) -> Result<bool, ApiError>

Returns true if the domain_sudo exists in the runtime and extrinsic is valid
§

fn construct_domain_sudo_extrinsic( &self, __runtime_api_at_param__: <Block as Block>::Hash, inner: Vec<u8>, ) -> Result<<Block as Block>::Extrinsic, ApiError>

Returns an encoded extrinsic for domain sudo call.
source§

impl<CBlock, Block, Executor> FetchRuntimeCode for StatelessRuntime<CBlock, Block, Executor>

source§

fn fetch_runtime_code(&self) -> Option<Cow<'static, [u8]>>

Fetch the runtime :code. Read more
source§

impl<CBlock, Block, Executor> MessengerApi<Block, <<CBlock as Block>::Header as Header>::Number, <CBlock as Block>::Hash> for StatelessRuntime<CBlock, Block, Executor>
where CBlock: BlockT, Block: BlockT, NumberFor<Block>: Codec, Executor: CodeExecutor + RuntimeVersionOf,

§

fn is_xdm_mmr_proof_valid( &self, __runtime_api_at_param__: <Block as Block>::Hash, ext: &<Block as Block>::Extrinsic, ) -> Result<Option<bool>, ApiError>

Returns Some(true) if valid XDM or Some(false) if not Returns None if this is not an XDM
§

fn extract_xdm_mmr_proof( &self, __runtime_api_at_param__: <Block as Block>::Hash, ext: &<Block as Block>::Extrinsic, ) -> Result<Option<ConsensusChainMmrLeafProof<CNumber, CHash, H256>>, ApiError>

§

fn confirmed_domain_block_storage_key( &self, __runtime_api_at_param__: <Block as Block>::Hash, domain_id: DomainId, ) -> Result<Vec<u8>, ApiError>

Returns the confirmed domain block storage for given domain.
§

fn outbox_storage_key( &self, __runtime_api_at_param__: <Block as Block>::Hash, message_key: (ChainId, U256, U256), ) -> Result<Vec<u8>, ApiError>

Returns storage key for outbox for a given message_id.
§

fn inbox_response_storage_key( &self, __runtime_api_at_param__: <Block as Block>::Hash, message_key: (ChainId, U256, U256), ) -> Result<Vec<u8>, ApiError>

Returns storage key for inbox response for a given message_id.
§

fn domain_chains_allowlist_update( &self, __runtime_api_at_param__: <Block as Block>::Hash, domain_id: DomainId, ) -> Result<Option<DomainAllowlistUpdates>, ApiError>

Returns any domain’s chains allowlist updates on consensus chain.
source§

impl<CBlock, Block, Executor> RelayerApi<Block, <<Block as Block>::Header as Header>::Number, u32, [u8; 32]> for StatelessRuntime<CBlock, Block, Executor>
where CBlock: BlockT, Block: BlockT, NumberFor<Block>: Codec, Executor: CodeExecutor + RuntimeVersionOf,

§

fn block_messages( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<BlockMessagesWithStorageKey, ApiError>

Returns all the outbox and inbox responses to deliver. Storage key is used to generate the storage proof for the message.
§

fn outbox_message_unsigned( &self, __runtime_api_at_param__: <Block as Block>::Hash, msg: CrossDomainMessage<CNumber, CHash, H256>, ) -> Result<Option<<Block as Block>::Extrinsic>, ApiError>

Constructs an outbox message to the dst_chain as an unsigned extrinsic.
§

fn inbox_response_message_unsigned( &self, __runtime_api_at_param__: <Block as Block>::Hash, msg: CrossDomainMessage<CNumber, CHash, H256>, ) -> Result<Option<<Block as Block>::Extrinsic>, ApiError>

Constructs an inbox response message to the dst_chain as an unsigned extrinsic.
§

fn should_relay_outbox_message( &self, __runtime_api_at_param__: <Block as Block>::Hash, dst_chain_id: ChainId, msg_id: (U256, U256), ) -> Result<bool, ApiError>

Returns true if the outbox message is ready to be relayed to dst_chain.
§

fn should_relay_inbox_message_response( &self, __runtime_api_at_param__: <Block as Block>::Hash, dst_chain_id: ChainId, msg_id: (U256, U256), ) -> Result<bool, ApiError>

Returns true if the inbox message response is ready to be relayed to dst_chain.
§

fn updated_channels( &self, __runtime_api_at_param__: <Block as Block>::Hash, ) -> Result<BTreeSet<(ChainId, U256)>, ApiError>

Returns the list of channels updated in the given block.
§

fn channel_storage_key( &self, __runtime_api_at_param__: <Block as Block>::Hash, chain_id: ChainId, channel_id: U256, ) -> Result<Vec<u8>, ApiError>

Returns storage key for channels for given chain and channel id.

Auto Trait Implementations§

§

impl<CBlock, Block, Executor> Freeze for StatelessRuntime<CBlock, Block, Executor>

§

impl<CBlock, Block, Executor> !RefUnwindSafe for StatelessRuntime<CBlock, Block, Executor>

§

impl<CBlock, Block, Executor> Send for StatelessRuntime<CBlock, Block, Executor>
where Executor: Sync + Send, CBlock: Send, Block: Send,

§

impl<CBlock, Block, Executor> Sync for StatelessRuntime<CBlock, Block, Executor>
where Executor: Sync + Send, CBlock: Sync, Block: Sync,

§

impl<CBlock, Block, Executor> Unpin for StatelessRuntime<CBlock, Block, Executor>
where CBlock: Unpin, Block: Unpin,

§

impl<CBlock, Block, Executor> !UnwindSafe for StatelessRuntime<CBlock, Block, Executor>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CheckedConversion for T

§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T, U> IntoKey<U> for T
where U: FromKey<T>,

§

fn into_key(self) -> U

§

impl<T> IsType<T> for T

§

fn from_ref(t: &T) -> &T

Cast reference.
§

fn into_ref(&self) -> &T

Cast reference.
§

fn from_mut(t: &mut T) -> &mut T

Cast mutable reference.
§

fn into_mut(&mut self) -> &mut T

Cast mutable reference.
§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<T> SaturatedConversion for T

§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryIntoKey<U> for T
where U: TryFromKey<T>,

§

type Error = <U as TryFromKey<T>>::Error

§

fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>

§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> JsonSchemaMaybe for T