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

Update to Substrate master and Parachains V1 #102

Merged
merged 79 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
81cc6ef
initial dependency updates
JoshOrndorff Nov 9, 2020
bfef481
standalone runtime checks
JoshOrndorff Nov 9, 2020
b34fd85
parachain runtime checks
JoshOrndorff Nov 9, 2020
86e8ee6
standalone node compiles
JoshOrndorff Nov 9, 2020
55a4f3d
take frontier branch from purestake fork
JoshOrndorff Nov 9, 2020
04042b2
progress toward parachain node
JoshOrndorff Nov 10, 2020
177c752
parachain node compiles
JoshOrndorff Nov 10, 2020
87d73ca
Add spec for parachain relay (#108)
crystalin Nov 11, 2020
c814829
Update to slightly newer cumulus
JoshOrndorff Nov 11, 2020
55d671d
Adds polkadot relay dockerfile
Nov 19, 2020
21ee04c
try to fix standalone node
JoshOrndorff Nov 20, 2020
5b351d2
temporarily disable cache
JoshOrndorff Nov 20, 2020
2901c70
attempt to merge master
JoshOrndorff Nov 29, 2020
2c8e623
start fixing merge; Need a custom frontier branch that points to corr…
JoshOrndorff Nov 29, 2020
b2dba22
Cargo happy, now make it compile.
JoshOrndorff Nov 29, 2020
bdb5f63
Runtime builds, substrate and polkadot versions don't match cumulus repo
JoshOrndorff Nov 29, 2020
d531d88
Progress toward making node compile
JoshOrndorff Nov 29, 2020
45c309b
Change Substrate dep to match cumulus; Polkadot is still mismatched
JoshOrndorff Nov 29, 2020
c9f41ca
Parachain compiles
JoshOrndorff Nov 29, 2020
be0130c
Change Polkadot dep to match cumulus
JoshOrndorff Nov 30, 2020
2bfda27
Find a rust version that works with both polkadot and frontier.
JoshOrndorff Nov 30, 2020
f82c43a
clean unused import
JoshOrndorff Nov 30, 2020
f712d8d
standalone dependencies
JoshOrndorff Nov 30, 2020
63b913c
standalone node compiles
JoshOrndorff Nov 30, 2020
646f265
comment cleanup
JoshOrndorff Nov 30, 2020
f298f24
Fix block tests
JoshOrndorff Nov 30, 2020
54b59cc
fix revert receipt tests
JoshOrndorff Nov 30, 2020
8928057
fix subscription tests
JoshOrndorff Nov 30, 2020
79469fb
Remove outdated refcount type, thus fixing balance test
JoshOrndorff Nov 30, 2020
37ec7f4
linting: line length
JoshOrndorff Nov 30, 2020
8194106
comma mistake
JoshOrndorff Nov 30, 2020
9fc22ba
format revert tests
JoshOrndorff Nov 30, 2020
affe4f2
remove commented code
JoshOrndorff Nov 30, 2020
e928b87
unused import
JoshOrndorff Nov 30, 2020
ebe3d04
remove commented prefix code
JoshOrndorff Nov 30, 2020
de33866
remove incorrect and outdated comment
JoshOrndorff Nov 30, 2020
22f3cdc
reformat for consistency and nicer diff
JoshOrndorff Nov 30, 2020
3b2d5d5
use default bogud support url rather than cumulus.
JoshOrndorff Nov 30, 2020
69872bf
Merge branch 'crystalin-add-relay-docker' into joshy-parachains-v1
JoshOrndorff Nov 30, 2020
03f3aeb
hack on dockerfile
JoshOrndorff Nov 30, 2020
f513f59
cd into dir before checking out specific commit
JoshOrndorff Nov 30, 2020
122fd64
Improve polkadot relay build process
Nov 30, 2020
698a002
Merge branch 'joshy-parachains-v1' of github.com:purestake/moonbeam i…
Nov 30, 2020
4b93f0d
WIP update substrate
JoshOrndorff Dec 3, 2020
250df1c
improve gitignore
JoshOrndorff Dec 3, 2020
69f71c3
finish upgrade
JoshOrndorff Dec 3, 2020
4782196
Actually include updated subcommands
JoshOrndorff Dec 3, 2020
929dd42
Updates parachain registration script to v1
Dec 4, 2020
69fc384
Updates registration script to parachain v1
Dec 4, 2020
34c20eb
Merge branch 'joshy-parachains-v1' of github.com:purestake/moonbeam i…
Dec 4, 2020
91ae3d6
Types are included by default
JoshOrndorff Dec 4, 2020
c77556b
another addition to gitignore
JoshOrndorff Dec 4, 2020
5cb4aa0
Draft launch notes
JoshOrndorff Dec 4, 2020
36b6b87
Note about open issue in polkadot
JoshOrndorff Dec 4, 2020
cd51250
add details about `ran out of wasm instances`
JoshOrndorff Dec 6, 2020
3b0cf1f
Add details about session keys
JoshOrndorff Dec 6, 2020
709e111
Bump standalone deps to fix build
JoshOrndorff Dec 6, 2020
c9e9074
Format register script to fix line length
JoshOrndorff Dec 6, 2020
6a00eab
master.into()
JoshOrndorff Dec 6, 2020
6aee5e4
bump spec versions
JoshOrndorff Dec 7, 2020
e4e15ea
Update dependencies
JoshOrndorff Dec 7, 2020
07ddeaa
Switch to correct frontier branch
JoshOrndorff Dec 7, 2020
de5af18
Include drop in EthApi replacement in repo
JoshOrndorff Dec 7, 2020
a4d257b
wire in EthApi replacement
JoshOrndorff Dec 7, 2020
68599a4
Update commit hashes in launch notes
JoshOrndorff Dec 7, 2020
ed011ed
Improves polkadot relay dockerimage
Dec 8, 2020
1fcfdb8
Revert changes t ogitignore
JoshOrndorff Dec 8, 2020
9d7a22c
Prune some unnecessary, and potentially harmful, version keys
JoshOrndorff Dec 8, 2020
632072d
Fiddle with Cargo.lock
JoshOrndorff Dec 8, 2020
329dfa0
Change default parachain id to 1000
JoshOrndorff Dec 10, 2020
1fe26f7
Add hotfix for pubsub rpc handler.
JoshOrndorff Dec 10, 2020
7713fdf
Oops, both cargo locks
JoshOrndorff Dec 10, 2020
b1ca760
fix broken support link
JoshOrndorff Dec 10, 2020
304bb42
typo parachain id 100 -> 1000
JoshOrndorff Dec 10, 2020
323005b
Remove some useless comments
JoshOrndorff Dec 10, 2020
7a50f26
Don't support eth signers
JoshOrndorff Dec 10, 2020
3b1b6c9
Update node/rpc/src/lib.rs
JoshOrndorff Dec 10, 2020
850fea2
format commetn
JoshOrndorff Dec 10, 2020
31683d6
this darn comment!
JoshOrndorff Dec 10, 2020
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,865 changes: 2,241 additions & 1,624 deletions Cargo.lock

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions docker/polkadot-relay.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Inspired by Polkadot Dockerfile

FROM phusion/baseimage:0.11 as builder
LABEL maintainer "alan@purestake.com"
LABEL description="This is the build stage for Polkadot. Here we create the binary."

ARG PROFILE=release
ARG POLKADOT_COMMIT=master
RUN echo "Using polkadot ${POLKADOT_COMMIT}"
WORKDIR /

# Install OS dependencies
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y cmake pkg-config libssl-dev git clang

# Grab the Polkadot Code
# TODO how to grab the correct commit from the lock file?
RUN git clone https://github.com/paritytech/polkadot
WORKDIR /polkadot
RUN git checkout ${POLKADOT_COMMIT}

# Download rust dependencies and build the rust binary
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
export PATH=$PATH:$HOME/.cargo/bin && \
scripts/init.sh && \
cargo build --$PROFILE --features=real-overseer

# ===== SECOND STAGE ======

FROM phusion/baseimage:0.11
LABEL maintainer "alan@purestake.com"
LABEL description="Polkadot for Moonbeam Alphanet Relay Chain"
ARG PROFILE=release
COPY --from=builder /polkadot/target/$PROFILE/polkadot /usr/local/bin

RUN mv /usr/share/ca* /tmp && \
rm -rf /usr/share/* && \
mv /tmp/ca-certificates /usr/share/ && \
rm -rf /usr/lib/python* && \
useradd -m -u 1000 -U -s /bin/sh -d /moonbeam moonbeam && \
mkdir -p /moonbeam/.local/share/moonbeam && \
chown -R moonbeam:moonbeam /moonbeam/.local && \
ln -s /moonbeam/.local/share/moonbeam /data && \
rm -rf /usr/bin /usr/sbin

USER moonbeam

# 30333 for p2p traffic
# 9933 for RPC call
# 9944 for Websocket
# 9615 for Prometheus (metrics)
EXPOSE 30333 9933 9944 9615

VOLUME ["/data"]

CMD ["/usr/local/bin/polkadot"]
208 changes: 208 additions & 0 deletions launch-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# Build
JoshOrndorff marked this conversation as resolved.
Show resolved Hide resolved

## Compile Polkadot with the real overseer feature
```bash
git checkout d7257026
cargo build --release --features=real-overseer
./target/release/polkadot --version
```

## Compile Moonbeam
```bash
git checkout a4d257b0
cargo build --release
./target/release/moonbase-alphanet --version
```

# Launch Relay

## Validator Keys

Determining what session keys are needed requires looking at the code in a few places.
* Rococo Session Key Definition - https://github.com/paritytech/polkadot/blob/master/runtime/rococo/src/lib.rs#L148-L152
* Substrate Session key codes - https://github.com/paritytech/substrate/blob/master/primitives/core/src/crypto.rs#L1085
* Polkadot Session key codes - https://github.com/paritytech/polkadot/blob/master/primitives/src/v0.rs#L71
* Upcoming (but not currently used) Polkadot session keys - https://github.com/paritytech/polkadot/blob/master/primitives/src/v1.rs#L62-L83
* Observation: We don't need session keys for "acco" and "stak", but they were in the old validator script.

```bash
# Generate a key and note the mnemonic
./polkadot-d7257026-real-overseer key generate
```

For this write up I'll be using these example keys.

### Alfie
```bash
# SR25519 - most keys
$ ./polkadot-d7257026-real-overseer key inspect-key --scheme sr25519 "rail order express dynamic sketch tip mask double cave medal guitar between"
Secret phrase `rail order express dynamic sketch tip mask double cave medal guitar between` is account:
Secret seed: 0xb7c888bf9f01da9a2cb5805d6d6ada744ed22d8a24aa41c509a26268ec701461
Public key (hex): 0xc0671bd602df3430ea648f52baef5068f1082ce03e6563677255d163220ddd42
Account ID: 0xc0671bd602df3430ea648f52baef5068f1082ce03e6563677255d163220ddd42
SS58 Address: 5GQygSBSa7BjEeYiE41Q7uFNMUVfMEuU3bjtPmjZQBUEvgjn

# ED25519 - grandpa
$ ./polkadot-d7257026-real-overseer key inspect-key --scheme ed25519 "rail order express dynamic sketch tip mask double cave medal guitar between"
Secret phrase `rail order express dynamic sketch tip mask double cave medal guitar between` is account:
Secret seed: 0xb7c888bf9f01da9a2cb5805d6d6ada744ed22d8a24aa41c509a26268ec701461
Public key (hex): 0x9a35999189aeac73680dbccc89b18335a545f62045a54c9225105a428976cc16
Account ID: 0x9a35999189aeac73680dbccc89b18335a545f62045a54c9225105a428976cc16
SS58 Address: 5FYu9sxGFZ15SapDCUJiJy8JXFCDBLv56iLrWrEDeT6BfybQ

```

### Bet
```bash
# SR25519 - most keys
$ ./polkadot-d7257026-real-overseer key inspect-key --scheme sr25519 "planet ill puzzle mirror fog system admit genre subject dance aim limit"
Secret phrase `planet ill puzzle mirror fog system admit genre subject dance aim limit` is account:
Secret seed: 0xa7854968eaa257ed5e87b3dc765feca8e7dadf5322b2d04e6ba60e080164da15
Public key (hex): 0x80d42ee5b73818f4cf65d9a4cbe87c990c83af82c9baceb565d85d0f2a3e4807
Account ID: 0x80d42ee5b73818f4cf65d9a4cbe87c990c83af82c9baceb565d85d0f2a3e4807
SS58 Address: 5Eyd1zj8BSFaAt66y152neBFhZTaQ1TJNoxZYdYkXqqXRf1X

# ED25519 - grandpa
$ ./polkadot-d7257026-real-overseer key inspect-key --scheme ed25519 "planet ill puzzle mirror fog system admit genre subject dance aim limit"
Secret phrase `planet ill puzzle mirror fog system admit genre subject dance aim limit` is account:
Secret seed: 0xa7854968eaa257ed5e87b3dc765feca8e7dadf5322b2d04e6ba60e080164da15
Public key (hex): 0xbd8d705b2742bb237d662b0a60414c9d7cef8f9407f816dac0912cac6b933f13
Account ID: 0xbd8d705b2742bb237d662b0a60414c9d7cef8f9407f816dac0912cac6b933f13
SS58 Address: 5GMEvWtt8CyxRwZeRAuxDy2rmuzsZAuwCochbHCkQVv1Mfev
```

Insert Alfie's session keys
```bash
./polkadot-d7257026-real-overseer key insert --keystore-path ./alfie/chains/rococo_local_testnet/keystore --base-path alfie --suri "rail order express dynamic sketch tip mask double cave medal guitar between" --key-type gran --scheme ed25519 && \
./polkadot-d7257026-real-overseer key insert --keystore-path ./alfie/chains/rococo_local_testnet/keystore --base-path alfie --suri "rail order express dynamic sketch tip mask double cave medal guitar between" --key-type babe && \
./polkadot-d7257026-real-overseer key insert --keystore-path ./alfie/chains/rococo_local_testnet/keystore --base-path alfie --suri "rail order express dynamic sketch tip mask double cave medal guitar between" --key-type imon && \
./polkadot-d7257026-real-overseer key insert --keystore-path ./alfie/chains/rococo_local_testnet/keystore --base-path alfie --suri "rail order express dynamic sketch tip mask double cave medal guitar between" --key-type para && \
./polkadot-d7257026-real-overseer key insert --keystore-path ./alfie/chains/rococo_local_testnet/keystore --base-path alfie --suri "rail order express dynamic sketch tip mask double cave medal guitar between" --key-type audi

#TODO Should we use different derivation paths for each keypair like Telmo recommended? Probably. But NOT for stash or controller. Session keys are HOT keys.
```

Repeat similarly for Bet
```bash
./polkadot-d7257026-real-overseer key insert --keystore-path ./bet/chains/rococo_local_testnet/keystore --base-path bet --suri "planet ill puzzle mirror fog system admit genre subject dance aim limit" --key-type gran --scheme ed25519 && \
./polkadot-d7257026-real-overseer key insert --keystore-path ./bet/chains/rococo_local_testnet/keystore --base-path bet --suri "planet ill puzzle mirror fog system admit genre subject dance aim limit" --key-type babe && \
./polkadot-d7257026-real-overseer key insert --keystore-path ./bet/chains/rococo_local_testnet/keystore --base-path bet --suri "planet ill puzzle mirror fog system admit genre subject dance aim limit" --key-type imon && \
./polkadot-d7257026-real-overseer key insert --keystore-path ./bet/chains/rococo_local_testnet/keystore --base-path bet --suri "planet ill puzzle mirror fog system admit genre subject dance aim limit" --key-type para && \
./polkadot-d7257026-real-overseer key insert --keystore-path ./bet/chains/rococo_local_testnet/keystore --base-path bet --suri "planet ill puzzle mirror fog system admit genre subject dance aim limit" --key-type audi
```

`polkadot key insert` was unintuitive to me for several reasons. I've reported these in https://github.com/paritytech/polkadot/issues/2072
* Specifying `--chain` doesn't seem to have any effect.
* Specifying `--base-path` alone "works" but puts the keys in the wrong place.
* Sepcifying `--keystore-path` alone complains that `--base-path` is not specified.

## Chain Spec

Rococo local is known to throw the warning `💸 Chain does not have enough staking candidates to operate. Era Some(0)`. This is normal and harmless.

```bash
./polkadot-d7257026-real-overseer build-spec --chain rococo-local --disable-default-bootnode > rococo-local-d7257026-real-overseer.json
```

Insert the custom session keys like so in the chain spec. (TODO as I mentioned above, we should eventually use different offline keys for stash and controller.)

```json
"palletSession": {
"keys": [
[
"5GQygSBSa7BjEeYiE41Q7uFNMUVfMEuU3bjtPmjZQBUEvgjn",
"5GQygSBSa7BjEeYiE41Q7uFNMUVfMEuU3bjtPmjZQBUEvgjn",
{
"grandpa": "5FYu9sxGFZ15SapDCUJiJy8JXFCDBLv56iLrWrEDeT6BfybQ",
"babe": "5GQygSBSa7BjEeYiE41Q7uFNMUVfMEuU3bjtPmjZQBUEvgjn",
"im_online": "5GQygSBSa7BjEeYiE41Q7uFNMUVfMEuU3bjtPmjZQBUEvgjn",
"parachain_validator": "5GQygSBSa7BjEeYiE41Q7uFNMUVfMEuU3bjtPmjZQBUEvgjn",
"authority_discovery": "5GQygSBSa7BjEeYiE41Q7uFNMUVfMEuU3bjtPmjZQBUEvgjn"
}
],
[
"5Eyd1zj8BSFaAt66y152neBFhZTaQ1TJNoxZYdYkXqqXRf1X",
"5Eyd1zj8BSFaAt66y152neBFhZTaQ1TJNoxZYdYkXqqXRf1X",
{
"grandpa": "5GMEvWtt8CyxRwZeRAuxDy2rmuzsZAuwCochbHCkQVv1Mfev",
"babe": "5Eyd1zj8BSFaAt66y152neBFhZTaQ1TJNoxZYdYkXqqXRf1X",
"im_online": "5Eyd1zj8BSFaAt66y152neBFhZTaQ1TJNoxZYdYkXqqXRf1X",
"parachain_validator": "5Eyd1zj8BSFaAt66y152neBFhZTaQ1TJNoxZYdYkXqqXRf1X",
"authority_discovery": "5Eyd1zj8BSFaAt66y152neBFhZTaQ1TJNoxZYdYkXqqXRf1X"
}
]
]
},
```

Finally, bake a raw spec

```bash
./polkadot-d7257026-real-overseer build-spec --chain rococo-local-d7257026-real-overseer.json --disable-default-bootnode > rococo-local-d7257026-real-overseer-raw.json
```

## Validator Commands

This version of Polkadot is known to throw the warning `Ran out of free WASM instances`. This harmless, and is [issue #2070](https://github.com/paritytech/polkadot/issues/2070) and addressed by [PR #2069](https://github.com/paritytech/polkadot/pull/2069).

```bash
# Alfie
./polkadot-d7257026-real-overseer --chain rococo-local-d7257026-real-overseer-raw.json --validator --base-path ./alfie/

# Bet
./polkadot-d7257026-real-overseer --chain rococo-local-d7257026-real-overseer-raw.json --validator --base-path ./bet/ --port 30334
```

# Launch Parachain

## Export genesis state and wasm

```bash
./target/release/moonbase-alphanet export-genesis-state --parachain-id 200 > genesis-state
./target/release/moonbase-alphanet export-genesis-wasm > genesis-wasm
```

## Launch Collators

Collators don't need session keys yet (They will once we have aura on the parachain). They only differ from each other in port numbers.

```bash
./target/release/moonbase-alphanet --collator --tmp --parachain-id 200 --port 40335 --ws-port 9946 -- --execution wasm --chain ../polkadot/rococo-local-d7257026-real-overseer-raw.json --port 30335
./target/release/moonbase-alphanet --collator --tmp --parachain-id 200 --port 40336 --ws-port 9947 -- --execution wasm --chain ../polkadot/rococo-local-d7257026-real-overseer-raw.json --port 30336
```

## Launch Parachain Full Nodes

Same as the Collators but no `--collator` flag (and different ports)

```bash
./target/release/moonbase-alphanet --tmp --parachain-id 200 --port 40337 --ws-port 9948 -- --execution wasm --chain ../polkadot/rococo-local-d7257026-real-overseer-raw.json --port 30337
./target/release/moonbase-alphanet --tmp --parachain-id 200 --port 40338 --ws-port 9949 -- --execution wasm --chain ../polkadot/rococo-local-d7257026-real-overseer-raw.json --port 30338
```

# Registration Transaction

Here we use the polkadot js tools docker image. The only tag available is `latest` which includes what we need as of 4 Dec 2020. For reference I'm using this image:
```
REPOSITORY TAG IMAGE ID CREATED SIZE
jacogr/polkadot-js-tools latest 755149046430 29 hours ago 664MB
```

The runtime wasm is too large (~1MB) to be passed directly on the CLI. Instead we use the `--parmas` flag introduced in https://github.com/polkadot-js/tools/pull/91. It requires all the params to be in a single space-separated file, so we make that first.

```bash
# Create the file that holds all the parameters
echo -n "200 {\"genesis_head\":\"$(cat genesis-state)\",\"validation_code\":\"" > parachain-config && \
cat genesis-wasm >> parachain-config && \
echo -n "\",\"parachain\":true}" >> parachain-config

# Submit the transaction
docker run --rm --network=host \
-v $(pwd)/parachain-config:/config \
jacogr/polkadot-js-tools:latest api \
--ws "ws://localhost:9944" \
--sudo \
--seed "//Alice" \
--params /config \
tx.parasSudoWrapper.sudoScheduleParaInitialize
```
Loading