Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
679fbbf
WIP converting runtime to a parachain
ascjones Feb 12, 2021
7219583
Update more deps
ascjones Feb 16, 2021
002f8a1
Pin funty
ascjones Feb 16, 2021
4e22208
Fix build runner
ascjones Feb 19, 2021
b8d4709
WIP update cli and command
ascjones Feb 19, 2021
90e36a6
Remove Grandpa, copying std crates from cumulus
ascjones Feb 19, 2021
d6018a7
Merge branch 'master' into aj-cumulus
ascjones Feb 24, 2021
bca92cf
cargo generate-lockfile after merge of master
ascjones Feb 24, 2021
0e5e804
cargo update, pinning funty
ascjones Feb 24, 2021
1acb06d
Update runtime to pure parachain, removing Aura
ascjones Feb 24, 2021
9d0b0b2
Fix up runtime
ascjones Feb 25, 2021
6086a71
Specify master branch for substrate deps
ascjones Feb 25, 2021
f971bc0
Fix BlockWeights and BlockLength types
ascjones Feb 25, 2021
9b6d952
cargo update
ascjones Feb 25, 2021
e6ce0d2
Use plain AccountId for address and Lookup to fix compiler errors
ascjones Feb 25, 2021
48eb8de
Add missing WeightInfo import
ascjones Feb 25, 2021
f26ee90
Update to latest cumulus
ascjones Mar 1, 2021
23e0504
Use diener to pin substrate and polkadot deps
ascjones Mar 1, 2021
59b96b6
Revert to substrate and polkadot master branches
ascjones Mar 2, 2021
af2bf45
Fix up chain_spec and command
ascjones Mar 3, 2021
83dfb84
service
ascjones Mar 3, 2021
2dc8713
Use cumulus master branch
ascjones Mar 4, 2021
1222d71
Fix up parachain command and chain_spec
ascjones Mar 4, 2021
b7320e9
Remove some spaces
ascjones Mar 4, 2021
20c1ddd
Register contracts rpc
ascjones Mar 5, 2021
3c7d11c
Use rpc module
ascjones Mar 5, 2021
5e9440b
Add missing rpc api impls
ascjones Mar 5, 2021
2a36f5d
Update substrate and polkadot
ascjones Mar 5, 2021
8db2aa8
Add polkadot launch files for local testnet
ascjones Mar 9, 2021
d432fe4
Update substrate and polkadot
ascjones Mar 10, 2021
8b33245
Update substrate and polkadot
ascjones Mar 12, 2021
cf5ef75
Fix errors after substrate and polkadot update
ascjones Mar 12, 2021
4f6be20
Use rococo-v1 branch for substrate/polkadot and cumulus
ascjones Mar 12, 2021
bc459ca
Revert previous update to substrate/polkadot master branches for roco…
ascjones Mar 12, 2021
d880756
Update cumulus/substrate/polkadot
ascjones Mar 25, 2021
6aeab36
Remove commented out dependencies
ascjones Mar 25, 2021
c69c2fb
Fix errors after upgrade
ascjones Mar 25, 2021
cd11ae0
Fix deprecation warning
ascjones Mar 25, 2021
6d39cdc
More node fixes
ascjones Mar 25, 2021
98afa53
Fix more errors
ascjones Mar 25, 2021
08421e3
Update cumulus/polkadot/substrate
ascjones Mar 29, 2021
501f772
Merge branch 'rococo-v1' into aj-cumulus
ascjones Mar 30, 2021
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
3,828 changes: 3,022 additions & 806 deletions Cargo.lock

Large diffs are not rendered by default.

80 changes: 52 additions & 28 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,67 @@ edition = "2018"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
log = "0.4.8"
serde = { version = "1.0.101", features = ["derive"] }
structopt = "0.3.8"
codec = { package = "parity-scale-codec", version = "2.0.0" }
hex-literal = "0.2.1"

sc-cli = { version = "0.9.0", git = "https://github.com/paritytech/substrate", package = "sc-cli", features = ["wasmtime"] }
sp-core = { git = "https://github.com/paritytech/substrate", package = "sp-core" }
sc-executor = { version = "0.9.0", git = "https://github.com/paritytech/substrate", package = "sc-executor", features = ["wasmtime"] }
sc-service = { version = "0.9.0", git = "https://github.com/paritytech/substrate", package = "sc-service", features = ["wasmtime"] }
sc-telemetry = { git = "https://github.com/paritytech/substrate", package = "sc-telemetry" }
sp-inherents = { git = "https://github.com/paritytech/substrate", package = "sp-inherents" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", package = "sc-transaction-pool" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", package = "sp-transaction-pool" }
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", package = "sc-consensus-aura" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", package = "sp-consensus-aura" }
sp-consensus = { git = "https://github.com/paritytech/substrate", package = "sp-consensus" }
sc-consensus = { git = "https://github.com/paritytech/substrate", package = "sc-consensus" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", package = "sc-finality-grandpa" }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", package = "sp-finality-grandpa" }
sc-client-api = { git = "https://github.com/paritytech/substrate", package = "sc-client-api" }
sp-runtime = { git = "https://github.com/paritytech/substrate", package = "sp-runtime" }
pallet-contracts = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts" }
# Substrate dependencies
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "rococo-v1" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
pallet-contracts = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts" , branch = "rococo-v1" }

