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

Combine standalone and parachain node #204

Merged
merged 47 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0ecedb0
basic idea
JoshOrndorff Jan 25, 2021
85b06c4
prune stray commetn
JoshOrndorff Jan 25, 2021
eacd799
prune stadalone node
JoshOrndorff Jan 25, 2021
45b9778
Restructure directories
JoshOrndorff Jan 25, 2021
757640c
missed a few
JoshOrndorff Jan 25, 2021
679548a
cargo fmt
JoshOrndorff Jan 25, 2021
8f5f90b
Update node/src/dev_service.rs
JoshOrndorff Jan 26, 2021
2815230
Reduce CI
JoshOrndorff Jan 26, 2021
0522483
fix broken links
JoshOrndorff Jan 26, 2021
651423b
Sketch ideas for mocking the validation data inherent
JoshOrndorff Jan 26, 2021
1b793b9
move file to right place
JoshOrndorff Jan 26, 2021
5e9961f
getting closer
JoshOrndorff Jan 26, 2021
dda6595
trie root
JoshOrndorff Jan 26, 2021
b1252a9
persisted vd
JoshOrndorff Jan 26, 2021
98ddf37
transient vd
JoshOrndorff Jan 26, 2021
50bb4d1
mock inherent makes it to the runtime but isn't valid.
JoshOrndorff Jan 26, 2021
b6ca327
Make it work!! (lots of hack'n'slash to be cleaned up still)
JoshOrndorff Jan 28, 2021
254860a
Move rpc module back into node directory
JoshOrndorff Jan 28, 2021
b33b191
Merge branch 'master' into joshy-unify-binary
JoshOrndorff Jan 28, 2021
4ac906d
prune standalone dockerfile
JoshOrndorff Jan 28, 2021
f2e2ce3
Remove standalone feature from runtime.
JoshOrndorff Jan 28, 2021
b3d35b4
cargo fmt
JoshOrndorff Jan 28, 2021
bfe259e
unit struct
JoshOrndorff Jan 28, 2021
d82b2e8
inherents.rs file
JoshOrndorff Jan 28, 2021
193bf18
cleanup mock timestamp provider
JoshOrndorff Jan 28, 2021
98a4c61
line length
JoshOrndorff Jan 28, 2021
8980770
Merge branch 'master' into joshy-unify-binary
JoshOrndorff Jan 29, 2021
e475223
properly import sproof builder
JoshOrndorff Jan 29, 2021
f5735e0
cargo fmt
JoshOrndorff Jan 29, 2021
d8c47b9
proper development config
JoshOrndorff Jan 29, 2021
c1a1a93
spec function docs
JoshOrndorff Jan 29, 2021
134c523
update README
JoshOrndorff Jan 29, 2021
996f334
default author in --dev mode
JoshOrndorff Jan 29, 2021
9faf62e
Update node/src/command.rs
JoshOrndorff Jan 29, 2021
b338513
wire tests back together
JoshOrndorff Jan 29, 2021
98153f5
Update node/src/inherents.rs
JoshOrndorff Feb 1, 2021
e271bef
Update node/src/inherents.rs
JoshOrndorff Feb 1, 2021
27d8d55
Fixes test for unified binaries
Feb 1, 2021
b85a418
Update node/src/inherents.rs
JoshOrndorff Feb 1, 2021
f7db282
Merge branch 'crystalin-unify-binary-fix-tests' into joshy-unify-binary
JoshOrndorff Feb 1, 2021
f9abac1
single `mock` parameter
JoshOrndorff Feb 1, 2021
205c4c9
ughh cargo fmt
JoshOrndorff Feb 1, 2021
32790cd
runtime version to match master
JoshOrndorff Feb 1, 2021
a37e8f8
Merge branch 'master' into joshy-unify-binary
JoshOrndorff Feb 1, 2021
d03100b
line length
JoshOrndorff Feb 1, 2021
d42f963
prettier
JoshOrndorff Feb 1, 2021
f68124e
Merge branch 'master' into joshy-unify-binary
JoshOrndorff Feb 1, 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
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