diff --git a/bridges/bin/node/node/Cargo.toml b/bridges/bin/node/node/Cargo.toml index cea3b69152..3dbae3a36b 100644 --- a/bridges/bin/node/node/Cargo.toml +++ b/bridges/bin/node/node/Cargo.toml @@ -12,11 +12,11 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" name = "bridge-node" [dependencies] +bp-eth-poa = { version = "0.1.0", path = "../../../primitives/ethereum-poa" } futures = "0.3.5" jsonrpc-core = "14.2.0" log = "0.4.11" structopt = "0.3.15" -sp-bridge-eth-poa = { version = "0.1.0", path = "../../../primitives/ethereum-poa" } [dependencies.bridge-node-runtime] version = "0.1.0" diff --git a/bridges/bin/node/runtime/Cargo.toml b/bridges/bin/node/runtime/Cargo.toml index 205932ca04..2e46acecac 100644 --- a/bridges/bin/node/runtime/Cargo.toml +++ b/bridges/bin/node/runtime/Cargo.toml @@ -123,16 +123,6 @@ tag = 'v2.0.0-rc5' default-features = false git = "https://github.com/paritytech/substrate/" -[dependencies.sp-bridge-eth-poa] -version = "0.1.0" -default-features = false -path = "../../../primitives/ethereum-poa" - -[dependencies.sp-currency-exchange] -version = "0.1.0" -default-features = false -path = "../../../primitives/currency-exchange" - [dependencies.sp-consensus-aura] version = "0.8.0-rc5" tag = 'v2.0.0-rc5' @@ -206,12 +196,24 @@ tag = 'v2.0.0-rc5' default-features = false git = "https://github.com/paritytech/substrate/" +[dependencies.bp-currency-exchange] +version = "0.1.0" +default-features = false +path = "../../../primitives/currency-exchange" + +[dependencies.bp-eth-poa] +version = "0.1.0" +default-features = false +path = "../../../primitives/ethereum-poa" + +# Dev Dependencies + [dev-dependencies.libsecp256k1] version = "0.3.4" default-features = false features = ["hmac"] -[dev-dependencies.sp-bridge-eth-poa] +[dev-dependencies.bp-eth-poa] version = "0.1.0" default-features = false features = ["std"] @@ -226,23 +228,26 @@ git = "https://github.com/paritytech/substrate/" [features] default = ["std"] std = [ - "pallet-aura/std", - "pallet-balances/std", - "pallet-bridge-eth-poa/std", - "pallet-bridge-currency-exchange/std", + "bp-currency-exchange/std", + "bp-eth-poa/std", "codec/std", "frame-benchmarking/std", "frame-executive/std", "frame-support/std", - "frame-system/std", "frame-system-rpc-runtime-api/std", + "frame-system/std", + "pallet-aura/std", + "pallet-balances/std", + "pallet-bridge-currency-exchange/std", + "pallet-bridge-eth-poa/std", "pallet-grandpa/std", "pallet-randomness-collective-flip/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment/std", "serde", "sp-api/std", "sp-block-builder/std", - "sp-bridge-eth-poa/std", - "sp-currency-exchange/std", "sp-consensus-aura/std", "sp-core/std", "sp-inherents/std", @@ -253,9 +258,6 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment/std", ] runtime-benchmarks = [ "frame-benchmarking", diff --git a/bridges/bin/node/runtime/src/exchange.rs b/bridges/bin/node/runtime/src/exchange.rs index 1048c66189..0812006ebd 100644 --- a/bridges/bin/node/runtime/src/exchange.rs +++ b/bridges/bin/node/runtime/src/exchange.rs @@ -27,13 +27,13 @@ //! to the PoA -> Substrate bridge module (it can be provided by you); //! 5) receive tokens by providing proof-of-inclusion of PoA transaction. +use bp_currency_exchange::{ + Error as ExchangeError, LockFundsTransaction, MaybeLockFundsTransaction, Result as ExchangeResult, +}; +use bp_eth_poa::{transaction_decode_rlp, RawTransaction, RawTransactionReceipt}; use codec::{Decode, Encode}; use frame_support::RuntimeDebug; use hex_literal::hex; -use sp_bridge_eth_poa::{transaction_decode_rlp, RawTransaction, RawTransactionReceipt}; -use sp_currency_exchange::{ - Error as ExchangeError, LockFundsTransaction, MaybeLockFundsTransaction, Result as ExchangeResult, -}; use sp_std::vec::Vec; /// Ethereum address where locked PoA funds must be sent to. @@ -130,12 +130,12 @@ impl MaybeLockFundsTransaction for EthTransaction { #[cfg(feature = "runtime-benchmarks")] pub(crate) fn prepare_environment_for_claim, I: pallet_bridge_eth_poa::Instance>( transactions: &[(RawTransaction, RawTransactionReceipt)], -) -> sp_bridge_eth_poa::H256 { +) -> bp_eth_poa::H256 { + use bp_eth_poa::compute_merkle_root; use pallet_bridge_eth_poa::{ test_utils::{insert_header, validator_utils::validator, HeaderBuilder}, BridgeStorage, Storage, }; - use sp_bridge_eth_poa::compute_merkle_root; let mut storage = BridgeStorage::::new(); let header = HeaderBuilder::with_parent_number_on_runtime::(0) @@ -153,9 +153,9 @@ pub(crate) fn prepare_environment_for_claim, #[cfg(any(feature = "runtime-benchmarks", test))] pub(crate) fn prepare_ethereum_transaction( recipient: &crate::AccountId, - editor: impl Fn(&mut sp_bridge_eth_poa::UnsignedTransaction), + editor: impl Fn(&mut bp_eth_poa::UnsignedTransaction), ) -> (RawTransaction, RawTransactionReceipt) { - use sp_bridge_eth_poa::{signatures::SignTransaction, Receipt, TransactionOutcome}; + use bp_eth_poa::{signatures::SignTransaction, Receipt, TransactionOutcome}; // prepare tx for OpenEthereum private dev chain: // chain id is 0x11 @@ -166,7 +166,7 @@ pub(crate) fn prepare_ethereum_transaction( )) .unwrap(); let recipient_raw: &[u8; 32] = recipient.as_ref(); - let mut eth_tx = sp_bridge_eth_poa::UnsignedTransaction { + let mut eth_tx = bp_eth_poa::UnsignedTransaction { nonce: 0.into(), to: Some(LOCK_FUNDS_ADDRESS.into()), value: 100.into(), diff --git a/bridges/bin/node/runtime/src/kovan.rs b/bridges/bin/node/runtime/src/kovan.rs index 005aaa8f7b..1855aa9dd3 100644 --- a/bridges/bin/node/runtime/src/kovan.rs +++ b/bridges/bin/node/runtime/src/kovan.rs @@ -16,13 +16,13 @@ use crate::exchange::EthereumTransactionInclusionProof; +use bp_eth_poa::{Address, Header, RawTransaction, U256}; use frame_support::RuntimeDebug; use hex_literal::hex; use pallet_bridge_currency_exchange::PeerBlockchain; use pallet_bridge_eth_poa::{ AuraConfiguration, PruningStrategy as BridgePruningStrategy, ValidatorsConfiguration, ValidatorsSource, }; -use sp_bridge_eth_poa::{Address, Header, RawTransaction, U256}; use sp_std::prelude::*; frame_support::parameter_types! { diff --git a/bridges/bin/node/runtime/src/lib.rs b/bridges/bin/node/runtime/src/lib.rs index 22abc50b6d..2ea3112891 100644 --- a/bridges/bin/node/runtime/src/lib.rs +++ b/bridges/bin/node/runtime/src/lib.rs @@ -251,9 +251,9 @@ impl pallet_bridge_currency_exchange::Trait for Runtime type OnTransactionSubmitted = (); type PeerBlockchain = rialto::RialtoBlockchain; type PeerMaybeLockFundsTransaction = exchange::EthTransaction; - type RecipientsMap = sp_currency_exchange::IdentityRecipients; + type RecipientsMap = bp_currency_exchange::IdentityRecipients; type Amount = Balance; - type CurrencyConverter = sp_currency_exchange::IdentityCurrencyConverter; + type CurrencyConverter = bp_currency_exchange::IdentityCurrencyConverter; type DepositInto = DepositInto; } @@ -262,19 +262,19 @@ impl pallet_bridge_currency_exchange::Trait for Runtime { type OnTransactionSubmitted = (); type PeerBlockchain = kovan::KovanBlockchain; type PeerMaybeLockFundsTransaction = exchange::EthTransaction; - type RecipientsMap = sp_currency_exchange::IdentityRecipients; + type RecipientsMap = bp_currency_exchange::IdentityRecipients; type Amount = Balance; - type CurrencyConverter = sp_currency_exchange::IdentityCurrencyConverter; + type CurrencyConverter = bp_currency_exchange::IdentityCurrencyConverter; type DepositInto = DepositInto; } pub struct DepositInto; -impl sp_currency_exchange::DepositInto for DepositInto { +impl bp_currency_exchange::DepositInto for DepositInto { type Recipient = AccountId; type Amount = Balance; - fn deposit_into(recipient: Self::Recipient, amount: Self::Amount) -> sp_currency_exchange::Result<()> { + 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 = as Currency>::deposit_creating(&recipient, amount); @@ -307,7 +307,7 @@ impl sp_currency_exchange::DepositInto for DepositInto { recipient, ); - Err(sp_currency_exchange::Error::DepositFailed) + Err(bp_currency_exchange::Error::DepositFailed) } _ => { frame_support::debug::error!( @@ -319,7 +319,7 @@ impl sp_currency_exchange::DepositInto for DepositInto { ); // we can't return DepositFailed error here, because storage changes were made - Err(sp_currency_exchange::Error::DepositPartiallyFailed) + Err(bp_currency_exchange::Error::DepositPartiallyFailed) } } } @@ -557,53 +557,53 @@ impl_runtime_apis! { } } - impl sp_bridge_eth_poa::RialtoHeaderApi for Runtime { - fn best_block() -> (u64, sp_bridge_eth_poa::H256) { + impl bp_eth_poa::RialtoHeaderApi for Runtime { + fn best_block() -> (u64, bp_eth_poa::H256) { let best_block = BridgeRialto::best_block(); (best_block.number, best_block.hash) } - fn finalized_block() -> (u64, sp_bridge_eth_poa::H256) { + fn finalized_block() -> (u64, bp_eth_poa::H256) { let finalized_block = BridgeRialto::finalized_block(); (finalized_block.number, finalized_block.hash) } - fn is_import_requires_receipts(header: sp_bridge_eth_poa::Header) -> bool { + fn is_import_requires_receipts(header: bp_eth_poa::Header) -> bool { BridgeRialto::is_import_requires_receipts(header) } - fn is_known_block(hash: sp_bridge_eth_poa::H256) -> bool { + fn is_known_block(hash: bp_eth_poa::H256) -> bool { BridgeRialto::is_known_block(hash) } } - impl sp_bridge_eth_poa::KovanHeaderApi for Runtime { - fn best_block() -> (u64, sp_bridge_eth_poa::H256) { + impl bp_eth_poa::KovanHeaderApi 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, sp_bridge_eth_poa::H256) { + 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: sp_bridge_eth_poa::Header) -> bool { + fn is_import_requires_receipts(header: bp_eth_poa::Header) -> bool { BridgeKovan::is_import_requires_receipts(header) } - fn is_known_block(hash: sp_bridge_eth_poa::H256) -> bool { + fn is_known_block(hash: bp_eth_poa::H256) -> bool { BridgeKovan::is_known_block(hash) } } - impl sp_currency_exchange::RialtoCurrencyExchangeApi for Runtime { + impl bp_currency_exchange::RialtoCurrencyExchangeApi for Runtime { fn filter_transaction_proof(proof: exchange::EthereumTransactionInclusionProof) -> bool { BridgeRialtoCurrencyExchange::filter_transaction_proof(&proof) } } - impl sp_currency_exchange::KovanCurrencyExchangeApi for Runtime { + impl bp_currency_exchange::KovanCurrencyExchangeApi for Runtime { fn filter_transaction_proof(proof: exchange::EthereumTransactionInclusionProof) -> bool { BridgeKovanCurrencyExchange::filter_transaction_proof(&proof) } @@ -714,7 +714,7 @@ impl_runtime_apis! { fn make_proof( proof_params: BridgeCurrencyExchangeProofParams, ) -> crate::exchange::EthereumTransactionInclusionProof { - use sp_currency_exchange::DepositInto; + use bp_currency_exchange::DepositInto; if proof_params.recipient_exists { >::DepositInto::deposit_into( @@ -761,7 +761,7 @@ impl_runtime_apis! { #[cfg(test)] mod tests { use super::*; - use sp_currency_exchange::DepositInto; + use bp_currency_exchange::DepositInto; #[test] fn shift_session_manager_works() { diff --git a/bridges/bin/node/runtime/src/rialto.rs b/bridges/bin/node/runtime/src/rialto.rs index 1a46fae0b5..800b0ab1c8 100644 --- a/bridges/bin/node/runtime/src/rialto.rs +++ b/bridges/bin/node/runtime/src/rialto.rs @@ -16,13 +16,13 @@ use crate::exchange::EthereumTransactionInclusionProof; +use bp_eth_poa::{Address, Header, RawTransaction, U256}; use frame_support::RuntimeDebug; use hex_literal::hex; use pallet_bridge_currency_exchange::PeerBlockchain; use pallet_bridge_eth_poa::{ AuraConfiguration, PruningStrategy as TPruningStrategy, ValidatorsConfiguration, ValidatorsSource, }; -use sp_bridge_eth_poa::{Address, Header, RawTransaction, U256}; use sp_std::prelude::*; frame_support::parameter_types! { diff --git a/bridges/modules/currency-exchange/Cargo.toml b/bridges/modules/currency-exchange/Cargo.toml index 4c8116aca8..03b3d692a3 100644 --- a/bridges/modules/currency-exchange/Cargo.toml +++ b/bridges/modules/currency-exchange/Cargo.toml @@ -7,9 +7,9 @@ edition = "2018" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -serde = { version = "1.0", optional = true } +bp-currency-exchange = { path = "../../primitives/currency-exchange", default-features = false } codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false } -sp-currency-exchange = { path = "../../primitives/currency-exchange", default-features = false } +serde = { version = "1.0", optional = true } # Substrate Based Dependencies [dependencies.frame-support] @@ -56,13 +56,13 @@ git = "https://github.com/paritytech/substrate/" [features] default = ["std"] std = [ + "bp-currency-exchange/std", "codec/std", "frame-benchmarking/std", "frame-support/std", "frame-system/std", "serde", - "sp-currency-exchange/std", - "sp-std/std", "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = ["frame-benchmarking"] diff --git a/bridges/modules/currency-exchange/src/lib.rs b/bridges/modules/currency-exchange/src/lib.rs index 29ba94631e..a7c3c5026a 100644 --- a/bridges/modules/currency-exchange/src/lib.rs +++ b/bridges/modules/currency-exchange/src/lib.rs @@ -18,10 +18,10 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{decl_error, decl_module, decl_storage, ensure, Parameter}; -use sp_currency_exchange::{ +use bp_currency_exchange::{ CurrencyConverter, DepositInto, Error as ExchangeError, MaybeLockFundsTransaction, RecipientsMap, }; +use frame_support::{decl_error, decl_module, decl_storage, ensure, Parameter}; use sp_runtime::DispatchResult; #[cfg(feature = "runtime-benchmarks")] @@ -221,9 +221,9 @@ fn prepare_deposit_details, I: Instance>( #[cfg(test)] mod tests { use super::*; + use bp_currency_exchange::LockFundsTransaction; use frame_support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight}; use sp_core::H256; - use sp_currency_exchange::LockFundsTransaction; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, @@ -272,7 +272,7 @@ mod tests { type Recipient = AccountId; type Amount = u64; - fn parse(tx: &Self::Transaction) -> sp_currency_exchange::Result { + fn parse(tx: &Self::Transaction) -> bp_currency_exchange::Result { match tx.id { INVALID_TRANSACTION_ID => Err(ExchangeError::InvalidTransaction), _ => Ok(tx.clone()), @@ -286,7 +286,7 @@ mod tests { type PeerRecipient = AccountId; type Recipient = AccountId; - fn map(peer_recipient: Self::PeerRecipient) -> sp_currency_exchange::Result { + fn map(peer_recipient: Self::PeerRecipient) -> bp_currency_exchange::Result { match peer_recipient { UNKNOWN_RECIPIENT_ID => Err(ExchangeError::FailedToMapRecipients), _ => Ok(peer_recipient * 10), @@ -300,7 +300,7 @@ mod tests { type SourceAmount = u64; type TargetAmount = u64; - fn convert(amount: Self::SourceAmount) -> sp_currency_exchange::Result { + fn convert(amount: Self::SourceAmount) -> bp_currency_exchange::Result { match amount { INVALID_AMOUNT => Err(ExchangeError::FailedToConvertCurrency), _ => Ok(amount * 10), @@ -314,7 +314,7 @@ mod tests { type Recipient = AccountId; type Amount = u64; - fn deposit_into(_recipient: Self::Recipient, amount: Self::Amount) -> sp_currency_exchange::Result<()> { + fn deposit_into(_recipient: Self::Recipient, amount: Self::Amount) -> bp_currency_exchange::Result<()> { match amount { amount if amount < MAX_DEPOSIT_AMOUNT * 10 => Ok(()), amount if amount == MAX_DEPOSIT_AMOUNT * 10 => Err(ExchangeError::DepositPartiallyFailed), diff --git a/bridges/modules/ethereum/Cargo.toml b/bridges/modules/ethereum/Cargo.toml index d2b17e0f63..bde8f95456 100644 --- a/bridges/modules/ethereum/Cargo.toml +++ b/bridges/modules/ethereum/Cargo.toml @@ -7,10 +7,10 @@ edition = "2018" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -serde = { version = "1.0", optional = true } +bp-eth-poa = { path = "../../primitives/ethereum-poa", default-features = false } codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false } hex-literal = "0.3" -primitives = { package = "sp-bridge-eth-poa", path = "../../primitives/ethereum-poa", default-features = false } +serde = { version = "1.0", optional = true } # Substrate Based Dependencies [dependencies.frame-support] @@ -58,18 +58,17 @@ features = ["hmac"] # Dev Dependencies [dev-dependencies] -# TODO: Stop renaming this on import -primitives = { package = "sp-bridge-eth-poa", path = "../../primitives/ethereum-poa", features = ["std"] } +bp-eth-poa = { path = "../../primitives/ethereum-poa", features = ["std"] } libsecp256k1 = { version = "0.3.4", features = ["hmac"] } [features] default = ["std"] std = [ + "bp-eth-poa/std", "codec/std", "frame-benchmarking/std", "frame-support/std", "frame-system/std", - "primitives/std", "serde", "sp-io/std", "sp-runtime/std", diff --git a/bridges/modules/ethereum/src/benchmarking.rs b/bridges/modules/ethereum/src/benchmarking.rs index 1da7019c64..b088c49bec 100644 --- a/bridges/modules/ethereum/src/benchmarking.rs +++ b/bridges/modules/ethereum/src/benchmarking.rs @@ -21,9 +21,9 @@ use crate::test_utils::{ HeaderBuilder, }; +use bp_eth_poa::{compute_merkle_root, U256}; use frame_benchmarking::benchmarks_instance; use frame_system::RawOrigin; -use primitives::{compute_merkle_root, U256}; benchmarks_instance! { _ { } diff --git a/bridges/modules/ethereum/src/finality.rs b/bridges/modules/ethereum/src/finality.rs index c847e77704..4d836cd8a5 100644 --- a/bridges/modules/ethereum/src/finality.rs +++ b/bridges/modules/ethereum/src/finality.rs @@ -16,8 +16,8 @@ use crate::error::Error; use crate::Storage; +use bp_eth_poa::{public_to_address, Address, Header, HeaderId, SealedEmptyStep, H256}; use codec::{Decode, Encode}; -use primitives::{public_to_address, Address, Header, HeaderId, SealedEmptyStep, H256}; use sp_io::crypto::secp256k1_ecdsa_recover; use sp_runtime::RuntimeDebug; use sp_std::collections::{ diff --git a/bridges/modules/ethereum/src/import.rs b/bridges/modules/ethereum/src/import.rs index 20c86cf6eb..97f423b2d9 100644 --- a/bridges/modules/ethereum/src/import.rs +++ b/bridges/modules/ethereum/src/import.rs @@ -19,7 +19,7 @@ use crate::finality::finalize_blocks; use crate::validators::{Validators, ValidatorsConfiguration}; use crate::verification::{is_importable_header, verify_aura_header}; use crate::{AuraConfiguration, ChangeToEnact, PruningStrategy, Storage}; -use primitives::{Header, HeaderId, Receipt}; +use bp_eth_poa::{Header, HeaderId, Receipt}; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; /// Imports bunch of headers and updates blocks finality. diff --git a/bridges/modules/ethereum/src/lib.rs b/bridges/modules/ethereum/src/lib.rs index cb8305543d..bbb2ba2956 100644 --- a/bridges/modules/ethereum/src/lib.rs +++ b/bridges/modules/ethereum/src/lib.rs @@ -19,9 +19,9 @@ #![allow(clippy::large_enum_variant)] use crate::finality::{CachedFinalityVotes, FinalityVotes}; +use bp_eth_poa::{Address, Header, HeaderId, RawTransaction, RawTransactionReceipt, Receipt, H256, U256}; use codec::{Decode, Encode}; use frame_support::{decl_module, decl_storage, traits::Get}; -use primitives::{Address, Header, HeaderId, RawTransaction, RawTransactionReceipt, Receipt, H256, U256}; use sp_runtime::{ transaction_validity::{ InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionSource, TransactionValidity, @@ -1025,7 +1025,7 @@ pub(crate) mod tests { genesis, insert_header, run_test, run_test_with_genesis, validators_addresses, HeaderBuilder, TestRuntime, GAS_LIMIT, }; - use primitives::compute_merkle_root; + use bp_eth_poa::compute_merkle_root; const TOTAL_VALIDATORS: usize = 3; @@ -1036,7 +1036,7 @@ pub(crate) mod tests { fn example_tx_receipt(success: bool) -> Vec { Receipt { // the only thing that we care of: - outcome: primitives::TransactionOutcome::StatusCode(if success { 1 } else { 0 }), + outcome: bp_eth_poa::TransactionOutcome::StatusCode(if success { 1 } else { 0 }), gas_used: Default::default(), log_bloom: Default::default(), logs: Vec::new(), diff --git a/bridges/modules/ethereum/src/mock.rs b/bridges/modules/ethereum/src/mock.rs index be173512a7..66d63d28d0 100644 --- a/bridges/modules/ethereum/src/mock.rs +++ b/bridges/modules/ethereum/src/mock.rs @@ -15,12 +15,12 @@ // along with Parity Bridges Common. If not, see . pub use crate::test_utils::{insert_header, validator_utils::*, validators_change_receipt, HeaderBuilder, GAS_LIMIT}; -pub use primitives::signatures::secret_to_address; +pub use bp_eth_poa::signatures::secret_to_address; use crate::validators::{ValidatorsConfiguration, ValidatorsSource}; use crate::{AuraConfiguration, GenesisConfig, PruningStrategy, Trait}; +use bp_eth_poa::{Address, Header, H256, U256}; use frame_support::{impl_outer_origin, parameter_types, weights::Weight}; -use primitives::{Address, Header, H256, U256}; use secp256k1::SecretKey; use sp_runtime::{ testing::Header as SubstrateHeader, diff --git a/bridges/modules/ethereum/src/test_utils.rs b/bridges/modules/ethereum/src/test_utils.rs index 035882450f..37f7a7a029 100644 --- a/bridges/modules/ethereum/src/test_utils.rs +++ b/bridges/modules/ethereum/src/test_utils.rs @@ -29,7 +29,7 @@ use crate::validators::CHANGE_EVENT_HASH; use crate::verification::calculate_score; use crate::{HeaderToImport, Storage, Trait}; -use primitives::{ +use bp_eth_poa::{ rlp_encode, signatures::{secret_to_address, sign, SignHeader}, Address, Bloom, Header, Receipt, SealedEmptyStep, H256, U256, @@ -53,7 +53,7 @@ impl HeaderBuilder { Self { header: Header { gas_limit: GAS_LIMIT.into(), - seal: vec![primitives::rlp_encode(¤t_step), vec![]], + seal: vec![bp_eth_poa::rlp_encode(¤t_step), vec![]], ..Default::default() }, parent_header: Default::default(), @@ -95,7 +95,7 @@ impl HeaderBuilder { pub fn with_number(number: u64) -> Self { Self::with_parent(&Header { number: number - 1, - seal: vec![primitives::rlp_encode(&(number - 1)), vec![]], + seal: vec![bp_eth_poa::rlp_encode(&(number - 1)), vec![]], ..Default::default() }) } @@ -109,7 +109,7 @@ impl HeaderBuilder { parent_hash: parent_header.compute_hash(), number: parent_header.number + 1, gas_limit: GAS_LIMIT.into(), - seal: vec![primitives::rlp_encode(¤t_step), vec![]], + seal: vec![bp_eth_poa::rlp_encode(¤t_step), vec![]], difficulty: calculate_score(parent_step, current_step, 0), ..Default::default() }, @@ -242,7 +242,7 @@ pub fn insert_header(storage: &mut S, header: Header) { } pub fn validators_change_receipt(parent_hash: H256) -> Receipt { - use primitives::{LogEntry, TransactionOutcome}; + use bp_eth_poa::{LogEntry, TransactionOutcome}; Receipt { gas_used: 0.into(), diff --git a/bridges/modules/ethereum/src/validators.rs b/bridges/modules/ethereum/src/validators.rs index 8253ab2def..e0b747fc3f 100644 --- a/bridges/modules/ethereum/src/validators.rs +++ b/bridges/modules/ethereum/src/validators.rs @@ -16,7 +16,7 @@ use crate::error::Error; use crate::{ChangeToEnact, Storage}; -use primitives::{Address, Header, HeaderId, LogEntry, Receipt, U256}; +use bp_eth_poa::{Address, Header, HeaderId, LogEntry, Receipt, U256}; use sp_std::prelude::*; /// The hash of InitiateChange event of the validators set contract. @@ -278,8 +278,8 @@ pub(crate) mod tests { use crate::mock::{run_test, validators_addresses, validators_change_receipt, TestRuntime}; use crate::DefaultInstance; use crate::{BridgeStorage, Headers, ScheduledChange, ScheduledChanges, StoredHeader}; + use bp_eth_poa::compute_merkle_root; use frame_support::StorageMap; - use primitives::compute_merkle_root; const TOTAL_VALIDATORS: usize = 3; diff --git a/bridges/modules/ethereum/src/verification.rs b/bridges/modules/ethereum/src/verification.rs index 8e028edbbc..ea5a208b40 100644 --- a/bridges/modules/ethereum/src/verification.rs +++ b/bridges/modules/ethereum/src/verification.rs @@ -17,10 +17,10 @@ use crate::error::Error; use crate::validators::{Validators, ValidatorsConfiguration}; use crate::{AuraConfiguration, ImportContext, PoolConfiguration, ScheduledChange, Storage}; -use codec::Encode; -use primitives::{ +use bp_eth_poa::{ public_to_address, step_validator, Address, Header, HeaderId, Receipt, SealedEmptyStep, H256, H520, U128, U256, }; +use codec::Encode; use sp_io::crypto::secp256k1_ecdsa_recover; use sp_runtime::transaction_validity::TransactionTag; use sp_std::{vec, vec::Vec}; @@ -366,8 +366,8 @@ mod tests { pool_configuration, BridgeStorage, FinalizedBlock, Headers, HeadersByNumber, NextValidatorsSetId, ScheduledChanges, ValidatorsSet, ValidatorsSets, }; + use bp_eth_poa::{compute_merkle_root, rlp_encode, TransactionOutcome, H520}; use frame_support::{StorageMap, StorageValue}; - use primitives::{compute_merkle_root, rlp_encode, TransactionOutcome, H520}; use secp256k1::SecretKey; use sp_runtime::transaction_validity::TransactionTag; diff --git a/bridges/primitives/currency-exchange/Cargo.toml b/bridges/primitives/currency-exchange/Cargo.toml index 91052ca850..ff2c98c118 100644 --- a/bridges/primitives/currency-exchange/Cargo.toml +++ b/bridges/primitives/currency-exchange/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-currency-exchange" +name = "bp-currency-exchange" description = "Primitives of currency exchange module." version = "0.1.0" authors = ["Parity Technologies "] diff --git a/bridges/primitives/ethereum-poa/Cargo.toml b/bridges/primitives/ethereum-poa/Cargo.toml index d77efda8a3..9beb08892e 100644 --- a/bridges/primitives/ethereum-poa/Cargo.toml +++ b/bridges/primitives/ethereum-poa/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-bridge-eth-poa" +name = "bp-eth-poa" description = "Primitives of Ethereum PoA Bridge module." version = "0.1.0" authors = ["Parity Technologies "] diff --git a/bridges/relays/ethereum/Cargo.toml b/bridges/relays/ethereum/Cargo.toml index e57a885d9d..922d6a2f85 100644 --- a/bridges/relays/ethereum/Cargo.toml +++ b/bridges/relays/ethereum/Cargo.toml @@ -11,6 +11,8 @@ async-std = "1.6.2" async-stream = "0.2.0" async-trait = "0.1.36" backoff = "0.2" +bp-currency-exchange = { path = "../../primitives/currency-exchange" } +bp-eth-poa = { path = "../../primitives/ethereum-poa" } clap = { version = "2.33.1", features = ["yaml"] } codec = { package = "parity-scale-codec", version = "1.3.1" } env_logger = "0.7.0" @@ -30,8 +32,6 @@ rustc-hex = "2.0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.57" sysinfo = "0.15" -sp-currency-exchange = { path = "../../primitives/currency-exchange" } -sp-bridge-eth-poa = { path = "../../primitives/ethereum-poa" } time = "0.2" web3 = "0.13" diff --git a/bridges/relays/ethereum/src/ethereum_exchange.rs b/bridges/relays/ethereum/src/ethereum_exchange.rs index d094d9bae3..bcaebdd9c5 100644 --- a/bridges/relays/ethereum/src/ethereum_exchange.rs +++ b/bridges/relays/ethereum/src/ethereum_exchange.rs @@ -37,8 +37,8 @@ use crate::substrate_types::into_substrate_ethereum_receipt; use crate::sync_types::HeaderId; use async_trait::async_trait; +use bp_currency_exchange::MaybeLockFundsTransaction; use bridge_node_runtime::exchange::EthereumTransactionInclusionProof; -use sp_currency_exchange::MaybeLockFundsTransaction; use std::time::Duration; /// Interval at which we ask Ethereum node for updates. @@ -240,7 +240,7 @@ impl TargetClient for SubstrateTransactionsTarget { } // now let's check if transaction is successful - match sp_bridge_eth_poa::Receipt::is_successful_raw_receipt(raw_tx_receipt) { + match bp_eth_poa::Receipt::is_successful_raw_receipt(raw_tx_receipt) { Ok(true) => (), _ => return Ok(false), } diff --git a/bridges/relays/ethereum/src/ethereum_exchange_submit.rs b/bridges/relays/ethereum/src/ethereum_exchange_submit.rs index 96a0fc68d0..69a4d7a39b 100644 --- a/bridges/relays/ethereum/src/ethereum_exchange_submit.rs +++ b/bridges/relays/ethereum/src/ethereum_exchange_submit.rs @@ -20,11 +20,11 @@ use crate::ethereum_client::{EthereumConnectionParams, EthereumRpcClient, Ethere use crate::ethereum_types::{CallRequest, U256}; use crate::rpc::EthereumRpc; -use bridge_node_runtime::exchange::LOCK_FUNDS_ADDRESS; -use sp_bridge_eth_poa::{ +use bp_eth_poa::{ signatures::{SecretKey, SignTransaction}, UnsignedTransaction, }; +use bridge_node_runtime::exchange::LOCK_FUNDS_ADDRESS; /// Ethereum exchange transaction params. #[derive(Debug)] diff --git a/bridges/relays/ethereum/src/rpc.rs b/bridges/relays/ethereum/src/rpc.rs index 5fc73ed02e..fd108f8963 100644 --- a/bridges/relays/ethereum/src/rpc.rs +++ b/bridges/relays/ethereum/src/rpc.rs @@ -35,7 +35,7 @@ use crate::substrate_types::{ }; use async_trait::async_trait; -use sp_bridge_eth_poa::Header as SubstrateEthereumHeader; +use bp_eth_poa::Header as SubstrateEthereumHeader; type Result = result::Result; type GrandpaAuthorityList = Vec; diff --git a/bridges/relays/ethereum/src/substrate_client.rs b/bridges/relays/ethereum/src/substrate_client.rs index 4970587d34..c2bc56ac26 100644 --- a/bridges/relays/ethereum/src/substrate_client.rs +++ b/bridges/relays/ethereum/src/substrate_client.rs @@ -22,12 +22,12 @@ use crate::substrate_types::{Hash, Header as SubstrateHeader, Number, SignedBloc use crate::sync_types::{HeaderId, SubmittedHeaders}; use async_trait::async_trait; +use bp_eth_poa::Header as SubstrateEthereumHeader; use codec::{Decode, Encode}; use jsonrpsee::raw::RawClient; use jsonrpsee::transport::http::HttpTransportClient; use jsonrpsee::Client; use num_traits::Zero; -use sp_bridge_eth_poa::Header as SubstrateEthereumHeader; use sp_core::crypto::Pair; use sp_runtime::traits::IdentifyAccount; use std::collections::VecDeque; @@ -142,7 +142,7 @@ impl SubstrateRpc for SubstrateRpcClient { let data = Bytes(Vec::new()); let encoded_response = Substrate::state_call(&self.client, call, data, None).await?; - let decoded_response: (u64, sp_bridge_eth_poa::H256) = Decode::decode(&mut &encoded_response.0[..])?; + let decoded_response: (u64, bp_eth_poa::H256) = Decode::decode(&mut &encoded_response.0[..])?; let best_header_id = HeaderId(decoded_response.0, decoded_response.1); Ok(best_header_id) @@ -153,7 +153,7 @@ impl SubstrateRpc for SubstrateRpcClient { let data = Bytes(Vec::new()); let encoded_response = Substrate::state_call(&self.client, call, data, None).await?; - let decoded_response: (u64, sp_bridge_eth_poa::H256) = Decode::decode(&mut &encoded_response.0[..])?; + let decoded_response: (u64, bp_eth_poa::H256) = Decode::decode(&mut &encoded_response.0[..])?; let best_header_id = HeaderId(decoded_response.0, decoded_response.1); Ok(best_header_id) diff --git a/bridges/relays/ethereum/src/substrate_types.rs b/bridges/relays/ethereum/src/substrate_types.rs index 9e5ce6b732..d03e8a86fd 100644 --- a/bridges/relays/ethereum/src/substrate_types.rs +++ b/bridges/relays/ethereum/src/substrate_types.rs @@ -19,7 +19,8 @@ use crate::ethereum_types::{ }; use crate::sync_types::{HeaderId, HeadersSyncPipeline, QueuedHeader, SourceHeader}; use codec::Encode; -pub use sp_bridge_eth_poa::{ + +pub use bp_eth_poa::{ Address, Bloom, Bytes, Header as SubstrateEthereumHeader, LogEntry as SubstrateEthereumLogEntry, Receipt as SubstrateEthereumReceipt, TransactionOutcome as SubstrateEthereumTransactionOutcome, H256, U256, };