Skip to content

Commit

Permalink
Add missing parts to rialto parachain bridge (part 1) (paritytech#1454)
Browse files Browse the repository at this point in the history
* add proper parameter names to bridge declaration

* associate RialtoParachain token with DOT

* RialtoParachain<>Millau message pallet owners

* fix compilation
  • Loading branch information
svyatonik authored and serban300 committed Apr 9, 2024
1 parent f498545 commit e339ac9
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 24 deletions.
9 changes: 6 additions & 3 deletions bridges/bin/rialto-parachain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

use cumulus_primitives_core::ParaId;
use rialto_parachain_runtime::{AccountId, AuraId, Signature};
use rialto_parachain_runtime::{AccountId, AuraId, BridgeMillauMessagesConfig, Signature};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -82,6 +82,7 @@ fn endowed_accounts() -> Vec<AccountId> {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
get_account_id_from_seed::<sr25519::Public>("George//stash"),
get_account_id_from_seed::<sr25519::Public>("MillauMessagesOwner"),
pallet_bridge_messages::relayer_fund_account_id::<
bp_rialto_parachain::AccountId,
bp_rialto_parachain::AccountIdConverter,
Expand Down Expand Up @@ -172,7 +173,9 @@ fn testnet_genesis(
parachain_info: rialto_parachain_runtime::ParachainInfoConfig { parachain_id: id },
aura: rialto_parachain_runtime::AuraConfig { authorities: initial_authorities },
aura_ext: Default::default(),
bridge_millau_messages: Default::default(),
// parachain_system: Default::default(),
bridge_millau_messages: BridgeMillauMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>("MillauMessagesOwner")),
..Default::default()
},
}
}
2 changes: 1 addition & 1 deletion bridges/bin/rialto-parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ use xcm_builder::{
};
use xcm_executor::{Config, XcmExecutor};

mod millau_messages;
pub mod millau_messages;

