Skip to content

Commit

Permalink
feat(wip): embedded relayer
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed Aug 18, 2023
1 parent 9fba5c6 commit 0dfa721
Show file tree
Hide file tree
Showing 8 changed files with 660 additions and 34 deletions.
347 changes: 321 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
2 changes: 1 addition & 1 deletion crates/btc-relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 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 = { path = "../../polkabtc-clients/bitcoin/", package = "bitcoin", features=["cli"]}
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 Down Expand Up @@ -124,6 +126,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
5 changes: 5 additions & 0 deletions parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ pub fn run() -> Result<()> {

runner
.run_node_until_exit(|config| async move {
log::info!("Im here");
// let bitcoin_rpc = cli.bitcoin.new_client(None).await.unwrap();
// plan: use pool.
// bitcoin_rpc.
if cli.instant_seal {
start_instant(cli, config).await
} else {
Expand All @@ -484,6 +488,7 @@ pub fn run() -> Result<()> {
async fn start_instant(cli: Cli, config: Configuration) -> sc_service::error::Result<TaskManager> {
with_runtime_or_err!(config.chain_spec, {
{
log::info!("starting instant..");
crate::service::start_instant::<RuntimeApi, Executor, TransactionConverter>(config, cli.eth)
.await
.map(|r| r.0)
Expand Down
Loading

0 comments on commit 0dfa721

Please sign in to comment.