mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
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:
committed by
Bastian Köcher
parent
868814e4b6
commit
9f6bd28384
@@ -12,11 +12,11 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|||||||
name = "bridge-node"
|
name = "bridge-node"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
bp-eth-poa = { version = "0.1.0", path = "../../../primitives/ethereum-poa" }
|
||||||
futures = "0.3.5"
|
futures = "0.3.5"
|
||||||
jsonrpc-core = "14.2.0"
|
jsonrpc-core = "14.2.0"
|
||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
structopt = "0.3.15"
|
structopt = "0.3.15"
|
||||||
sp-bridge-eth-poa = { version = "0.1.0", path = "../../../primitives/ethereum-poa" }
|
|
||||||
|
|
||||||
[dependencies.bridge-node-runtime]
|
[dependencies.bridge-node-runtime]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@@ -123,16 +123,6 @@ tag = 'v2.0.0-rc5'
|
|||||||
default-features = false
|
default-features = false
|
||||||
git = "https://github.com/paritytech/substrate/"
|
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]
|
[dependencies.sp-consensus-aura]
|
||||||
version = "0.8.0-rc5"
|
version = "0.8.0-rc5"
|
||||||
tag = 'v2.0.0-rc5'
|
tag = 'v2.0.0-rc5'
|
||||||
@@ -206,12 +196,24 @@ tag = 'v2.0.0-rc5'
|
|||||||
default-features = false
|
default-features = false
|
||||||
git = "https://github.com/paritytech/substrate/"
|
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]
|
[dev-dependencies.libsecp256k1]
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["hmac"]
|
features = ["hmac"]
|
||||||
|
|
||||||
[dev-dependencies.sp-bridge-eth-poa]
|
[dev-dependencies.bp-eth-poa]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["std"]
|
features = ["std"]
|
||||||
@@ -226,23 +228,26 @@ git = "https://github.com/paritytech/substrate/"
|
|||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
"pallet-aura/std",
|
"bp-currency-exchange/std",
|
||||||
"pallet-balances/std",
|
"bp-eth-poa/std",
|
||||||
"pallet-bridge-eth-poa/std",
|
|
||||||
"pallet-bridge-currency-exchange/std",
|
|
||||||
"codec/std",
|
"codec/std",
|
||||||
"frame-benchmarking/std",
|
"frame-benchmarking/std",
|
||||||
"frame-executive/std",
|
"frame-executive/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"frame-system/std",
|
|
||||||
"frame-system-rpc-runtime-api/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-grandpa/std",
|
||||||
"pallet-randomness-collective-flip/std",
|
"pallet-randomness-collective-flip/std",
|
||||||
|
"pallet-sudo/std",
|
||||||
|
"pallet-timestamp/std",
|
||||||
|
"pallet-transaction-payment/std",
|
||||||
"serde",
|
"serde",
|
||||||
"sp-api/std",
|
"sp-api/std",
|
||||||
"sp-block-builder/std",
|
"sp-block-builder/std",
|
||||||
"sp-bridge-eth-poa/std",
|
|
||||||
"sp-currency-exchange/std",
|
|
||||||
"sp-consensus-aura/std",
|
"sp-consensus-aura/std",
|
||||||
"sp-core/std",
|
"sp-core/std",
|
||||||
"sp-inherents/std",
|
"sp-inherents/std",
|
||||||
@@ -253,9 +258,6 @@ std = [
|
|||||||
"sp-std/std",
|
"sp-std/std",
|
||||||
"sp-transaction-pool/std",
|
"sp-transaction-pool/std",
|
||||||
"sp-version/std",
|
"sp-version/std",
|
||||||
"pallet-sudo/std",
|
|
||||||
"pallet-timestamp/std",
|
|
||||||
"pallet-transaction-payment/std",
|
|
||||||
]
|
]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
|
|||||||
@@ -27,13 +27,13 @@
|
|||||||
//! to the PoA -> Substrate bridge module (it can be provided by you);
|
//! to the PoA -> Substrate bridge module (it can be provided by you);
|
||||||
//! 5) receive tokens by providing proof-of-inclusion of PoA transaction.
|
//! 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 codec::{Decode, Encode};
|
||||||
use frame_support::RuntimeDebug;
|
use frame_support::RuntimeDebug;
|
||||||
use hex_literal::hex;
|
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;
|
use sp_std::vec::Vec;
|
||||||
|
|
||||||
/// Ethereum address where locked PoA funds must be sent to.
|
/// Ethereum address where locked PoA funds must be sent to.
|
||||||
@@ -130,12 +130,12 @@ impl MaybeLockFundsTransaction for EthTransaction {
|
|||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
pub(crate) fn prepare_environment_for_claim<T: pallet_bridge_eth_poa::Trait<I>, I: pallet_bridge_eth_poa::Instance>(
|
pub(crate) fn prepare_environment_for_claim<T: pallet_bridge_eth_poa::Trait<I>, I: pallet_bridge_eth_poa::Instance>(
|
||||||
transactions: &[(RawTransaction, RawTransactionReceipt)],
|
transactions: &[(RawTransaction, RawTransactionReceipt)],
|
||||||
) -> sp_bridge_eth_poa::H256 {
|
) -> bp_eth_poa::H256 {
|
||||||
|
use bp_eth_poa::compute_merkle_root;
|
||||||
use pallet_bridge_eth_poa::{
|
use pallet_bridge_eth_poa::{
|
||||||
test_utils::{insert_header, validator_utils::validator, HeaderBuilder},
|
test_utils::{insert_header, validator_utils::validator, HeaderBuilder},
|
||||||
BridgeStorage, Storage,
|
BridgeStorage, Storage,
|
||||||
};
|
};
|
||||||
use sp_bridge_eth_poa::compute_merkle_root;
|
|
||||||
|
|
||||||
let mut storage = BridgeStorage::<T, I>::new();
|
let mut storage = BridgeStorage::<T, I>::new();
|
||||||
let header = HeaderBuilder::with_parent_number_on_runtime::<T, I>(0)
|
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))]
|
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||||
pub(crate) fn prepare_ethereum_transaction(
|
pub(crate) fn prepare_ethereum_transaction(
|
||||||
recipient: &crate::AccountId,
|
recipient: &crate::AccountId,
|
||||||
editor: impl Fn(&mut sp_bridge_eth_poa::UnsignedTransaction),
|
editor: impl Fn(&mut bp_eth_poa::UnsignedTransaction),
|
||||||
) -> (RawTransaction, RawTransactionReceipt) {
|
) -> (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:
|
// prepare tx for OpenEthereum private dev chain:
|
||||||
// chain id is 0x11
|
// chain id is 0x11
|
||||||
@@ -166,7 +166,7 @@ pub(crate) fn prepare_ethereum_transaction(
|
|||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let recipient_raw: &[u8; 32] = recipient.as_ref();
|
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(),
|
nonce: 0.into(),
|
||||||
to: Some(LOCK_FUNDS_ADDRESS.into()),
|
to: Some(LOCK_FUNDS_ADDRESS.into()),
|
||||||
value: 100.into(),
|
value: 100.into(),
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
|
|
||||||
use crate::exchange::EthereumTransactionInclusionProof;
|
use crate::exchange::EthereumTransactionInclusionProof;
|
||||||
|
|
||||||
|
use bp_eth_poa::{Address, Header, RawTransaction, U256};
|
||||||
use frame_support::RuntimeDebug;
|
use frame_support::RuntimeDebug;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use pallet_bridge_currency_exchange::PeerBlockchain;
|
use pallet_bridge_currency_exchange::PeerBlockchain;
|
||||||
use pallet_bridge_eth_poa::{
|
use pallet_bridge_eth_poa::{
|
||||||
AuraConfiguration, PruningStrategy as BridgePruningStrategy, ValidatorsConfiguration, ValidatorsSource,
|
AuraConfiguration, PruningStrategy as BridgePruningStrategy, ValidatorsConfiguration, ValidatorsSource,
|
||||||
};
|
};
|
||||||
use sp_bridge_eth_poa::{Address, Header, RawTransaction, U256};
|
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
|
|||||||
@@ -251,9 +251,9 @@ impl pallet_bridge_currency_exchange::Trait<RialtoCurrencyExchange> for Runtime
|
|||||||
type OnTransactionSubmitted = ();
|
type OnTransactionSubmitted = ();
|
||||||
type PeerBlockchain = rialto::RialtoBlockchain;
|
type PeerBlockchain = rialto::RialtoBlockchain;
|
||||||
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
||||||
type RecipientsMap = sp_currency_exchange::IdentityRecipients<AccountId>;
|
type RecipientsMap = bp_currency_exchange::IdentityRecipients<AccountId>;
|
||||||
type Amount = Balance;
|
type Amount = Balance;
|
||||||
type CurrencyConverter = sp_currency_exchange::IdentityCurrencyConverter<Balance>;
|
type CurrencyConverter = bp_currency_exchange::IdentityCurrencyConverter<Balance>;
|
||||||
type DepositInto = DepositInto;
|
type DepositInto = DepositInto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,19 +262,19 @@ impl pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange> for Runtime {
|
|||||||
type OnTransactionSubmitted = ();
|
type OnTransactionSubmitted = ();
|
||||||
type PeerBlockchain = kovan::KovanBlockchain;
|
type PeerBlockchain = kovan::KovanBlockchain;
|
||||||
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
||||||
type RecipientsMap = sp_currency_exchange::IdentityRecipients<AccountId>;
|
type RecipientsMap = bp_currency_exchange::IdentityRecipients<AccountId>;
|
||||||
type Amount = Balance;
|
type Amount = Balance;
|
||||||
type CurrencyConverter = sp_currency_exchange::IdentityCurrencyConverter<Balance>;
|
type CurrencyConverter = bp_currency_exchange::IdentityCurrencyConverter<Balance>;
|
||||||
type DepositInto = DepositInto;
|
type DepositInto = DepositInto;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DepositInto;
|
pub struct DepositInto;
|
||||||
|
|
||||||
impl sp_currency_exchange::DepositInto for DepositInto {
|
impl bp_currency_exchange::DepositInto for DepositInto {
|
||||||
type Recipient = AccountId;
|
type Recipient = AccountId;
|
||||||
type Amount = Balance;
|
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
|
// let balances module make all checks for us (it won't allow depositing lower than existential
|
||||||
// deposit, balance overflow, ...)
|
// deposit, balance overflow, ...)
|
||||||
let deposited = <pallet_balances::Module<Runtime> as Currency<AccountId>>::deposit_creating(&recipient, amount);
|
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,
|
recipient,
|
||||||
);
|
);
|
||||||
|
|
||||||
Err(sp_currency_exchange::Error::DepositFailed)
|
Err(bp_currency_exchange::Error::DepositFailed)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
frame_support::debug::error!(
|
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
|
// 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 {
|
impl bp_eth_poa::RialtoHeaderApi<Block> for Runtime {
|
||||||
fn best_block() -> (u64, sp_bridge_eth_poa::H256) {
|
fn best_block() -> (u64, bp_eth_poa::H256) {
|
||||||
let best_block = BridgeRialto::best_block();
|
let best_block = BridgeRialto::best_block();
|
||||||
(best_block.number, best_block.hash)
|
(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();
|
let finalized_block = BridgeRialto::finalized_block();
|
||||||
(finalized_block.number, finalized_block.hash)
|
(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)
|
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)
|
BridgeRialto::is_known_block(hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sp_bridge_eth_poa::KovanHeaderApi<Block> for Runtime {
|
impl bp_eth_poa::KovanHeaderApi<Block> for Runtime {
|
||||||
fn best_block() -> (u64, sp_bridge_eth_poa::H256) {
|
fn best_block() -> (u64, bp_eth_poa::H256) {
|
||||||
let best_block = BridgeKovan::best_block();
|
let best_block = BridgeKovan::best_block();
|
||||||
(best_block.number, best_block.hash)
|
(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();
|
let finalized_block = BridgeKovan::finalized_block();
|
||||||
(finalized_block.number, finalized_block.hash)
|
(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)
|
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)
|
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 {
|
fn filter_transaction_proof(proof: exchange::EthereumTransactionInclusionProof) -> bool {
|
||||||
BridgeRialtoCurrencyExchange::filter_transaction_proof(&proof)
|
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 {
|
fn filter_transaction_proof(proof: exchange::EthereumTransactionInclusionProof) -> bool {
|
||||||
BridgeKovanCurrencyExchange::filter_transaction_proof(&proof)
|
BridgeKovanCurrencyExchange::filter_transaction_proof(&proof)
|
||||||
}
|
}
|
||||||
@@ -714,7 +714,7 @@ impl_runtime_apis! {
|
|||||||
fn make_proof(
|
fn make_proof(
|
||||||
proof_params: BridgeCurrencyExchangeProofParams<AccountId>,
|
proof_params: BridgeCurrencyExchangeProofParams<AccountId>,
|
||||||
) -> crate::exchange::EthereumTransactionInclusionProof {
|
) -> crate::exchange::EthereumTransactionInclusionProof {
|
||||||
use sp_currency_exchange::DepositInto;
|
use bp_currency_exchange::DepositInto;
|
||||||
|
|
||||||
if proof_params.recipient_exists {
|
if proof_params.recipient_exists {
|
||||||
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||||
@@ -761,7 +761,7 @@ impl_runtime_apis! {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use sp_currency_exchange::DepositInto;
|
use bp_currency_exchange::DepositInto;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn shift_session_manager_works() {
|
fn shift_session_manager_works() {
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
|
|
||||||
use crate::exchange::EthereumTransactionInclusionProof;
|
use crate::exchange::EthereumTransactionInclusionProof;
|
||||||
|
|
||||||
|
use bp_eth_poa::{Address, Header, RawTransaction, U256};
|
||||||
use frame_support::RuntimeDebug;
|
use frame_support::RuntimeDebug;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use pallet_bridge_currency_exchange::PeerBlockchain;
|
use pallet_bridge_currency_exchange::PeerBlockchain;
|
||||||
use pallet_bridge_eth_poa::{
|
use pallet_bridge_eth_poa::{
|
||||||
AuraConfiguration, PruningStrategy as TPruningStrategy, ValidatorsConfiguration, ValidatorsSource,
|
AuraConfiguration, PruningStrategy as TPruningStrategy, ValidatorsConfiguration, ValidatorsSource,
|
||||||
};
|
};
|
||||||
use sp_bridge_eth_poa::{Address, Header, RawTransaction, U256};
|
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ edition = "2018"
|
|||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[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 }
|
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
|
# Substrate Based Dependencies
|
||||||
[dependencies.frame-support]
|
[dependencies.frame-support]
|
||||||
@@ -56,13 +56,13 @@ git = "https://github.com/paritytech/substrate/"
|
|||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
|
"bp-currency-exchange/std",
|
||||||
"codec/std",
|
"codec/std",
|
||||||
"frame-benchmarking/std",
|
"frame-benchmarking/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"frame-system/std",
|
"frame-system/std",
|
||||||
"serde",
|
"serde",
|
||||||
"sp-currency-exchange/std",
|
|
||||||
"sp-std/std",
|
|
||||||
"sp-runtime/std",
|
"sp-runtime/std",
|
||||||
|
"sp-std/std",
|
||||||
]
|
]
|
||||||
runtime-benchmarks = ["frame-benchmarking"]
|
runtime-benchmarks = ["frame-benchmarking"]
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
use frame_support::{decl_error, decl_module, decl_storage, ensure, Parameter};
|
use bp_currency_exchange::{
|
||||||
use sp_currency_exchange::{
|
|
||||||
CurrencyConverter, DepositInto, Error as ExchangeError, MaybeLockFundsTransaction, RecipientsMap,
|
CurrencyConverter, DepositInto, Error as ExchangeError, MaybeLockFundsTransaction, RecipientsMap,
|
||||||
};
|
};
|
||||||
|
use frame_support::{decl_error, decl_module, decl_storage, ensure, Parameter};
|
||||||
use sp_runtime::DispatchResult;
|
use sp_runtime::DispatchResult;
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
@@ -221,9 +221,9 @@ fn prepare_deposit_details<T: Trait<I>, I: Instance>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use bp_currency_exchange::LockFundsTransaction;
|
||||||
use frame_support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight};
|
use frame_support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight};
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_currency_exchange::LockFundsTransaction;
|
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
testing::Header,
|
testing::Header,
|
||||||
traits::{BlakeTwo256, IdentityLookup},
|
traits::{BlakeTwo256, IdentityLookup},
|
||||||
@@ -272,7 +272,7 @@ mod tests {
|
|||||||
type Recipient = AccountId;
|
type Recipient = AccountId;
|
||||||
type Amount = u64;
|
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 {
|
match tx.id {
|
||||||
INVALID_TRANSACTION_ID => Err(ExchangeError::InvalidTransaction),
|
INVALID_TRANSACTION_ID => Err(ExchangeError::InvalidTransaction),
|
||||||
_ => Ok(tx.clone()),
|
_ => Ok(tx.clone()),
|
||||||
@@ -286,7 +286,7 @@ mod tests {
|
|||||||
type PeerRecipient = AccountId;
|
type PeerRecipient = AccountId;
|
||||||
type Recipient = 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 {
|
match peer_recipient {
|
||||||
UNKNOWN_RECIPIENT_ID => Err(ExchangeError::FailedToMapRecipients),
|
UNKNOWN_RECIPIENT_ID => Err(ExchangeError::FailedToMapRecipients),
|
||||||
_ => Ok(peer_recipient * 10),
|
_ => Ok(peer_recipient * 10),
|
||||||
@@ -300,7 +300,7 @@ mod tests {
|
|||||||
type SourceAmount = u64;
|
type SourceAmount = u64;
|
||||||
type TargetAmount = 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 {
|
match amount {
|
||||||
INVALID_AMOUNT => Err(ExchangeError::FailedToConvertCurrency),
|
INVALID_AMOUNT => Err(ExchangeError::FailedToConvertCurrency),
|
||||||
_ => Ok(amount * 10),
|
_ => Ok(amount * 10),
|
||||||
@@ -314,7 +314,7 @@ mod tests {
|
|||||||
type Recipient = AccountId;
|
type Recipient = AccountId;
|
||||||
type Amount = u64;
|
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 {
|
match amount {
|
||||||
amount if amount < MAX_DEPOSIT_AMOUNT * 10 => Ok(()),
|
amount if amount < MAX_DEPOSIT_AMOUNT * 10 => Ok(()),
|
||||||
amount if amount == MAX_DEPOSIT_AMOUNT * 10 => Err(ExchangeError::DepositPartiallyFailed),
|
amount if amount == MAX_DEPOSIT_AMOUNT * 10 => Err(ExchangeError::DepositPartiallyFailed),
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ edition = "2018"
|
|||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[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 }
|
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||||
hex-literal = "0.3"
|
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
|
# Substrate Based Dependencies
|
||||||
[dependencies.frame-support]
|
[dependencies.frame-support]
|
||||||
@@ -58,18 +58,17 @@ features = ["hmac"]
|
|||||||
|
|
||||||
# Dev Dependencies
|
# Dev Dependencies
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# TODO: Stop renaming this on import
|
bp-eth-poa = { path = "../../primitives/ethereum-poa", features = ["std"] }
|
||||||
primitives = { package = "sp-bridge-eth-poa", path = "../../primitives/ethereum-poa", features = ["std"] }
|
|
||||||
libsecp256k1 = { version = "0.3.4", features = ["hmac"] }
|
libsecp256k1 = { version = "0.3.4", features = ["hmac"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
|
"bp-eth-poa/std",
|
||||||
"codec/std",
|
"codec/std",
|
||||||
"frame-benchmarking/std",
|
"frame-benchmarking/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"frame-system/std",
|
"frame-system/std",
|
||||||
"primitives/std",
|
|
||||||
"serde",
|
"serde",
|
||||||
"sp-io/std",
|
"sp-io/std",
|
||||||
"sp-runtime/std",
|
"sp-runtime/std",
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ use crate::test_utils::{
|
|||||||
HeaderBuilder,
|
HeaderBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use bp_eth_poa::{compute_merkle_root, U256};
|
||||||
use frame_benchmarking::benchmarks_instance;
|
use frame_benchmarking::benchmarks_instance;
|
||||||
use frame_system::RawOrigin;
|
use frame_system::RawOrigin;
|
||||||
use primitives::{compute_merkle_root, U256};
|
|
||||||
|
|
||||||
benchmarks_instance! {
|
benchmarks_instance! {
|
||||||
_ { }
|
_ { }
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::Storage;
|
use crate::Storage;
|
||||||
|
use bp_eth_poa::{public_to_address, Address, Header, HeaderId, SealedEmptyStep, H256};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use primitives::{public_to_address, Address, Header, HeaderId, SealedEmptyStep, H256};
|
|
||||||
use sp_io::crypto::secp256k1_ecdsa_recover;
|
use sp_io::crypto::secp256k1_ecdsa_recover;
|
||||||
use sp_runtime::RuntimeDebug;
|
use sp_runtime::RuntimeDebug;
|
||||||
use sp_std::collections::{
|
use sp_std::collections::{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use crate::finality::finalize_blocks;
|
|||||||
use crate::validators::{Validators, ValidatorsConfiguration};
|
use crate::validators::{Validators, ValidatorsConfiguration};
|
||||||
use crate::verification::{is_importable_header, verify_aura_header};
|
use crate::verification::{is_importable_header, verify_aura_header};
|
||||||
use crate::{AuraConfiguration, ChangeToEnact, PruningStrategy, Storage};
|
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::*};
|
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||||
|
|
||||||
/// Imports bunch of headers and updates blocks finality.
|
/// Imports bunch of headers and updates blocks finality.
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
#![allow(clippy::large_enum_variant)]
|
#![allow(clippy::large_enum_variant)]
|
||||||
|
|
||||||
use crate::finality::{CachedFinalityVotes, FinalityVotes};
|
use crate::finality::{CachedFinalityVotes, FinalityVotes};
|
||||||
|
use bp_eth_poa::{Address, Header, HeaderId, RawTransaction, RawTransactionReceipt, Receipt, H256, U256};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use frame_support::{decl_module, decl_storage, traits::Get};
|
use frame_support::{decl_module, decl_storage, traits::Get};
|
||||||
use primitives::{Address, Header, HeaderId, RawTransaction, RawTransactionReceipt, Receipt, H256, U256};
|
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
transaction_validity::{
|
transaction_validity::{
|
||||||
InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionSource, TransactionValidity,
|
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,
|
genesis, insert_header, run_test, run_test_with_genesis, validators_addresses, HeaderBuilder, TestRuntime,
|
||||||
GAS_LIMIT,
|
GAS_LIMIT,
|
||||||
};
|
};
|
||||||
use primitives::compute_merkle_root;
|
use bp_eth_poa::compute_merkle_root;
|
||||||
|
|
||||||
const TOTAL_VALIDATORS: usize = 3;
|
const TOTAL_VALIDATORS: usize = 3;
|
||||||
|
|
||||||
@@ -1036,7 +1036,7 @@ pub(crate) mod tests {
|
|||||||
fn example_tx_receipt(success: bool) -> Vec<u8> {
|
fn example_tx_receipt(success: bool) -> Vec<u8> {
|
||||||
Receipt {
|
Receipt {
|
||||||
// the only thing that we care of:
|
// 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(),
|
gas_used: Default::default(),
|
||||||
log_bloom: Default::default(),
|
log_bloom: Default::default(),
|
||||||
logs: Vec::new(),
|
logs: Vec::new(),
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// 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 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::validators::{ValidatorsConfiguration, ValidatorsSource};
|
||||||
use crate::{AuraConfiguration, GenesisConfig, PruningStrategy, Trait};
|
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 frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||||
use primitives::{Address, Header, H256, U256};
|
|
||||||
use secp256k1::SecretKey;
|
use secp256k1::SecretKey;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
testing::Header as SubstrateHeader,
|
testing::Header as SubstrateHeader,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ use crate::validators::CHANGE_EVENT_HASH;
|
|||||||
use crate::verification::calculate_score;
|
use crate::verification::calculate_score;
|
||||||
use crate::{HeaderToImport, Storage, Trait};
|
use crate::{HeaderToImport, Storage, Trait};
|
||||||
|
|
||||||
use primitives::{
|
use bp_eth_poa::{
|
||||||
rlp_encode,
|
rlp_encode,
|
||||||
signatures::{secret_to_address, sign, SignHeader},
|
signatures::{secret_to_address, sign, SignHeader},
|
||||||
Address, Bloom, Header, Receipt, SealedEmptyStep, H256, U256,
|
Address, Bloom, Header, Receipt, SealedEmptyStep, H256, U256,
|
||||||
@@ -53,7 +53,7 @@ impl HeaderBuilder {
|
|||||||
Self {
|
Self {
|
||||||
header: Header {
|
header: Header {
|
||||||
gas_limit: GAS_LIMIT.into(),
|
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()
|
..Default::default()
|
||||||
},
|
},
|
||||||
parent_header: Default::default(),
|
parent_header: Default::default(),
|
||||||
@@ -95,7 +95,7 @@ impl HeaderBuilder {
|
|||||||
pub fn with_number(number: u64) -> Self {
|
pub fn with_number(number: u64) -> Self {
|
||||||
Self::with_parent(&Header {
|
Self::with_parent(&Header {
|
||||||
number: number - 1,
|
number: number - 1,
|
||||||
seal: vec![primitives::rlp_encode(&(number - 1)), vec![]],
|
seal: vec![bp_eth_poa::rlp_encode(&(number - 1)), vec![]],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ impl HeaderBuilder {
|
|||||||
parent_hash: parent_header.compute_hash(),
|
parent_hash: parent_header.compute_hash(),
|
||||||
number: parent_header.number + 1,
|
number: parent_header.number + 1,
|
||||||
gas_limit: GAS_LIMIT.into(),
|
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),
|
difficulty: calculate_score(parent_step, current_step, 0),
|
||||||
..Default::default()
|
..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 {
|
pub fn validators_change_receipt(parent_hash: H256) -> Receipt {
|
||||||
use primitives::{LogEntry, TransactionOutcome};
|
use bp_eth_poa::{LogEntry, TransactionOutcome};
|
||||||
|
|
||||||
Receipt {
|
Receipt {
|
||||||
gas_used: 0.into(),
|
gas_used: 0.into(),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::{ChangeToEnact, Storage};
|
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::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
/// The hash of InitiateChange event of the validators set contract.
|
/// 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::mock::{run_test, validators_addresses, validators_change_receipt, TestRuntime};
|
||||||
use crate::DefaultInstance;
|
use crate::DefaultInstance;
|
||||||
use crate::{BridgeStorage, Headers, ScheduledChange, ScheduledChanges, StoredHeader};
|
use crate::{BridgeStorage, Headers, ScheduledChange, ScheduledChanges, StoredHeader};
|
||||||
|
use bp_eth_poa::compute_merkle_root;
|
||||||
use frame_support::StorageMap;
|
use frame_support::StorageMap;
|
||||||
use primitives::compute_merkle_root;
|
|
||||||
|
|
||||||
const TOTAL_VALIDATORS: usize = 3;
|
const TOTAL_VALIDATORS: usize = 3;
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::validators::{Validators, ValidatorsConfiguration};
|
use crate::validators::{Validators, ValidatorsConfiguration};
|
||||||
use crate::{AuraConfiguration, ImportContext, PoolConfiguration, ScheduledChange, Storage};
|
use crate::{AuraConfiguration, ImportContext, PoolConfiguration, ScheduledChange, Storage};
|
||||||
use codec::Encode;
|
use bp_eth_poa::{
|
||||||
use primitives::{
|
|
||||||
public_to_address, step_validator, Address, Header, HeaderId, Receipt, SealedEmptyStep, H256, H520, U128, U256,
|
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_io::crypto::secp256k1_ecdsa_recover;
|
||||||
use sp_runtime::transaction_validity::TransactionTag;
|
use sp_runtime::transaction_validity::TransactionTag;
|
||||||
use sp_std::{vec, vec::Vec};
|
use sp_std::{vec, vec::Vec};
|
||||||
@@ -366,8 +366,8 @@ mod tests {
|
|||||||
pool_configuration, BridgeStorage, FinalizedBlock, Headers, HeadersByNumber, NextValidatorsSetId,
|
pool_configuration, BridgeStorage, FinalizedBlock, Headers, HeadersByNumber, NextValidatorsSetId,
|
||||||
ScheduledChanges, ValidatorsSet, ValidatorsSets,
|
ScheduledChanges, ValidatorsSet, ValidatorsSets,
|
||||||
};
|
};
|
||||||
|
use bp_eth_poa::{compute_merkle_root, rlp_encode, TransactionOutcome, H520};
|
||||||
use frame_support::{StorageMap, StorageValue};
|
use frame_support::{StorageMap, StorageValue};
|
||||||
use primitives::{compute_merkle_root, rlp_encode, TransactionOutcome, H520};
|
|
||||||
use secp256k1::SecretKey;
|
use secp256k1::SecretKey;
|
||||||
use sp_runtime::transaction_validity::TransactionTag;
|
use sp_runtime::transaction_validity::TransactionTag;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sp-currency-exchange"
|
name = "bp-currency-exchange"
|
||||||
description = "Primitives of currency exchange module."
|
description = "Primitives of currency exchange module."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sp-bridge-eth-poa"
|
name = "bp-eth-poa"
|
||||||
description = "Primitives of Ethereum PoA Bridge module."
|
description = "Primitives of Ethereum PoA Bridge module."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ async-std = "1.6.2"
|
|||||||
async-stream = "0.2.0"
|
async-stream = "0.2.0"
|
||||||
async-trait = "0.1.36"
|
async-trait = "0.1.36"
|
||||||
backoff = "0.2"
|
backoff = "0.2"
|
||||||
|
bp-currency-exchange = { path = "../../primitives/currency-exchange" }
|
||||||
|
bp-eth-poa = { path = "../../primitives/ethereum-poa" }
|
||||||
clap = { version = "2.33.1", features = ["yaml"] }
|
clap = { version = "2.33.1", features = ["yaml"] }
|
||||||
codec = { package = "parity-scale-codec", version = "1.3.1" }
|
codec = { package = "parity-scale-codec", version = "1.3.1" }
|
||||||
env_logger = "0.7.0"
|
env_logger = "0.7.0"
|
||||||
@@ -30,8 +32,6 @@ rustc-hex = "2.0.1"
|
|||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0.57"
|
serde_json = "1.0.57"
|
||||||
sysinfo = "0.15"
|
sysinfo = "0.15"
|
||||||
sp-currency-exchange = { path = "../../primitives/currency-exchange" }
|
|
||||||
sp-bridge-eth-poa = { path = "../../primitives/ethereum-poa" }
|
|
||||||
time = "0.2"
|
time = "0.2"
|
||||||
web3 = "0.13"
|
web3 = "0.13"
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ use crate::substrate_types::into_substrate_ethereum_receipt;
|
|||||||
use crate::sync_types::HeaderId;
|
use crate::sync_types::HeaderId;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
use bp_currency_exchange::MaybeLockFundsTransaction;
|
||||||
use bridge_node_runtime::exchange::EthereumTransactionInclusionProof;
|
use bridge_node_runtime::exchange::EthereumTransactionInclusionProof;
|
||||||
use sp_currency_exchange::MaybeLockFundsTransaction;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
/// Interval at which we ask Ethereum node for updates.
|
/// 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
|
// 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) => (),
|
Ok(true) => (),
|
||||||
_ => return Ok(false),
|
_ => return Ok(false),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ use crate::ethereum_client::{EthereumConnectionParams, EthereumRpcClient, Ethere
|
|||||||
use crate::ethereum_types::{CallRequest, U256};
|
use crate::ethereum_types::{CallRequest, U256};
|
||||||
use crate::rpc::EthereumRpc;
|
use crate::rpc::EthereumRpc;
|
||||||
|
|
||||||
use bridge_node_runtime::exchange::LOCK_FUNDS_ADDRESS;
|
use bp_eth_poa::{
|
||||||
use sp_bridge_eth_poa::{
|
|
||||||
signatures::{SecretKey, SignTransaction},
|
signatures::{SecretKey, SignTransaction},
|
||||||
UnsignedTransaction,
|
UnsignedTransaction,
|
||||||
};
|
};
|
||||||
|
use bridge_node_runtime::exchange::LOCK_FUNDS_ADDRESS;
|
||||||
|
|
||||||
/// Ethereum exchange transaction params.
|
/// Ethereum exchange transaction params.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ use crate::substrate_types::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
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 Result<T> = result::Result<T, RpcError>;
|
||||||
type GrandpaAuthorityList = Vec<u8>;
|
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 crate::sync_types::{HeaderId, SubmittedHeaders};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
use bp_eth_poa::Header as SubstrateEthereumHeader;
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use jsonrpsee::raw::RawClient;
|
use jsonrpsee::raw::RawClient;
|
||||||
use jsonrpsee::transport::http::HttpTransportClient;
|
use jsonrpsee::transport::http::HttpTransportClient;
|
||||||
use jsonrpsee::Client;
|
use jsonrpsee::Client;
|
||||||
use num_traits::Zero;
|
use num_traits::Zero;
|
||||||
use sp_bridge_eth_poa::Header as SubstrateEthereumHeader;
|
|
||||||
use sp_core::crypto::Pair;
|
use sp_core::crypto::Pair;
|
||||||
use sp_runtime::traits::IdentifyAccount;
|
use sp_runtime::traits::IdentifyAccount;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
@@ -142,7 +142,7 @@ impl SubstrateRpc for SubstrateRpcClient {
|
|||||||
let data = Bytes(Vec::new());
|
let data = Bytes(Vec::new());
|
||||||
|
|
||||||
let encoded_response = Substrate::state_call(&self.client, call, data, None).await?;
|
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);
|
let best_header_id = HeaderId(decoded_response.0, decoded_response.1);
|
||||||
Ok(best_header_id)
|
Ok(best_header_id)
|
||||||
@@ -153,7 +153,7 @@ impl SubstrateRpc for SubstrateRpcClient {
|
|||||||
let data = Bytes(Vec::new());
|
let data = Bytes(Vec::new());
|
||||||
|
|
||||||
let encoded_response = Substrate::state_call(&self.client, call, data, None).await?;
|
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);
|
let best_header_id = HeaderId(decoded_response.0, decoded_response.1);
|
||||||
Ok(best_header_id)
|
Ok(best_header_id)
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ use crate::ethereum_types::{
|
|||||||
};
|
};
|
||||||
use crate::sync_types::{HeaderId, HeadersSyncPipeline, QueuedHeader, SourceHeader};
|
use crate::sync_types::{HeaderId, HeadersSyncPipeline, QueuedHeader, SourceHeader};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
pub use sp_bridge_eth_poa::{
|
|
||||||
|
pub use bp_eth_poa::{
|
||||||
Address, Bloom, Bytes, Header as SubstrateEthereumHeader, LogEntry as SubstrateEthereumLogEntry,
|
Address, Bloom, Bytes, Header as SubstrateEthereumHeader, LogEntry as SubstrateEthereumLogEntry,
|
||||||
Receipt as SubstrateEthereumReceipt, TransactionOutcome as SubstrateEthereumTransactionOutcome, H256, U256,
|
Receipt as SubstrateEthereumReceipt, TransactionOutcome as SubstrateEthereumTransactionOutcome, H256, U256,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user