Skip to content

Commit

Permalink
Merge pull request #15 from hammeWang/master
Browse files Browse the repository at this point in the history
Darwinia POC-1 Testnet
  • Loading branch information
hackfisher authored Jul 1, 2019
2 parents a154e0e + 144a264 commit 8d5c84d
Show file tree
Hide file tree
Showing 72 changed files with 9,848 additions and 8,120 deletions.
3,644 changes: 2,131 additions & 1,513 deletions Cargo.lock

Large diffs are not rendered by default.

117 changes: 52 additions & 65 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,57 +1,42 @@
[dependencies]
error-chain = '0.12'
exit-future = '0.1'
futures = '0.1'
hex-literal = '0.2'
log = '0.4'
parity-codec = '3.3'
parking_lot = '0.7.1'
tokio = '0.1'
trie-root = '0.12.0'
cli = { package = "node-cli", path = "node/cli" }
futures = "0.1"
ctrlc = { version = "3.0", features = ["termination"] }
substrate-cli = { git = 'https://github.com/paritytech/substrate.git' }
substrate-client = { git = 'https://github.com/paritytech/substrate.git' }
substrate-client-db = { git = 'https://github.com/paritytech/substrate.git' }
substrate-consensus-aura = { git = 'https://github.com/paritytech/substrate.git' }
substrate-consensus-babe = { git = 'https://github.com/paritytech/substrate.git' }
substrate-consensus-common = { git = 'https://github.com/paritytech/substrate.git' }
substrate-consensus-rhd = { git = 'https://github.com/paritytech/substrate.git' }
substrate-consensus-slots = { git = 'https://github.com/paritytech/substrate.git' }
substrate-executor = { git = 'https://github.com/paritytech/substrate.git' }
substrate-finality-grandpa = { git = 'https://github.com/paritytech/substrate.git' }
substrate-finality-grandpa-primitives = { git = 'https://github.com/paritytech/substrate.git' }
substrate-inherents = { git = 'https://github.com/paritytech/substrate.git' }
substrate-keyring = { git = 'https://github.com/paritytech/substrate.git' }
substrate-keystore = { git = 'https://github.com/paritytech/substrate.git' }
substrate-network = { git = 'https://github.com/paritytech/substrate.git' }
substrate-panic-handler = { git = 'https://github.com/paritytech/substrate.git' }
substrate-primitives = { git = 'https://github.com/paritytech/substrate.git' }
substrate-rpc = { git = 'https://github.com/paritytech/substrate.git' }
substrate-rpc-servers = { git = 'https://github.com/paritytech/substrate.git' }
substrate-serializer = { git = 'https://github.com/paritytech/substrate.git' }
substrate-service = { git = 'https://github.com/paritytech/substrate.git' }
substrate-service-test = { git = 'https://github.com/paritytech/substrate.git' }
sr-api-macros = { git = 'https://github.com/paritytech/substrate.git' }
sr-io = { git = 'https://github.com/paritytech/substrate.git' }
sr-primitives = { git = 'https://github.com/paritytech/substrate.git' }
sr-sandbox = { git = 'https://github.com/paritytech/substrate.git' }
sr-std = { git = 'https://github.com/paritytech/substrate.git' }
sr-version = { git = 'https://github.com/paritytech/substrate.git' }
substrate-state-machine = { git = 'https://github.com/paritytech/substrate.git' }
substrate-telemetry = { git = 'https://github.com/paritytech/substrate.git' }
substrate-transaction-pool = { git = 'https://github.com/paritytech/substrate.git' }
substrate-transaction-graph = { git = 'https://github.com/paritytech/substrate.git' }
substrate-trie = { git = 'https://github.com/paritytech/substrate.git' }
fork-tree = { git = 'https://github.com/paritytech/substrate.git' }

[dependencies.basic-authorship]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-basic-authorship'

[dependencies.consensus]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-aura'

[dependencies.ctrlc]
features = ['termination']
version = '3.0'

[dependencies.inherents]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-inherents'

[dependencies.network]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-network'

[dependencies.node-template-runtime]
path = 'runtime'

[dependencies.primitives]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives'


[dependencies.substrate-cli]
git = 'https://github.com/paritytech/substrate.git'

[dependencies.substrate-client]
git = 'https://github.com/paritytech/substrate.git'

[dependencies.substrate-executor]
git = 'https://github.com/paritytech/substrate.git'

[dependencies.substrate-service]
git = 'https://github.com/paritytech/substrate.git'

