Skip to content

Commit f96fa0a

Browse files
committed
feat: embedded relayer
1 parent 9fba5c6 commit f96fa0a

11 files changed

Lines changed: 737 additions & 33 deletions

File tree

Cargo.lock

Lines changed: 324 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bitcoin/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ pub(crate) mod tests {
413413

414414
#[test]
415415
fn test_parse_block_header() {
416-
let hex_header = sample_block_header();
416+
let hex_header = "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000";
417417
let parsed_header = BlockHeader::from_hex(&hex_header).unwrap();
418418
assert_eq!(parsed_header.version, 4);
419419
assert_eq!(parsed_header.timestamp, 1415239972);

crates/btc-relay/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ pub mod pallet {
339339

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

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

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

357357
/// Increment-only counter used to track new BlockChain entries
358358
#[pallet::storage]

parachain/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ futures = "0.3.15"
2525
jsonrpsee = { version = "0.16.2", features = ["server", "macros"] }
2626
serde_json = "1.0.68"
2727
regex = "1.5.6"
28+
bitcoin_client = { git = "https://github.com/interlay/interbtc-clients.git", package = "bitcoin", features=["cli"], rev = "3e1a15aeac825aa436fd70ac0e9f9f3706635845"}
29+
hex = "0.4.2"
2830

2931
# Parachain dependencies
3032
interlay-runtime = { package = "interlay-runtime-parachain", path = "./runtime/interlay" }
3133
kintsugi-runtime = { package = "kintsugi-runtime-parachain", path = "./runtime/kintsugi" }
3234
runtime-common = { package = "runtime-common", path = "./runtime/common" }
3335
interbtc-rpc = { path = "../rpc" }
34-
bitcoin = { path = "../crates/bitcoin" }
36+
bitcoin = { path = "../crates/bitcoin", features = ["parser"] }
3537
loans = { path = "../crates/loans" }
3638
primitives = { package = "interbtc-primitives", path = "../primitives" }
3739

@@ -58,6 +60,7 @@ sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v
5860
sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
5961
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
6062
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
63+
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
6164
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
6265
sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
6366
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
@@ -124,6 +127,9 @@ fp-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0
124127
fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" }
125128
pallet-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" }
126129

130+
tokio = "1.22.0"
131+
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
132+
127133
[features]
128134
default = []
129135

parachain/runtime/kintsugi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub use sp_runtime::BuildStorage;
7575
pub use sp_runtime::{FixedU128, Perbill, Permill};
7676

7777
// interBTC exports
78-
pub use btc_relay::{bitcoin, Call as BtcRelayCall, TARGET_SPACING};
78+
pub use btc_relay::{self, bitcoin, Call as BtcRelayCall, TARGET_SPACING};
7979
pub use constants::{currency::*, time::*};
8080
pub use oracle_rpc_runtime_api::BalanceWrapper;
8181
pub use orml_asset_registry::AssetMetadata;

parachain/src/cli.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ pub struct Cli {
9090
#[clap(flatten)]
9191
pub eth: EthConfiguration,
9292

93+
/// Connection settings for Bitcoin Core for relay purposes.
94+
#[clap(flatten)]
95+
pub bitcoin: bitcoin_client::cli::BitcoinOpts,
96+
9397
/// Relaychain arguments
9498
#[clap(raw = true)]
9599
pub relaychain_args: Vec<String>,

parachain/src/command.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ pub fn run() -> Result<()> {
470470

471471
runner
472472
.run_node_until_exit(|config| async move {
473+
log::info!("Im here");
474+
// plan: use pool.
475+
// bitcoin_rpc.
473476
if cli.instant_seal {
474477
start_instant(cli, config).await
475478
} else {
@@ -484,7 +487,9 @@ pub fn run() -> Result<()> {
484487
async fn start_instant(cli: Cli, config: Configuration) -> sc_service::error::Result<TaskManager> {
485488
with_runtime_or_err!(config.chain_spec, {
486489
{
487-
crate::service::start_instant::<RuntimeApi, Executor, TransactionConverter>(config, cli.eth)
490+
log::info!("starting instant..");
491+
492+
crate::service::start_instant::<RuntimeApi, Executor, TransactionConverter>(config, cli.eth, cli.bitcoin)
488493
.await
489494
.map(|r| r.0)
490495
.map_err(Into::into)

0 commit comments

Comments
 (0)