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

chore: update dependecies #29

Merged
merged 13 commits into from May 20, 2021
3,018 changes: 1,749 additions & 1,269 deletions Cargo.lock

Large diffs are not rendered by default.

173 changes: 88 additions & 85 deletions Cargo.toml

Large diffs are not rendered by default.

45 changes: 26 additions & 19 deletions node/Cargo.toml
Expand Up @@ -29,7 +29,7 @@ structopt = '0.3.8'

# local dependencies
basilisk-runtime = {path = '../runtime', version = '3.0.0'}
module-amm-rpc = {version = '3.0.0'}
pallet-xyk-rpc = {version = '1.0.0'}
primitives = {version = '3.0.0'}

# Substrate dependencies
Expand Down Expand Up @@ -64,21 +64,29 @@ sp-timestamp = '3.0.0'
sp-transaction-pool = '3.0.0'
sp-trie = '3.0.0'
substrate-frame-rpc-system = '3.0.0'
sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }

# Cumulus dependencies
cumulus-client-cli = {git = "https://github.com/paritytech/cumulus", branch = "rococo-v1"}
cumulus-client-collator = {git = "https://github.com/paritytech/cumulus", branch = "rococo-v1"}
cumulus-client-consensus-relay-chain = {git = "https://github.com/paritytech/cumulus", branch = "rococo-v1"}
cumulus-client-network = {git = "https://github.com/paritytech/cumulus", branch = "rococo-v1"}
cumulus-client-service = {git = "https://github.com/paritytech/cumulus", branch = "rococo-v1"}
cumulus-primitives-core = {git = "https://github.com/paritytech/cumulus", branch = "rococo-v1"}
cumulus-client-cli = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1"}
cumulus-client-collator = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1"}
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1" }
cumulus-client-consensus-relay-chain = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1"}
cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1" }
cumulus-client-network = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1"}
cumulus-client-service = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1"}
cumulus-primitives-core = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1"}
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1" }

# Polkadot dependencies
polkadot-cli = {git = "https://github.com/paritytech/polkadot", branch = "rococo-v1"}
polkadot-parachain = {git = "https://github.com/paritytech/polkadot", branch = "rococo-v1"}
polkadot-primitives = {git = "https://github.com/paritytech/polkadot", branch = "rococo-v1"}
polkadot-service = {git = "https://github.com/paritytech/polkadot", branch = "rococo-v1"}
polkadot-test-service = {git = "https://github.com/paritytech/polkadot", branch = "rococo-v1"}
polkadot-cli = {version="0.9.1"}
polkadot-parachain = {version="0.9.1"}
polkadot-primitives = {version="0.9.1"}
polkadot-service = {version="0.9.1"}
polkadot-test-service = {version="0.9.1"}