[dependencies.transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-transaction-pool'

[build-dependencies]
vergen = '3'
Expand All @@ -61,27 +46,29 @@ panic = 'unwind'

[[bin]]
name = 'darwinia'
path = 'src/main.rs'
path = 'node/src/main.rs'

[workspace]
members = [
"runtime",
"srml/support",
"srml/token/sdr",
"srml/token/ring",
"srml/token/kton",
"srml/contract",
"node/cli",
"node/executor",
"node/primitives",
"node/runtime",
"node/rpc-client",
"srml/staking",
"srml/token/ring",
"srml/token/kton",
"srml/support",
"srml/aura",
"srml/try",
"srml/staking",
"srml/treasury",
"srml/session",
]
exclude = ["runtime/wasm"]

exclude = ["node/runtime/wasm"]

[package]
authors = ['Parity Technologies <admin@parity.io>']
build = 'build.rs'
edition = '2018'
name = 'node-template'
version = '1.0.0'
name = 'darwinia-poc1'
version = '0.1.0'

81 changes: 50 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,20 @@ Alice should run t his command from ${PATH_TO_DARWINIA_APPCHAIN_ROOT}:
cd {path_to_darwinia_appchain_root}
./target/release/darwinia \
--base-path /tmp/alice \
--chain=local \
--key //Alice \
--port 30333 \
--validator \
--name AliceDarwiniaNode \
--telemetry-url ws://telemetry.polkadot.io:1024 \
--rpc-external \
--ws-external
```
`rpc-external` and `ws-external` flags are optional.

#### Bob Joins In
Now that Alice's node is up and running, Bob can join the network by bootstrapping from her node. His command will look very similar.
```bash
./target/release/darwinia \
--base-path /tmp/bob \
--chain=local \
--key //Bob \
--port 30334 \
--validator \
Expand All @@ -137,43 +135,64 @@ Now that Alice's node is up and running, Bob can join the network by bootstrappi
- How to figure out Alice's Node ID
you can find Alice's node id in terminal outputs when AliceNode starts:
```bash
2019-05-24 16:45:33 Darwinia AppChain
2019-05-24 16:45:33 version 1.0.0-fdf0687-x86_64-macos
2019-05-24 16:45:33 by Evolution Land <hello@evolution.land>, 2017, 2018
2019-05-24 16:45:33 Chain specification: Local Testnet
2019-05-24 16:45:33 Node name: AliceNode
2019-05-24 16:45:33 Roles: AUTHORITY
2019-05-24 16:45:33 Best block: #19
2019-05-24 16:45:33 Using default protocol ID "sup" because none is configured in the chain specs
2019-05-24 16:45:33 Local node identity is: Qmc1RbjHGWGY4E4gkEGbSX3RMcfqbmZwZumga1uNaYQvU5
2019-06-29 18:22:56 Darwinia POC-1 Node
2019-06-29 18:22:56 version 0.1.0-9d2ab05-x86_64-macos
2019-06-29 18:22:56 by Darwinia Network, 2017-2019
2019-06-29 18:22:56 Chain specification: Darwinia POC-1 Testnet
2019-06-29 18:22:56 Node name: alexxxxx
2019-06-29 18:22:56 Roles: AUTHORITY
2019-06-29 18:22:56 Highest known block at #20
2019-06-29 18:22:56 Using default protocol ID "sup" because none is configured in the chain specs
2019-06-29 18:22:56 Local node identity is: QmdSidct8sAvQbMZE7YoU5hk3bPnpmQUN6BCo3Vgd8BZAG
2019-06-29 18:22:56 Libp2p => Random Kademlia query has yielded empty results
2019-06-29 18:22:56 Using authority key 5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu
2019-06-29 18:22:56 Running Grandpa session as Authority 5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu
2019-06-29 18:22:57 Libp2p => Random Kademlia query has yielded empty results
2019-06-29 18:22:59 Libp2p => Random Kademlia query has yielded empty results
2019-06-29 18:23:01 Idle (0 peers), best: #20 (0xd7ab…9164), finalized #20 (0xd7ab…9164), ⬇ 0 ⬆ 0
^C2019-06-29 18:23:03 Libp2p => Random Kademlia query has yielded empty results
```

If all is going well, after a few seconds, the nodes should peer together and start producing blocks. You should see some lines like:
for Alice:
```bash
2019-05-24 16:59:54 Idle (0 peers), best: #45 (0xf5d0…5549), finalized #0 (0xe6fe…6664), ⬇ 0 ⬆ 0
2019-05-24 16:59:54 Discovered external node address: /ip4/192.168.2.185/tcp/30333/p2p/Qmc1RbjHGWGY4E4gkEGbSX3RMcfqbmZwZumga1uNaYQvU5
2019-05-24 16:59:59 Idle (1 peers), best: #45 (0xf5d0…5549), finalized #0 (0xe6fe…6664), ⬇ 0.5kiB/s ⬆ 0.5kiB/s
2019-05-24 17:00:00 Starting consensus session on top of parent 0xf5d07ea0778109602f93c40bc9586e331355e68cfcf3deb1721a65258c545549
2019-05-24 17:00:00 Prepared block for proposing at 46 [hash: 0xc394f4f58614b4bf4ce45ef593b04cce5953eead47e72286d5d288f5f97f9c7d; parent_hash: 0xf5d0…5549; extrinsics: [0xfc6d…480f]]
2019-05-24 17:00:00 Pre-sealed block for proposal at 46. Hash now 0x2b21cf6d11e6978e548abcdc80da20bb7cf6eca8ed352b06464d7e3b43153c40, previously 0xc394f4f58614b4bf4ce45ef593b04cce5953eead47e72286d5d288f5f97f9c7d.
2019-05-24 17:00:00 Imported #46 (0x2b21…3c40)
2019-05-24 17:00:04 Idle (1 peers), best: #46 (0x2b21…3c40), finalized #0 (0xe6fe…6664), ⬇ 15 B/s ⬆ 0.1kiB/s
2019-06-29 18:25:06 Libp2p => Random Kademlia query has yielded empty results
2019-06-29 18:25:08 Idle (0 peers), best: #20 (0xd7ab…9164), finalized #20 (0xd7ab…9164), ⬇ 0 ⬆ 0
2019-06-29 18:25:10 Libp2p => Random Kademlia query has yielded empty results
2019-06-29 18:25:13 Idle (1 peers), best: #20 (0xd7ab…9164), finalized #20 (0xd7ab…9164), ⬇ 0.4kiB/s ⬆ 0.4kiB/s
2019-06-29 18:25:13 Discovered new external address for our node: /ip4/192.168.110.246/tcp/20222/p2p/QmdSidct8sAvQbMZE7YoU5hk3bPnpmQUN6BCo3Vgd8BZAG
2019-06-29 18:25:16 Imported #21 (0x737a…ea93)
2019-06-29 18:25:18 Idle (1 peers), best: #21 (0x737a…ea93), finalized #20 (0xd7ab…9164), ⬇ 1.2kiB/s ⬆ 0.9kiB/s
2019-06-29 18:25:20 Starting consensus session on top of parent 0x737a8e622371b9c33c7ed284ce5ed422b81e7fb02d1397dc1c1676dae5efea93
2019-06-29 18:25:20 Prepared block for proposing at 22 [hash: 0x3d0c8c24c5208432cfe87658b0cfe04db0b9ec0a16d4cd8b2e2cc40e8f03ba6a; parent_hash: 0x737a…ea93; extrinsics: [0x842d…8482, 0xfc43…52da]]
2019-06-29 18:25:20 Pre-sealed block for proposal at 22. Hash now 0x024b81b36f673b2c3338cc4665cb42190b82fc0342dba30b6bc2570080b80d78, previously 0x3d0c8c24c5208432cfe87658b0cfe04db0b9ec0a16d4cd8b2e2cc40e8f03ba6a.
2019-06-29 18:25:20 Imported #22 (0x024b…0d78)
2019-06-29 18:25:23 Idle (1 peers), best: #22 (0x024b…0d78), finalized #22 (0x024b…0d78), ⬇ 1.2kiB/s ⬆ 1.1kiB/s
```
for Bob:
```bash
2019-05-24 16:59:53 Idle (0 peers), best: #45 (0xf5d0…5549), finalized #0 (0xe6fe…6664), ⬇ 0 ⬆ 0
2019-05-24 16:59:54 Discovered external node address: /ip4/192.168.2.185/tcp/30334/p2p/QmPQdzXx95sex3wtrUFPP1oS4AWRHBsbhMnAJmfKJqX5Ly
2019-05-24 16:59:58 Libp2p => Random Kademlia query has yielded empty results
2019-05-24 16:59:58 Idle (1 peers), best: #45 (0xf5d0…5549), finalized #0 (0xe6fe…6664), ⬇ 0.5kiB/s ⬆ 0.5kiB/s
2019-05-24 17:00:00 Imported #46 (0x2b21…3c40)
2019-05-24 17:00:02 Libp2p => Random Kademlia query has yielded empty results
2019-05-24 17:00:03 Idle (1 peers), best: #46 (0x2b21…3c40), finalized #0 (0xe6fe…6664), ⬇ 0.1kiB/s ⬆ 15 B/s
2019-05-24 17:00:08 Idle (1 peers), best: #46 (0x2b21…3c40), finalized #0 (0xe6fe…6664), ⬇ 63 B/s ⬆ 73 B/s
2019-05-24 17:00:10 Starting consensus session on top of parent 0x2b21cf6d11e6978e548abcdc80da20bb7cf6eca8ed352b06464d7e3b43153c40
2019-05-24 17:00:10 Prepared block for proposing at 47 [hash: 0xeba1f1859e37f0761b096e4a33026067a2f36a31ab8a01a503536c8603cacc27; parent_hash: 0x2b21…3c40; extrinsics: [0xc66c…35b9]]
2019-05-24 17:00:10 Pre-sealed block for proposal at 47. Hash now 0xe10a87970b7e4d3014d8faaa995e034cb4427d6fe0958c917f2ab572dc721969, previously 0xeba1f1859e37f0761b096e4a33026067a2f36a31ab8a01a503536c8603cacc27.
2019-06-29 18:25:12 Highest known block at #20
2019-06-29 18:25:12 Using default protocol ID "sup" because none is configured in the chain specs
2019-06-29 18:25:12 Local node identity is: QmRJGKPvX76KZfGGhzUo6xTcb9UM9RwEM19bKqwxBDS5Vp
2019-06-29 18:25:12 Libp2p => Random Kademlia query has yielded empty results
2019-06-29 18:25:12 Unable to bind server to 127.0.0.1:9944. Trying random port.
2019-06-29 18:25:12 Using authority key 5GoNkf6WdbxCFnPdAnYYQyCjAKPJgLNxXwPjwTh6DGg6gN3E
2019-06-29 18:25:12 Running Grandpa session as Authority 5GoNkf6WdbxCFnPdAnYYQyCjAKPJgLNxXwPjwTh6DGg6gN3E
2019-06-29 18:25:13 Discovered new external address for our node: /ip4/192.168.110.246/tcp/20223/p2p/QmRJGKPvX76KZfGGhzUo6xTcb9UM9RwEM19bKqwxBDS5Vp
2019-06-29 18:25:16 Starting consensus session on top of parent 0xd7ab506dd6e388e8ccfcb62c6e64689be0a26fa1a0cfc4027d05c32d55a79164
2019-06-29 18:25:16 Prepared block for proposing at 21 [hash: 0x5e2f5d1ea92bd60087fd30f20a5917d1ca60ec5d5d32190f752bcf2f826c3a5c; parent_hash: 0xd7ab…9164; extrinsics: [0x977d…1cc9, 0x73e9…bfed]]
2019-06-29 18:25:16 Pre-sealed block for proposal at 21. Hash now 0x737a8e622371b9c33c7ed284ce5ed422b81e7fb02d1397dc1c1676dae5efea93, previously 0x5e2f5d1ea92bd60087fd30f20a5917d1ca60ec5d5d32190f752bcf2f826c3a5c.
2019-06-29 18:25:16 Imported #21 (0x737a…ea93)
2019-06-29 18:25:17 Idle (1 peers), best: #21 (0x737a…ea93), finalized #20 (0xd7ab…9164), ⬇ 1.4kiB/s ⬆ 1.7kiB/s
2019-06-29 18:25:20 Imported #22 (0x024b…0d78)
2019-06-29 18:25:22 Idle (1 peers), best: #22 (0x024b…0d78), finalized #22 (0x024b…0d78), ⬇ 1.0kiB/s ⬆ 1.1kiB/s
2019-06-29 18:25:24 Starting consensus session on top of parent 0x024b81b36f673b2c3338cc4665cb42190b82fc0342dba30b6bc2570080b80d78
2019-06-29 18:25:24 Prepared block for proposing at 23 [hash: 0x8947ad3cebd65d9de60166743eae1dd198cb10751764faefba6c71be8d5ccf5f; parent_hash: 0x024b…0d78; extrinsics: [0x5b14…3439, 0xec49…f2f5]]
2019-06-29 18:25:24 Pre-sealed block for proposal at 23. Hash now 0xcd96f0558e8c2f2a38e680f2eb280ccbb1422f6df3bc3dfa306ef89c943f8a05, previously 0x8947ad3cebd65d9de60166743eae1dd198cb10751764faefba6c71be8d5ccf5f.
2019-06-29 18:25:24 Imported #23 (0xcd96…8a05)
2019-06-29 18:25:27 Idle (1 peers), best: #23 (0xcd96…8a05), finalized #23 (0xcd96…8a05), ⬇ 1.0kiB/s ⬆ 1.1kiB/s
2019-06-29 18:25:28 Imported #24 (0xe4b1…e584)
```
The first line shows that Bob has discovered Alice on the network. The second shows that he has peered with her (1 peers), they have produced a block (best: #1 (0xf5d0…5549)), and the block is not finalized (finalized #0 (0xe6fe…6664)).
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ normal=$(tput sgr0)
# Save current directory.
pushd . >/dev/null

for SRC in runtime/wasm
for SRC in node/runtime/wasm
do
echo "${bold}Building webassembly binary in $SRC...${normal}"
cd "$PROJECT_ROOT/$SRC"
Expand Down
49 changes: 49 additions & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
name = "node-cli"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Substrate node implementation in Rust."
build = "build.rs"
edition = "2018"

[dependencies]
log = "0.4"
tokio = "0.1.7"
futures = "0.1"
exit-future = "0.1"
cli = { package = "substrate-cli", git = 'https://github.com/paritytech/substrate.git' }
parity-codec = { version = "3.3" }
sr-io = { git = 'https://github.com/paritytech/substrate.git' }
client = { package = "substrate-client", git = 'https://github.com/paritytech/substrate.git' }
primitives = { package = "substrate-primitives", git = 'https://github.com/paritytech/substrate.git' }
inherents = { package = "substrate-inherents", git = 'https://github.com/paritytech/substrate.git' }
node-runtime = { path = "../runtime" }
node-primitives = { path = "../primitives" }
hex-literal = "0.2"
substrate-basic-authorship = { git = 'https://github.com/paritytech/substrate.git' }
substrate-service = { git = 'https://github.com/paritytech/substrate.git' }
transaction_pool = { package = "substrate-transaction-pool", git = 'https://github.com/paritytech/substrate.git' }
network = { package = "substrate-network", git = 'https://github.com/paritytech/substrate.git' }
consensus = { package = "substrate-consensus-aura", git = 'https://github.com/paritytech/substrate.git' }
grandpa = { package = "substrate-finality-grandpa", git = 'https://github.com/paritytech/substrate.git' }
sr-primitives = { git = 'https://github.com/paritytech/substrate.git' }
aura_primitives = { package = "substrate-consensus-aura-primitives", git = 'https://github.com/paritytech/substrate.git' }
node-executor = { path = "../executor" }
substrate-keystore = { git = 'https://github.com/paritytech/substrate.git' }
substrate-telemetry = { package = "substrate-telemetry", git = 'https://github.com/paritytech/substrate.git' }
structopt = "0.2"
transaction-factory = { git = 'https://github.com/paritytech/substrate.git' }
keyring = { package = "substrate-keyring", git = 'https://github.com/paritytech/substrate.git' }
indices = { package = "srml-indices", git = 'https://github.com/paritytech/substrate.git' }
timestamp = { package = "srml-timestamp", git = 'https://github.com/paritytech/substrate.git', default-features = false }
rand = "0.6"
finality_tracker = { package = "srml-finality-tracker", git = 'https://github.com/paritytech/substrate.git', default-features = false }
srml-support = { git = 'https://github.com/paritytech/substrate.git', default-features = false }

[dev-dependencies]
consensus-common = { package = "substrate-consensus-common", git = 'https://github.com/paritytech/substrate.git' }
service-test = { package = "substrate-service-test", git = 'https://github.com/paritytech/substrate.git' }

[build-dependencies]
cli = { package = "substrate-cli", git = 'https://github.com/paritytech/substrate.git'}
structopt = "0.2"
50 changes: 50 additions & 0 deletions node/cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.

// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use cli::{NoCustom, CoreParams};

use std::{fs, env, path::Path};

use structopt::{StructOpt, clap::Shell};

fn main() {
build_shell_completion();
}

/// Build shell completion scripts for all known shells
/// Full list in https://github.com/kbknapp/clap-rs/blob/e9d0562a1dc5dfe731ed7c767e6cee0af08f0cf9/src/app/parser.rs#L123
fn build_shell_completion() {
for shell in &[Shell::Bash, Shell::Fish, Shell::Zsh, Shell::Elvish, Shell::PowerShell] {
build_completion(shell);
}
}

/// Build the shell auto-completion for a given Shell
fn build_completion(shell: &Shell) {
let outdir = match env::var_os("OUT_DIR") {
None => return,
Some(dir) => dir,
};
let path = Path::new(&outdir)
.parent().unwrap()
.parent().unwrap()
.parent().unwrap()
.join("completion-scripts");

fs::create_dir(&path).ok();

CoreParams::<NoCustom, NoCustom>::clap().gen_completions("substrate-node", *shell, &path);
}
Loading

0 comments on commit 8d5c84d

Please sign in to comment.