mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Separate signers for different complex relay layers (#1465)
* separate accounts for different complex relay layers * fix clippy issue * cleanup + expose relay accounts balance metrics * expose messages pallet owner balance metric * use new metrics in maintenance dashboard * tests + use separate accounts to sign RialtoHeaders -> Millau transactions in RialtoParachain<>Millau bridge * clippy + fmt + spellcheck
This commit is contained in:
committed by
Bastian Köcher
parent
4bbef37a12
commit
418942826d
@@ -48,3 +48,61 @@ pub struct TransactionParams<TS> {
|
||||
/// Transactions mortality.
|
||||
pub mortality: Option<u32>,
|
||||
}
|
||||
|
||||
/// Tagged relay account, which balance may be exposed as metrics by the relay.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum TaggedAccount<AccountId> {
|
||||
/// Account, used to sign headers relay transactions from given bridged chain.
|
||||
Headers {
|
||||
/// Account id.
|
||||
id: AccountId,
|
||||
/// Name of the bridged chain, which headers are relayed.
|
||||
bridged_chain: String,
|
||||
},
|
||||
/// Account, used to sign parachains relay transactions from given bridged relay chain.
|
||||
Parachains {
|
||||
/// Account id.
|
||||
id: AccountId,
|
||||
/// Name of the bridged relay chain with parachain heads.
|
||||
bridged_chain: String,
|
||||
},
|
||||
/// Account, used to sign message relay transactions from given bridged chain.
|
||||
Messages {
|
||||
/// Account id.
|
||||
id: AccountId,
|
||||
/// Name of the bridged chain, which sends us messages or delivery confirmations.
|
||||
bridged_chain: String,
|
||||
},
|
||||
/// Account, used to sign messages with-bridged-chain pallet parameters update transactions.
|
||||
MessagesPalletOwner {
|
||||
/// Account id.
|
||||
id: AccountId,
|
||||
/// Name of the chain, bridged using messages pallet at our chain.
|
||||
bridged_chain: String,
|
||||
},
|
||||
}
|
||||
|
||||
impl<AccountId> TaggedAccount<AccountId> {
|
||||
/// Returns reference to the account id.
|
||||
pub fn id(&self) -> &AccountId {
|
||||
match *self {
|
||||
TaggedAccount::Headers { ref id, .. } => id,
|
||||
TaggedAccount::Parachains { ref id, .. } => id,
|
||||
TaggedAccount::Messages { ref id, .. } => id,
|
||||
TaggedAccount::MessagesPalletOwner { ref id, .. } => id,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns stringified account tag.
|
||||
pub fn tag(&self) -> String {
|
||||
match *self {
|
||||
TaggedAccount::Headers { ref bridged_chain, .. } => format!("{}Headers", bridged_chain),
|
||||
TaggedAccount::Parachains { ref bridged_chain, .. } =>
|
||||
format!("{}Parachains", bridged_chain),
|
||||
TaggedAccount::Messages { ref bridged_chain, .. } =>
|
||||
format!("{}Messages", bridged_chain),
|
||||
TaggedAccount::MessagesPalletOwner { ref bridged_chain, .. } =>
|
||||
format!("{}MessagesPalletOwner", bridged_chain),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Tools for supporting message lanes between two Substrate-based chains.
|
||||
|
||||
use crate::{helpers::tokens_conversion_rate, messages_lane::SubstrateMessageLane};
|
||||
use crate::{helpers::tokens_conversion_rate, messages_lane::SubstrateMessageLane, TaggedAccount};
|
||||
|
||||
use codec::Decode;
|
||||
use frame_system::AccountInfo;
|
||||
@@ -274,13 +274,12 @@ pub fn standalone_metrics<P: SubstrateMessageLane>(
|
||||
pub async fn add_relay_balances_metrics<C: ChainWithBalances>(
|
||||
client: Client<C>,
|
||||
metrics: MetricsParams,
|
||||
relay_account_id: Option<AccountIdOf<C>>,
|
||||
messages_pallet_owner_account_id: Option<AccountIdOf<C>>,
|
||||
relay_accounts: Vec<TaggedAccount<AccountIdOf<C>>>,
|
||||
) -> anyhow::Result<MetricsParams>
|
||||
where
|
||||
BalanceOf<C>: Into<u128> + std::fmt::Debug,
|
||||
{
|
||||
if relay_account_id.is_none() && messages_pallet_owner_account_id.is_none() {
|
||||
if relay_accounts.is_empty() {
|
||||
return Ok(metrics)
|
||||
}
|
||||
|
||||
@@ -306,26 +305,18 @@ where
|
||||
e,
|
||||
)
|
||||
})?;
|
||||
if let Some(relay_account_id) = relay_account_id {
|
||||
|
||||
for account in relay_accounts {
|
||||
let relay_account_balance_metric = FloatStorageValueMetric::new(
|
||||
FreeAccountBalance::<C> { token_decimals, _phantom: Default::default() },
|
||||
client.clone(),
|
||||
C::account_info_storage_key(&relay_account_id),
|
||||
format!("at_{}_relay_balance", C::NAME),
|
||||
format!("Balance of the relay account at the {}", C::NAME),
|
||||
C::account_info_storage_key(account.id()),
|
||||
format!("at_{}_relay_{}_balance", C::NAME, account.tag()),
|
||||
format!("Balance of the {} relay account at the {}", account.tag(), C::NAME),
|
||||
)?;
|
||||
relay_account_balance_metric.register_and_spawn(&metrics.registry)?;
|
||||
}
|
||||
if let Some(messages_pallet_owner_account_id) = messages_pallet_owner_account_id {
|
||||
let pallet_owner_account_balance_metric = FloatStorageValueMetric::new(
|
||||
FreeAccountBalance::<C> { token_decimals, _phantom: Default::default() },
|
||||
client.clone(),
|
||||
C::account_info_storage_key(&messages_pallet_owner_account_id),
|
||||
format!("at_{}_messages_pallet_owner_balance", C::NAME),
|
||||
format!("Balance of the messages pallet owner at the {}", C::NAME),
|
||||
)?;
|
||||
pallet_owner_account_balance_metric.register_and_spawn(&metrics.registry)?;
|
||||
}
|
||||
|
||||
Ok(metrics)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user