Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wip): embedded relayer #1179

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
350 changes: 324 additions & 26 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/bitcoin/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ pub(crate) mod tests {

#[test]
fn test_parse_block_header() {
let hex_header = sample_block_header();
let hex_header = "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000";
let parsed_header = BlockHeader::from_hex(&hex_header).unwrap();
assert_eq!(parsed_header.version, 4);
assert_eq!(parsed_header.timestamp, 1415239972);
Expand Down
4 changes: 2 additions & 2 deletions crates/btc-relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub mod pallet {

/// Stores a mapping from (chain_index, block_height) to block hash
#[pallet::storage]
pub(super) type ChainsHashes<T: Config> =
pub type ChainsHashes<T: Config> =
StorageDoubleMap<_, Blake2_128Concat, u32, Blake2_128Concat, u32, H256Le, ValueQuery>;

/// Store the current blockchain tip
Expand All @@ -352,7 +352,7 @@ pub mod pallet {

/// BTC height when the relay was initialized
#[pallet::storage]
pub(super) type StartBlockHeight<T: Config> = StorageValue<_, u32, ValueQuery>;
pub type StartBlockHeight<T: Config> = StorageValue<_, u32, ValueQuery>;

/// Increment-only counter used to track new BlockChain entries
#[pallet::storage]
Expand Down
8 changes: 7 additions & 1 deletion parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ futures = "0.3.15"
jsonrpsee = { version = "0.16.2", features = ["server", "macros"] }
serde_json = "1.0.68"
regex = "1.5.6"
bitcoin_client = { git = "https://github.com/interlay/interbtc-clients.git", package = "bitcoin", features=["cli"], rev = "3e1a15aeac825aa436fd70ac0e9f9f3706635845"}
hex = "0.4.2"

# Parachain dependencies
interlay-runtime = { package = "interlay-runtime-parachain", path = "./runtime/interlay" }
kintsugi-runtime = { package = "kintsugi-runtime-parachain", path = "./runtime/kintsugi" }
runtime-common = { package = "runtime-common", path = "./runtime/common" }
interbtc-rpc = { path = "../rpc" }
bitcoin = { path = "../crates/bitcoin" }
bitcoin = { path = "../crates/bitcoin", features = ["parser"] }
loans = { path = "../crates/loans" }
primitives = { package = "interbtc-primitives", path = "../primitives" }

Expand All @@ -58,6 +60,7 @@ sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v
sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
Expand Down Expand Up @@ -124,6 +127,9 @@ fp-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0
fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" }
pallet-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" }

tokio = "1.22.0"
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }

[features]
default = []

Expand Down
2 changes: 1 addition & 1 deletion parachain/runtime/kintsugi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub use sp_runtime::BuildStorage;
pub use sp_runtime::{FixedU128, Perbill, Permill};

// interBTC exports
pub use btc_relay::{bitcoin, Call as BtcRelayCall, TARGET_SPACING};
pub use btc_relay::{self, bitcoin, Call as BtcRelayCall, TARGET_SPACING};
pub use constants::{currency::*, time::*};
pub use oracle_rpc_runtime_api::BalanceWrapper;
pub use orml_asset_registry::AssetMetadata;
Expand Down
4 changes: 4 additions & 0 deletions parachain/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pub struct Cli {
#[clap(flatten)]
pub eth: EthConfiguration,

/// Connection settings for Bitcoin Core for relay purposes.
#[clap(flatten)]
pub bitcoin: bitcoin_client::cli::BitcoinOpts,

/// Relaychain arguments
#[clap(raw = true)]
pub relaychain_args: Vec<String>,
Expand Down
7 changes: 6 additions & 1 deletion parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ pub fn run() -> Result<()> {

runner
.run_node_until_exit(|config| async move {
log::info!("Im here");
// plan: use pool.
// bitcoin_rpc.
if cli.instant_seal {
start_instant(cli, config).await
} else {
Expand All @@ -484,7 +487,9 @@ pub fn run() -> Result<()> {
async fn start_instant(cli: Cli, config: Configuration) -> sc_service::error::Result<TaskManager> {
with_runtime_or_err!(config.chain_spec, {
{
crate::service::start_instant::<RuntimeApi, Executor, TransactionConverter>(config, cli.eth)
log::info!("starting instant..");

crate::service::start_instant::<RuntimeApi, Executor, TransactionConverter>(config, cli.eth, cli.bitcoin)
.await
.map(|r| r.0)
.map_err(Into::into)
Expand Down
Loading