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
+1 -1
View File
@@ -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"
+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! {
+4 -4
View File
@@ -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"]
+7 -7
View File
@@ -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<T: Trait<I>, 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<RawTransaction> {
fn parse(tx: &Self::Transaction) -> bp_currency_exchange::Result<RawTransaction> {
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<Self::Recipient> {
fn map(peer_recipient: Self::PeerRecipient) -> bp_currency_exchange::Result<Self::Recipient> {
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<Self::TargetAmount> {
fn convert(amount: Self::SourceAmount) -> bp_currency_exchange::Result<Self::TargetAmount> {
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),
+4 -5
View File
@@ -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",
+1 -1
View File
@@ -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! {
_ { }
+1 -1
View File
@@ -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::{
+1 -1
View File
@@ -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.
+3 -3
View File
@@ -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<u8> {
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(),
+2 -2
View File
@@ -15,12 +15,12 @@
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
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,
+5 -5
View File
@@ -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(&current_step), vec![]],
seal: vec![bp_eth_poa::rlp_encode(&current_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(&current_step), vec![]],
seal: vec![bp_eth_poa::rlp_encode(&current_step), vec![]],
difficulty: calculate_score(parent_step, current_step, 0),
..Default::default()
},
@@ -242,7 +242,7 @@ pub fn insert_header<S: Storage>(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(),
+2 -2
View File
@@ -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;
+3 -3
View File
@@ -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;
@@ -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 <admin@parity.io>"]
+1 -1
View File
@@ -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 <admin@parity.io>"]
+2 -2
View File
@@ -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"
@@ -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<EthereumToSubstrateExchange> 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),
}
@@ -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)]
+1 -1
View File
@@ -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<T> = result::Result<T, RpcError>;
type GrandpaAuthorityList = Vec<u8>;
@@ -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)
@@ -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,
};