remove account derivation functions (#1498)

This commit is contained in:
Svyatoslav Nikolsky
2022-07-12 11:07:38 +03:00
committed by Bastian Köcher
parent d327b25724
commit ceefd1b05d
22 changed files with 6 additions and 327 deletions
@@ -63,13 +63,6 @@ impl WeightToFeePolynomial for WeightToFee {
}
}
// We use this to get the account on Kusama (target) which is derived from Polkadot's (source)
// account.
pub fn derive_account_from_polkadot_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::POLKADOT_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
/// Per-byte fee for Kusama transactions.
pub const TRANSACTION_BYTE_FEE: Balance = 10 * 1_000_000_000_000 / 30_000 / 1_000;
+1 -38
View File
@@ -32,7 +32,7 @@ use frame_system::limits;
use scale_info::TypeInfo;
use sp_core::{storage::StateVersion, Hasher as HasherT};
use sp_runtime::{
traits::{Convert, IdentifyAccount, Verify},
traits::{IdentifyAccount, Verify},
FixedU128, MultiSignature, MultiSigner, Perbill,
};
use sp_std::prelude::*;
@@ -218,43 +218,6 @@ impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 {
}
}
/// Convert a 256-bit hash into an AccountId.
pub struct AccountIdConverter;
impl sp_runtime::traits::Convert<sp_core::H256, AccountId> for AccountIdConverter {
fn convert(hash: sp_core::H256) -> AccountId {
hash.to_fixed_bytes().into()
}
}
/// We use this to get the account on Millau (target) which is derived from Rialto's (source)
/// account. We do this so we can fund the derived account on Millau at Genesis to it can pay
/// transaction fees.
///
/// The reason we can use the same `AccountId` type for both chains is because they share the same
/// development seed phrase.
///
/// Note that this should only be used for testing.
pub fn derive_account_from_rialto_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::RIALTO_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
/// We use this to get the account on Millau (target) which is derived from RialtoParachain's
/// (source) account. We do this so we can fund the derived account on Millau at Genesis to it can
/// pay transaction fees.
///
/// The reason we can use the same `AccountId` type for both chains is because they share the same
/// development seed phrase.
///
/// Note that this should only be used for testing.
pub fn derive_account_from_rialto_parachain_id(
id: bp_runtime::SourceAccount<AccountId>,
) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::RIALTO_PARACHAIN_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
frame_support::parameter_types! {
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(2 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
@@ -63,13 +63,6 @@ impl WeightToFeePolynomial for WeightToFee {
}
}
// We use this to get the account on Polkadot (target) which is derived from Kusama's (source)
// account.
pub fn derive_account_from_kusama_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::KUSAMA_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
/// Per-byte fee for Polkadot transactions.
pub const TRANSACTION_BYTE_FEE: Balance = 10 * 10_000_000_000 / 100 / 1_000;
@@ -29,7 +29,7 @@ use frame_support::{
use frame_system::limits;
use sp_core::Hasher as HasherT;
use sp_runtime::{
traits::{BlakeTwo256, Convert, IdentifyAccount, Verify},
traits::{BlakeTwo256, IdentifyAccount, Verify},
FixedU128, MultiSignature, MultiSigner, Perbill,
};
use sp_std::vec::Vec;
@@ -161,15 +161,6 @@ impl Chain for RialtoParachain {
}
}
/// Convert a 256-bit hash into an AccountId.
pub struct AccountIdConverter;
impl Convert<sp_core::H256, AccountId> for AccountIdConverter {
fn convert(hash: sp_core::H256) -> AccountId {
hash.to_fixed_bytes().into()
}
}
frame_support::parameter_types! {
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
@@ -218,19 +209,6 @@ pub const TO_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
pub const FROM_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
"FromRialtoParachainInboundLaneApi_message_details";
// We use this to get the account on RialtoParachain (target) which is derived from Millau's
// (source) account. We do this so we can fund the derived account on RialtoParachain at Genesis to
// it can pay transaction fees.
//
// The reason we can use the same `AccountId` type for both chains is because they share the same
// development seed phrase.
//
// Note that this should only be used for testing.
pub fn derive_account_from_millau_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::MILLAU_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
sp_api::decl_runtime_apis! {
/// API for querying information about the finalized RialtoParachain headers.
///
+1 -23
View File
@@ -29,7 +29,7 @@ use frame_support::{
use frame_system::limits;
use sp_core::Hasher as HasherT;
use sp_runtime::{
traits::{BlakeTwo256, Convert, IdentifyAccount, Verify},
traits::{BlakeTwo256, IdentifyAccount, Verify},
FixedU128, MultiSignature, MultiSigner, Perbill,
};
use sp_std::prelude::*;
@@ -181,28 +181,6 @@ impl Chain for Rialto {
}
}
/// Convert a 256-bit hash into an AccountId.
pub struct AccountIdConverter;
impl Convert<sp_core::H256, AccountId> for AccountIdConverter {
fn convert(hash: sp_core::H256) -> AccountId {
hash.to_fixed_bytes().into()
}
}
// We use this to get the account on Rialto (target) which is derived from Millau's (source)
// account. We do this so we can fund the derived account on Rialto at Genesis to it can pay
// transaction fees.
//
// The reason we can use the same `AccountId` type for both chains is because they share the same
// development seed phrase.
//
// Note that this should only be used for testing.
pub fn derive_account_from_millau_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::MILLAU_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
frame_support::parameter_types! {
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
@@ -69,13 +69,6 @@ impl WeightToFeePolynomial for WeightToFee {
}
}
// We use this to get the account on Rococo (target) which is derived from Wococo's (source)
// account.
pub fn derive_account_from_wococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::WOCOCO_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
/// Name of the With-Rococo GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa";
/// Name of the With-Rococo messages pallet instance that is deployed at bridged chains.
@@ -79,13 +79,6 @@ impl sp_runtime::traits::Dispatchable for Call {
}
}
// We use this to get the account on Westend (target) which is derived from Rococo's (source)
// account.
pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::ROCOCO_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
/// Name of the parachains pallet at the Westend runtime.
pub const PARAS_PALLET_NAME: &str = "Paras";
@@ -38,13 +38,6 @@ pub type Wococo = PolkadotLike;
/// conditions.
pub const SESSION_LENGTH: BlockNumber = time_units::MINUTES;
// We use this to get the account on Wococo (target) which is derived from Rococo's (source)
// account.
pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
let encoded_id = bp_runtime::derive_account_id(bp_runtime::ROCOCO_CHAIN_ID, id);
AccountIdConverter::convert(encoded_id)
}
/// Name of the With-Wococo GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa";
/// Name of the With-Wococo messages pallet instance that is deployed at bridged chains.
@@ -133,7 +133,6 @@ pub trait MessageDeliveryAndDispatchPayment<SenderOrigin, AccountId, Balance> {
fn pay_delivery_and_dispatch_fee(
submitter: &SenderOrigin,
fee: &Balance,
relayer_fund_account: &AccountId,
) -> Result<(), Self::Error>;
/// Pay rewards for delivering messages to the given relayers.
@@ -145,7 +144,6 @@ pub trait MessageDeliveryAndDispatchPayment<SenderOrigin, AccountId, Balance> {
messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
confirmation_relayer: &AccountId,
received_range: &RangeInclusive<MessageNonce>,
relayer_fund_account: &AccountId,
);
}
@@ -157,7 +155,6 @@ impl<SenderOrigin, AccountId, Balance>
fn pay_delivery_and_dispatch_fee(
_submitter: &SenderOrigin,
_fee: &Balance,
_relayer_fund_account: &AccountId,
) -> Result<(), Self::Error> {
Ok(())
}
@@ -167,7 +164,6 @@ impl<SenderOrigin, AccountId, Balance>
_messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
_confirmation_relayer: &AccountId,
_received_range: &RangeInclusive<MessageNonce>,
_relayer_fund_account: &AccountId,
) {
}
}
@@ -306,7 +302,6 @@ impl<SenderOrigin, AccountId, Balance>
fn pay_delivery_and_dispatch_fee(
_submitter: &SenderOrigin,
_fee: &Balance,
_relayer_fund_account: &AccountId,
) -> Result<(), Self::Error> {
Err(ALL_OUTBOUND_MESSAGES_REJECTED)
}
@@ -316,7 +311,6 @@ impl<SenderOrigin, AccountId, Balance>
_messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
_confirmation_relayer: &AccountId,
_received_range: &RangeInclusive<MessageNonce>,
_relayer_fund_account: &AccountId,
) {
}
}
@@ -390,15 +390,6 @@ impl Chain for PolkadotLike {
}
}
/// Convert a 256-bit hash into an AccountId.
pub struct AccountIdConverter;
impl Convert<sp_core::H256, AccountId> for AccountIdConverter {
fn convert(hash: sp_core::H256) -> AccountId {
hash.to_fixed_bytes().into()
}
}
/// Return a storage key for account data.
///
/// This is based on FRAME storage-generation code from Substrate:
-10
View File
@@ -127,16 +127,6 @@ where
.into()
}
/// Derive the account ID of the shared relayer fund account.
///
/// This account is used to collect fees for relayers that are passing messages across the bridge.
///
/// The account ID can be the same across different instances of `pallet-bridge-messages` if the
/// same `bridge_id` is used.
pub fn derive_relayer_fund_account_id(bridge_id: ChainId) -> H256 {
("relayer-fund-account", bridge_id).using_encoded(blake2_256).into()
}
/// Anything that has size.
pub trait Size {
/// Return size of this object (in bytes).