# These dependencies are used for the node's RPCs
jsonrpc-core = "15.0.0"
sc-rpc = { git = "https://github.com/paritytech/substrate", package = "sc-rpc" }
sp-api = { git = "https://github.com/paritytech/substrate", package = "sp-api" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", package = "sc-rpc-api" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", package = "sp-blockchain" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", package = "sp-block-builder" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", package = "sc-basic-authorship" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", package = "substrate-frame-rpc-system" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", package = "pallet-transaction-payment-rpc" }
pallet-contracts-rpc = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts-rpc" }
jsonrpc-core = "15.1.0"
sp-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", package = "substrate-frame-rpc-system" , branch = "rococo-v1" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", package = "pallet-transaction-payment-rpc" , branch = "rococo-v1" }
pallet-contracts-rpc = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts-rpc" , branch = "rococo-v1" }

# Cumulus dependencies
cumulus-client-cli = { 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-collator = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" }
cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" }
cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" }

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

canvas-runtime = { version = "0.1.0", path = "../runtime" }

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", package = "substrate-build-script-utils" }
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", package = "substrate-build-script-utils" , branch = "rococo-v1" }

[[bin]]
name = "canvas"
Expand Down
172 changes: 86 additions & 86 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use sp_core::{Pair, Public, sr25519};
use cumulus_primitives_core::ParaId;
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};

use canvas_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
SudoConfig, SystemConfig, WASM_BINARY, Signature,
AccountId, BalancesConfig, GenesisConfig,
SudoConfig, SystemConfig, Signature,
ContractsConfig,
};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_finality_grandpa::AuthorityId as GrandpaId;
use sp_runtime::traits::{Verify, IdentifyAccount};
use sc_service::ChainType;
use hex_literal::hex;

// Note this is the URL for the telemetry server
//const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<canvas_runtime::GenesisConfig, Extensions>;

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand All @@ -23,130 +21,132 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu
.public()
}

type AccountPublic = <Signature as Verify>::Signer;

/// Helper function to generate an account ID from seed
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId where
AccountPublic: From<<TPublic::Pair as Pair>::Public>
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
/// The extensions for the [`ChainSpec`].
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
#[serde(deny_unknown_fields)]
pub struct Extensions {
/// The relay chain of the Parachain.
pub relay_chain: String,
/// The id of the Parachain.
pub para_id: u32,
}

/// Helper function to generate an authority key for Aura
pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
(
get_from_seed::<AuraId>(s),
get_from_seed::<GrandpaId>(s),
)
impl Extensions {
/// Try to get the extension from the given `ChainSpec`.
pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
sc_chain_spec::get_extension(chain_spec.extensions())
}
}

type AccountPublic = <Signature as Verify>::Signer;

pub fn testnet_authorities() -> Vec<(AuraId, GrandpaId)> {
use sp_core::crypto::UncheckedInto;
vec![
(
hex!("74608217b1709e1d3a4fe65b132db5c3f321e625026080833189661aa5e20712").unchecked_into(),
hex!("a5abc21ac95ae63dd6e61e5bec263ab46d1efe16d3dcc085d0de297318cb662d").unchecked_into(),
),
(
hex!("44f3876fe4f653533c65e79461a476b8d6a107fb71b6ec0f3485bb53b4e7b842").unchecked_into(),
hex!("281be34a71b661b257153e1145522fd0820cfff6a3601b40e7f85d3bc155240d").unchecked_into(),
),
]
}

pub fn testnet_root() -> AccountId {
hex!("baa78c7154c7f82d6d377177e20bcab65d327eca0086513f9964f5a0f6bdad56").into()
/// Helper function to generate an account ID from seed
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}

pub fn development_config() -> Result<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;

pub fn development_config(id: ParaId) -> Result<ChainSpec, String> {
Ok(ChainSpec::from_genesis(
"Development",
"dev",
ChainType::Development,
move || testnet_genesis(
wasm_binary,
vec![
authority_keys_from_seed("Alice"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
],
id,
true,
),
vec![],
None,
None,
None,
None,
Extensions {
relay_chain: "rococo-dev".into(),
para_id: id.into(),
},
))
}

pub fn testnet_config() -> Result<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;

Ok(ChainSpec::from_genesis(
"Canvas Testnet 1",
"canvas_testnet1",
ChainType::Live,
move || testnet_genesis(
wasm_binary,
testnet_authorities(),
testnet_root(),
vec![testnet_root()],
true,
),
vec![
"/ip4/35.233.19.96/tcp/30333/p2p/QmNvYhAZSBtahCqCXznYiq8e24Yes1GraPFYCc3DyA5f3z".parse()
.expect("MultiaddrWithPeerId"),
"/ip4/35.205.110.21/tcp/30333/p2p/QmPKFc9B2oeQFc5oxbNsRENwSYibzzafKmcHs9wBZCJH4U".parse()
.expect("MultiaddrWithPeerId"),
],
pub fn local_testnet_config(id: ParaId) -> ChainSpec {
ChainSpec::from_genesis(
// Name
"Local Testnet",
// ID
"local_testnet",
ChainType::Local,
move || {
testnet_genesis(
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
id,
true,
)
},
vec![],
None,
Some("prc"),
None,
None
))
None,
Extensions {
relay_chain: "rococo-local".into(),
para_id: id.into(),
},
)
}

fn testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(AuraId, GrandpaId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
parachain_id: ParaId,
enable_println: bool
) -> GenesisConfig {

GenesisConfig {
frame_system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
code: canvas_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
changes_trie_config: Default::default(),
},
pallet_balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(),
},
pallet_aura: AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
},
pallet_grandpa: GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
balances: endowed_accounts
.iter()
.cloned()
.map(|k|(k, 1 << 60))
.collect(),
},
parachain_info: canvas_runtime::ParachainInfoConfig { parachain_id },
pallet_sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
},
pallet_contracts: ContractsConfig {
// println should only be enabled on development chains
current_schedule: pallet_contracts::Schedule::default()
.enable_println(enable_println),
current_schedule: pallet_contracts::Schedule {
enable_println,
..Default::default()
},
},
}
}
Loading