Skip to content

Commit

Permalink
Combine standalone and parachain node (#204)
Browse files Browse the repository at this point in the history
* basic idea

* prune stray commetn

* prune stadalone node

* Restructure directories

* missed a few

* cargo fmt

* Update node/src/dev_service.rs

Co-authored-by: nanocryk <6422796+nanocryk@users.noreply.github.com>

* Reduce CI

* fix broken links

* Sketch ideas for mocking the validation data inherent

* move file to right place

* getting closer

* trie root

* persisted vd

* transient vd

* mock inherent makes it to the runtime but isn't valid.

* Make it work!! (lots of hack'n'slash to be cleaned up still)

* Move rpc module back into node directory

* prune standalone dockerfile

* Remove standalone feature from runtime.

There is truly only one runtime now.

* cargo fmt

* unit struct

* inherents.rs file

* cleanup mock timestamp provider

* line length

* properly import sproof builder

* cargo fmt

* proper development config

* spec function docs

* update README

* default author in --dev mode

* Update node/src/command.rs

Co-authored-by: Stephen Shelton <steve@brewcraft.org>

* wire tests back together

* Update node/src/inherents.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Update node/src/inherents.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Fixes test for unified binaries

* Update node/src/inherents.rs

* single `mock` parameter

* ughh cargo fmt

* runtime version to match master

* line length

and less focused test

* prettier

Co-authored-by: nanocryk <6422796+nanocryk@users.noreply.github.com>
Co-authored-by: Stephen Shelton <steve@brewcraft.org>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Crystalin <alan@purestake.com>
  • Loading branch information
5 people authored Feb 1, 2021
1 parent 7ffc7f3 commit 1a8a62b
Show file tree
Hide file tree
Showing 33 changed files with 588 additions and 10,784 deletions.
88 changes: 3 additions & 85 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ jobs:
echo "::set-output name=rustc::$(rustc --version)"
- name: Build Parachain Node
run: cargo build --release --verbose --all
- name: Build Standalone Node
run: |
cd node/standalone
cargo build --release --verbose --all
# We determine whether there are unmodified Cargo.lock files by:
# 1. Asking git for a list of all modified files
# 2. Using grep to reduce the list to only Cargo.lock files
Expand All @@ -195,9 +191,9 @@ jobs:
git diff-index --name-only HEAD | grep Cargo.lock
false
fi
- name: Run tests
- name: Unit tests
run: cargo test --release --verbose --all
- name: Typescript tests (against standalone node)
- name: Typescript integration tests (against dev service)
run: |
cd moonbeam-types-bundle
npm install
Expand All @@ -207,19 +203,12 @@ jobs:
- name: Save parachain binary
run: |
mkdir -p build/alphanet
mkdir -p build/standalone
cp target/release/moonbase-alphanet build/alphanet/moonbase-alphanet;
cp node/standalone/target/release/moonbase-standalone build/standalone/moonbase-standalone;
- name: Upload moonbase-alphanet node
uses: actions/upload-artifact@v2
with:
name: moonbase-alphanet
path: build/alphanet
- name: Upload moonbase-standalone node
uses: actions/upload-artifact@v2
with:
name: moonbase-standalone
path: build/standalone

####### Prepare and Deploy Docker images #######

Expand All @@ -236,7 +225,7 @@ jobs:
path: build/alphanet
- name: Generate specs
run: |
chmod uog+x build/alphanet/moonbase-alphanet
chmod uog+x build/alphanet/moonbase-alphanet
PARACHAIN_BINARY=build/alphanet/moonbase-alphanet scripts/generate-parachain-specs.sh
- name: Upload parachain specs
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -315,77 +304,6 @@ jobs:
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
docker-standalone:
runs-on: self-hosted
needs: ["build"]
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: moonbase-standalone
path: build/standalone
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=purestake/moonbase
VERSION=noop
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
elif [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
driver-opts: |
image=moby/buildkit:master
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push standalone node
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/moonbase-standalone.Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
####### Prepare the release draft #######

publish-draft-release:
Expand Down
50 changes: 17 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
[workspace]
members = [
'runtime',
'node/parachain',
'client/rpc/txpool',
'client/rpc-core/txpool',
# We do NOT include the standalone node in this main workspace because it builds the
# runtime with the `standalone` feature, which the parachain does not support.
'node',
]

[profile.release]
Expand Down
73 changes: 24 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,14 @@ Install Substrate pre-requisites (including Rust):
curl https://getsubstrate.io -sSf | bash -s -- --fast
```

Run the initialization script, which checks the correct rust nightly version and adds the WASM to
that specific version:
Run the initialization script, which checks the correct rust nightly version and adds the
`wasm32-unknown-unknown` target to that specific version:

```bash
./scripts/init.sh
```

## Build Standalone

Build the corresponding binary file:

```bash
cd node/standalone
cargo build --release
```

## Build Parachain
## Build the Moonbeam Node

Build the corresponding binary file:

Expand All @@ -53,50 +44,49 @@ cargo build --release

The first build takes a long time, as it compiles all the necessary libraries.

### Troubleshooting

If a _cargo not found_ error appears in the terminal, manually add Rust to your system path (or
> If a _cargo not found_ error appears in the terminal, manually add Rust to your system path (or
restart your system):
>
> ```bash
> source $HOME/.cargo/env
> ```
```bash
source $HOME/.cargo/env
```
## Run a Development Node
## Run
Moonbeam is designed to be a parachain on the Polkadot network. For testing your
contracts locally, spinning up a full relay-para network is a lot of overhead.
### Standalone Node in dev mode
A simpler solution is to run the `--dev` node, a simple node that is not backed
by any relay chain, but still runs the Moonbeam runtime logic.
```bash
./node/standalone/target/release/moonbase-standalone --dev
./target/release/moonbase-standalone --dev
```
## Docker image
### Docker image

### Standlone node

An alternative to the steps higlighted before is to use docker to run a pre-build binary. Doing so, you prevent having to install Substrate and all the dependencies, and you can skip the building the node process as well. The only requirement is to have Docker installed, and then you can execute the following command to download the corresponding image:
An alternative to building locally is to use docker to run a pre-build binary.
The only requirement is to have Docker installed.

```bash
docker pull purestake/moonbase:tutorial-v3
```

Once the Docker image is downloaded, you can run it with the following line:
# Pull the docker image
docker pull purestake/moonbase-parachain-testnet:latest

```bash
docker run --rm --name moonbeam_standalone --network host purestake/moonbase:tutorial-v3 /moonbase/moonbase-standalone --dev
# Start a dev node
docker run --rm --network host purestake/moonbase /moonbase/moonbase-standalone --dev
```

## Chain IDs

The ethereum specification described a numeric Chain Id. The Moonbeam mainnet Chain Id will be 1284
The Ethereum specification described a numeric Chain Id. The Moonbeam mainnet Chain Id will be 1284
because it takes 1284 milliseconds for a moonbeam to reach Earth.

Moonbeam nodes support multiple public chains and testnets, with the following Chain Ids.

| Network Description | Chain ID |
| ---------------------------------- | ----------- |
| Local Parachain TestNet | 1280 |
| Local Standalone TestNet | 1281 |
| Local Development TestNet | 1281 |
| Reserved for other TestNets | 1282 - 1283 |
| Moonbeam (Polkadot) | 1284 |
| Moonriver (Kusama) | 1285 |
Expand All @@ -106,8 +96,7 @@ Moonbeam nodes support multiple public chains and testnets, with the following C

## Runtime Architecture

The Moonbeam Runtime is built using FRAME and consists of several core pallets, as well as a few
pallets that are only present conditionally. The core pallets are:
The Moonbeam Runtime is built using FRAME and consists of several pallets.

- _Balances_: Tracks GLMR token balances
- _Sudo_: Allows a privledged acocunt to make arbitrary runtime changes - will be removed before
Expand All @@ -119,22 +108,8 @@ pallets that are only present conditionally. The core pallets are:
- _Transaction Payment_: Transaction payment (fee) management
- _Randomness Collective Flip_: A (mock) onchain randomness beacon. Will be replaced by parachain
randomness by mainnet.

### Parachain

In addition to the core pallets above, the parachain node also features

- _ParachainUpgrade_: A helper to perform runtime upgrades on parachains
- _MessageBroker_: A helper to receive incoming XCPM messages
- _ParachainInfo_: A place to store parachain-relevant constants like parachain id
- _TokenDealer_: A helper for accepting incoming cross-chain asset transfers

### Standalone

In addition to the core pallets above, the standalone node also features

- _Aura_: Slot-based Authority Consensus
- _Grandpa_: GRANDPA Authority consensus (This will be removed once it becomes a parachain)

## Tests

Expand Down
Loading

0 comments on commit 1a8a62b

Please sign in to comment.