mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Integrate message-lane module RPCs into Rialto/Millau nodes (#458)
* integrate message-lane RPCs into Millau and Rialto runtime * fmt * use instance in InboundLanes * moved RialtoMessageLaneKeys/MillauMessageLaneKeys inside rpc_extensions_builder to ease Substrate refs update
This commit is contained in:
committed by
Bastian Köcher
parent
ddef170340
commit
74249a0896
@@ -14,8 +14,12 @@ jsonrpc-core = "15.1.0"
|
||||
structopt = "0.3.20"
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-message-lane = { path = "../../../primitives/message-lane" }
|
||||
bp-rialto = { path = "../../../primitives/rialto" }
|
||||
bp-runtime = { path = "../../../primitives/runtime" }
|
||||
millau-runtime = { path = "../runtime" }
|
||||
pallet-message-lane-rpc = { path = "../../../modules/message-lane/rpc" }
|
||||
|
||||
# Substrate Dependencies
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
|
||||
use bp_message_lane::{LaneId, MessageNonce};
|
||||
use bp_runtime::{InstanceId, RIALTO_BRIDGE_INSTANCE};
|
||||
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||
use sc_executor::native_executor_instance;
|
||||
@@ -36,6 +38,7 @@ use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider,
|
||||
use sc_finality_grandpa_rpc::GrandpaRpcHandler;
|
||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_inherents::InherentDataProviders;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -161,10 +164,40 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let telemetry_connection_sinks = sc_service::TelemetryConnectionSinks::default();
|
||||
|
||||
let rpc_extensions_builder = {
|
||||
// This struct is here to ease update process.
|
||||
|
||||
/// Millau runtime from message-lane RPC point of view.
|
||||
struct MillauMessageLaneKeys;
|
||||
|
||||
impl pallet_message_lane_rpc::Runtime for MillauMessageLaneKeys {
|
||||
fn message_key(&self, instance: &InstanceId, lane: &LaneId, nonce: MessageNonce) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
RIALTO_BRIDGE_INSTANCE => Some(millau_runtime::rialto_messages::message_key(lane, nonce)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn outbound_lane_data_key(&self, instance: &InstanceId, lane: &LaneId) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
RIALTO_BRIDGE_INSTANCE => Some(millau_runtime::rialto_messages::outbound_lane_data_key(lane)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn inbound_lane_data_key(&self, instance: &InstanceId, lane: &LaneId) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
RIALTO_BRIDGE_INSTANCE => Some(millau_runtime::rialto_messages::inbound_lane_data_key(lane)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use pallet_message_lane_rpc::{MessageLaneApi, MessageLaneRpcHandler};
|
||||
use sc_finality_grandpa_rpc::GrandpaApi;
|
||||
use sc_rpc::DenyUnsafe;
|
||||
use substrate_frame_rpc_system::{FullSystem, SystemApi};
|
||||
|
||||
let backend = backend.clone();
|
||||
let client = client.clone();
|
||||
let pool = transaction_pool.clone();
|
||||
|
||||
@@ -188,6 +221,10 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
subscription_executor,
|
||||
finality_proof_provider.clone(),
|
||||
)));
|
||||
io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new(
|
||||
backend.clone(),
|
||||
Arc::new(MillauMessageLaneKeys),
|
||||
)));
|
||||
|
||||
io
|
||||
})
|
||||
|
||||
@@ -16,21 +16,41 @@
|
||||
|
||||
//! Everything required to serve Millau <-> Rialto message lanes.
|
||||
|
||||
use bridge_runtime_common::messages;
|
||||
use crate::Runtime;
|
||||
|
||||
use bp_message_lane::{
|
||||
source_chain::TargetHeaderChain,
|
||||
target_chain::{ProvedMessages, SourceHeaderChain},
|
||||
InboundLaneData, LaneId, Message, MessageNonce,
|
||||
InboundLaneData, LaneId, Message, MessageKey, MessageNonce,
|
||||
};
|
||||
use bp_runtime::InstanceId;
|
||||
use bridge_runtime_common::messages::MessageBridge;
|
||||
use bridge_runtime_common::messages::{self, MessageBridge};
|
||||
use frame_support::{
|
||||
storage::generator::StorageMap,
|
||||
weights::{Weight, WeightToFeePolynomial},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use pallet_message_lane::{DefaultInstance, InboundLanes, OutboundLanes, OutboundMessages};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_trie::StorageProof;
|
||||
|
||||
/// Storage key of the Millau -> Rialto message in the runtime storage.
|
||||
pub fn message_key(lane: &LaneId, nonce: MessageNonce) -> StorageKey {
|
||||
let message_key = MessageKey { lane_id: *lane, nonce };
|
||||
let raw_storage_key = OutboundMessages::<Runtime, DefaultInstance>::storage_map_final_key(message_key);
|
||||
StorageKey(raw_storage_key)
|
||||
}
|
||||
|
||||
/// Storage key of the Millau -> Rialto message lane state in the runtime storage.
|
||||
pub fn outbound_lane_data_key(lane: &LaneId) -> StorageKey {
|
||||
StorageKey(OutboundLanes::<DefaultInstance>::storage_map_final_key(*lane))
|
||||
}
|
||||
|
||||
/// Storage key of the Rialto -> Millau message lane state in the runtime storage.
|
||||
pub fn inbound_lane_data_key(lane: &LaneId) -> StorageKey {
|
||||
StorageKey(InboundLanes::<Runtime, DefaultInstance>::storage_map_final_key(*lane))
|
||||
}
|
||||
|
||||
/// Message payload for Millau -> Rialto messages.
|
||||
pub type ToRialtoMessagePayload = messages::source::FromThisChainMessagePayload<WithRialtoMessageBridge>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user