mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Remove unused PoA<>Substrate bridge (#1210)
* Decouple the PoA bridge code from Rialto
* Remove Rialto PoA bridge code
* Remove relays/bin-ethereum code
* Remove relays/client-ethereum code
* Remove modules/ethereum code
* Remove modules/ethereum-contract-builtin code
* Remove PoA bridge documentation
* Remove primitives/ethereum-poa code
* Decouple Rialto from currency-exchange
* Fix building with runtime-benchmarks
* Fix should_encode_bridge_send_message_call test
Because we removed some runtime modules/pallets, the
substrate2substrate bridge pallet has a different index within
the runtime so its calls have a different encoding.
Update the test to use the new encoding.
* Update readme - no more PoA bridge
* Remove deployments/bridges/poa-rialto
Also removes:
- deployments/networks/eth-poa.yml
- deployments/networks/OpenEthereum.Dockerfile
* Remove deployments/dev/poa-config
* Update deployments readme - no more PoA bridge
* Remove eth-related scripts
Deletes:
- deployments/networks/eth-poa.yml
- scripts/run-openethereum-node.sh
* Remove poa-relay from gitlab-ci
* Dockerfiles to use substrate-relay as default
* Remove modules/currency-exchange code
* Remove primitives/currency-exchange code
Signed-off-by: acatangiu <adrian@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
2d05583b15
commit
57f3f36cb1
@@ -30,14 +30,8 @@
|
||||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
pub mod exchange;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub mod benches;
|
||||
pub mod kovan;
|
||||
pub mod millau_messages;
|
||||
pub mod parachains;
|
||||
pub mod rialto_poa;
|
||||
|
||||
use crate::millau_messages::{ToMillauMessagePayload, WithMillauMessageBridge};
|
||||
|
||||
@@ -72,8 +66,6 @@ pub use frame_support::{
|
||||
|
||||
pub use frame_system::Call as SystemCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use pallet_bridge_currency_exchange::Call as BridgeCurrencyExchangeCall;
|
||||
pub use pallet_bridge_eth_poa::Call as BridgeEthPoACall;
|
||||
pub use pallet_bridge_grandpa::Call as BridgeGrandpaMillauCall;
|
||||
pub use pallet_bridge_messages::Call as MessagesCall;
|
||||
pub use pallet_sudo::Call as SudoCall;
|
||||
@@ -253,48 +245,6 @@ impl pallet_babe::Config for Runtime {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
type RialtoPoA = pallet_bridge_eth_poa::Instance1;
|
||||
impl pallet_bridge_eth_poa::Config<RialtoPoA> for Runtime {
|
||||
type AuraConfiguration = rialto_poa::BridgeAuraConfiguration;
|
||||
type FinalityVotesCachingInterval = rialto_poa::FinalityVotesCachingInterval;
|
||||
type ValidatorsConfiguration = rialto_poa::BridgeValidatorsConfiguration;
|
||||
type PruningStrategy = rialto_poa::PruningStrategy;
|
||||
type ChainTime = rialto_poa::ChainTime;
|
||||
type OnHeadersSubmitted = ();
|
||||
}
|
||||
|
||||
type Kovan = pallet_bridge_eth_poa::Instance2;
|
||||
impl pallet_bridge_eth_poa::Config<Kovan> for Runtime {
|
||||
type AuraConfiguration = kovan::BridgeAuraConfiguration;
|
||||
type FinalityVotesCachingInterval = kovan::FinalityVotesCachingInterval;
|
||||
type ValidatorsConfiguration = kovan::BridgeValidatorsConfiguration;
|
||||
type PruningStrategy = kovan::PruningStrategy;
|
||||
type ChainTime = kovan::ChainTime;
|
||||
type OnHeadersSubmitted = ();
|
||||
}
|
||||
|
||||
type RialtoCurrencyExchange = pallet_bridge_currency_exchange::Instance1;
|
||||
impl pallet_bridge_currency_exchange::Config<RialtoCurrencyExchange> for Runtime {
|
||||
type OnTransactionSubmitted = ();
|
||||
type PeerBlockchain = rialto_poa::RialtoBlockchain;
|
||||
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
||||
type RecipientsMap = bp_currency_exchange::IdentityRecipients<AccountId>;
|
||||
type Amount = Balance;
|
||||
type CurrencyConverter = bp_currency_exchange::IdentityCurrencyConverter<Balance>;
|
||||
type DepositInto = DepositInto;
|
||||
}
|
||||
|
||||
type KovanCurrencyExchange = pallet_bridge_currency_exchange::Instance2;
|
||||
impl pallet_bridge_currency_exchange::Config<KovanCurrencyExchange> for Runtime {
|
||||
type OnTransactionSubmitted = ();
|
||||
type PeerBlockchain = kovan::KovanBlockchain;
|
||||
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
||||
type RecipientsMap = bp_currency_exchange::IdentityRecipients<AccountId>;
|
||||
type Amount = Balance;
|
||||
type CurrencyConverter = bp_currency_exchange::IdentityCurrencyConverter<Balance>;
|
||||
type DepositInto = DepositInto;
|
||||
}
|
||||
|
||||
impl pallet_bridge_dispatch::Config for Runtime {
|
||||
type Event = Event;
|
||||
type BridgeMessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
|
||||
@@ -307,68 +257,6 @@ impl pallet_bridge_dispatch::Config for Runtime {
|
||||
type AccountIdConverter = bp_rialto::AccountIdConverter;
|
||||
}
|
||||
|
||||
pub struct DepositInto;
|
||||
|
||||
impl bp_currency_exchange::DepositInto for DepositInto {
|
||||
type Recipient = AccountId;
|
||||
type Amount = Balance;
|
||||
|
||||
fn deposit_into(
|
||||
recipient: Self::Recipient,
|
||||
amount: Self::Amount,
|
||||
) -> bp_currency_exchange::Result<()> {
|
||||
// let balances module make all checks for us (it won't allow depositing lower than
|
||||
// existential deposit, balance overflow, ...)
|
||||
let deposited = <pallet_balances::Pallet<Runtime> as Currency<AccountId>>::deposit_creating(
|
||||
&recipient, amount,
|
||||
);
|
||||
|
||||
// I'm dropping deposited here explicitly to illustrate the fact that it'll update
|
||||
// `TotalIssuance` on drop
|
||||
let deposited_amount = deposited.peek();
|
||||
drop(deposited);
|
||||
|
||||
// we have 3 cases here:
|
||||
// - deposited == amount: success
|
||||
// - deposited == 0: deposit has failed and no changes to storage were made
|
||||
// - deposited != 0: (should never happen in practice) deposit has been partially completed
|
||||
match deposited_amount {
|
||||
_ if deposited_amount == amount => {
|
||||
log::trace!(
|
||||
target: "runtime",
|
||||
"Deposited {} to {:?}",
|
||||
amount,
|
||||
recipient,
|
||||
);
|
||||
|
||||
Ok(())
|
||||
},
|
||||
_ if deposited_amount == 0 => {
|
||||
log::error!(
|
||||
target: "runtime",
|
||||
"Deposit of {} to {:?} has failed",
|
||||
amount,
|
||||
recipient,
|
||||
);
|
||||
|
||||
Err(bp_currency_exchange::Error::DepositFailed)
|
||||
},
|
||||
_ => {
|
||||
log::error!(
|
||||
target: "runtime",
|
||||
"Deposit of {} to {:?} has partially competed. {} has been deposited",
|
||||
amount,
|
||||
recipient,
|
||||
deposited_amount,
|
||||
);
|
||||
|
||||
// we can't return DepositFailed error here, because storage changes were made
|
||||
Err(bp_currency_exchange::Error::DepositPartiallyFailed)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
@@ -578,12 +466,6 @@ construct_runtime!(
|
||||
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
|
||||
ShiftSessionManager: pallet_shift_session_manager::{Pallet},
|
||||
|
||||
// Eth-PoA chains bridge modules.
|
||||
BridgeRialtoPoa: pallet_bridge_eth_poa::<Instance1>::{Pallet, Call, Config, Storage, ValidateUnsigned},
|
||||
BridgeKovan: pallet_bridge_eth_poa::<Instance2>::{Pallet, Call, Config, Storage, ValidateUnsigned},
|
||||
BridgeRialtoCurrencyExchange: pallet_bridge_currency_exchange::<Instance1>::{Pallet, Call},
|
||||
BridgeKovanCurrencyExchange: pallet_bridge_currency_exchange::<Instance2>::{Pallet, Call},
|
||||
|
||||
// Millau bridge modules.
|
||||
BridgeMillauGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage},
|
||||
BridgeDispatch: pallet_bridge_dispatch::{Pallet, Event<T>},
|
||||
@@ -693,46 +575,6 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_eth_poa::RialtoPoAHeaderApi<Block> for Runtime {
|
||||
fn best_block() -> (u64, bp_eth_poa::H256) {
|
||||
let best_block = BridgeRialtoPoa::best_block();
|
||||
(best_block.number, best_block.hash)
|
||||
}
|
||||
|
||||
fn finalized_block() -> (u64, bp_eth_poa::H256) {
|
||||
let finalized_block = BridgeRialtoPoa::finalized_block();
|
||||
(finalized_block.number, finalized_block.hash)
|
||||
}
|
||||
|
||||
fn is_import_requires_receipts(header: bp_eth_poa::AuraHeader) -> bool {
|
||||
BridgeRialtoPoa::is_import_requires_receipts(header)
|
||||
}
|
||||
|
||||
fn is_known_block(hash: bp_eth_poa::H256) -> bool {
|
||||
BridgeRialtoPoa::is_known_block(hash)
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_eth_poa::KovanHeaderApi<Block> for Runtime {
|
||||
fn best_block() -> (u64, bp_eth_poa::H256) {
|
||||
let best_block = BridgeKovan::best_block();
|
||||
(best_block.number, best_block.hash)
|
||||
}
|
||||
|
||||
fn finalized_block() -> (u64, bp_eth_poa::H256) {
|
||||
let finalized_block = BridgeKovan::finalized_block();
|
||||
(finalized_block.number, finalized_block.hash)
|
||||
}
|
||||
|
||||
fn is_import_requires_receipts(header: bp_eth_poa::AuraHeader) -> bool {
|
||||
BridgeKovan::is_import_requires_receipts(header)
|
||||
}
|
||||
|
||||
fn is_known_block(hash: bp_eth_poa::H256) -> bool {
|
||||
BridgeKovan::is_known_block(hash)
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_millau::MillauFinalityApi<Block> for Runtime {
|
||||
fn best_finalized() -> (bp_millau::BlockNumber, bp_millau::Hash) {
|
||||
let header = BridgeMillauGrandpa::best_finalized();
|
||||
@@ -744,18 +586,6 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_currency_exchange::RialtoCurrencyExchangeApi<Block, exchange::EthereumTransactionInclusionProof> for Runtime {
|
||||
fn filter_transaction_proof(proof: exchange::EthereumTransactionInclusionProof) -> bool {
|
||||
BridgeRialtoCurrencyExchange::filter_transaction_proof(&proof)
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_currency_exchange::KovanCurrencyExchangeApi<Block, exchange::EthereumTransactionInclusionProof> for Runtime {
|
||||
fn filter_transaction_proof(proof: exchange::EthereumTransactionInclusionProof) -> bool {
|
||||
BridgeKovanCurrencyExchange::filter_transaction_proof(&proof)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(
|
||||
source: TransactionSource,
|
||||
@@ -1028,17 +858,10 @@ impl_runtime_apis! {
|
||||
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
|
||||
use frame_support::traits::StorageInfoTrait;
|
||||
|
||||
use pallet_bridge_currency_exchange::benchmarking::Pallet as BridgeCurrencyExchangeBench;
|
||||
use pallet_bridge_messages::benchmarking::Pallet as MessagesBench;
|
||||
|
||||
let mut list = Vec::<BenchmarkList>::new();
|
||||
|
||||
list_benchmark!(list, extra, pallet_bridge_eth_poa, BridgeRialtoPoa);
|
||||
list_benchmark!(
|
||||
list,
|
||||
extra,
|
||||
pallet_bridge_currency_exchange, BridgeCurrencyExchangeBench::<Runtime, KovanCurrencyExchange>
|
||||
);
|
||||
list_benchmark!(list, extra, pallet_bridge_messages, MessagesBench::<Runtime, WithMillauMessagesInstance>);
|
||||
list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeMillauGrandpa);
|
||||
|
||||
@@ -1068,46 +891,6 @@ impl_runtime_apis! {
|
||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
||||
let params = (&config, &whitelist);
|
||||
|
||||
use pallet_bridge_currency_exchange::benchmarking::{
|
||||
Pallet as BridgeCurrencyExchangeBench,
|
||||
Config as BridgeCurrencyExchangeConfig,
|
||||
ProofParams as BridgeCurrencyExchangeProofParams,
|
||||
};
|
||||
|
||||
impl BridgeCurrencyExchangeConfig<KovanCurrencyExchange> for Runtime {
|
||||
fn make_proof(
|
||||
proof_params: BridgeCurrencyExchangeProofParams<AccountId>,
|
||||
) -> crate::exchange::EthereumTransactionInclusionProof {
|
||||
use bp_currency_exchange::DepositInto;
|
||||
|
||||
if proof_params.recipient_exists {
|
||||
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
proof_params.recipient.clone(),
|
||||
ExistentialDeposit::get(),
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
let (transaction, receipt) = crate::exchange::prepare_ethereum_transaction(
|
||||
&proof_params.recipient,
|
||||
|tx| {
|
||||
// our runtime only supports transactions where data is exactly 32 bytes long
|
||||
// (receiver key)
|
||||
// => we are ignoring `transaction_size_factor` here
|
||||
tx.value = (ExistentialDeposit::get() * 10).into();
|
||||
},
|
||||
);
|
||||
let transactions = sp_std::iter::repeat((transaction, receipt))
|
||||
.take(1 + proof_params.proof_size_factor as usize)
|
||||
.collect::<Vec<_>>();
|
||||
let block_hash = crate::exchange::prepare_environment_for_claim::<Runtime, Kovan>(&transactions);
|
||||
crate::exchange::EthereumTransactionInclusionProof {
|
||||
block: block_hash,
|
||||
index: 0,
|
||||
proof: transactions,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use crate::millau_messages::{ToMillauMessagePayload, WithMillauMessageBridge};
|
||||
use bp_runtime::messages::DispatchFeePayment;
|
||||
use bridge_runtime_common::messages;
|
||||
@@ -1274,13 +1057,6 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
add_benchmark!(params, batches, pallet_bridge_eth_poa, BridgeRialtoPoa);
|
||||
add_benchmark!(
|
||||
params,
|
||||
batches,
|
||||
pallet_bridge_currency_exchange,
|
||||
BridgeCurrencyExchangeBench::<Runtime, KovanCurrencyExchange>
|
||||
);
|
||||
add_benchmark!(
|
||||
params,
|
||||
batches,
|
||||
@@ -1322,48 +1098,8 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bp_currency_exchange::DepositInto;
|
||||
use bridge_runtime_common::messages;
|
||||
|
||||
fn run_deposit_into_test(test: impl Fn(AccountId) -> Balance) {
|
||||
let mut ext: sp_io::TestExternalities =
|
||||
SystemConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||
ext.execute_with(|| {
|
||||
// initially issuance is zero
|
||||
assert_eq!(
|
||||
<pallet_balances::Pallet<Runtime> as Currency<AccountId>>::total_issuance(),
|
||||
0,
|
||||
);
|
||||
|
||||
// create account
|
||||
let account: AccountId = [1u8; 32].into();
|
||||
let initial_amount = ExistentialDeposit::get();
|
||||
let deposited =
|
||||
<pallet_balances::Pallet<Runtime> as Currency<AccountId>>::deposit_creating(
|
||||
&account,
|
||||
initial_amount,
|
||||
);
|
||||
drop(deposited);
|
||||
assert_eq!(
|
||||
<pallet_balances::Pallet<Runtime> as Currency<AccountId>>::total_issuance(),
|
||||
initial_amount,
|
||||
);
|
||||
assert_eq!(
|
||||
<pallet_balances::Pallet<Runtime> as Currency<AccountId>>::free_balance(&account),
|
||||
initial_amount,
|
||||
);
|
||||
|
||||
// run test
|
||||
let total_issuance_change = test(account);
|
||||
|
||||
// check that total issuance has changed by `run_deposit_into_test`
|
||||
assert_eq!(
|
||||
<pallet_balances::Pallet<Runtime> as Currency<AccountId>>::total_issuance(),
|
||||
initial_amount + total_issuance_change,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ensure_rialto_message_lane_weights_are_correct() {
|
||||
type Weights = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
||||
@@ -1405,50 +1141,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deposit_into_existing_account_works() {
|
||||
run_deposit_into_test(|existing_account| {
|
||||
let initial_amount =
|
||||
<pallet_balances::Pallet<Runtime> as Currency<AccountId>>::free_balance(
|
||||
&existing_account,
|
||||
);
|
||||
let additional_amount = 10_000;
|
||||
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
existing_account.clone(),
|
||||
additional_amount,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
<pallet_balances::Pallet<Runtime> as Currency<AccountId>>::free_balance(
|
||||
&existing_account
|
||||
),
|
||||
initial_amount + additional_amount,
|
||||
);
|
||||
additional_amount
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deposit_into_new_account_works() {
|
||||
run_deposit_into_test(|_| {
|
||||
let initial_amount = 0;
|
||||
let additional_amount = ExistentialDeposit::get() + 10_000;
|
||||
let new_account: AccountId = [42u8; 32].into();
|
||||
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
new_account.clone(),
|
||||
additional_amount,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
<pallet_balances::Pallet<Runtime> as Currency<AccountId>>::free_balance(
|
||||
&new_account
|
||||
),
|
||||
initial_amount + additional_amount,
|
||||
);
|
||||
additional_amount
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_size() {
|
||||
const MAX_CALL_SIZE: usize = 230; // value from polkadot-runtime tests
|
||||
|
||||
Reference in New Issue
Block a user