Prepare separate runtime for testing sub2sub bridge (#341)

* renamed bin/node/runtime to bin/node/rialto-runtime

* replaced bridge-node-runtime references with rialto-runtime references

* separate folders for millau/rialto nodes+runtimes

* extracted pallet-shift-session-manager

* bridge-node -> bridge-node-runtime

* uninstall previous rust (temp solution???)

* fix dockerfile

* cargo fmt

* fix benchmarks check

* fix benchmarks again

* update LAST_RUST_UPDATE to clear the cache

* changed runtime comments

* move bin/node/* to bin/

* REVERT ME

* Revert "REVERT ME"

This reverts commit 7c335f946308ed11d9ed6ffec7c1c13dbe2743ed.

* specify container name

* REVERT ME

* container_name -> hostname

* fix typo

* aliases

* Revert "REVERT ME"

This reverts commit 0e74af5f8430f1975a3fc924d8b52079f266bda1.

* removed prefixes
This commit is contained in:
Svyatoslav Nikolsky
2020-09-14 12:13:03 +03:00
committed by Bastian Köcher
parent bed44dec13
commit d8ae786792
31 changed files with 939 additions and 96 deletions
+2 -2
View File
@@ -77,6 +77,6 @@ version = "0.8.0-rc6"
tag = 'v2.0.0-rc6'
git = "https://github.com/paritytech/substrate.git"
[dependencies.bridge-node-runtime]
[dependencies.rialto-runtime]
version = "0.1.0"
path = "../../bin/node/runtime"
path = "../../bin/rialto-runtime"
@@ -38,7 +38,7 @@ use crate::utils::HeaderId;
use async_trait::async_trait;
use bp_currency_exchange::MaybeLockFundsTransaction;
use bridge_node_runtime::exchange::EthereumTransactionInclusionProof;
use rialto_runtime::exchange::EthereumTransactionInclusionProof;
use std::time::Duration;
/// Interval at which we ask Ethereum node for updates.
@@ -234,7 +234,7 @@ impl TargetClient<EthereumToSubstrateExchange> for SubstrateTransactionsTarget {
async fn filter_transaction_proof(&self, proof: &EthereumTransactionInclusionProof) -> Result<bool, Self::Error> {
// let's try to parse transaction locally
let (raw_tx, raw_tx_receipt) = &proof.proof[proof.index as usize];
let parse_result = bridge_node_runtime::exchange::EthTransaction::parse(raw_tx);
let parse_result = rialto_runtime::exchange::EthTransaction::parse(raw_tx);
if parse_result.is_err() {
return Ok(false);
}
@@ -24,7 +24,7 @@ use bp_eth_poa::{
signatures::{SecretKey, SignTransaction},
UnsignedTransaction,
};
use bridge_node_runtime::exchange::LOCK_FUNDS_ADDRESS;
use rialto_runtime::exchange::LOCK_FUNDS_ADDRESS;
/// Ethereum exchange transaction params.
#[derive(Debug)]
+14 -14
View File
@@ -26,8 +26,8 @@
use crate::ethereum_types::QueuedEthereumHeader;
use crate::substrate_types::{into_substrate_ethereum_header, into_substrate_ethereum_receipts};
use bridge_node_runtime::exchange::EthereumTransactionInclusionProof as Proof;
use bridge_node_runtime::Call;
use rialto_runtime::exchange::EthereumTransactionInclusionProof as Proof;
use rialto_runtime::Call;
/// Interface for `Calls` which are needed to correctly sync the bridge.
///
@@ -48,7 +48,7 @@ pub struct Rialto;
impl BridgeInstance for Rialto {
fn build_signed_header_call(&self, headers: Vec<QueuedEthereumHeader>) -> Call {
let pallet_call = bridge_node_runtime::BridgeEthPoACall::import_signed_headers(
let pallet_call = rialto_runtime::BridgeEthPoACall::import_signed_headers(
headers
.into_iter()
.map(|header| {
@@ -60,21 +60,21 @@ impl BridgeInstance for Rialto {
.collect(),
);
bridge_node_runtime::Call::BridgeRialto(pallet_call)
rialto_runtime::Call::BridgeRialto(pallet_call)
}
fn build_unsigned_header_call(&self, header: QueuedEthereumHeader) -> Call {
let pallet_call = bridge_node_runtime::BridgeEthPoACall::import_unsigned_header(
let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header(
into_substrate_ethereum_header(header.header()),
into_substrate_ethereum_receipts(header.extra()),
);
bridge_node_runtime::Call::BridgeRialto(pallet_call)
rialto_runtime::Call::BridgeRialto(pallet_call)
}
fn build_currency_exchange_call(&self, proof: Proof) -> Call {
let pallet_call = bridge_node_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof);
bridge_node_runtime::Call::BridgeRialtoCurrencyExchange(pallet_call)
let pallet_call = rialto_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof);
rialto_runtime::Call::BridgeRialtoCurrencyExchange(pallet_call)
}
}
@@ -84,7 +84,7 @@ pub struct Kovan;
impl BridgeInstance for Kovan {
fn build_signed_header_call(&self, headers: Vec<QueuedEthereumHeader>) -> Call {
let pallet_call = bridge_node_runtime::BridgeEthPoACall::import_signed_headers(
let pallet_call = rialto_runtime::BridgeEthPoACall::import_signed_headers(
headers
.into_iter()
.map(|header| {
@@ -96,20 +96,20 @@ impl BridgeInstance for Kovan {
.collect(),
);
bridge_node_runtime::Call::BridgeKovan(pallet_call)
rialto_runtime::Call::BridgeKovan(pallet_call)
}
fn build_unsigned_header_call(&self, header: QueuedEthereumHeader) -> Call {
let pallet_call = bridge_node_runtime::BridgeEthPoACall::import_unsigned_header(
let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header(
into_substrate_ethereum_header(header.header()),
into_substrate_ethereum_receipts(header.extra()),
);
bridge_node_runtime::Call::BridgeKovan(pallet_call)
rialto_runtime::Call::BridgeKovan(pallet_call)
}
fn build_currency_exchange_call(&self, proof: Proof) -> Call {
let pallet_call = bridge_node_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof);
bridge_node_runtime::Call::BridgeKovanCurrencyExchange(pallet_call)
let pallet_call = rialto_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof);
rialto_runtime::Call::BridgeKovanCurrencyExchange(pallet_call)
}
}
+21 -21
View File
@@ -314,13 +314,13 @@ pub trait SubmitEthereumExchangeTransactionProof: SubstrateRpc {
/// Pre-verify Ethereum exchange transaction proof.
async fn verify_exchange_transaction_proof(
&self,
proof: bridge_node_runtime::exchange::EthereumTransactionInclusionProof,
proof: rialto_runtime::exchange::EthereumTransactionInclusionProof,
) -> RpcResult<bool>;
/// Submits Ethereum exchange transaction proof to Substrate runtime.
async fn submit_exchange_transaction_proof(
&self,
params: SubstrateSigningParams,
proof: bridge_node_runtime::exchange::EthereumTransactionInclusionProof,
proof: rialto_runtime::exchange::EthereumTransactionInclusionProof,
) -> RpcResult<()>;
}
@@ -328,7 +328,7 @@ pub trait SubmitEthereumExchangeTransactionProof: SubstrateRpc {
impl SubmitEthereumExchangeTransactionProof for SubstrateRpcClient {
async fn verify_exchange_transaction_proof(
&self,
proof: bridge_node_runtime::exchange::EthereumTransactionInclusionProof,
proof: rialto_runtime::exchange::EthereumTransactionInclusionProof,
) -> RpcResult<bool> {
let call = EXCH_API_FILTER_TRANSACTION_PROOF.to_string();
let data = Bytes(proof.encode());
@@ -342,7 +342,7 @@ impl SubmitEthereumExchangeTransactionProof for SubstrateRpcClient {
async fn submit_exchange_transaction_proof(
&self,
params: SubstrateSigningParams,
proof: bridge_node_runtime::exchange::EthereumTransactionInclusionProof,
proof: rialto_runtime::exchange::EthereumTransactionInclusionProof,
) -> RpcResult<()> {
let account_id = params.signer.public().as_array_ref().clone().into();
let nonce = self.next_account_index(account_id).await?;
@@ -357,43 +357,43 @@ impl SubmitEthereumExchangeTransactionProof for SubstrateRpcClient {
/// Create signed Substrate transaction for submitting Ethereum headers.
fn create_signed_submit_transaction(
signed_call: bridge_node_runtime::Call,
signed_call: rialto_runtime::Call,
signer: &sp_core::sr25519::Pair,
index: node_primitives::Index,
genesis_hash: H256,
) -> bridge_node_runtime::UncheckedExtrinsic {
) -> rialto_runtime::UncheckedExtrinsic {
create_signed_transaction(signed_call, signer, index, genesis_hash)
}
/// Create unsigned Substrate transaction for submitting Ethereum header.
fn create_unsigned_submit_transaction(call: bridge_node_runtime::Call) -> bridge_node_runtime::UncheckedExtrinsic {
bridge_node_runtime::UncheckedExtrinsic::new_unsigned(call)
fn create_unsigned_submit_transaction(call: rialto_runtime::Call) -> rialto_runtime::UncheckedExtrinsic {
rialto_runtime::UncheckedExtrinsic::new_unsigned(call)
}
/// Create signed Substrate transaction.
fn create_signed_transaction(
function: bridge_node_runtime::Call,
function: rialto_runtime::Call,
signer: &sp_core::sr25519::Pair,
index: node_primitives::Index,
genesis_hash: H256,
) -> bridge_node_runtime::UncheckedExtrinsic {
) -> rialto_runtime::UncheckedExtrinsic {
let extra = |i: node_primitives::Index, f: node_primitives::Balance| {
(
frame_system::CheckSpecVersion::<bridge_node_runtime::Runtime>::new(),
frame_system::CheckTxVersion::<bridge_node_runtime::Runtime>::new(),
frame_system::CheckGenesis::<bridge_node_runtime::Runtime>::new(),
frame_system::CheckEra::<bridge_node_runtime::Runtime>::from(sp_runtime::generic::Era::Immortal),
frame_system::CheckNonce::<bridge_node_runtime::Runtime>::from(i),
frame_system::CheckWeight::<bridge_node_runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<bridge_node_runtime::Runtime>::from(f),
frame_system::CheckSpecVersion::<rialto_runtime::Runtime>::new(),
frame_system::CheckTxVersion::<rialto_runtime::Runtime>::new(),
frame_system::CheckGenesis::<rialto_runtime::Runtime>::new(),
frame_system::CheckEra::<rialto_runtime::Runtime>::from(sp_runtime::generic::Era::Immortal),
frame_system::CheckNonce::<rialto_runtime::Runtime>::from(i),
frame_system::CheckWeight::<rialto_runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<rialto_runtime::Runtime>::from(f),
)
};
let raw_payload = bridge_node_runtime::SignedPayload::from_raw(
let raw_payload = rialto_runtime::SignedPayload::from_raw(
function,
extra(index, 0),
(
bridge_node_runtime::VERSION.spec_version,
bridge_node_runtime::VERSION.transaction_version,
rialto_runtime::VERSION.spec_version,
rialto_runtime::VERSION.transaction_version,
genesis_hash,
genesis_hash,
(),
@@ -405,5 +405,5 @@ fn create_signed_transaction(
let signer: sp_runtime::MultiSigner = signer.public().into();
let (function, extra, _) = raw_payload.deconstruct();
bridge_node_runtime::UncheckedExtrinsic::new_signed(function, signer.into_account(), signature.into(), extra)
rialto_runtime::UncheckedExtrinsic::new_signed(function, signer.into_account(), signature.into(), extra)
}
@@ -28,22 +28,22 @@ pub use bp_eth_poa::{
};
/// Substrate header hash.
pub type Hash = bridge_node_runtime::Hash;
pub type Hash = rialto_runtime::Hash;
/// Substrate header number.
pub type Number = bridge_node_runtime::BlockNumber;
pub type Number = rialto_runtime::BlockNumber;
/// Substrate header type.
pub type Header = bridge_node_runtime::Header;
pub type Header = rialto_runtime::Header;
/// Substrate signed block type.
pub type SignedBlock = bridge_node_runtime::SignedBlock;
pub type SignedBlock = rialto_runtime::SignedBlock;
/// GRANDPA justification.
pub type GrandpaJustification = Vec<u8>;
/// Substrate header ID.
pub type SubstrateHeaderId = HeaderId<bridge_node_runtime::Hash, bridge_node_runtime::BlockNumber>;
pub type SubstrateHeaderId = HeaderId<rialto_runtime::Hash, rialto_runtime::BlockNumber>;
/// Queued substrate header ID.
pub type QueuedSubstrateHeader = QueuedHeader<SubstrateHeadersSyncPipeline>;
@@ -57,8 +57,8 @@ impl HeadersSyncPipeline for SubstrateHeadersSyncPipeline {
const SOURCE_NAME: &'static str = "Substrate";
const TARGET_NAME: &'static str = "Ethereum";
type Hash = bridge_node_runtime::Hash;
type Number = bridge_node_runtime::BlockNumber;
type Hash = rialto_runtime::Hash;
type Number = rialto_runtime::BlockNumber;
type Header = Header;
type Extra = ();
type Completion = GrandpaJustification;
@@ -68,7 +68,7 @@ impl HeadersSyncPipeline for SubstrateHeadersSyncPipeline {
}
}
impl SourceHeader<bridge_node_runtime::Hash, bridge_node_runtime::BlockNumber> for Header {
impl SourceHeader<rialto_runtime::Hash, rialto_runtime::BlockNumber> for Header {
fn id(&self) -> SubstrateHeaderId {
HeaderId(self.number, self.hash())
}