Rename Primitive Crates (#271)

* Rename Ethereum PoA primitives crate

The "sp" prefix comes from Substrate primitives, since this crate originated
in that repo. However, it is not part of Substrate anymore and its name should
be updated to reflect that.

* Rename currency exchange primitives

* Rust Fmt

* Update import in benchmarking module

* Rust Fmt

* Split pub and no-pub

* Sort toml files.

Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
Hernando Castano
2020-08-07 10:23:40 -04:00
committed by Bastian Köcher
parent 868814e4b6
commit 9f6bd28384
25 changed files with 104 additions and 102 deletions
+23 -21
View File
@@ -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",
+9 -9
View File
@@ -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<T: pallet_bridge_eth_poa::Trait<I>, 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::<T, I>::new();
let header = HeaderBuilder::with_parent_number_on_runtime::<T, I>(0)
@@ -153,9 +153,9 @@ pub(crate) fn prepare_environment_for_claim<T: pallet_bridge_eth_poa::Trait<I>,
#[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(),
+1 -1
View File
@@ -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! {
+22 -22
View File
@@ -251,9 +251,9 @@ impl pallet_bridge_currency_exchange::Trait<RialtoCurrencyExchange> for Runtime
type OnTransactionSubmitted = ();
type PeerBlockchain = rialto::RialtoBlockchain;
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
type RecipientsMap = sp_currency_exchange::IdentityRecipients<AccountId>;
type RecipientsMap = bp_currency_exchange::IdentityRecipients<AccountId>;
type Amount = Balance;
type CurrencyConverter = sp_currency_exchange::IdentityCurrencyConverter<Balance>;
type CurrencyConverter = bp_currency_exchange::IdentityCurrencyConverter<Balance>;
type DepositInto = DepositInto;
}
@@ -262,19 +262,19 @@ impl pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange> for Runtime {
type OnTransactionSubmitted = ();
type PeerBlockchain = kovan::KovanBlockchain;
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
type RecipientsMap = sp_currency_exchange::IdentityRecipients<AccountId>;
type RecipientsMap = bp_currency_exchange::IdentityRecipients<AccountId>;
type Amount = Balance;
type CurrencyConverter = sp_currency_exchange::IdentityCurrencyConverter<Balance>;
type CurrencyConverter = bp_currency_exchange::IdentityCurrencyConverter<Balance>;
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 = <pallet_balances::Module<Runtime> as Currency<AccountId>>::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<Block> for Runtime {
fn best_block() -> (u64, sp_bridge_eth_poa::H256) {
impl bp_eth_poa::RialtoHeaderApi<Block> 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<Block> for Runtime {
fn best_block() -> (u64, sp_bridge_eth_poa::H256) {
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, 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<Block, exchange::EthereumTransactionInclusionProof> for Runtime {
impl bp_currency_exchange::RialtoCurrencyExchangeApi<Block, exchange::EthereumTransactionInclusionProof> for Runtime {
fn filter_transaction_proof(proof: exchange::EthereumTransactionInclusionProof) -> bool {
BridgeRialtoCurrencyExchange::filter_transaction_proof(&proof)
}
}
impl sp_currency_exchange::KovanCurrencyExchangeApi<Block, exchange::EthereumTransactionInclusionProof> for Runtime {
impl bp_currency_exchange::KovanCurrencyExchangeApi<Block, exchange::EthereumTransactionInclusionProof> 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<AccountId>,
) -> crate::exchange::EthereumTransactionInclusionProof {
use sp_currency_exchange::DepositInto;
use bp_currency_exchange::DepositInto;
if proof_params.recipient_exists {
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::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() {
+1 -1
View File
@@ -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! {