Skip to content

Commit

Permalink
Remove unnecesary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dimartiro committed Dec 23, 2024
1 parent 3bf9655 commit d975df2
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 64 deletions.
51 changes: 1 addition & 50 deletions client/manual-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@ const DEFAULT_PROOF_SIZE: u64 = 64 * 1024;
#[jsonrpsee::core::async_trait]
pub trait ManualXcmApi {
/// Inject a downward xcm message - A message that comes from the relay chain.
/// You may provide an arbitrary message, or if you provide an empty byte array,
/// You may provide an arbitrary message, or if you provide an emtpy byte array,
/// Then a default message (DOT transfer down to ALITH) will be injected
#[method(name = "xcm_injectDownwardMessage")]
async fn inject_downward_message(&self, message: Vec<u8>) -> RpcResult<()>;

/// Inject a upward xcm message - A message that comes from the a parachain.
/// You may provide an arbitrary message, or if you provide an empty byte array,
/// Then a default message (DOT transfer up to ALITH) will be injected
#[method(name = "xcm_injectUpwardMessage")]
async fn inject_upward_message(&self, message: Vec<u8>) -> RpcResult<()>;

/// Inject an HRMP message - A message that comes from a dedicated channel to a sibling
/// parachain.
///
Expand All @@ -57,7 +51,6 @@ pub trait ManualXcmApi {

pub struct ManualXcm {
pub downward_message_channel: flume::Sender<Vec<u8>>,
pub upward_message_channel: Option<flume::Sender<Vec<u8>>>,
pub hrmp_message_channel: flume::Sender<(ParaId, Vec<u8>)>,
}

Expand Down Expand Up @@ -103,48 +96,6 @@ impl ManualXcmApiServer for ManualXcm {
Ok(())
}

async fn inject_upward_message(&self, msg: Vec<u8>) -> RpcResult<()> {
let upward_message_channel = self.upward_message_channel.clone();
// If no message is supplied, inject a default one.
let msg = if msg.is_empty() {
staging_xcm::VersionedXcm::<()>::V4(Xcm(vec![
ReserveAssetDeposited((Here, 10000000000000u128).into()),
ClearOrigin,
BuyExecution {
fees: (Here, 10000000000000u128).into(),
weight_limit: Limited(Weight::from_parts(
4_000_000_000u64,
DEFAULT_PROOF_SIZE * 2,
)),
},
DepositAsset {
assets: AllCounted(1).into(),
beneficiary: Location::new(
0,
[AccountKey20 {
network: None,
key: hex_literal::hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"),
}],
),
},
]))
.encode()
} else {
msg
};

// Push the message to the shared channel where it will be queued up
// to be injected in to an upcoming block.
if let Some(upm_channel) = upward_message_channel {
upm_channel
.send_async(msg)
.await
.map_err(|err| internal_err(err.to_string()))?;
}

Ok(())
}

async fn inject_hrmp_message(&self, sender: ParaId, msg: Vec<u8>) -> RpcResult<()> {
let hrmp_message_channel = self.hrmp_message_channel.clone();

Expand Down
1 change: 0 additions & 1 deletion client/service-container-chain/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ where
module.merge(
ManualXcm {
downward_message_channel,
upward_message_channel: None,
hrmp_message_channel,
}
.into_rpc(),
Expand Down
1 change: 0 additions & 1 deletion container-chains/nodes/frontier/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ where
io.merge(
ManualXcm {
downward_message_channel,
upward_message_channel: None,
hrmp_message_channel,
}
.into_rpc(),
Expand Down
1 change: 0 additions & 1 deletion container-chains/nodes/simple/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ where
module.merge(
ManualXcm {
downward_message_channel,
upward_message_channel: None,
hrmp_message_channel,
}
.into_rpc(),
Expand Down
11 changes: 2 additions & 9 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ pub struct FullDeps<C, P> {
/// Manual seal command sink
pub command_sink: Option<futures::channel::mpsc::Sender<EngineCommand<Hash>>>,
/// Channels for manual xcm messages (downward, hrmp)
pub xcm_senders: Option<(
flume::Sender<Vec<u8>>,
flume::Sender<Vec<u8>>,
flume::Sender<(ParaId, Vec<u8>)>,
)>,
pub xcm_senders: Option<(flume::Sender<Vec<u8>>, flume::Sender<(ParaId, Vec<u8>)>)>,
}

/// Instantiate all RPC extensions.
Expand Down Expand Up @@ -102,13 +98,10 @@ where
)?;
};

if let Some((downward_message_channel, upward_message_channel, hrmp_message_channel)) =
xcm_senders
{
if let Some((downward_message_channel, hrmp_message_channel)) = xcm_senders {
module.merge(
ManualXcm {
downward_message_channel,
upward_message_channel: Some(upward_message_channel),
hrmp_message_channel,
}
.into_rpc(),
Expand Down
3 changes: 1 addition & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,8 @@ pub fn start_dev_node(
if parachain_config.role.is_authority() {
let client = node_builder.client.clone();
let (downward_xcm_sender, downward_xcm_receiver) = flume::bounded::<Vec<u8>>(100);
let (upward_xcm_sender, _) = flume::bounded::<Vec<u8>>(100);
let (hrmp_xcm_sender, hrmp_xcm_receiver) = flume::bounded::<(ParaId, Vec<u8>)>(100);
xcm_senders = Some((downward_xcm_sender, upward_xcm_sender, hrmp_xcm_sender));
xcm_senders = Some((downward_xcm_sender, hrmp_xcm_sender));

command_sink = node_builder.install_manual_seal(ManualSealConfiguration {
block_import,
Expand Down

0 comments on commit d975df2

Please sign in to comment.