Skip to content

Commit

Permalink
Better testnet instructions in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshOrndorff committed Dec 20, 2023
1 parent a41d030 commit 2136f65
Showing 1 changed file with 66 additions and 2 deletions.
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A Proof of Work blockchain node for use in the Polkadot Blockchain Academy.
It happens to be based on Substrate, but no Substrate knowledge is required.
Students will use this node to start their own network, perform hard and soft forks, and execute smart contracts.

Instructors, planning to host such an activity should see the docs on [setting up a bootnode](./SettingUpTheBootnode.md).
Instructors, planning to host such an activity should see the docs on [setting up a bootnode](./SettingUpTheBootnode.md). TODO Expand that doc into a full guide to running the workshop.

## Building the Node

Expand All @@ -16,6 +16,70 @@ First you will need a [Substrate developer environment](https://docs.substrate.i
1. Cloning this repo
2. Running `cargo build --release`

TODO show how to use `--mining-account-id` to mine to different accounts.

## Run a Single Development Node

You can use a native binary if you built it in the previous section. Otherwise you can use a Docker.

```sh
./target/release/academy-pow --dev
```

### Docker Single Node

If you use docker, you need to map the RPC port and specify `--rpc-external` so that the node listens on `0.0.0.0`. Or something like that....

Networking can be challenging for new Docker users, like me. If you are on linux, you may prefer to use `--network host` which allows the containerized node to operate directly on the local network. Consult the Docker docs for more details.

```sh
docker run -p 9944:9944 ghcr.io/polkadot-blockchain-academy/academy-pow:main --dev --rpc-external
```

## MultiNode Testnet

When using the local networking, you can use the `--discover-local` flag to discover peers on your local network.

```sh
# Start the first node.
# Same as a single node network above.
./target/release/academy-pow --dev --mining-algo keccak

# Start the second node
# Choose a non-default rpc port because the default port is taken by the first node.
./target/release/academy-pow --dev --mining-algo sha3 --rpc-port 9955 --discover-local
```

### Docker Multi Node

With Docker, we can't rely on local peer discovery. Instead, copy the bootnode address from the logs of the first node.
Look for a line like this

```
🏷 Local node identity is: 12D3KooWR2y4tUSpqrPgvSoqfcx9bT8aV2LwHR3BJkWJFTBjZMbZ
```

```sh
# Start the first node.
# Same as a single node network above.
docker run -p 9944:9944 ghcr.io/polkadot-blockchain-academy/academy-pow:main \
--dev \
--mining-algo keccak \
--rpc-external

# Start the second node.
# Publish all exposed ports to RANDOM ports on the host.
# Specify the bootnode address you copied from the first node
docker run --publish-all ghcr.io/polkadot-blockchain-academy/academy-pow:main \
--dev \
--mining-algo sha3 \
--rpc-external \
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWR2y4tUSpqrPgvSoqfcx9bT8aV2LwHR3BJkWJFTBjZMbZ

```

## More Help

This code will be used primarily as an in-class activity that is instructor led, so just wait for details in class.
```sh
academy-pow --help
```

0 comments on commit 2136f65

Please sign in to comment.