mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 15:41:02 +00:00
Generate large messages (#700)
* generate large messages * consider headers sync lag when computing number of rewards in confirmation * more fixes * fix logs * fix warnings * do not wait until tx that has delivered nonces will be finalized before submitting other tx * tests for maximal weight/size * cleanup * cleanup * clippy * compilation * args for dispatch weight and remark size * ExplicitOrMaximal * clippy
This commit is contained in:
committed by
Bastian Köcher
parent
3dfef2cd2c
commit
1b2e6cdeb0
@@ -17,6 +17,7 @@
|
||||
//! Deal with CLI args of substrate-to-substrate relay.
|
||||
|
||||
use bp_message_lane::LaneId;
|
||||
use frame_support::weights::Weight;
|
||||
use sp_core::Bytes;
|
||||
use sp_finality_grandpa::SetId as GrandpaAuthoritiesSetId;
|
||||
use structopt::{clap::arg_enum, StructOpt};
|
||||
@@ -153,6 +154,9 @@ pub enum SendMessage {
|
||||
/// Hex-encoded lane id.
|
||||
#[structopt(long)]
|
||||
lane: HexLaneId,
|
||||
/// Dispatch weight of the message. If not passed, determined automatically.
|
||||
#[structopt(long)]
|
||||
dispatch_weight: Option<ExplicitOrMaximal<Weight>>,
|
||||
/// Delivery and dispatch fee. If not passed, determined automatically.
|
||||
#[structopt(long)]
|
||||
fee: Option<bp_millau::Balance>,
|
||||
@@ -174,6 +178,9 @@ pub enum SendMessage {
|
||||
/// Hex-encoded lane id.
|
||||
#[structopt(long)]
|
||||
lane: HexLaneId,
|
||||
/// Dispatch weight of the message. If not passed, determined automatically.
|
||||
#[structopt(long)]
|
||||
dispatch_weight: Option<ExplicitOrMaximal<Weight>>,
|
||||
/// Delivery and dispatch fee. If not passed, determined automatically.
|
||||
#[structopt(long)]
|
||||
fee: Option<bp_rialto::Balance>,
|
||||
@@ -190,7 +197,11 @@ pub enum SendMessage {
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub enum ToRialtoMessage {
|
||||
/// Make an on-chain remark (comment).
|
||||
Remark,
|
||||
Remark {
|
||||
/// Remark size. If not passed, small UTF8-encoded string is generated by relay as remark.
|
||||
#[structopt(long)]
|
||||
remark_size: Option<ExplicitOrMaximal<usize>>,
|
||||
},
|
||||
/// Transfer the specified `amount` of native tokens to a particular `recipient`.
|
||||
Transfer {
|
||||
#[structopt(long)]
|
||||
@@ -204,7 +215,11 @@ pub enum ToRialtoMessage {
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub enum ToMillauMessage {
|
||||
/// Make an on-chain remark (comment).
|
||||
Remark,
|
||||
Remark {
|
||||
/// Size of the remark. If not passed, small UTF8-encoded string is generated by relay as remark.
|
||||
#[structopt(long)]
|
||||
remark_size: Option<ExplicitOrMaximal<usize>>,
|
||||
},
|
||||
/// Transfer the specified `amount` of native tokens to a particular `recipient`.
|
||||
Transfer {
|
||||
#[structopt(long)]
|
||||
@@ -273,6 +288,32 @@ impl From<PrometheusParams> for Option<relay_utils::metrics::MetricsParams> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Either explicit or maximal allowed value.
|
||||
#[derive(Debug)]
|
||||
pub enum ExplicitOrMaximal<V> {
|
||||
/// User has explicitly specified argument value.
|
||||
Explicit(V),
|
||||
/// Maximal allowed value for this argument.
|
||||
Maximal,
|
||||
}
|
||||
|
||||
impl<V: std::str::FromStr> std::str::FromStr for ExplicitOrMaximal<V>
|
||||
where
|
||||
V::Err: std::fmt::Debug,
|
||||
{
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
if s.to_lowercase() == "max" {
|
||||
return Ok(ExplicitOrMaximal::Maximal);
|
||||
}
|
||||
|
||||
V::from_str(s)
|
||||
.map(ExplicitOrMaximal::Explicit)
|
||||
.map_err(|e| format!("Failed to parse '{:?}'. Expected 'max' or explicit value", e))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! declare_chain_options {
|
||||
($chain:ident, $chain_prefix:ident) => {
|
||||
paste::item! {
|
||||
|
||||
Reference in New Issue
Block a user