[features]
default = [
Expand All @@ -91,12 +99,11 @@ runtime-benchmarks = [

[dev-dependencies]
# Polkadot dependencies
polkadot-runtime-common = {git = 'https://github.com/paritytech/polkadot', branch = "rococo-v1"}
polkadot-test-client = {git = 'https://github.com/paritytech/polkadot', branch = "rococo-v1"}
polkadot-test-runtime = {git = 'https://github.com/paritytech/polkadot', branch = "rococo-v1"}
polkadot-test-service = {git = 'https://github.com/paritytech/polkadot', branch = "rococo-v1"}
polkadot-runtime-common = {version="0.9.1"}
polkadot-test-client = {version="0.9.1"}
polkadot-test-runtime = {version="0.9.1"}

# Substrate dependencies
pallet-sudo = {git = 'https://github.com/paritytech/substrate', branch = "rococo-v1"}
substrate-test-client = {git = 'https://github.com/paritytech/substrate', branch = "rococo-v1"}
substrate-test-runtime-client = {git = 'https://github.com/paritytech/substrate', branch = "rococo-v1"}
pallet-sudo = {version="3.0.0"}
substrate-test-client = {version="2.0.1"}
substrate-test-runtime-client = {version="2.0.0"}
26 changes: 22 additions & 4 deletions node/src/chain_spec.rs
Expand Up @@ -2,7 +2,7 @@

use cumulus_primitives_core::ParaId;
use basilisk_runtime::{
AccountId, AssetRegistryConfig, BalancesConfig, FaucetConfig, GenesisConfig, ParachainInfoConfig, Signature,
AccountId, AuraId, AuraConfig, AssetRegistryConfig, BalancesConfig, FaucetConfig, GenesisConfig, ParachainInfoConfig, Signature,
SudoConfig, SystemConfig, TokensConfig, CORE_ASSET_ID, WASM_BINARY,
};
use hex_literal::hex;
Expand Down Expand Up @@ -68,6 +68,11 @@ pub fn roccocco_parachain_config(para_id: ParaId) -> Result<ChainSpec, String> {
wasm_binary,
// Sudo account
hex!["30035c21ba9eda780130f2029a80c3e962f56588bc04c36be95a225cb536fb55"].into(),
// TODO generate real authorities
vec![
get_from_seed::<AuraId>("Alice"),
get_from_seed::<AuraId>("Bob"),
],
// Pre-funded accounts
vec![hex!["30035c21ba9eda780130f2029a80c3e962f56588bc04c36be95a225cb536fb55"].into()],
true,
Expand All @@ -84,7 +89,7 @@ pub fn roccocco_parachain_config(para_id: ParaId) -> Result<ChainSpec, String> {
Some(properties),
// Extensions
Extensions {
relay_chain: "rococo".into(),
relay_chain: "westend-dev".into(),
para_id: para_id.into(),
},
))
Expand All @@ -106,6 +111,10 @@ pub fn parachain_development_config(para_id: ParaId) -> Result<ChainSpec, String
wasm_binary,
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_from_seed::<AuraId>("Alice"),
get_from_seed::<AuraId>("Bob"),
],
// Pre-funded accounts
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand All @@ -127,7 +136,7 @@ pub fn parachain_development_config(para_id: ParaId) -> Result<ChainSpec, String
Some(properties),
// Extensions
Extensions {
relay_chain: "local_testnet".into(),
relay_chain: "westend-dev".into(),
para_id: para_id.into(),
},
))
Expand All @@ -150,6 +159,10 @@ pub fn local_parachain_config(para_id: ParaId) -> Result<ChainSpec, String> {
wasm_binary,
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_from_seed::<AuraId>("Alice"),
get_from_seed::<AuraId>("Bob"),
],
// Pre-funded accounts
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand Down Expand Up @@ -179,7 +192,7 @@ pub fn local_parachain_config(para_id: ParaId) -> Result<ChainSpec, String> {
Some(properties),
// Extensions
Extensions {
relay_chain: "local_testnet".into(),
relay_chain: "westend-dev".into(),
para_id: para_id.into(),
},
))
Expand All @@ -189,6 +202,7 @@ pub fn local_parachain_config(para_id: ParaId) -> Result<ChainSpec, String> {
fn parachain_genesis(
wasm_binary: &[u8],
root_key: AccountId,
initial_authorities: Vec<AuraId>,
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
parachain_id: ParaId,
Expand All @@ -211,6 +225,9 @@ fn parachain_genesis(
// Assign network admin rights.
key: root_key,
},
pallet_aura: AuraConfig {
authorities: initial_authorities,
},
pallet_asset_registry: AssetRegistryConfig {
core_asset_id: CORE_ASSET_ID,
asset_ids: vec![
Expand Down Expand Up @@ -240,5 +257,6 @@ fn parachain_genesis(
mint_limit: 5,
mintable_currencies: vec![0, 1, 2],
},
cumulus_pallet_aura_ext: Default::default(),
}
}
31 changes: 6 additions & 25 deletions node/src/cli.rs
@@ -1,4 +1,5 @@
use crate::chain_spec;
use sc_cli;
use std::path::PathBuf;
use structopt::StructOpt;

Expand All @@ -13,13 +14,7 @@ pub struct Cli {
pub subcommand: Option<Subcommand>,

#[structopt(flatten)]
pub run: RunCmd,

/// Run node as collator.
///
/// Note that this is the same as running with `--validator`.
#[structopt(long, conflicts_with = "validator")]
pub collator: bool,
pub run: cumulus_client_cli::RunCmd,

/// Relaychain arguments
#[structopt(raw = true)]
Expand Down Expand Up @@ -102,6 +97,10 @@ pub struct ExportGenesisStateCommand {
#[structopt(long, default_value = "200")]
pub parachain_id: u32,

/// Write output in binary. Default is to write in hex.
#[structopt(short, long)]
pub raw: bool,

/// The name of the chain for that the genesis state should be exported.
#[structopt(long)]
pub chain: Option<String>,
Expand All @@ -122,21 +121,3 @@ pub struct ExportGenesisWasmCommand {
#[structopt(long)]
pub chain: Option<String>,
}

#[derive(Debug, StructOpt)]
pub struct RunCmd {
#[structopt(flatten)]
pub base: sc_cli::RunCmd,

/// Id of the parachain this collator collates for.
#[structopt(long)]
pub parachain_id: Option<u32>,
}

impl std::ops::Deref for RunCmd {
type Target = sc_cli::RunCmd;

fn deref(&self) -> &Self::Target {
&self.base
}
}
40 changes: 26 additions & 14 deletions node/src/command.rs
Expand Up @@ -62,11 +62,11 @@ impl SubstrateCli for Cli {
}

fn support_url() -> String {
"support.anonymous.an".into()
"https://github.com/galacticcouncil/Basilisk-node/issues".into()
}

fn copyright_start_year() -> i32 {
2017
2020
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
Expand All @@ -86,7 +86,7 @@ impl SubstrateCli for Cli {

impl SubstrateCli for RelayChainCli {
fn impl_name() -> String {
"basilisk rococo relay node".into()
"basilisk collator".into()
}

fn impl_version() -> String {
Expand All @@ -102,15 +102,16 @@ impl SubstrateCli for RelayChainCli {
}

fn support_url() -> String {
"support.anonymous.an".into()
"https://github.com/galacticcouncil/Basilisk-node/issues".into()
}

fn copyright_start_year() -> i32 {
2017
2020
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name().to_string()].iter())
.load_spec(id)
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
Expand Down Expand Up @@ -228,12 +229,17 @@ pub fn run() -> sc_cli::Result<()> {
&params.chain.clone().unwrap_or_default(),
params.parachain_id.into(),
)?)?;
let header_hex = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
let raw_header = block.header().encode();
let output_buf = if params.raw {
raw_header
} else {
format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()
};

if let Some(output) = &params.output {
std::fs::write(output, header_hex)?;
std::fs::write(output, output_buf)?;
} else {
print!("{}", header_hex);
std::io::stdout().write_all(&output_buf)?;
}

Ok(())
Expand All @@ -259,7 +265,7 @@ pub fn run() -> sc_cli::Result<()> {
Ok(())
}
None => {
let runner = cli.create_runner(&*cli.run)?;
let runner = cli.create_runner(&cli.run.normalize())?;

runner.run_node_until_exit(|config| async move {
// TODO
Expand All @@ -269,7 +275,7 @@ pub fn run() -> sc_cli::Result<()> {

let polkadot_cli = RelayChainCli::new(
&config,
[RelayChainCli::executable_name()]
[RelayChainCli::executable_name().to_string()]
.iter()
.chain(cli.relaychain_args.iter()),
);
Expand All @@ -284,14 +290,20 @@ pub fn run() -> sc_cli::Result<()> {
let task_executor = config.task_executor.clone();
let polkadot_config = SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, task_executor)
.map_err(|err| format!("Relay chain argument error: {}", err))?;
let collator = cli.run.base.validator || cli.collator;

info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
info!("Parachain genesis state: {}", genesis_state);
info!("Is collating: {}", if collator { "yes" } else { "no" });
info!(
"Is collating: {}",
if config.role.is_authority() {
"yes"
} else {
"no"
}
);

crate::service::start_node(config, key, polkadot_config, id, collator)
crate::service::start_node(config, key, polkadot_config, id)
.await
.map(|r| r.0)
.map_err(Into::into)
Expand Down
6 changes: 3 additions & 3 deletions node/src/rpc.rs
Expand Up @@ -32,11 +32,11 @@ where
C: Send + Sync + 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: module_amm_rpc::AMMRuntimeApi<Block, AccountId, AssetId, Balance>,
C::Api: pallet_xyk_rpc::XYKRuntimeApi<Block, AccountId, AssetId, Balance>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
{
use module_amm_rpc::{AMMApi, AMM};
use pallet_xyk_rpc::{XYKApi, XYK};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
use substrate_frame_rpc_system::{FullSystem, SystemApi};

Expand All @@ -62,7 +62,7 @@ where
// to call into the runtime.
// `io.extend_with(YourRpcTrait::to_delegate(YourRpcStruct::new(ReferenceToClient, ...)));`

io.extend_with(AMMApi::to_delegate(AMM::new(client)));
io.extend_with(XYKApi::to_delegate(XYK::new(client)));

io
}