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: interlay testnet from chain spec #641

Merged
merged 2 commits into from
Jun 14, 2022
Merged
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
108 changes: 105 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/rococo-local-xcm.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
]
}
],
"chain": "rococo-local-2000"
"chain": "rococo-local-interlay-2000"
},
{
"bin": "/usr/local/bin/interbtc-parachain",
Expand Down
6 changes: 3 additions & 3 deletions parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ futures = "0.3.15"
# Parachain dependencies
interlay-runtime = { package = "interlay-runtime-parachain", path = "./runtime/interlay" }
kintsugi-runtime = { package = "kintsugi-runtime-parachain", path = "./runtime/kintsugi" }
testnet-runtime = { package = "testnet-runtime-parachain", path = "./runtime/testnet" }
testnet-kintsugi-runtime = { package = "testnet-kintsugi-runtime-parachain", path = "./runtime/testnet-kintsugi" }
testnet-interlay-runtime = { package = "testnet-interlay-runtime-parachain", path = "./runtime/testnet-interlay" }
interbtc-rpc = { path = "../rpc" }
bitcoin = { path = "../crates/bitcoin" }
primitives = { package = "interbtc-primitives", path = "../primitives" }
Expand Down Expand Up @@ -106,5 +107,4 @@ rococo-native = [ "polkadot-cli/rococo-native" ]
runtime-benchmarks = [
"interlay-runtime/runtime-benchmarks",
"polkadot-service/runtime-benchmarks",
]
dev-interlay = ["testnet-runtime/dev-interlay"]
]
6 changes: 4 additions & 2 deletions parachain/runtime/runtime-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ annuity = { path = "../../../crates/annuity", default-features = false }
supply = { path = "../../../crates/supply", default-features = false }

kintsugi-runtime-parachain = { path = "../kintsugi", default-features = false }
testnet-runtime-parachain = { path = "../testnet", default-features = false }
testnet-kintsugi-runtime-parachain = { path = "../testnet-kintsugi", default-features = false }
testnet-interlay-runtime-parachain = { path = "../testnet-interlay", default-features = false }

primitives = { package = "interbtc-primitives", path = "../../../primitives", default-features = false }

Expand Down Expand Up @@ -194,7 +195,8 @@ std = [
"pallet-xcm/std",

"kintsugi-runtime-parachain/std",
"testnet-runtime-parachain/std",
"testnet-kintsugi-runtime-parachain/std",
"testnet-interlay-runtime-parachain/std",

"btc-relay/std",
"btc-relay/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,16 @@ fn subscribe_version_notify_works() {
)));
});
Sibling::execute_with(|| {
assert!(testnet_runtime_parachain::System::events().iter().any(|r| matches!(
r.event,
testnet_runtime_parachain::Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent(Some(_)))
| testnet_runtime_parachain::Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success(Some(_)))
)));
assert!(testnet_kintsugi_runtime_parachain::System::events()
.iter()
.any(|r| matches!(
r.event,
testnet_kintsugi_runtime_parachain::Event::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::XcmpMessageSent(Some(_))
) | testnet_kintsugi_runtime_parachain::Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success(
Some(_)
))
)));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ decl_test_parachain! {

decl_test_parachain! {
pub struct Sibling {
Runtime = testnet_runtime_parachain::Runtime,
Origin = testnet_runtime_parachain::Origin,
XcmpMessageHandler = testnet_runtime_parachain::XcmpQueue,
DmpMessageHandler = testnet_runtime_parachain::DmpQueue,
Runtime = testnet_kintsugi_runtime_parachain::Runtime,
Origin = testnet_kintsugi_runtime_parachain::Origin,
XcmpMessageHandler = testnet_kintsugi_runtime_parachain::XcmpQueue,
DmpMessageHandler = testnet_kintsugi_runtime_parachain::DmpQueue,
new_ext = para_ext(SIBLING_PARA_ID),
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Interlay Ltd"]
edition = "2021"
name = 'testnet-runtime-parachain'
name = 'testnet-interlay-runtime-parachain'
version = "1.2.0"

[package.metadata.docs.rs]
Expand Down
44 changes: 44 additions & 0 deletions parachain/runtime/testnet-interlay/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//! A set of constant values used in the testnet runtime.

/// Money matters.
pub mod currency {
use primitives::TokenSymbol;
pub use primitives::{Balance, CurrencyId, CurrencyId::Token, DOT, IBTC, INTR};

pub const NATIVE_TOKEN_ID: TokenSymbol = INTR;
pub const NATIVE_CURRENCY_ID: CurrencyId = Token(NATIVE_TOKEN_ID);
pub const PARENT_TOKEN_ID: TokenSymbol = DOT;
pub const PARENT_CURRENCY_ID: CurrencyId = Token(PARENT_TOKEN_ID);
pub const WRAPPED_CURRENCY_ID: CurrencyId = Token(IBTC);

// https://github.com/paritytech/polkadot/blob/c4ee9d463adccfa3bf436433e3e26d0de5a4abbc/runtime/polkadot/src/constants.rs#L18
pub const UNITS: Balance = NATIVE_TOKEN_ID.one();
pub const DOLLARS: Balance = UNITS; // 10_000_000_000
pub const CENTS: Balance = DOLLARS / 100; // 100_000_000
pub const MILLICENTS: Balance = CENTS / 1_000; // 100_000

pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS
}
}

/// Time and blocks.
pub mod time {
use btc_relay::TARGET_SPACING;
use primitives::{BlockNumber, Moment};

// The relay chain is limited to 12s to include parachain blocks.
pub const MILLISECS_PER_BLOCK: u64 = 12000;

pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;

// These time units are defined in number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
pub const WEEKS: BlockNumber = DAYS * 7;
pub const YEARS: BlockNumber = DAYS * 365;

pub const BITCOIN_SPACING_MS: u32 = TARGET_SPACING * 1000;
pub const BITCOIN_BLOCK_SPACING: BlockNumber = BITCOIN_SPACING_MS / MILLISECS_PER_BLOCK as BlockNumber;
}
Loading