/// The address format for describing accounts.
pub type Address = MultiAddress<AccountId, ()>;
Expand Down
8 changes: 8 additions & 0 deletions bridges/primitives/chain-millau/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,17 @@ frame_support::parameter_types! {
pub const WITH_MILLAU_GRANDPA_PALLET_NAME: &str = "BridgeMillauGrandpa";
/// Name of the With-Millau messages pallet instance that is deployed at bridged chains.
pub const WITH_MILLAU_MESSAGES_PALLET_NAME: &str = "BridgeMillauMessages";
/// Name of the transaction payment pallet at the Millau runtime.
pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment";

/// Name of the Rialto->Millau (actually DOT->KSM) conversion rate stored in the Millau runtime.
pub const RIALTO_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME: &str = "RialtoToMillauConversionRate";
/// Name of the RialtoParachain->Millau (actually DOT->KSM) conversion rate stored in the Millau
/// runtime.
pub const RIALTO_PARACHAIN_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME: &str =
"RialtoParachainToMillauConversionRate";
/// Name of the RialtoParachain fee multiplier parameter, stored in the Millau runtime.
pub const RIALTO_PARACHAIN_FEE_MULTIPLIER_PARAMETER_NAME: &str = "RialtoParachainFeeMultiplier";

/// Name of the `MillauFinalityApi::best_finalized` runtime method.
pub const BEST_FINALIZED_MILLAU_HEADER_METHOD: &str = "MillauFinalityApi_best_finalized";
Expand Down
13 changes: 9 additions & 4 deletions bridges/primitives/chain-rialto-parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,15 @@ frame_support::parameter_types! {

/// Name of the With-Rialto-Parachain messages pallet instance that is deployed at bridged chains.
pub const WITH_RIALTO_PARACHAIN_MESSAGES_PALLET_NAME: &str = "BridgeRialtoParachainMessages";

/// Name of the Millau->Rialto (actually KSM->DOT) conversion rate stored in the Rialto parachain
/// runtime.
pub const MILLAU_TO_RIALTO_CONVERSION_RATE_PARAMETER_NAME: &str = "MillauToRialtoConversionRate";
/// Name of the transaction payment pallet at the Rialto parachain runtime.
pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment";

/// Name of the Millau->RialtoParachain (actually KSM->DOT) conversion rate stored in the Rialto
/// parachain runtime.
pub const MILLAU_TO_RIALTO_PARACHAIN_CONVERSION_RATE_PARAMETER_NAME: &str =
"MillauToRialtoParachainConversionRate";
/// Name of the Millau fee multiplier parameter, stored in the Rialto parachain runtime.
pub const MILLAU_FEE_MULTIPLIER_PARAMETER_NAME: &str = "MillauFeeMultiplier";

/// Name of the `RialtoParachainFinalityApi::best_finalized` runtime method.
pub const BEST_FINALIZED_RIALTO_PARACHAIN_HEADER_METHOD: &str =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,29 @@ use substrate_relay_helper::messages_lane::{
/// Description of Millau -> RialtoParachain messages bridge.
#[derive(Clone, Debug)]
pub struct MillauMessagesToRialtoParachain;
substrate_relay_helper::generate_direct_update_conversion_rate_call_builder!(
Millau,
MillauMessagesToRialtoParachainUpdateConversionRateCallBuilder,
millau_runtime::Runtime,
millau_runtime::WithRialtoParachainMessagesInstance,
millau_runtime::rialto_parachain_messages::MillauToRialtoParachainMessagesParameter::RialtoParachainToMillauConversionRate
);

impl SubstrateMessageLane for MillauMessagesToRialtoParachain {
const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> =
Some(bp_rialto_parachain::MILLAU_TO_RIALTO_CONVERSION_RATE_PARAMETER_NAME);
Some(bp_rialto_parachain::MILLAU_TO_RIALTO_PARACHAIN_CONVERSION_RATE_PARAMETER_NAME);
const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> =
Some(bp_millau::RIALTO_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME);
Some(bp_millau::RIALTO_PARACHAIN_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME);

const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None;
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None;
const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None;
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None;
const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> =
Some(bp_rialto_parachain::MILLAU_FEE_MULTIPLIER_PARAMETER_NAME);
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> =
Some(bp_millau::RIALTO_PARACHAIN_FEE_MULTIPLIER_PARAMETER_NAME);

const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> =
Some(bp_millau::TRANSACTION_PAYMENT_PALLET_NAME);
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> =
Some(bp_rialto_parachain::TRANSACTION_PAYMENT_PALLET_NAME);

type SourceChain = Millau;
type TargetChain = RialtoParachain;
Expand All @@ -56,7 +68,8 @@ impl SubstrateMessageLane for MillauMessagesToRialtoParachain {
millau_runtime::WithRialtoParachainMessagesInstance,
>;

type TargetToSourceChainConversionRateUpdateBuilder = ();
type TargetToSourceChainConversionRateUpdateBuilder =
MillauMessagesToRialtoParachainUpdateConversionRateCallBuilder;

type RelayStrategy = MixStrategy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,29 @@ use substrate_relay_helper::messages_lane::{
/// Description of RialtoParachain -> Millau messages bridge.
#[derive(Clone, Debug)]
pub struct RialtoParachainMessagesToMillau;
substrate_relay_helper::generate_direct_update_conversion_rate_call_builder!(
RialtoParachain,
RialtoParachainMessagesToMillauUpdateConversionRateCallBuilder,
rialto_parachain_runtime::Runtime,
rialto_parachain_runtime::WithMillauMessagesInstance,
rialto_parachain_runtime::millau_messages::RialtoParachainToMillauMessagesParameter::MillauToRialtoParachainConversionRate
);

impl SubstrateMessageLane for RialtoParachainMessagesToMillau {
const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> =
Some(bp_millau::RIALTO_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME);
Some(bp_millau::RIALTO_PARACHAIN_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME);
const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> =
Some(bp_rialto_parachain::MILLAU_TO_RIALTO_CONVERSION_RATE_PARAMETER_NAME);
Some(bp_rialto_parachain::MILLAU_TO_RIALTO_PARACHAIN_CONVERSION_RATE_PARAMETER_NAME);

const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None;
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None;
const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None;
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None;
const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> =
Some(bp_millau::RIALTO_PARACHAIN_FEE_MULTIPLIER_PARAMETER_NAME);
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> =
Some(bp_rialto_parachain::MILLAU_FEE_MULTIPLIER_PARAMETER_NAME);

const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> =
Some(bp_rialto_parachain::TRANSACTION_PAYMENT_PALLET_NAME);
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> =
Some(bp_millau::TRANSACTION_PAYMENT_PALLET_NAME);

type SourceChain = RialtoParachain;
type TargetChain = Millau;
Expand Down
5 changes: 2 additions & 3 deletions bridges/relays/client-rialto-parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ impl ChainBase for RialtoParachain {

impl Chain for RialtoParachain {
const NAME: &'static str = "RialtoParachain";
const TOKEN_ID: Option<&'static str> = None;
// should be fixed/changed in https://github.com/paritytech/parity-bridges-common/pull/1199
// should be removed in https://github.com/paritytech/parity-bridges-common/issues/1246
// RialtoParachain token has no value, but we associate it with DOT token
const TOKEN_ID: Option<&'static str> = Some("polkadot");
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_rialto_parachain::BEST_FINALIZED_RIALTO_PARACHAIN_HEADER_METHOD;
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(5);
Expand Down

0 comments on commit e339ac9

Please sign in to comment.