mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 21:48:02 +00:00
Adding Bridges code as git subtree. (#2515)
* Add instructions. * Squashed 'bridges/' content from commit 345e84a21 git-subtree-dir: bridges git-subtree-split: 345e84a2146b56628e9888c9f5e129cb40e868a9 * Remove bridges workspace file to avoid confusing Cargo. * Add some bridges primitives to Polkadot workspace. * Improve docs.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# Using Parity Bridges Common dependency (`git subtree`).
|
||||
|
||||
In `./bridges` sub-directory you can find a `git subtree` imported version of:
|
||||
[parity-bridges-common](https://github.com/paritytech/parity-bridges-common/) repository.
|
||||
|
||||
# How to fix broken Bridges code?
|
||||
|
||||
To fix Bridges code simply create a commit in current (`polkadot`) repo. Best if
|
||||
the commit is isolated to changes in `./bridges` sub-directory, because it makes
|
||||
it easier to import that change back to upstream repo.
|
||||
|
||||
# How to pull latest Bridges code or contribute back?
|
||||
|
||||
Note that it's totally fine to ping the Bridges Team to do that for you. The point
|
||||
of adding the code as `git subtree` is to **reduce maintenance cost** for Polkadot
|
||||
developers.
|
||||
|
||||
If you still would like to either update the code to match latest code from the repo
|
||||
or create an upstream PR read below. The following commands should be run in the
|
||||
current (`polkadot`) repo.
|
||||
|
||||
1. Add Bridges repo as a local remote:
|
||||
```
|
||||
$ git remote add -f bridges git@github.com:paritytech/parity-bridges-common.git
|
||||
```
|
||||
|
||||
If you plan to contribute back, consider forking the repository on Github and adding
|
||||
your personal fork as a remote as well.
|
||||
```
|
||||
$ git remote add -f my-bridges git@github.com:tomusdrw/parity-bridges-common.git
|
||||
```
|
||||
|
||||
2. To update Bridges:
|
||||
```
|
||||
$ git fetch bridges master
|
||||
$ git subtree pull --prefix=bridges bridges master --squash
|
||||
````
|
||||
|
||||
We use `--squash` to avoid adding individual commits and rather squashing them
|
||||
all into one.
|
||||
|
||||
3. Contributing back to Bridges (creating upstream PR)
|
||||
```
|
||||
$ git subtree push --prefix=bridges my-bridges master
|
||||
```
|
||||
This command will push changes to your personal fork of Bridges repo, from where
|
||||
you can simply create a PR to the main repo.
|
||||
Generated
+52
@@ -597,6 +597,58 @@ dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bp-kusama"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bp-message-lane",
|
||||
"bp-runtime",
|
||||
"frame-support",
|
||||
"frame-system",
|
||||
"sp-api",
|
||||
"sp-core",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bp-message-lane"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bp-runtime",
|
||||
"frame-support",
|
||||
"frame-system",
|
||||
"parity-scale-codec",
|
||||
"sp-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bp-polkadot"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bp-message-lane",
|
||||
"bp-runtime",
|
||||
"frame-support",
|
||||
"frame-system",
|
||||
"sp-api",
|
||||
"sp-core",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bp-runtime"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"frame-support",
|
||||
"num-traits",
|
||||
"parity-scale-codec",
|
||||
"sp-core",
|
||||
"sp-io",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bs58"
|
||||
version = "0.4.0"
|
||||
|
||||
@@ -26,6 +26,9 @@ tempfile = "3.2.0"
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"bridges/primitives/kusama",
|
||||
"bridges/primitives/polkadot",
|
||||
"bridges/primitives/runtime",
|
||||
"cli",
|
||||
"core-primitives",
|
||||
"erasure-coding",
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
version: 1
|
||||
update_configs:
|
||||
- package_manager: "rust:cargo"
|
||||
directory: "/"
|
||||
update_schedule: "weekly"
|
||||
ignored_updates:
|
||||
- match:
|
||||
dependency_name: "sp-*"
|
||||
- match:
|
||||
dependency_name: "sc-*"
|
||||
- match:
|
||||
dependency_name: "substrate-*"
|
||||
- match:
|
||||
dependency_name: "frame-*"
|
||||
- match:
|
||||
dependency_name: "pallet-*"
|
||||
automerged_updates:
|
||||
- match:
|
||||
update_type: "all"
|
||||
version_requirement_updates: "auto"
|
||||
@@ -0,0 +1 @@
|
||||
**/target/
|
||||
@@ -0,0 +1,16 @@
|
||||
root = true
|
||||
[*]
|
||||
indent_style=tab
|
||||
indent_size=tab
|
||||
tab_width=4
|
||||
end_of_line=lf
|
||||
charset=utf-8
|
||||
trim_trailing_whitespace=true
|
||||
max_line_length=100
|
||||
insert_final_newline=true
|
||||
|
||||
[*.{yml,md,yaml,sh}]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
tab_width=8
|
||||
end_of_line=lf
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
name: Cargo deny
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- v*
|
||||
paths-ignore:
|
||||
- '**/README.md'
|
||||
- diagrams/*
|
||||
- docs/*
|
||||
jobs:
|
||||
cargo-deny:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.4.1
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Checkout sources & submodules
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 5
|
||||
submodules: recursive
|
||||
- name: Cargo deny
|
||||
uses: EmbarkStudios/cargo-deny-action@v1
|
||||
with:
|
||||
command: "check --hide-inclusion-graph"
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
name: Check style
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- v*
|
||||
paths-ignore:
|
||||
- '**/README.md'
|
||||
- diagrams/*
|
||||
- docs/*
|
||||
schedule: # Weekly build
|
||||
- cron: '0 0 * * 0'
|
||||
jobs:
|
||||
## Check stage
|
||||
check-fmt:
|
||||
name: Check RustFmt
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUST_BACKTRACE: full
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.4.1
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Checkout sources & submodules
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 5
|
||||
submodules: recursive
|
||||
- name: Add rustfmt
|
||||
run: rustup component add rustfmt
|
||||
- name: rust-fmt check
|
||||
uses: actions-rs/cargo@master
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
@@ -0,0 +1,49 @@
|
||||
name: Publish Dependencies to Docker hub
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
paths-ignore:
|
||||
- '**/README.md'
|
||||
- diagrams/*
|
||||
- docs/*
|
||||
schedule: # Weekly build
|
||||
- cron: '0 0 * * 0'
|
||||
|
||||
jobs:
|
||||
## Publish to Docker hub
|
||||
publish:
|
||||
name: Publishing
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: docker:git
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.4.1
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Checkout sources & submodules
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 5
|
||||
submodules: recursive
|
||||
- name: Build and push dependencies
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: paritytech/bridge-dependencies
|
||||
dockerfile: deployments/BridgeDeps.Dockerfile
|
||||
tag_with_ref: true
|
||||
tag_with_sha: true
|
||||
labels:
|
||||
org.opencontainers.image.source="https://github.com/paritytech/parity-bridges-common",
|
||||
org.opencontainers.image.authors="devops-team@parity.io",
|
||||
org.opencontainers.image.vendor="Parity Technologies",
|
||||
org.opencontainers.image.url="https://github.com/paritytech/parity-bridges-common",
|
||||
org.opencontainers.image.documentation="https://github.com/paritytech/parity-bridges-common/README.md",
|
||||
org.opencontainers.image.title=${{ matrix.project }},
|
||||
org.opencontainers.image.description="${{ matrix.project }} - component of Parity Bridges Common",
|
||||
org.opencontainers.image.licenses="GPL-3.0 License"
|
||||
add_git_labels: true
|
||||
@@ -0,0 +1,76 @@
|
||||
name: Publish images to Docker hub
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
paths-ignore:
|
||||
- '**/README.md'
|
||||
- diagrams/*
|
||||
- docs/*
|
||||
schedule: # Nightly build
|
||||
- cron: '0 1 * * *'
|
||||
|
||||
jobs:
|
||||
## Publish to Docker hub
|
||||
publish:
|
||||
name: Publishing
|
||||
strategy:
|
||||
matrix:
|
||||
project:
|
||||
- rialto-bridge-node
|
||||
- millau-bridge-node
|
||||
- ethereum-poa-relay
|
||||
- substrate-relay
|
||||
include:
|
||||
- project: rialto-bridge-node
|
||||
healthcheck: http://localhost:9933/health
|
||||
- project: millau-bridge-node
|
||||
healthcheck: http://localhost:9933/health
|
||||
- project: ethereum-poa-relay
|
||||
healthcheck: http://localhost:9616/metrics
|
||||
- project: substrate-relay
|
||||
healthcheck: http://localhost:9616/metrics
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: docker:git
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.4.1
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Checkout sources & submodules
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 5
|
||||
submodules: recursive
|
||||
- name: Set vars
|
||||
id: vars
|
||||
run: |
|
||||
echo ::set-output name=DATE::$(date +%d-%m-%Y)
|
||||
if [[ ${GITHUB_REF} = refs/tags/* ]]
|
||||
then
|
||||
echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
|
||||
else
|
||||
echo ::set-output name=TAG::nightly-$(date +%d-%m-%Y)
|
||||
fi
|
||||
- name: Build and push ${{ matrix.project }}
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: paritytech/${{ matrix.project }}
|
||||
build_args: PROJECT=${{ matrix.project }}, HEALTH=${{ matrix.healthcheck }}
|
||||
tags: ${{ steps.vars.outputs.TAG }}, latest
|
||||
labels:
|
||||
org.opencontainers.image.created=${{ steps.vars.outputs.DATE }},
|
||||
org.opencontainers.image.source="https://github.com/paritytech/parity-bridges-common",
|
||||
org.opencontainers.image.authors="devops-team@parity.io",
|
||||
org.opencontainers.image.vendor="Parity Technologies",
|
||||
org.opencontainers.image.url="https://github.com/paritytech/parity-bridges-common",
|
||||
org.opencontainers.image.documentation="https://github.com/paritytech/parity-bridges-common/README.md",
|
||||
org.opencontainers.image.version=${{ steps.vars.outputs.TAG }},
|
||||
org.opencontainers.image.title=${{ matrix.project }},
|
||||
org.opencontainers.image.description="${{ matrix.project }} - component of Parity Bridges Common",
|
||||
org.opencontainers.image.licenses="GPL-3.0 License"
|
||||
add_git_labels: true
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
name: Compilation and Testing Suite
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- v*
|
||||
paths-ignore:
|
||||
- '**/README.md'
|
||||
- diagrams/*
|
||||
- docs/*
|
||||
schedule: # Weekly build
|
||||
- cron: '0 0 * * 0'
|
||||
jobs:
|
||||
|
||||
## Check Stage
|
||||
check-test:
|
||||
name: Check and test
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
- stable
|
||||
#- beta
|
||||
- nightly
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUST_BACKTRACE: full
|
||||
NIGHTLY: nightly #if necessary, specify the version, nightly-2020-10-04, etc.
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.4.1
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Checkout sources & submodules
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 5
|
||||
submodules: recursive
|
||||
- name: Install Toolchain
|
||||
run: rustup toolchain add $NIGHTLY
|
||||
- name: Add WASM Utilities
|
||||
run: rustup target add wasm32-unknown-unknown --toolchain $NIGHTLY
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v1.2.0
|
||||
- name: Checking rust-${{ matrix.toolchain }}
|
||||
uses: actions-rs/cargo@master
|
||||
with:
|
||||
command: check
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
args: --all --verbose
|
||||
|
||||
## Test Stage
|
||||
- name: Testing rust-${{ matrix.toolchain }}
|
||||
uses: actions-rs/cargo@master
|
||||
if: matrix.toolchain == 'stable'
|
||||
with:
|
||||
command: test
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
args: --all --verbose
|
||||
|
||||
## Check Node Benchmarks
|
||||
- name: Check Rialto benchmarks runtime ${{ matrix.platform }} rust-${{ matrix.toolchain }}
|
||||
uses: actions-rs/cargo@master
|
||||
with:
|
||||
command: check
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
args: --manifest-path ./bin/rialto/node/Cargo.toml --no-default-features --features runtime-benchmarks --verbose
|
||||
- name: Check Millau benchmarks runtime ${{ matrix.platform }} rust-${{ matrix.toolchain }}
|
||||
uses: actions-rs/cargo@master
|
||||
with:
|
||||
command: check
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
args: --manifest-path ./bin/millau/node/Cargo.toml --no-default-features --features runtime-benchmarks --verbose
|
||||
|
||||
## Build Stage
|
||||
build:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
- stable
|
||||
#- beta
|
||||
- nightly
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUST_BACKTRACE: full
|
||||
NIGHTLY: nightly #if necessary, specify the version, nightly-2020-10-04, etc.
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.4.1
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Checkout sources & submodules
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 5
|
||||
submodules: recursive
|
||||
- name: Install Toolchain
|
||||
run: rustup toolchain add $NIGHTLY
|
||||
- name: Add WASM Utilities
|
||||
run: rustup target add wasm32-unknown-unknown --toolchain $NIGHTLY
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v1.2.0
|
||||
- name: Building rust-${{ matrix.toolchain }}
|
||||
uses: actions-rs/cargo@master
|
||||
if: github.ref == 'refs/heads/master'
|
||||
with:
|
||||
command: build
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
args: --all --verbose
|
||||
- name: Prepare artifacts
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
mkdir -p ./artifacts;
|
||||
mv -v target/debug/rialto-bridge-node ./artifacts/;
|
||||
mv -v target/debug/millau-bridge-node ./artifacts/;
|
||||
mv -v target/debug/ethereum-poa-relay ./artifacts/;
|
||||
mv -v target/debug/substrate-relay ./artifacts/;
|
||||
shell: bash
|
||||
- name: Upload artifacts
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: ${{ matrix.toolchain }}.zip
|
||||
path: artifacts/
|
||||
|
||||
## Linting Stage
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUST_BACKTRACE: full
|
||||
NIGHTLY: nightly #if necessary, specify the version, nightly-2020-10-04, etc.
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.4.1
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Checkout sources & submodules
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 5
|
||||
submodules: recursive
|
||||
- name: Install Toolchain
|
||||
run: rustup toolchain add $NIGHTLY
|
||||
- name: Add WASM Utilities
|
||||
run: rustup target add wasm32-unknown-unknown --toolchain $NIGHTLY
|
||||
- name: Add clippy
|
||||
run: rustup component add clippy --toolchain $NIGHTLY
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v1.2.0
|
||||
- name: Clippy
|
||||
uses: actions-rs/cargo@master
|
||||
with:
|
||||
command: clippy
|
||||
toolchain: nightly #if necessary, specify the version, nightly-2020-10-04, etc.
|
||||
args: --all-targets -- -D warnings
|
||||
@@ -0,0 +1,22 @@
|
||||
**/target/
|
||||
**/.env
|
||||
**/.env2
|
||||
**/rust-toolchain
|
||||
|
||||
**/*.rs.bk
|
||||
|
||||
*.o
|
||||
*.so
|
||||
*.rlib
|
||||
*.dll
|
||||
.gdb_history
|
||||
|
||||
*.exe
|
||||
|
||||
.DS_Store
|
||||
|
||||
.idea
|
||||
.vscode
|
||||
*.iml
|
||||
*.swp
|
||||
*.swo
|
||||
@@ -0,0 +1,103 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for {{pallet}}
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}}
|
||||
//! DATE: {{date}}, STEPS: {{cmd.steps}}, REPEAT: {{cmd.repeat}}
|
||||
//! LOW RANGE: {{cmd.lowest_range_values}}, HIGH RANGE: {{cmd.highest_range_values}}
|
||||
//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}
|
||||
//! CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}}
|
||||
|
||||
// Executed Command:
|
||||
{{#each args as |arg|~}}
|
||||
// {{arg}}
|
||||
{{/each}}
|
||||
|
||||
#![allow(clippy::all)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for {{pallet}}.
|
||||
pub trait WeightInfo {
|
||||
{{~#each benchmarks as |benchmark|}}
|
||||
fn {{benchmark.name~}}
|
||||
(
|
||||
{{~#each benchmark.components as |c| ~}}
|
||||
{{c.name}}: u32, {{/each~}}
|
||||
) -> Weight;
|
||||
{{~/each}}
|
||||
}
|
||||
|
||||
/// Weights for {{pallet}} using the Rialto node and recommended hardware.
|
||||
pub struct RialtoWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
||||
{{~#each benchmarks as |benchmark|}}
|
||||
fn {{benchmark.name~}}
|
||||
(
|
||||
{{~#each benchmark.components as |c| ~}}
|
||||
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
|
||||
) -> Weight {
|
||||
({{underscore benchmark.base_weight}} as Weight)
|
||||
{{~#each benchmark.component_weight as |cw|}}
|
||||
.saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))
|
||||
{{~/each}}
|
||||
{{~#if (ne benchmark.base_reads "0")}}
|
||||
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight))
|
||||
{{~/if}}
|
||||
{{~#each benchmark.component_reads as |cr|}}
|
||||
.saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight)))
|
||||
{{~/each}}
|
||||
{{~#if (ne benchmark.base_writes "0")}}
|
||||
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight))
|
||||
{{~/if}}
|
||||
{{~#each benchmark.component_writes as |cw|}}
|
||||
.saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)))
|
||||
{{~/each}}
|
||||
}
|
||||
{{~/each}}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
{{~#each benchmarks as |benchmark|}}
|
||||
fn {{benchmark.name~}}
|
||||
(
|
||||
{{~#each benchmark.components as |c| ~}}
|
||||
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
|
||||
) -> Weight {
|
||||
({{underscore benchmark.base_weight}} as Weight)
|
||||
{{~#each benchmark.component_weight as |cw|}}
|
||||
.saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))
|
||||
{{~/each}}
|
||||
{{~#if (ne benchmark.base_reads "0")}}
|
||||
.saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as Weight))
|
||||
{{~/if}}
|
||||
{{~#each benchmark.component_reads as |cr|}}
|
||||
.saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight)))
|
||||
{{~/each}}
|
||||
{{~#if (ne benchmark.base_writes "0")}}
|
||||
.saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as Weight))
|
||||
{{~/if}}
|
||||
{{~#each benchmark.component_writes as |cw|}}
|
||||
.saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)))
|
||||
{{~/each}}
|
||||
}
|
||||
{{~/each}}
|
||||
}
|
||||
Generated
+9422
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
# Builds images used by the bridge.
|
||||
#
|
||||
# In particular, it can be used to build Substrate nodes and bridge relayers. The binary that gets
|
||||
# built can be specified with the `PROJECT` build-arg. For example, to build the `substrate-relay`
|
||||
# you would do the following:
|
||||
#
|
||||
# `docker build . -t local/substrate-relay --build-arg=PROJECT=substrate-relay`
|
||||
#
|
||||
# See the `deployments/README.md` for all the available `PROJECT` values.
|
||||
|
||||
# This first stage prepares our dependencies to be built by `cargo-chef`.
|
||||
FROM rust as planner
|
||||
WORKDIR /parity-bridges-common
|
||||
RUN cargo install cargo-chef --version 0.1.13
|
||||
COPY . .
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
# This second stage is where the dependencies actually get built.
|
||||
# The reason we split it from the first stage is so that the `COPY . .`
|
||||
# step doesn't blow our cache.
|
||||
FROM paritytech/bridge-dependencies AS cacher
|
||||
WORKDIR /parity-bridges-common
|
||||
RUN cargo install cargo-chef --version 0.1.13
|
||||
|
||||
COPY --from=planner /parity-bridges-common/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
# In this third stage we go ahead and build the actual binary we want.
|
||||
# This should be fairly quick since the dependencies are being built and
|
||||
# cached in the previous stage.
|
||||
FROM paritytech/bridge-dependencies as builder
|
||||
WORKDIR /parity-bridges-common
|
||||
RUN cargo install cargo-chef --version 0.1.13
|
||||
|
||||
COPY . .
|
||||
COPY --from=cacher /parity-bridges-common/target target
|
||||
COPY --from=cacher $CARGO_HOME $CARGO_HOME
|
||||
|
||||
ARG PROJECT=ethereum-poa-relay
|
||||
RUN cargo build --release --verbose -p ${PROJECT}
|
||||
RUN strip ./target/release/${PROJECT}
|
||||
|
||||
# In this final stage we copy over the final binary and do some checks
|
||||
# to make sure that everything looks good.
|
||||
FROM ubuntu:xenial as runtime
|
||||
|
||||
# show backtraces
|
||||
ENV RUST_BACKTRACE 1
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update && \
|
||||
apt-get install -y libssl-dev curl
|
||||
|
||||
RUN groupadd -g 1000 user \
|
||||
&& useradd -u 1000 -g user -s /bin/sh -m user
|
||||
|
||||
# switch to non-root user
|
||||
USER user
|
||||
|
||||
WORKDIR /home/user
|
||||
|
||||
ARG PROJECT=ethereum-poa-relay
|
||||
|
||||
COPY --chown=user:user --from=builder /parity-bridges-common/target/release/${PROJECT} ./
|
||||
COPY --chown=user:user --from=builder /parity-bridges-common/deployments/local-scripts/bridge-entrypoint.sh ./
|
||||
|
||||
# check if executable works in this container
|
||||
RUN ./${PROJECT} --version
|
||||
|
||||
ENV PROJECT=$PROJECT
|
||||
ENTRYPOINT ["/home/user/bridge-entrypoint.sh"]
|
||||
@@ -0,0 +1,675 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
# Parity Bridges Common
|
||||
|
||||
This is a collection of components for building bridges.
|
||||
|
||||
These components include Substrate pallets for syncing headers, passing arbitrary messages, as well
|
||||
as libraries for building relayers to provide cross-chain communication capabilities.
|
||||
|
||||
Three bridge nodes are also available. The nodes can be used to run test networks which bridge other
|
||||
Substrate chains or Ethereum Proof-of-Authority chains.
|
||||
|
||||
🚧 The bridges are currently under construction - a hardhat is recommended beyond this point 🚧
|
||||
|
||||
## Contents
|
||||
- [Installation](#installation)
|
||||
- [High-Level Architecture](#high-level-architecture)
|
||||
- [Project Layout](#project-layout)
|
||||
- [Running the Bridge](#running-the-bridge)
|
||||
- [How to send a message](#how-to-send-a-message)
|
||||
- [Community](#community)
|
||||
|
||||
## Installation
|
||||
To get up and running you need both stable and nightly Rust. Rust nightly is used to build the Web
|
||||
Assembly (WASM) runtime for the node. You can configure the WASM support as so:
|
||||
|
||||
```
|
||||
rustup install nightly
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
||||
```
|
||||
|
||||
Once this is configured you can build and test the repo as follows:
|
||||
|
||||
```
|
||||
git clone https://github.com/paritytech/parity-bridges-common.git
|
||||
cd parity-bridges-common
|
||||
cargo build --all
|
||||
cargo test --all
|
||||
```
|
||||
|
||||
If you need more information about setting up your development environment Substrate's
|
||||
[Getting Started](https://substrate.dev/docs/en/knowledgebase/getting-started/) page is a good
|
||||
resource.
|
||||
|
||||
## High-Level Architecture
|
||||
|
||||
This repo has support for bridging foreign chains together using a combination of Substrate pallets
|
||||
and external processes called relayers. A bridge chain is one that is able to follow the consensus
|
||||
of a foreign chain independently. For example, consider the case below where we want to bridge two
|
||||
Substrate based chains.
|
||||
|
||||
```
|
||||
+---------------+ +---------------+
|
||||
| | | |
|
||||
| Rialto | | Millau |
|
||||
| | | |
|
||||
+-------+-------+ +-------+-------+
|
||||
^ ^
|
||||
| +---------------+ |
|
||||
| | | |
|
||||
+-----> | Bridge Relay | <-------+
|
||||
| |
|
||||
+---------------+
|
||||
```
|
||||
|
||||
The Millau chain must be able to accept Rialto headers and verify their integrity. It does this by
|
||||
using a runtime module designed to track GRANDPA finality. Since two blockchains can't interact
|
||||
directly they need an external service, called a relayer, to communicate. The relayer will subscribe
|
||||
to new Rialto headers via RPC and submit them to the Millau chain for verification.
|
||||
|
||||
Take a look at [Bridge High Level Documentation](./docs/high-level-overview.md) for more in-depth
|
||||
description of the bridge interaction.
|
||||
|
||||
## Project Layout
|
||||
Here's an overview of how the project is laid out. The main bits are the `node`, which is the actual
|
||||
"blockchain", the `modules` which are used to build the blockchain's logic (a.k.a the runtime) and
|
||||
the `relays` which are used to pass messages between chains.
|
||||
|
||||
```
|
||||
├── bin // Node and Runtime for the various Substrate chains
|
||||
│ └── ...
|
||||
├── deployments // Useful tools for deploying test networks
|
||||
│ └── ...
|
||||
├── diagrams // Pretty pictures of the project architecture
|
||||
│ └── ...
|
||||
├── modules // Substrate Runtime Modules (a.k.a Pallets)
|
||||
│ ├── ethereum // Ethereum PoA Header Sync Module
|
||||
│ ├── substrate // Substrate Based Chain Header Sync Module
|
||||
│ ├── message-lane // Cross Chain Message Passing
|
||||
│ └── ...
|
||||
├── primitives // Code shared between modules, runtimes, and relays
|
||||
│ └── ...
|
||||
├── relays // Application for sending headers and messages between chains
|
||||
│ └── ...
|
||||
└── scripts // Useful development and maintenence scripts
|
||||
```
|
||||
|
||||
## Running the Bridge
|
||||
|
||||
To run the Bridge you need to be able to connect the bridge relay node to the RPC interface of nodes
|
||||
on each side of the bridge (source and target chain).
|
||||
|
||||
There are 3 ways to run the bridge, described below:
|
||||
- building & running from source,
|
||||
- building or using Docker images for each individual component,
|
||||
- running a Docker Compose setup (recommended).
|
||||
|
||||
### Using the Source
|
||||
|
||||
First you'll need to build the bridge nodes and relay. This can be done as follows:
|
||||
|
||||
```bash
|
||||
# In `parity-bridges-common` folder
|
||||
cargo build -p rialto-bridge-node
|
||||
cargo build -p millau-bridge-node
|
||||
cargo build -p substrate-relay
|
||||
```
|
||||
|
||||
### Running
|
||||
|
||||
To run a simple dev network you'll can use the scripts located in
|
||||
[the `deployments/local-scripts` folder](./deployments/local-scripts). Since the relayer connects to
|
||||
both Substrate chains it must be run last.
|
||||
|
||||
```bash
|
||||
# In `parity-bridges-common` folder
|
||||
./deployments/local-scripts/run-rialto-bridge-node.sh
|
||||
./deployments/local-scripts/run-millau-bridge-node.sh
|
||||
./deployments/local-scripts/relay-millau-to-rialto.sh
|
||||
```
|
||||
|
||||
At this point you should see the relayer submitting headers from the Millau Substrate chain to the
|
||||
Rialto Substrate chain.
|
||||
|
||||
### Local Docker Setup
|
||||
|
||||
To get up and running quickly you can use published Docker images for the bridge nodes and relayer.
|
||||
The images are published on [Docker Hub](https://hub.docker.com/u/paritytech).
|
||||
|
||||
To run the dev network we first run the two bridge nodes:
|
||||
|
||||
```bash
|
||||
docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 \
|
||||
-it paritytech/rialto-bridge-node --dev --tmp \
|
||||
--rpc-cors=all --unsafe-rpc-external --unsafe-ws-external
|
||||
|
||||
docker run -p 30334:30333 -p 9934:9933 -p 9945:9944 \
|
||||
-it paritytech/millau-bridge-node --dev --tmp \
|
||||
--rpc-cors=all --unsafe-rpc-external --unsafe-ws-external
|
||||
```
|
||||
|
||||
Notice that the `docker run` command will accept all the normal Substrate flags. For local
|
||||
development you should at minimum run with the `--dev` flag or else no blocks will be produced.
|
||||
|
||||
Then we need to initialize and run the relayer:
|
||||
|
||||
```bash
|
||||
docker run --network=host -it \
|
||||
paritytech/substrate-relay initialize-rialto-headers-bridge-in-millau \
|
||||
--millau-host localhost \
|
||||
--millau-port 9945 \
|
||||
--rialto-host localhost \
|
||||
--rialto-port 9944 \
|
||||
--millau-signer //Alice
|
||||
|
||||
docker run --network=host -it \
|
||||
paritytech/substrate-relay rialto-headers-to-millau \
|
||||
--millau-host localhost \
|
||||
--millau-port 9945 \
|
||||
--rialto-host localhost \
|
||||
--rialto-port 9944 \
|
||||
--millau-signer //Bob \
|
||||
```
|
||||
|
||||
You should now see the relayer submitting headers from the Millau chain to the Rialto chain.
|
||||
|
||||
If you don't want to use the published Docker images you can build images yourself. You can do this
|
||||
by running the following commands at the top level of the repository.
|
||||
|
||||
```bash
|
||||
# In `parity-bridges-common` folder
|
||||
docker build . -t local/rialto-bridge-node --build-arg PROJECT=rialto-bridge-node
|
||||
docker build . -t local/millau-bridge-node --build-arg PROJECT=millau-bridge-node
|
||||
docker build . -t local/substrate-relay --build-arg PROJECT=substrate-relay
|
||||
```
|
||||
|
||||
_Note: Building the node images will take a long time, so make sure you have some coffee handy._
|
||||
|
||||
Once you have the images built you can use them in the previous commands by replacing
|
||||
`paritytech/<component_name>` with `local/<component_name>` everywhere.
|
||||
|
||||
### Full Network Docker Compose Setup
|
||||
|
||||
For a more sophisticated deployment which includes bidirectional header sync, message passing,
|
||||
monitoring dashboards, etc. see the [Deployments README](./deployments/README.md).
|
||||
|
||||
### How to send a message
|
||||
|
||||
A straightforward way to interact with and test the bridge is sending messages. This is explained
|
||||
in the [send message](./docs/send-message.md) document.
|
||||
## Community
|
||||
|
||||
Main hangout for the community is [Element](https://element.io/) (formerly Riot). Element is a chat
|
||||
server like, for example, Discord. Most discussions around Polkadot and Substrate happen
|
||||
in various Element "rooms" (channels). So, joining Element might be a good idea, anyway.
|
||||
|
||||
If you are interested in information exchange and development of Polkadot related bridges please
|
||||
feel free to join the [Polkadot Bridges](https://app.element.io/#/room/#bridges:web3.foundation)
|
||||
Element channel.
|
||||
|
||||
The [Substrate Technical](https://app.element.io/#/room/#substrate-technical:matrix.org) Element
|
||||
channel is most suited for discussions regarding Substrate itself.
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
[package]
|
||||
name = "millau-bridge-node"
|
||||
description = "Substrate node compatible with Millau runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
homepage = "https://substrate.dev"
|
||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
jsonrpc-core = "15.1.0"
|
||||
structopt = "0.3.21"
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-message-lane = { path = "../../../primitives/message-lane" }
|
||||
bp-millau= { path = "../../../primitives/millau" }
|
||||
bp-runtime = { path = "../../../primitives/runtime" }
|
||||
millau-runtime = { path = "../runtime" }
|
||||
pallet-message-lane = { path = "../../../modules/message-lane" }
|
||||
pallet-message-lane-rpc = { path = "../../../modules/message-lane/rpc" }
|
||||
|
||||
# Substrate Dependencies
|
||||
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master", features = ["wasmtime"] }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-executor = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-keystore = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-service = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
|
||||
[build-dependencies]
|
||||
build-script-utils = { package = "substrate-build-script-utils", version = "2.0" }
|
||||
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
vergen = "3.1.0"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
# TODO: https://github.com/paritytech/parity-bridges-common/issues/390
|
||||
# I've left the feature flag here to test our CI configuration
|
||||
runtime-benchmarks = [
|
||||
# "millau-runtime/runtime-benchmarks",
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use vergen::{generate_cargo_keys, ConstantsFlags};
|
||||
|
||||
const ERROR_MSG: &str = "Failed to generate metadata files";
|
||||
|
||||
fn main() {
|
||||
generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG);
|
||||
|
||||
build_script_utils::rerun_if_git_head_changed();
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use bp_millau::derive_account_from_rialto_id;
|
||||
use millau_runtime::{
|
||||
AccountId, AuraConfig, BalancesConfig, BridgeRialtoConfig, GenesisConfig, GrandpaConfig, SessionConfig,
|
||||
SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY,
|
||||
};
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use sp_core::{sr25519, Pair, Public};
|
||||
use sp_finality_grandpa::AuthorityId as GrandpaId;
|
||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||
|
||||
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
||||
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
|
||||
|
||||
/// The chain specification option. This is expected to come in from the CLI and
|
||||
/// is little more than one of a number of alternatives which can easily be converted
|
||||
/// from a string (`--chain=...`) into a `ChainSpec`.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Alternative {
|
||||
/// Whatever the current runtime is, with just Alice as an auth.
|
||||
Development,
|
||||
/// Whatever the current runtime is, with simple Alice/Bob/Charlie/Dave/Eve auths.
|
||||
LocalTestnet,
|
||||
}
|
||||
|
||||
/// Helper function to generate a crypto pair from seed
|
||||
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
||||
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
||||
.expect("static values are valid; qed")
|
||||
.public()
|
||||
}
|
||||
|
||||
type AccountPublic = <Signature as Verify>::Signer;
|
||||
|
||||
/// Helper function to generate an account ID from seed
|
||||
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
||||
where
|
||||
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
||||
{
|
||||
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
||||
}
|
||||
|
||||
/// Helper function to generate an authority key for Aura
|
||||
pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, GrandpaId) {
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>(s),
|
||||
get_from_seed::<AuraId>(s),
|
||||
get_from_seed::<GrandpaId>(s),
|
||||
)
|
||||
}
|
||||
|
||||
impl Alternative {
|
||||
/// Get an actual chain config from one of the alternatives.
|
||||
pub(crate) fn load(self) -> ChainSpec {
|
||||
match self {
|
||||
Alternative::Development => ChainSpec::from_genesis(
|
||||
"Development",
|
||||
"dev",
|
||||
sc_service::ChainType::Development,
|
||||
|| {
|
||||
testnet_genesis(
|
||||
vec![get_authority_keys_from_seed("Alice")],
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
],
|
||||
true,
|
||||
)
|
||||
},
|
||||
vec![],
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
),
|
||||
Alternative::LocalTestnet => ChainSpec::from_genesis(
|
||||
"Local Testnet",
|
||||
"local_testnet",
|
||||
sc_service::ChainType::Local,
|
||||
|| {
|
||||
testnet_genesis(
|
||||
vec![
|
||||
get_authority_keys_from_seed("Alice"),
|
||||
get_authority_keys_from_seed("Bob"),
|
||||
get_authority_keys_from_seed("Charlie"),
|
||||
get_authority_keys_from_seed("Dave"),
|
||||
get_authority_keys_from_seed("Eve"),
|
||||
],
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("George"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Harry"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("George//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Harry//stash"),
|
||||
pallet_message_lane::Module::<millau_runtime::Runtime, pallet_message_lane::DefaultInstance>::relayer_fund_account_id(),
|
||||
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
)),
|
||||
],
|
||||
true,
|
||||
)
|
||||
},
|
||||
vec![],
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn session_keys(aura: AuraId, grandpa: GrandpaId) -> SessionKeys {
|
||||
SessionKeys { aura, grandpa }
|
||||
}
|
||||
|
||||
fn testnet_genesis(
|
||||
initial_authorities: Vec<(AccountId, AuraId, GrandpaId)>,
|
||||
root_key: AccountId,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
_enable_println: bool,
|
||||
) -> GenesisConfig {
|
||||
GenesisConfig {
|
||||
frame_system: Some(SystemConfig {
|
||||
code: WASM_BINARY.to_vec(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
pallet_balances: Some(BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(),
|
||||
}),
|
||||
pallet_aura: Some(AuraConfig {
|
||||
authorities: Vec::new(),
|
||||
}),
|
||||
pallet_grandpa: Some(GrandpaConfig {
|
||||
authorities: Vec::new(),
|
||||
}),
|
||||
pallet_substrate_bridge: Some(BridgeRialtoConfig {
|
||||
// We'll initialize the pallet with a dispatchable instead.
|
||||
init_data: None,
|
||||
owner: Some(root_key.clone()),
|
||||
}),
|
||||
pallet_sudo: Some(SudoConfig { key: root_key }),
|
||||
pallet_session: Some(SessionConfig {
|
||||
keys: initial_authorities
|
||||
.iter()
|
||||
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone())))
|
||||
.collect::<Vec<_>>(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn derived_dave_account_is_as_expected() {
|
||||
let dave = get_account_id_from_seed::<sr25519::Public>("Dave");
|
||||
let derived: AccountId = derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(dave));
|
||||
assert_eq!(
|
||||
derived.to_string(),
|
||||
"5DNW6UVnb7TN6wX5KwXtDYR3Eccecbdzuw89HqjyNfkzce6J".to_string()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use sc_cli::RunCmd;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct Cli {
|
||||
#[structopt(subcommand)]
|
||||
pub subcommand: Option<Subcommand>,
|
||||
|
||||
#[structopt(flatten)]
|
||||
pub run: RunCmd,
|
||||
}
|
||||
|
||||
/// Possible subcommands of the main binary.
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub enum Subcommand {
|
||||
/// Key management cli utilities
|
||||
Key(sc_cli::KeySubcommand),
|
||||
/// Verify a signature for a message, provided on STDIN, with a given (public or secret) key.
|
||||
Verify(sc_cli::VerifyCmd),
|
||||
|
||||
/// Generate a seed that provides a vanity address.
|
||||
Vanity(sc_cli::VanityCmd),
|
||||
|
||||
/// Sign a message, with a given (secret) key.
|
||||
Sign(sc_cli::SignCmd),
|
||||
|
||||
/// Build a chain specification.
|
||||
BuildSpec(sc_cli::BuildSpecCmd),
|
||||
|
||||
/// Validate blocks.
|
||||
CheckBlock(sc_cli::CheckBlockCmd),
|
||||
|
||||
/// Export blocks.
|
||||
ExportBlocks(sc_cli::ExportBlocksCmd),
|
||||
|
||||
/// Export the state of a given block into a chain spec.
|
||||
ExportState(sc_cli::ExportStateCmd),
|
||||
|
||||
/// Import blocks.
|
||||
ImportBlocks(sc_cli::ImportBlocksCmd),
|
||||
|
||||
/// Remove the whole chain.
|
||||
PurgeChain(sc_cli::PurgeChainCmd),
|
||||
|
||||
/// Revert the chain to a previous state.
|
||||
Revert(sc_cli::RevertCmd),
|
||||
|
||||
/// The custom benchmark subcommmand benchmarking runtime pallets.
|
||||
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
|
||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::cli::{Cli, Subcommand};
|
||||
use crate::service;
|
||||
use crate::service::new_partial;
|
||||
use millau_runtime::Block;
|
||||
use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli};
|
||||
use sc_service::PartialComponents;
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
"Millau Bridge Node".into()
|
||||
}
|
||||
|
||||
fn impl_version() -> String {
|
||||
env!("CARGO_PKG_VERSION").into()
|
||||
}
|
||||
|
||||
fn description() -> String {
|
||||
"Millau Bridge Node".into()
|
||||
}
|
||||
|
||||
fn author() -> String {
|
||||
"Parity Technologies".into()
|
||||
}
|
||||
|
||||
fn support_url() -> String {
|
||||
"https://github.com/paritytech/parity-bridges-common/".into()
|
||||
}
|
||||
|
||||
fn copyright_start_year() -> i32 {
|
||||
2019
|
||||
}
|
||||
|
||||
fn executable_name() -> String {
|
||||
"millau-bridge-node".into()
|
||||
}
|
||||
|
||||
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||
&millau_runtime::VERSION
|
||||
}
|
||||
|
||||
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
Ok(Box::new(
|
||||
match id {
|
||||
"" | "dev" => crate::chain_spec::Alternative::Development,
|
||||
"local" => crate::chain_spec::Alternative::LocalTestnet,
|
||||
_ => return Err(format!("Unsupported chain specification: {}", id)),
|
||||
}
|
||||
.load(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse and run command line arguments
|
||||
pub fn run() -> sc_cli::Result<()> {
|
||||
let cli = Cli::from_args();
|
||||
// make sure to set correct crypto version.
|
||||
sp_core::crypto::set_default_ss58_version(sp_core::crypto::Ss58AddressFormat::Custom(
|
||||
millau_runtime::SS58Prefix::get() as u16,
|
||||
));
|
||||
|
||||
match &cli.subcommand {
|
||||
Some(Subcommand::Benchmark(cmd)) => {
|
||||
if cfg!(feature = "runtime-benchmarks") {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
|
||||
runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
|
||||
} else {
|
||||
println!(
|
||||
"Benchmarking wasn't enabled when building the node. \
|
||||
You can enable it with `--features runtime-benchmarks`."
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
||||
Some(Subcommand::Sign(cmd)) => cmd.run(),
|
||||
Some(Subcommand::Verify(cmd)) => cmd.run(),
|
||||
Some(Subcommand::Vanity(cmd)) => cmd.run(),
|
||||
Some(Subcommand::BuildSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
}
|
||||
Some(Subcommand::CheckBlock(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client,
|
||||
task_manager,
|
||||
import_queue,
|
||||
..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, import_queue), task_manager))
|
||||
})
|
||||
}
|
||||
Some(Subcommand::ExportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client, task_manager, ..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, config.database), task_manager))
|
||||
})
|
||||
}
|
||||
Some(Subcommand::ExportState(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client, task_manager, ..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, config.chain_spec), task_manager))
|
||||
})
|
||||
}
|
||||
Some(Subcommand::ImportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client,
|
||||
task_manager,
|
||||
import_queue,
|
||||
..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, import_queue), task_manager))
|
||||
})
|
||||
}
|
||||
Some(Subcommand::PurgeChain(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.database))
|
||||
}
|
||||
Some(Subcommand::Revert(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client,
|
||||
task_manager,
|
||||
backend,
|
||||
..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, backend), task_manager))
|
||||
})
|
||||
}
|
||||
None => {
|
||||
let runner = cli.create_runner(&cli.run)?;
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
match config.role {
|
||||
Role::Light => service::new_light(config),
|
||||
_ => service::new_full(config),
|
||||
}
|
||||
.map_err(sc_cli::Error::Service)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Substrate Node Template CLI library.
|
||||
#![warn(missing_docs)]
|
||||
|
||||
mod chain_spec;
|
||||
#[macro_use]
|
||||
mod service;
|
||||
mod cli;
|
||||
mod command;
|
||||
|
||||
/// Node run result.
|
||||
pub type Result = sc_cli::Result<()>;
|
||||
|
||||
/// Run node.
|
||||
pub fn run() -> Result {
|
||||
command::run()
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Millau bridge node.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
mod chain_spec;
|
||||
#[macro_use]
|
||||
mod service;
|
||||
mod cli;
|
||||
mod command;
|
||||
|
||||
/// Run the Millau Node
|
||||
fn main() -> sc_cli::Result<()> {
|
||||
command::run()
|
||||
}
|
||||
@@ -0,0 +1,433 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
|
||||
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
// UPDATE GUIDE:
|
||||
// 1) replace everything with node-template/src/service.rs contents (found in main Substrate repo);
|
||||
// 2) the only thing to keep from old code, is `rpc_extensions_builder` - we use our own custom RPCs;
|
||||
// 3) fix compilation errors;
|
||||
// 4) test :)
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
|
||||
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||
use sc_executor::native_executor_instance;
|
||||
pub use sc_executor::NativeExecutor;
|
||||
use sc_finality_grandpa::SharedVoterState;
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use sp_inherents::InherentDataProviders;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
// Our native executor instance.
|
||||
native_executor_instance!(
|
||||
pub Executor,
|
||||
millau_runtime::api::dispatch,
|
||||
millau_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn new_partial(
|
||||
config: &Configuration,
|
||||
) -> Result<
|
||||
sc_service::PartialComponents<
|
||||
FullClient,
|
||||
FullBackend,
|
||||
FullSelectChain,
|
||||
sp_consensus::DefaultImportQueue<Block, FullClient>,
|
||||
sc_transaction_pool::FullPool<Block, FullClient>,
|
||||
(
|
||||
sc_consensus_aura::AuraBlockImport<
|
||||
Block,
|
||||
FullClient,
|
||||
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
|
||||
AuraPair,
|
||||
>,
|
||||
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
),
|
||||
>,
|
||||
ServiceError,
|
||||
> {
|
||||
if config.keystore_remote.is_some() {
|
||||
return Err(ServiceError::Other("Remote Keystores are not supported.".to_string()));
|
||||
}
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||
config.transaction_pool.clone(),
|
||||
config.role.is_authority().into(),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
);
|
||||
|
||||
let (grandpa_block_import, grandpa_link) =
|
||||
sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain.clone())?;
|
||||
|
||||
let aura_block_import =
|
||||
sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone());
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import.clone(),
|
||||
Some(Box::new(grandpa_block_import)),
|
||||
client.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_essential_handle(),
|
||||
config.prometheus_registry(),
|
||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
|
||||
)?;
|
||||
|
||||
Ok(sc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
task_manager,
|
||||
import_queue,
|
||||
keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
inherent_data_providers,
|
||||
other: (aura_block_import, grandpa_link),
|
||||
})
|
||||
}
|
||||
|
||||
fn remote_keystore(_url: &str) -> Result<Arc<LocalKeystore>, &'static str> {
|
||||
// FIXME: here would the concrete keystore be built,
|
||||
// must return a concrete type (NOT `LocalKeystore`) that
|
||||
// implements `CryptoStore` and `SyncCryptoStore`
|
||||
Err("Remote Keystore not supported.")
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let sc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
mut task_manager,
|
||||
import_queue,
|
||||
mut keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
inherent_data_providers,
|
||||
other: (block_import, grandpa_link),
|
||||
} = new_partial(&config)?;
|
||||
|
||||
if let Some(url) = &config.keystore_remote {
|
||||
match remote_keystore(url) {
|
||||
Ok(k) => keystore_container.set_remote_keystore(k),
|
||||
Err(e) => {
|
||||
return Err(ServiceError::Other(format!(
|
||||
"Error hooking up remote keystore for {}: {}",
|
||||
url, e
|
||||
)))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
.push(sc_finality_grandpa::grandpa_peers_set_config());
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: &config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
import_queue,
|
||||
on_demand: None,
|
||||
block_announce_validator_builder: None,
|
||||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
sc_service::build_offchain_workers(
|
||||
&config,
|
||||
backend.clone(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
let role = config.role.clone();
|
||||
let force_authoring = config.force_authoring;
|
||||
let backoff_authoring_blocks: Option<()> = None;
|
||||
let name = config.network.node_name.clone();
|
||||
let enable_grandpa = !config.disable_grandpa;
|
||||
let prometheus_registry = config.prometheus_registry().cloned();
|
||||
|
||||
let rpc_extensions_builder = {
|
||||
use bp_message_lane::{LaneId, MessageNonce};
|
||||
use bp_runtime::{InstanceId, RIALTO_BRIDGE_INSTANCE};
|
||||
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
|
||||
use sp_core::storage::StorageKey;
|
||||
|
||||
// This struct is here to ease update process.
|
||||
|
||||
/// Millau runtime from message-lane RPC point of view.
|
||||
struct MillauMessageLaneKeys;
|
||||
|
||||
impl pallet_message_lane_rpc::Runtime for MillauMessageLaneKeys {
|
||||
fn message_key(&self, instance: &InstanceId, lane: &LaneId, nonce: MessageNonce) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
RIALTO_BRIDGE_INSTANCE => Some(millau_runtime::rialto_messages::message_key(lane, nonce)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn outbound_lane_data_key(&self, instance: &InstanceId, lane: &LaneId) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
RIALTO_BRIDGE_INSTANCE => Some(millau_runtime::rialto_messages::outbound_lane_data_key(lane)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn inbound_lane_data_key(&self, instance: &InstanceId, lane: &LaneId) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
RIALTO_BRIDGE_INSTANCE => Some(millau_runtime::rialto_messages::inbound_lane_data_key(lane)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use pallet_message_lane_rpc::{MessageLaneApi, MessageLaneRpcHandler};
|
||||
use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler};
|
||||
use sc_rpc::DenyUnsafe;
|
||||
use substrate_frame_rpc_system::{FullSystem, SystemApi};
|
||||
|
||||
let backend = backend.clone();
|
||||
let client = client.clone();
|
||||
let pool = transaction_pool.clone();
|
||||
|
||||
let justification_stream = grandpa_link.justification_stream();
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
let shared_voter_state = sc_finality_grandpa::SharedVoterState::empty();
|
||||
|
||||
let finality_proof_provider =
|
||||
GrandpaFinalityProofProvider::new_for_service(backend.clone(), Some(shared_authority_set.clone()));
|
||||
|
||||
Box::new(move |_, subscription_executor| {
|
||||
let mut io = jsonrpc_core::IoHandler::default();
|
||||
io.extend_with(SystemApi::to_delegate(FullSystem::new(
|
||||
client.clone(),
|
||||
pool.clone(),
|
||||
DenyUnsafe::No,
|
||||
)));
|
||||
io.extend_with(GrandpaApi::to_delegate(GrandpaRpcHandler::new(
|
||||
shared_authority_set.clone(),
|
||||
shared_voter_state.clone(),
|
||||
justification_stream.clone(),
|
||||
subscription_executor,
|
||||
finality_proof_provider.clone(),
|
||||
)));
|
||||
io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new(
|
||||
backend.clone(),
|
||||
Arc::new(MillauMessageLaneKeys),
|
||||
)));
|
||||
|
||||
io
|
||||
})
|
||||
};
|
||||
|
||||
let (_rpc_handlers, telemetry_connection_notifier) = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
network: network.clone(),
|
||||
client: client.clone(),
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
task_manager: &mut task_manager,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
rpc_extensions_builder,
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
backend,
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
config,
|
||||
telemetry_span: None,
|
||||
})?;
|
||||
|
||||
if role.is_authority() {
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool,
|
||||
prometheus_registry.as_ref(),
|
||||
);
|
||||
|
||||
let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
|
||||
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
client.clone(),
|
||||
select_chain,
|
||||
block_import,
|
||||
proposer,
|
||||
network.clone(),
|
||||
inherent_data_providers,
|
||||
force_authoring,
|
||||
backoff_authoring_blocks,
|
||||
keystore_container.sync_keystore(),
|
||||
can_author_with,
|
||||
)?;
|
||||
|
||||
// the AURA authoring task is considered essential, i.e. if it
|
||||
// fails we take down the service with it.
|
||||
task_manager.spawn_essential_handle().spawn_blocking("aura", aura);
|
||||
}
|
||||
|
||||
// if the node isn't actively participating in consensus then it doesn't
|
||||
// need a keystore, regardless of which protocol we use below.
|
||||
let keystore = if role.is_authority() {
|
||||
Some(keystore_container.sync_keystore())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let grandpa_config = sc_finality_grandpa::Config {
|
||||
// FIXME #1578 make this available through chainspec
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
justification_period: 512,
|
||||
name: Some(name),
|
||||
observer_enabled: false,
|
||||
keystore,
|
||||
is_authority: role.is_authority(),
|
||||
};
|
||||
|
||||
if enable_grandpa {
|
||||
// start the full GRANDPA voter
|
||||
// NOTE: non-authorities could run the GRANDPA observer protocol, but at
|
||||
// this point the full voter should provide better guarantees of block
|
||||
// and vote data availability than the observer. The observer has not
|
||||
// been tested extensively yet and having most nodes in a network run it
|
||||
// could lead to finality stalls.
|
||||
let grandpa_config = sc_finality_grandpa::GrandpaParams {
|
||||
config: grandpa_config,
|
||||
link: grandpa_link,
|
||||
network,
|
||||
telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),
|
||||
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
|
||||
prometheus_registry,
|
||||
shared_voter_state: SharedVoterState::empty(),
|
||||
};
|
||||
|
||||
// the GRANDPA voter task is considered infallible, i.e.
|
||||
// if it fails we take down the service with it.
|
||||
task_manager
|
||||
.spawn_essential_handle()
|
||||
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
|
||||
}
|
||||
|
||||
network_starter.start_network();
|
||||
Ok(task_manager)
|
||||
}
|
||||
|
||||
/// Builds a new service for a light client.
|
||||
pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let (client, backend, keystore_container, mut task_manager, on_demand) =
|
||||
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
.push(sc_finality_grandpa::grandpa_peers_set_config());
|
||||
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
|
||||
config.transaction_pool.clone(),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
on_demand.clone(),
|
||||
));
|
||||
|
||||
let (grandpa_block_import, _) =
|
||||
sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?;
|
||||
|
||||
let aura_block_import =
|
||||
sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone());
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import,
|
||||
Some(Box::new(grandpa_block_import)),
|
||||
client.clone(),
|
||||
InherentDataProviders::new(),
|
||||
&task_manager.spawn_essential_handle(),
|
||||
config.prometheus_registry(),
|
||||
sp_consensus::NeverCanAuthor,
|
||||
)?;
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: &config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
import_queue,
|
||||
on_demand: Some(on_demand.clone()),
|
||||
block_announce_validator_builder: None,
|
||||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
sc_service::build_offchain_workers(
|
||||
&config,
|
||||
backend.clone(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
remote_blockchain: Some(backend.remote_blockchain()),
|
||||
transaction_pool,
|
||||
task_manager: &mut task_manager,
|
||||
on_demand: Some(on_demand),
|
||||
rpc_extensions_builder: Box::new(|_, _| ()),
|
||||
config,
|
||||
client,
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
backend,
|
||||
network,
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
telemetry_span: None,
|
||||
})?;
|
||||
|
||||
network_starter.start_network();
|
||||
|
||||
Ok(task_manager)
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
[package]
|
||||
name = "millau-runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
homepage = "https://substrate.dev"
|
||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
hex-literal = "0.3"
|
||||
serde = { version = "1.0.123", optional = true, features = ["derive"] }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-header-chain = { path = "../../../primitives/header-chain", default-features = false }
|
||||
bp-message-lane = { path = "../../../primitives/message-lane", default-features = false }
|
||||
bp-millau = { path = "../../../primitives/millau", default-features = false }
|
||||
bp-rialto = { path = "../../../primitives/rialto", default-features = false }
|
||||
bp-runtime = { path = "../../../primitives/runtime", default-features = false }
|
||||
bridge-runtime-common = { path = "../../runtime-common", default-features = false }
|
||||
pallet-bridge-call-dispatch = { path = "../../../modules/call-dispatch", default-features = false }
|
||||
pallet-finality-verifier = { path = "../../../modules/finality-verifier", default-features = false }
|
||||
pallet-message-lane = { path = "../../../modules/message-lane", default-features = false }
|
||||
pallet-shift-session-manager = { path = "../../../modules/shift-session-manager", default-features = false }
|
||||
pallet-substrate-bridge = { path = "../../../modules/substrate", default-features = false }
|
||||
|
||||
# Substrate Dependencies
|
||||
|
||||
frame-executive = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-session = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-sudo = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-block-builder = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "2.0.0" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"bp-header-chain/std",
|
||||
"bp-message-lane/std",
|
||||
"bp-millau/std",
|
||||
"bp-rialto/std",
|
||||
"bp-runtime/std",
|
||||
"bridge-runtime-common/std",
|
||||
"codec/std",
|
||||
"frame-executive/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"frame-system-rpc-runtime-api/std",
|
||||
"pallet-aura/std",
|
||||
"pallet-balances/std",
|
||||
"pallet-bridge-call-dispatch/std",
|
||||
"pallet-finality-verifier/std",
|
||||
"pallet-grandpa/std",
|
||||
"pallet-message-lane/std",
|
||||
"pallet-randomness-collective-flip/std",
|
||||
"pallet-shift-session-manager/std",
|
||||
"pallet-session/std",
|
||||
"pallet-substrate-bridge/std",
|
||||
"pallet-sudo/std",
|
||||
"pallet-timestamp/std",
|
||||
"pallet-transaction-payment/std",
|
||||
"serde",
|
||||
"sp-api/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-aura/std",
|
||||
"sp-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-finality-grandpa/std",
|
||||
"sp-offchain/std",
|
||||
"sp-runtime/std",
|
||||
"sp-session/std",
|
||||
"sp-std/std",
|
||||
"sp-transaction-pool/std",
|
||||
"sp-trie/std",
|
||||
"sp-version/std",
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use wasm_builder_runner::WasmBuilder;
|
||||
|
||||
fn main() {
|
||||
WasmBuilder::new()
|
||||
.with_current_project()
|
||||
.with_wasm_builder_from_crates("1.0.11")
|
||||
.export_heap_base()
|
||||
.import_memory()
|
||||
.build()
|
||||
}
|
||||
@@ -0,0 +1,684 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! The Millau runtime. This can be compiled with `#[no_std]`, ready for Wasm.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
|
||||
#![recursion_limit = "256"]
|
||||
// Runtime-generated enums
|
||||
#![allow(clippy::large_enum_variant)]
|
||||
// Runtime-generated DecodeLimit::decode_all_With_depth_limit
|
||||
#![allow(clippy::unnecessary_mut_passed)]
|
||||
// From construct_runtime macro
|
||||
#![allow(clippy::from_over_into)]
|
||||
|
||||
// Make the WASM binary available.
|
||||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
pub mod rialto_messages;
|
||||
|
||||
use crate::rialto_messages::{ToRialtoMessagePayload, WithRialtoMessageBridge};
|
||||
|
||||
use bridge_runtime_common::messages::{source::estimate_message_dispatch_and_delivery_fee, MessageBridge};
|
||||
use codec::Decode;
|
||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
use sp_runtime::traits::{Block as BlockT, IdentityLookup, NumberFor, OpaqueKeys};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
transaction_validity::{TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult, MultiSignature, MultiSigner,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
#[cfg(feature = "std")]
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
// A few exports that help ease life for downstream crates.
|
||||
pub use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness},
|
||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, RuntimeDbWeight, Weight},
|
||||
StorageValue,
|
||||
};
|
||||
|
||||
pub use frame_system::Call as SystemCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use pallet_message_lane::Call as MessageLaneCall;
|
||||
pub use pallet_substrate_bridge::Call as BridgeRialtoCall;
|
||||
pub use pallet_sudo::Call as SudoCall;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use sp_runtime::{Perbill, Permill};
|
||||
|
||||
/// An index to a block.
|
||||
pub type BlockNumber = bp_millau::BlockNumber;
|
||||
|
||||
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
|
||||
pub type Signature = bp_millau::Signature;
|
||||
|
||||
/// Some way of identifying an account on the chain. We intentionally make it equivalent
|
||||
/// to the public key of our transaction signing scheme.
|
||||
pub type AccountId = bp_millau::AccountId;
|
||||
|
||||
/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
|
||||
/// never know...
|
||||
pub type AccountIndex = u32;
|
||||
|
||||
/// Balance of an account.
|
||||
pub type Balance = bp_millau::Balance;
|
||||
|
||||
/// Index of a transaction in the chain.
|
||||
pub type Index = u32;
|
||||
|
||||
/// A hash of some data used by the chain.
|
||||
pub type Hash = bp_millau::Hash;
|
||||
|
||||
/// Hashing algorithm used by the chain.
|
||||
pub type Hashing = bp_millau::Hasher;
|
||||
|
||||
/// Digest item type.
|
||||
pub type DigestItem = generic::DigestItem<Hash>;
|
||||
|
||||
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
|
||||
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
|
||||
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
|
||||
/// to even the core data structures.
|
||||
pub mod opaque {
|
||||
use super::*;
|
||||
|
||||
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
|
||||
|
||||
/// Opaque block header type.
|
||||
pub type Header = generic::Header<BlockNumber, Hashing>;
|
||||
/// Opaque block type.
|
||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
/// Opaque block identifier type.
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
}
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
pub aura: Aura,
|
||||
pub grandpa: Grandpa,
|
||||
}
|
||||
}
|
||||
|
||||
/// This runtime version.
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("millau-runtime"),
|
||||
impl_name: create_runtime_str!("millau-runtime"),
|
||||
authoring_version: 1,
|
||||
spec_version: 1,
|
||||
impl_version: 1,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 1,
|
||||
};
|
||||
|
||||
/// The version information used to identify this runtime when compiled natively.
|
||||
#[cfg(feature = "std")]
|
||||
pub fn native_version() -> NativeVersion {
|
||||
NativeVersion {
|
||||
runtime_version: VERSION,
|
||||
can_author_with: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: BlockNumber = 250;
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||
read: 60_000_000, // ~0.06 ms = ~60 µs
|
||||
write: 200_000_000, // ~0.2 ms = 200 µs
|
||||
};
|
||||
pub const SS58Prefix: u8 = 60;
|
||||
}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
/// The basic call filter to use in dispatchable.
|
||||
type BaseCallFilter = ();
|
||||
/// The identifier used to distinguish between accounts.
|
||||
type AccountId = AccountId;
|
||||
/// The aggregated dispatch type that is available for extrinsics.
|
||||
type Call = Call;
|
||||
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
|
||||
type Lookup = IdentityLookup<AccountId>;
|
||||
/// The index type for storing how many extrinsics an account has signed.
|
||||
type Index = Index;
|
||||
/// The index type for blocks.
|
||||
type BlockNumber = BlockNumber;
|
||||
/// The type for hashing blocks and tries.
|
||||
type Hash = Hash;
|
||||
/// The hashing algorithm used.
|
||||
type Hashing = Hashing;
|
||||
/// The header type.
|
||||
type Header = generic::Header<BlockNumber, Hashing>;
|
||||
/// The ubiquitous event type.
|
||||
type Event = Event;
|
||||
/// The ubiquitous origin type.
|
||||
type Origin = Origin;
|
||||
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||
type BlockHashCount = BlockHashCount;
|
||||
/// Version of the runtime.
|
||||
type Version = Version;
|
||||
/// Provides information about the pallet setup in the runtime.
|
||||
type PalletInfo = PalletInfo;
|
||||
/// What to do if a new account is created.
|
||||
type OnNewAccount = ();
|
||||
/// What to do if an account is fully reaped from the system.
|
||||
type OnKilledAccount = ();
|
||||
/// The data to be stored in an account.
|
||||
type AccountData = pallet_balances::AccountData<Balance>;
|
||||
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
/// Weight information for the extrinsics of this pallet.
|
||||
type SystemWeightInfo = ();
|
||||
/// Block and extrinsics weights: base values and limits.
|
||||
type BlockWeights = bp_millau::BlockWeights;
|
||||
/// The maximum length of a block (in bytes).
|
||||
type BlockLength = bp_millau::BlockLength;
|
||||
/// The weight of database operations that the runtime can invoke.
|
||||
type DbWeight = DbWeight;
|
||||
/// The designated SS58 prefix of this chain.
|
||||
type SS58Prefix = SS58Prefix;
|
||||
}
|
||||
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
impl pallet_bridge_call_dispatch::Config for Runtime {
|
||||
type Event = Event;
|
||||
type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce);
|
||||
type Call = Call;
|
||||
type CallFilter = ();
|
||||
type EncodedCall = crate::rialto_messages::FromRialtoEncodedCall;
|
||||
type SourceChainAccountId = bp_rialto::AccountId;
|
||||
type TargetChainAccountPublic = MultiSigner;
|
||||
type TargetChainSignature = MultiSignature;
|
||||
type AccountIdConverter = bp_millau::AccountIdConverter;
|
||||
}
|
||||
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type KeyOwnerProofSystem = ();
|
||||
type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
|
||||
type KeyOwnerIdentification =
|
||||
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::IdentificationTuple;
|
||||
type HandleEquivocation = ();
|
||||
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MinimumPeriod: u64 = bp_millau::SLOT_DURATION / 2;
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: bp_millau::Balance = 500;
|
||||
// For weight estimation, we assume that the most locks on an individual account will be 50.
|
||||
// This number may need to be adjusted in the future if this assumption no longer holds true.
|
||||
pub const MaxLocks: u32 = 50;
|
||||
}
|
||||
|
||||
impl pallet_balances::Config for Runtime {
|
||||
/// The type for recording an account's balance.
|
||||
type Balance = Balance;
|
||||
/// The ubiquitous event type.
|
||||
type Event = Event;
|
||||
type DustRemoval = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = System;
|
||||
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
type WeightInfo = ();
|
||||
type MaxLocks = MaxLocks;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const TransactionBaseFee: Balance = 0;
|
||||
pub const TransactionByteFee: Balance = 1;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = IdentityFee<Balance>;
|
||||
type FeeMultiplierUpdate = ();
|
||||
}
|
||||
|
||||
impl pallet_sudo::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
/// Authorities are changing every 5 minutes.
|
||||
pub const Period: BlockNumber = bp_millau::SESSION_LENGTH;
|
||||
pub const Offset: BlockNumber = 0;
|
||||
}
|
||||
|
||||
impl pallet_session::Config for Runtime {
|
||||
type Event = Event;
|
||||
type ValidatorId = <Self as frame_system::Config>::AccountId;
|
||||
type ValidatorIdOf = ();
|
||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type SessionManager = pallet_shift_session_manager::Module<Runtime>;
|
||||
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
|
||||
type Keys = SessionKeys;
|
||||
type DisabledValidatorsThreshold = ();
|
||||
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
impl pallet_substrate_bridge::Config for Runtime {
|
||||
type BridgedChain = bp_rialto::Rialto;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// This is a pretty unscientific cap.
|
||||
//
|
||||
// Note that once this is hit the pallet will essentially throttle incoming requests down to one
|
||||
// call per block.
|
||||
pub const MaxRequests: u32 = 50;
|
||||
}
|
||||
|
||||
impl pallet_finality_verifier::Config for Runtime {
|
||||
type BridgedChain = bp_rialto::Rialto;
|
||||
type HeaderChain = pallet_substrate_bridge::Module<Runtime>;
|
||||
type AncestryProof = Vec<bp_rialto::Header>;
|
||||
type AncestryChecker = bp_header_chain::LinearAncestryChecker;
|
||||
type MaxRequests = MaxRequests;
|
||||
}
|
||||
|
||||
impl pallet_shift_session_manager::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxMessagesToPruneAtOnce: bp_message_lane::MessageNonce = 8;
|
||||
pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_message_lane::MessageNonce =
|
||||
bp_millau::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE;
|
||||
pub const MaxUnconfirmedMessagesAtInboundLane: bp_message_lane::MessageNonce =
|
||||
bp_millau::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE;
|
||||
// `IdentityFee` is used by Millau => we may use weight directly
|
||||
pub const GetDeliveryConfirmationTransactionFee: Balance =
|
||||
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _;
|
||||
pub const RootAccountForPayments: Option<AccountId> = None;
|
||||
}
|
||||
|
||||
impl pallet_message_lane::Config for Runtime {
|
||||
type Event = Event;
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/390
|
||||
type WeightInfo = pallet_message_lane::weights::RialtoWeight<Runtime>;
|
||||
type Parameter = rialto_messages::MillauToRialtoMessageLaneParameter;
|
||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||
type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane;
|
||||
|
||||
type OutboundPayload = crate::rialto_messages::ToRialtoMessagePayload;
|
||||
type OutboundMessageFee = Balance;
|
||||
|
||||
type InboundPayload = crate::rialto_messages::FromRialtoMessagePayload;
|
||||
type InboundMessageFee = bp_rialto::Balance;
|
||||
type InboundRelayer = bp_rialto::AccountId;
|
||||
|
||||
type AccountIdConverter = bp_millau::AccountIdConverter;
|
||||
|
||||
type TargetHeaderChain = crate::rialto_messages::Rialto;
|
||||
type LaneMessageVerifier = crate::rialto_messages::ToRialtoMessageVerifier;
|
||||
type MessageDeliveryAndDispatchPayment = pallet_message_lane::instant_payments::InstantCurrencyPayments<
|
||||
Runtime,
|
||||
pallet_balances::Module<Runtime>,
|
||||
GetDeliveryConfirmationTransactionFee,
|
||||
RootAccountForPayments,
|
||||
>;
|
||||
|
||||
type SourceHeaderChain = crate::rialto_messages::Rialto;
|
||||
type MessageDispatch = crate::rialto_messages::FromRialtoMessageDispatch;
|
||||
}
|
||||
|
||||
construct_runtime!(
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = opaque::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
BridgeRialto: pallet_substrate_bridge::{Module, Call, Storage, Config<T>},
|
||||
BridgeRialtoMessageLane: pallet_message_lane::{Module, Call, Storage, Event<T>},
|
||||
BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event<T>},
|
||||
BridgeFinalityVerifier: pallet_finality_verifier::{Module, Call},
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
|
||||
Aura: pallet_aura::{Module, Config<T>},
|
||||
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
|
||||
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
TransactionPayment: pallet_transaction_payment::{Module, Storage},
|
||||
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
|
||||
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
|
||||
ShiftSessionManager: pallet_shift_session_manager::{Module},
|
||||
}
|
||||
);
|
||||
|
||||
/// The address format for describing accounts.
|
||||
pub type Address = AccountId;
|
||||
/// Block header type as expected by this runtime.
|
||||
pub type Header = generic::Header<BlockNumber, Hashing>;
|
||||
/// Block type as expected by this runtime.
|
||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
/// A Block signed with a Justification
|
||||
pub type SignedBlock = generic::SignedBlock<Block>;
|
||||
/// BlockId type as expected by this runtime.
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
/// The SignedExtension to the basic transaction logic.
|
||||
pub type SignedExtra = (
|
||||
frame_system::CheckSpecVersion<Runtime>,
|
||||
frame_system::CheckTxVersion<Runtime>,
|
||||
frame_system::CheckGenesis<Runtime>,
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
);
|
||||
/// The payload being signed in transactions.
|
||||
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive =
|
||||
frame_executive::Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllModules>;
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
}
|
||||
|
||||
fn execute_block(block: Block) {
|
||||
Executive::execute_block(block)
|
||||
}
|
||||
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) {
|
||||
Executive::initialize_block(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_api::Metadata<Block> for Runtime {
|
||||
fn metadata() -> OpaqueMetadata {
|
||||
Runtime::metadata().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
||||
Executive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
|
||||
fn finalize_block() -> <Block as BlockT>::Header {
|
||||
Executive::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
data.create_extrinsics()
|
||||
}
|
||||
|
||||
fn check_inherents(
|
||||
block: Block,
|
||||
data: sp_inherents::InherentData,
|
||||
) -> sp_inherents::CheckInherentsResult {
|
||||
data.check_extrinsics(&block)
|
||||
}
|
||||
|
||||
fn random_seed() -> <Block as BlockT>::Hash {
|
||||
RandomnessCollectiveFlip::random_seed()
|
||||
}
|
||||
}
|
||||
|
||||
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
|
||||
fn account_nonce(account: AccountId) -> Index {
|
||||
System::account_nonce(account)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(
|
||||
source: TransactionSource,
|
||||
tx: <Block as BlockT>::Extrinsic,
|
||||
) -> TransactionValidity {
|
||||
Executive::validate_transaction(source, tx)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(header: &<Block as BlockT>::Header) {
|
||||
Executive::offchain_worker(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> u64 {
|
||||
Aura::slot_duration()
|
||||
}
|
||||
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
Aura::authorities()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_session::SessionKeys<Block> for Runtime {
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
SessionKeys::generate(seed)
|
||||
}
|
||||
|
||||
fn decode_session_keys(
|
||||
encoded: Vec<u8>,
|
||||
) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
|
||||
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||
}
|
||||
}
|
||||
|
||||
impl fg_primitives::GrandpaApi<Block> for Runtime {
|
||||
fn grandpa_authorities() -> GrandpaAuthorityList {
|
||||
Grandpa::grandpa_authorities()
|
||||
}
|
||||
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
equivocation_proof: fg_primitives::EquivocationProof<
|
||||
<Block as BlockT>::Hash,
|
||||
NumberFor<Block>,
|
||||
>,
|
||||
key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
let key_owner_proof = key_owner_proof.decode()?;
|
||||
|
||||
Grandpa::submit_unsigned_equivocation_report(
|
||||
equivocation_proof,
|
||||
key_owner_proof,
|
||||
)
|
||||
}
|
||||
|
||||
fn generate_key_ownership_proof(
|
||||
_set_id: fg_primitives::SetId,
|
||||
_authority_id: GrandpaId,
|
||||
) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
|
||||
// NOTE: this is the only implementation possible since we've
|
||||
// defined our key owner proof type as a bottom type (i.e. a type
|
||||
// with no values).
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_rialto::RialtoHeaderApi<Block> for Runtime {
|
||||
fn best_blocks() -> Vec<(bp_rialto::BlockNumber, bp_rialto::Hash)> {
|
||||
BridgeRialto::best_headers()
|
||||
}
|
||||
|
||||
fn finalized_block() -> (bp_rialto::BlockNumber, bp_rialto::Hash) {
|
||||
let header = BridgeRialto::best_finalized();
|
||||
(header.number, header.hash())
|
||||
}
|
||||
|
||||
fn incomplete_headers() -> Vec<(bp_rialto::BlockNumber, bp_rialto::Hash)> {
|
||||
BridgeRialto::require_justifications()
|
||||
}
|
||||
|
||||
fn is_known_block(hash: bp_rialto::Hash) -> bool {
|
||||
BridgeRialto::is_known_header(hash)
|
||||
}
|
||||
|
||||
fn is_finalized_block(hash: bp_rialto::Hash) -> bool {
|
||||
BridgeRialto::is_finalized_header(hash)
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_rialto::ToRialtoOutboundLaneApi<Block, Balance, ToRialtoMessagePayload> for Runtime {
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
_lane_id: bp_message_lane::LaneId,
|
||||
payload: ToRialtoMessagePayload,
|
||||
) -> Option<Balance> {
|
||||
estimate_message_dispatch_and_delivery_fee::<WithRialtoMessageBridge>(
|
||||
&payload,
|
||||
WithRialtoMessageBridge::RELAYER_FEE_PERCENT,
|
||||
).ok()
|
||||
}
|
||||
|
||||
fn messages_dispatch_weight(
|
||||
lane: bp_message_lane::LaneId,
|
||||
begin: bp_message_lane::MessageNonce,
|
||||
end: bp_message_lane::MessageNonce,
|
||||
) -> Vec<(bp_message_lane::MessageNonce, Weight, u32)> {
|
||||
(begin..=end).filter_map(|nonce| {
|
||||
let encoded_payload = BridgeRialtoMessageLane::outbound_message_payload(lane, nonce)?;
|
||||
let decoded_payload = rialto_messages::ToRialtoMessagePayload::decode(
|
||||
&mut &encoded_payload[..]
|
||||
).ok()?;
|
||||
Some((nonce, decoded_payload.weight, encoded_payload.len() as _))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeRialtoMessageLane::outbound_latest_received_nonce(lane)
|
||||
}
|
||||
|
||||
fn latest_generated_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeRialtoMessageLane::outbound_latest_generated_nonce(lane)
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_rialto::FromRialtoInboundLaneApi<Block> for Runtime {
|
||||
fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeRialtoMessageLane::inbound_latest_received_nonce(lane)
|
||||
}
|
||||
|
||||
fn latest_confirmed_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeRialtoMessageLane::inbound_latest_confirmed_nonce(lane)
|
||||
}
|
||||
|
||||
fn unrewarded_relayers_state(lane: bp_message_lane::LaneId) -> bp_message_lane::UnrewardedRelayersState {
|
||||
BridgeRialtoMessageLane::inbound_unrewarded_relayers_state(lane)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Rialto account ownership digest from Millau.
|
||||
///
|
||||
/// The byte vector returned by this function should be signed with a Rialto account private key.
|
||||
/// This way, the owner of `millau_account_id` on Millau proves that the Rialto account private key
|
||||
/// is also under his control.
|
||||
pub fn rialto_account_ownership_digest<Call, AccountId, SpecVersion>(
|
||||
rialto_call: &Call,
|
||||
millau_account_id: AccountId,
|
||||
rialto_spec_version: SpecVersion,
|
||||
) -> sp_std::vec::Vec<u8>
|
||||
where
|
||||
Call: codec::Encode,
|
||||
AccountId: codec::Encode,
|
||||
SpecVersion: codec::Encode,
|
||||
{
|
||||
pallet_bridge_call_dispatch::account_ownership_digest(
|
||||
rialto_call,
|
||||
millau_account_id,
|
||||
rialto_spec_version,
|
||||
bp_runtime::MILLAU_BRIDGE_INSTANCE,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bridge_runtime_common::messages;
|
||||
|
||||
#[test]
|
||||
fn ensure_millau_message_lane_weights_are_correct() {
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/390
|
||||
type Weights = pallet_message_lane::weights::RialtoWeight<Runtime>;
|
||||
|
||||
pallet_message_lane::ensure_weights_are_correct::<Weights>(
|
||||
bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT,
|
||||
bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT,
|
||||
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT,
|
||||
);
|
||||
|
||||
let max_incoming_message_proof_size = bp_rialto::EXTRA_STORAGE_PROOF_SIZE.saturating_add(
|
||||
messages::target::maximal_incoming_message_size(bp_millau::max_extrinsic_size()),
|
||||
);
|
||||
pallet_message_lane::ensure_able_to_receive_message::<Weights>(
|
||||
bp_millau::max_extrinsic_size(),
|
||||
bp_millau::max_extrinsic_weight(),
|
||||
max_incoming_message_proof_size,
|
||||
bridge_runtime_common::messages::transaction_weight_without_multiplier(
|
||||
bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
|
||||
max_incoming_message_proof_size as _,
|
||||
0,
|
||||
),
|
||||
messages::target::maximal_incoming_message_dispatch_weight(bp_millau::max_extrinsic_weight()),
|
||||
);
|
||||
|
||||
let max_incoming_inbound_lane_data_proof_size = bp_message_lane::InboundLaneData::<()>::encoded_size_hint(
|
||||
bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
||||
bp_rialto::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE as _,
|
||||
)
|
||||
.unwrap_or(u32::MAX);
|
||||
pallet_message_lane::ensure_able_to_receive_confirmation::<Weights>(
|
||||
bp_millau::max_extrinsic_size(),
|
||||
bp_millau::max_extrinsic_weight(),
|
||||
max_incoming_inbound_lane_data_proof_size,
|
||||
bp_rialto::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE,
|
||||
bp_rialto::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE,
|
||||
bridge_runtime_common::messages::transaction_weight_without_multiplier(
|
||||
bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
|
||||
max_incoming_inbound_lane_data_proof_size as _,
|
||||
0,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Everything required to serve Millau <-> Rialto message lanes.
|
||||
|
||||
use crate::Runtime;
|
||||
|
||||
use bp_message_lane::{
|
||||
source_chain::TargetHeaderChain,
|
||||
target_chain::{ProvedMessages, SourceHeaderChain},
|
||||
InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessageLaneParameter,
|
||||
};
|
||||
use bp_runtime::{InstanceId, RIALTO_BRIDGE_INSTANCE};
|
||||
use bridge_runtime_common::messages::{self, ChainWithMessageLanes, MessageBridge};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
weights::{DispatchClass, Weight, WeightToFeePolynomial},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_runtime::{FixedPointNumber, FixedU128};
|
||||
use sp_std::{convert::TryFrom, ops::RangeInclusive};
|
||||
|
||||
parameter_types! {
|
||||
/// Rialto to Millau conversion rate. Initially we treat both tokens as equal.
|
||||
storage RialtoToMillauConversionRate: FixedU128 = 1.into();
|
||||
}
|
||||
|
||||
/// Storage key of the Millau -> Rialto message in the runtime storage.
|
||||
pub fn message_key(lane: &LaneId, nonce: MessageNonce) -> StorageKey {
|
||||
pallet_message_lane::storage_keys::message_key::<Runtime, <Millau as ChainWithMessageLanes>::MessageLaneInstance>(
|
||||
lane, nonce,
|
||||
)
|
||||
}
|
||||
|
||||
/// Storage key of the Millau -> Rialto message lane state in the runtime storage.
|
||||
pub fn outbound_lane_data_key(lane: &LaneId) -> StorageKey {
|
||||
pallet_message_lane::storage_keys::outbound_lane_data_key::<<Millau as ChainWithMessageLanes>::MessageLaneInstance>(
|
||||
lane,
|
||||
)
|
||||
}
|
||||
|
||||
/// Storage key of the Rialto -> Millau message lane state in the runtime storage.
|
||||
pub fn inbound_lane_data_key(lane: &LaneId) -> StorageKey {
|
||||
pallet_message_lane::storage_keys::inbound_lane_data_key::<
|
||||
Runtime,
|
||||
<Millau as ChainWithMessageLanes>::MessageLaneInstance,
|
||||
>(lane)
|
||||
}
|
||||
|
||||
/// Message payload for Millau -> Rialto messages.
|
||||
pub type ToRialtoMessagePayload = messages::source::FromThisChainMessagePayload<WithRialtoMessageBridge>;
|
||||
|
||||
/// Message verifier for Millau -> Rialto messages.
|
||||
pub type ToRialtoMessageVerifier = messages::source::FromThisChainMessageVerifier<WithRialtoMessageBridge>;
|
||||
|
||||
/// Message payload for Rialto -> Millau messages.
|
||||
pub type FromRialtoMessagePayload = messages::target::FromBridgedChainMessagePayload<WithRialtoMessageBridge>;
|
||||
|
||||
/// Encoded Millau Call as it comes from Rialto.
|
||||
pub type FromRialtoEncodedCall = messages::target::FromBridgedChainEncodedMessageCall<WithRialtoMessageBridge>;
|
||||
|
||||
/// Messages proof for Rialto -> Millau messages.
|
||||
type FromRialtoMessagesProof = messages::target::FromBridgedChainMessagesProof<bp_rialto::Hash>;
|
||||
|
||||
/// Messages delivery proof for Millau -> Rialto messages.
|
||||
type ToRialtoMessagesDeliveryProof = messages::source::FromBridgedChainMessagesDeliveryProof<bp_rialto::Hash>;
|
||||
|
||||
/// Call-dispatch based message dispatch for Rialto -> Millau messages.
|
||||
pub type FromRialtoMessageDispatch = messages::target::FromBridgedChainMessageDispatch<
|
||||
WithRialtoMessageBridge,
|
||||
crate::Runtime,
|
||||
pallet_bridge_call_dispatch::DefaultInstance,
|
||||
>;
|
||||
|
||||
/// Millau <-> Rialto message bridge.
|
||||
#[derive(RuntimeDebug, Clone, Copy)]
|
||||
pub struct WithRialtoMessageBridge;
|
||||
|
||||
impl MessageBridge for WithRialtoMessageBridge {
|
||||
const INSTANCE: InstanceId = RIALTO_BRIDGE_INSTANCE;
|
||||
|
||||
const RELAYER_FEE_PERCENT: u32 = 10;
|
||||
|
||||
type ThisChain = Millau;
|
||||
type BridgedChain = Rialto;
|
||||
|
||||
fn maximal_extrinsic_size_on_target_chain() -> u32 {
|
||||
bp_rialto::max_extrinsic_size()
|
||||
}
|
||||
|
||||
fn weight_limits_of_message_on_bridged_chain(_message_payload: &[u8]) -> RangeInclusive<Weight> {
|
||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||
let upper_limit = messages::target::maximal_incoming_message_dispatch_weight(bp_rialto::max_extrinsic_weight());
|
||||
|
||||
// we're charging for payload bytes in `WithRialtoMessageBridge::weight_of_delivery_transaction` function
|
||||
//
|
||||
// this bridge may be used to deliver all kind of messages, so we're not making any assumptions about
|
||||
// minimal dispatch weight here
|
||||
|
||||
0..=upper_limit
|
||||
}
|
||||
|
||||
fn weight_of_delivery_transaction(message_payload: &[u8]) -> Weight {
|
||||
let message_payload_len = u32::try_from(message_payload.len())
|
||||
.map(Into::into)
|
||||
.unwrap_or(Weight::MAX);
|
||||
let extra_bytes_in_payload =
|
||||
message_payload_len.saturating_sub(pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH.into());
|
||||
messages::transaction_weight_without_multiplier(
|
||||
bp_rialto::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
|
||||
message_payload_len.saturating_add(bp_millau::EXTRA_STORAGE_PROOF_SIZE as _),
|
||||
extra_bytes_in_payload
|
||||
.saturating_mul(bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT)
|
||||
.saturating_add(bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT),
|
||||
)
|
||||
}
|
||||
|
||||
fn weight_of_delivery_confirmation_transaction_on_this_chain() -> Weight {
|
||||
let inbounded_data_size: Weight =
|
||||
InboundLaneData::<bp_rialto::AccountId>::encoded_size_hint(bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, 1)
|
||||
.map(Into::into)
|
||||
.unwrap_or(Weight::MAX);
|
||||
|
||||
messages::transaction_weight_without_multiplier(
|
||||
bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
|
||||
inbounded_data_size.saturating_add(bp_rialto::EXTRA_STORAGE_PROOF_SIZE as _),
|
||||
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT,
|
||||
)
|
||||
}
|
||||
|
||||
fn this_weight_to_this_balance(weight: Weight) -> bp_millau::Balance {
|
||||
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight)
|
||||
}
|
||||
|
||||
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_rialto::Balance {
|
||||
// we're using the same weights in both chains now
|
||||
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight) as _
|
||||
}
|
||||
|
||||
fn bridged_balance_to_this_balance(bridged_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
||||
bp_millau::Balance::try_from(RialtoToMillauConversionRate::get().saturating_mul_int(bridged_balance))
|
||||
.unwrap_or(bp_millau::Balance::MAX)
|
||||
}
|
||||
}
|
||||
|
||||
/// Millau chain from message lane point of view.
|
||||
#[derive(RuntimeDebug, Clone, Copy)]
|
||||
pub struct Millau;
|
||||
|
||||
impl messages::ChainWithMessageLanes for Millau {
|
||||
type Hash = bp_millau::Hash;
|
||||
type AccountId = bp_millau::AccountId;
|
||||
type Signer = bp_millau::AccountSigner;
|
||||
type Signature = bp_millau::Signature;
|
||||
type Call = crate::Call;
|
||||
type Weight = Weight;
|
||||
type Balance = bp_millau::Balance;
|
||||
|
||||
type MessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||
}
|
||||
|
||||
impl messages::ThisChainWithMessageLanes for Millau {
|
||||
fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
|
||||
*lane == LaneId::default()
|
||||
}
|
||||
|
||||
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
||||
MessageNonce::MAX
|
||||
}
|
||||
}
|
||||
|
||||
/// Rialto chain from message lane point of view.
|
||||
#[derive(RuntimeDebug, Clone, Copy)]
|
||||
pub struct Rialto;
|
||||
|
||||
impl messages::ChainWithMessageLanes for Rialto {
|
||||
type Hash = bp_rialto::Hash;
|
||||
type AccountId = bp_rialto::AccountId;
|
||||
type Signer = bp_rialto::AccountSigner;
|
||||
type Signature = bp_rialto::Signature;
|
||||
type Call = (); // unknown to us
|
||||
type Weight = Weight;
|
||||
type Balance = bp_rialto::Balance;
|
||||
|
||||
type MessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||
}
|
||||
|
||||
impl TargetHeaderChain<ToRialtoMessagePayload, bp_rialto::AccountId> for Rialto {
|
||||
type Error = &'static str;
|
||||
// The proof is:
|
||||
// - hash of the header this proof has been created with;
|
||||
// - the storage proof or one or several keys;
|
||||
// - id of the lane we prove state of.
|
||||
type MessagesDeliveryProof = ToRialtoMessagesDeliveryProof;
|
||||
|
||||
fn verify_message(payload: &ToRialtoMessagePayload) -> Result<(), Self::Error> {
|
||||
messages::source::verify_chain_message::<WithRialtoMessageBridge>(payload)
|
||||
}
|
||||
|
||||
fn verify_messages_delivery_proof(
|
||||
proof: Self::MessagesDeliveryProof,
|
||||
) -> Result<(LaneId, InboundLaneData<bp_millau::AccountId>), Self::Error> {
|
||||
messages::source::verify_messages_delivery_proof::<WithRialtoMessageBridge, Runtime>(proof)
|
||||
}
|
||||
}
|
||||
|
||||
impl SourceHeaderChain<bp_rialto::Balance> for Rialto {
|
||||
type Error = &'static str;
|
||||
// The proof is:
|
||||
// - hash of the header this proof has been created with;
|
||||
// - the storage proof or one or several keys;
|
||||
// - id of the lane we prove messages for;
|
||||
// - inclusive range of messages nonces that are proved.
|
||||
type MessagesProof = FromRialtoMessagesProof;
|
||||
|
||||
fn verify_messages_proof(
|
||||
proof: Self::MessagesProof,
|
||||
messages_count: u32,
|
||||
) -> Result<ProvedMessages<Message<bp_rialto::Balance>>, Self::Error> {
|
||||
messages::target::verify_messages_proof::<WithRialtoMessageBridge, Runtime>(proof, messages_count)
|
||||
}
|
||||
}
|
||||
|
||||
/// Millau -> Rialto message lane pallet parameters.
|
||||
#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq)]
|
||||
pub enum MillauToRialtoMessageLaneParameter {
|
||||
/// The conversion formula we use is: `MillauTokens = RialtoTokens * conversion_rate`.
|
||||
RialtoToMillauConversionRate(FixedU128),
|
||||
}
|
||||
|
||||
impl MessageLaneParameter for MillauToRialtoMessageLaneParameter {
|
||||
fn save(&self) {
|
||||
match *self {
|
||||
MillauToRialtoMessageLaneParameter::RialtoToMillauConversionRate(ref conversion_rate) => {
|
||||
RialtoToMillauConversionRate::set(conversion_rate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
[package]
|
||||
name = "rialto-bridge-node"
|
||||
description = "Substrate node compatible with Rialto runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
homepage = "https://substrate.dev"
|
||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
jsonrpc-core = "15.1.0"
|
||||
structopt = "0.3.21"
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-message-lane = { path = "../../../primitives/message-lane" }
|
||||
bp-runtime = { path = "../../../primitives/runtime" }
|
||||
bp-rialto = { path = "../../../primitives/rialto" }
|
||||
pallet-message-lane = { path = "../../../modules/message-lane" }
|
||||
pallet-message-lane-rpc = { path = "../../../modules/message-lane/rpc" }
|
||||
rialto-runtime = { path = "../runtime" }
|
||||
|
||||
# Substrate Dependencies
|
||||
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master", features = ["wasmtime"] }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-executor = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-keystore = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-service = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sc-telemetry = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
|
||||
[build-dependencies]
|
||||
build-script-utils = { package = "substrate-build-script-utils", version = "2.0" }
|
||||
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
vergen = "3.1.0"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
runtime-benchmarks = [
|
||||
"rialto-runtime/runtime-benchmarks",
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use vergen::{generate_cargo_keys, ConstantsFlags};
|
||||
|
||||
const ERROR_MSG: &str = "Failed to generate metadata files";
|
||||
|
||||
fn main() {
|
||||
generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG);
|
||||
|
||||
build_script_utils::rerun_if_git_head_changed();
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use bp_rialto::derive_account_from_millau_id;
|
||||
use rialto_runtime::{
|
||||
AccountId, AuraConfig, BalancesConfig, BridgeKovanConfig, BridgeMillauConfig, BridgeRialtoPoAConfig, GenesisConfig,
|
||||
GrandpaConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY,
|
||||
};
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use sp_core::{sr25519, Pair, Public};
|
||||
use sp_finality_grandpa::AuthorityId as GrandpaId;
|
||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||
|
||||
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
||||
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
|
||||
|
||||
/// The chain specification option. This is expected to come in from the CLI and
|
||||
/// is little more than one of a number of alternatives which can easily be converted
|
||||
/// from a string (`--chain=...`) into a `ChainSpec`.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Alternative {
|
||||
/// Whatever the current runtime is, with just Alice as an auth.
|
||||
Development,
|
||||
/// Whatever the current runtime is, with simple Alice/Bob/Charlie/Dave/Eve auths.
|
||||
LocalTestnet,
|
||||
}
|
||||
|
||||
/// Helper function to generate a crypto pair from seed
|
||||
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
||||
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
||||
.expect("static values are valid; qed")
|
||||
.public()
|
||||
}
|
||||
|
||||
type AccountPublic = <Signature as Verify>::Signer;
|
||||
|
||||
/// Helper function to generate an account ID from seed
|
||||
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
||||
where
|
||||
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
||||
{
|
||||
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
||||
}
|
||||
|
||||
/// Helper function to generate an authority key for Aura
|
||||
pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, GrandpaId) {
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>(s),
|
||||
get_from_seed::<AuraId>(s),
|
||||
get_from_seed::<GrandpaId>(s),
|
||||
)
|
||||
}
|
||||
|
||||
impl Alternative {
|
||||
/// Get an actual chain config from one of the alternatives.
|
||||
pub(crate) fn load(self) -> ChainSpec {
|
||||
match self {
|
||||
Alternative::Development => ChainSpec::from_genesis(
|
||||
"Development",
|
||||
"dev",
|
||||
sc_service::ChainType::Development,
|
||||
|| {
|
||||
testnet_genesis(
|
||||
vec![get_authority_keys_from_seed("Alice")],
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
],
|
||||
true,
|
||||
)
|
||||
},
|
||||
vec![],
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
),
|
||||
Alternative::LocalTestnet => ChainSpec::from_genesis(
|
||||
"Local Testnet",
|
||||
"local_testnet",
|
||||
sc_service::ChainType::Local,
|
||||
|| {
|
||||
testnet_genesis(
|
||||
vec![
|
||||
get_authority_keys_from_seed("Alice"),
|
||||
get_authority_keys_from_seed("Bob"),
|
||||
get_authority_keys_from_seed("Charlie"),
|
||||
get_authority_keys_from_seed("Dave"),
|
||||
get_authority_keys_from_seed("Eve"),
|
||||
],
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("George"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Harry"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("George//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Harry//stash"),
|
||||
pallet_message_lane::Module::<rialto_runtime::Runtime, pallet_message_lane::DefaultInstance>::relayer_fund_account_id(),
|
||||
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
)),
|
||||
],
|
||||
true,
|
||||
)
|
||||
},
|
||||
vec![],
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn session_keys(aura: AuraId, grandpa: GrandpaId) -> SessionKeys {
|
||||
SessionKeys { aura, grandpa }
|
||||
}
|
||||
|
||||
fn testnet_genesis(
|
||||
initial_authorities: Vec<(AccountId, AuraId, GrandpaId)>,
|
||||
root_key: AccountId,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
_enable_println: bool,
|
||||
) -> GenesisConfig {
|
||||
GenesisConfig {
|
||||
frame_system: Some(SystemConfig {
|
||||
code: WASM_BINARY.to_vec(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
pallet_balances: Some(BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(),
|
||||
}),
|
||||
pallet_aura: Some(AuraConfig {
|
||||
authorities: Vec::new(),
|
||||
}),
|
||||
pallet_bridge_eth_poa_Instance1: Some(load_rialto_poa_bridge_config()),
|
||||
pallet_bridge_eth_poa_Instance2: Some(load_kovan_bridge_config()),
|
||||
pallet_grandpa: Some(GrandpaConfig {
|
||||
authorities: Vec::new(),
|
||||
}),
|
||||
pallet_substrate_bridge: Some(BridgeMillauConfig {
|
||||
// We'll initialize the pallet with a dispatchable instead.
|
||||
init_data: None,
|
||||
owner: Some(root_key.clone()),
|
||||
}),
|
||||
pallet_sudo: Some(SudoConfig { key: root_key }),
|
||||
pallet_session: Some(SessionConfig {
|
||||
keys: initial_authorities
|
||||
.iter()
|
||||
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone())))
|
||||
.collect::<Vec<_>>(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn load_rialto_poa_bridge_config() -> BridgeRialtoPoAConfig {
|
||||
BridgeRialtoPoAConfig {
|
||||
initial_header: rialto_runtime::rialto_poa::genesis_header(),
|
||||
initial_difficulty: 0.into(),
|
||||
initial_validators: rialto_runtime::rialto_poa::genesis_validators(),
|
||||
}
|
||||
}
|
||||
|
||||
fn load_kovan_bridge_config() -> BridgeKovanConfig {
|
||||
BridgeKovanConfig {
|
||||
initial_header: rialto_runtime::kovan::genesis_header(),
|
||||
initial_difficulty: 0.into(),
|
||||
initial_validators: rialto_runtime::kovan::genesis_validators(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn derived_dave_account_is_as_expected() {
|
||||
let dave = get_account_id_from_seed::<sr25519::Public>("Dave");
|
||||
let derived: AccountId = derive_account_from_millau_id(bp_runtime::SourceAccount::Account(dave));
|
||||
assert_eq!(
|
||||
derived.to_string(),
|
||||
"5HZhdv53gSJmWWtD8XR5Ypu4PgbT5JNWwGw2mkE75cN61w9t".to_string()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use sc_cli::RunCmd;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct Cli {
|
||||
#[structopt(subcommand)]
|
||||
pub subcommand: Option<Subcommand>,
|
||||
|
||||
#[structopt(flatten)]
|
||||
pub run: RunCmd,
|
||||
}
|
||||
|
||||
/// Possible subcommands of the main binary.
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub enum Subcommand {
|
||||
/// Key management cli utilities
|
||||
Key(sc_cli::KeySubcommand),
|
||||
/// Verify a signature for a message, provided on STDIN, with a given (public or secret) key.
|
||||
Verify(sc_cli::VerifyCmd),
|
||||
|
||||
/// Generate a seed that provides a vanity address.
|
||||
Vanity(sc_cli::VanityCmd),
|
||||
|
||||
/// Sign a message, with a given (secret) key.
|
||||
Sign(sc_cli::SignCmd),
|
||||
|
||||
/// Build a chain specification.
|
||||
BuildSpec(sc_cli::BuildSpecCmd),
|
||||
|
||||
/// Validate blocks.
|
||||
CheckBlock(sc_cli::CheckBlockCmd),
|
||||
|
||||
/// Export blocks.
|
||||
ExportBlocks(sc_cli::ExportBlocksCmd),
|
||||
|
||||
/// Export the state of a given block into a chain spec.
|
||||
ExportState(sc_cli::ExportStateCmd),
|
||||
|
||||
/// Import blocks.
|
||||
ImportBlocks(sc_cli::ImportBlocksCmd),
|
||||
|
||||
/// Remove the whole chain.
|
||||
PurgeChain(sc_cli::PurgeChainCmd),
|
||||
|
||||
/// Revert the chain to a previous state.
|
||||
Revert(sc_cli::RevertCmd),
|
||||
|
||||
/// The custom benchmark subcommmand benchmarking runtime pallets.
|
||||
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
|
||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::cli::{Cli, Subcommand};
|
||||
use crate::service;
|
||||
use crate::service::new_partial;
|
||||
use rialto_runtime::Block;
|
||||
use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli};
|
||||
use sc_service::PartialComponents;
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
"Rialto Bridge Node".into()
|
||||
}
|
||||
|
||||
fn impl_version() -> String {
|
||||
env!("CARGO_PKG_VERSION").into()
|
||||
}
|
||||
|
||||
fn description() -> String {
|
||||
"Rialto Bridge Node".into()
|
||||
}
|
||||
|
||||
fn author() -> String {
|
||||
"Parity Technologies".into()
|
||||
}
|
||||
|
||||
fn support_url() -> String {
|
||||
"https://github.com/paritytech/parity-bridges-common/".into()
|
||||
}
|
||||
|
||||
fn copyright_start_year() -> i32 {
|
||||
2019
|
||||
}
|
||||
|
||||
fn executable_name() -> String {
|
||||
"rialto-bridge-node".into()
|
||||
}
|
||||
|
||||
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||
&rialto_runtime::VERSION
|
||||
}
|
||||
|
||||
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
Ok(Box::new(
|
||||
match id {
|
||||
"" | "dev" => crate::chain_spec::Alternative::Development,
|
||||
"local" => crate::chain_spec::Alternative::LocalTestnet,
|
||||
_ => return Err(format!("Unsupported chain specification: {}", id)),
|
||||
}
|
||||
.load(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse and run command line arguments
|
||||
pub fn run() -> sc_cli::Result<()> {
|
||||
let cli = Cli::from_args();
|
||||
sp_core::crypto::set_default_ss58_version(sp_core::crypto::Ss58AddressFormat::Custom(
|
||||
rialto_runtime::SS58Prefix::get() as u16,
|
||||
));
|
||||
|
||||
match &cli.subcommand {
|
||||
Some(Subcommand::Benchmark(cmd)) => {
|
||||
if cfg!(feature = "runtime-benchmarks") {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
|
||||
runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
|
||||
} else {
|
||||
println!(
|
||||
"Benchmarking wasn't enabled when building the node. \
|
||||
You can enable it with `--features runtime-benchmarks`."
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
||||
Some(Subcommand::Sign(cmd)) => cmd.run(),
|
||||
Some(Subcommand::Verify(cmd)) => cmd.run(),
|
||||
Some(Subcommand::Vanity(cmd)) => cmd.run(),
|
||||
Some(Subcommand::BuildSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
}
|
||||
Some(Subcommand::CheckBlock(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client,
|
||||
task_manager,
|
||||
import_queue,
|
||||
..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, import_queue), task_manager))
|
||||
})
|
||||
}
|
||||
Some(Subcommand::ExportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client, task_manager, ..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, config.database), task_manager))
|
||||
})
|
||||
}
|
||||
Some(Subcommand::ExportState(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client, task_manager, ..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, config.chain_spec), task_manager))
|
||||
})
|
||||
}
|
||||
Some(Subcommand::ImportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client,
|
||||
task_manager,
|
||||
import_queue,
|
||||
..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, import_queue), task_manager))
|
||||
})
|
||||
}
|
||||
Some(Subcommand::PurgeChain(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.database))
|
||||
}
|
||||
Some(Subcommand::Revert(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents {
|
||||
client,
|
||||
task_manager,
|
||||
backend,
|
||||
..
|
||||
} = new_partial(&config)?;
|
||||
Ok((cmd.run(client, backend), task_manager))
|
||||
})
|
||||
}
|
||||
None => {
|
||||
let runner = cli.create_runner(&cli.run)?;
|
||||
runner
|
||||
.run_node_until_exit(|config| async move {
|
||||
match config.role {
|
||||
Role::Light => service::new_light(config),
|
||||
_ => service::new_full(config),
|
||||
}
|
||||
})
|
||||
.map_err(sc_cli::Error::Service)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Rialto bridge node.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
mod chain_spec;
|
||||
#[macro_use]
|
||||
mod service;
|
||||
mod cli;
|
||||
mod command;
|
||||
|
||||
/// Run the Rialto Node
|
||||
fn main() -> sc_cli::Result<()> {
|
||||
command::run()
|
||||
}
|
||||
@@ -0,0 +1,433 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
|
||||
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
// UPDATE GUIDE:
|
||||
// 1) replace everything with node-template/src/service.rs contents (found in main Substrate repo);
|
||||
// 2) the only thing to keep from old code, is `rpc_extensions_builder` - we use our own custom RPCs;
|
||||
// 3) fix compilation errors;
|
||||
// 4) test :)
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
|
||||
use rialto_runtime::{self, opaque::Block, RuntimeApi};
|
||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||
use sc_executor::native_executor_instance;
|
||||
pub use sc_executor::NativeExecutor;
|
||||
use sc_finality_grandpa::SharedVoterState;
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use sp_inherents::InherentDataProviders;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
// Our native executor instance.
|
||||
native_executor_instance!(
|
||||
pub Executor,
|
||||
rialto_runtime::api::dispatch,
|
||||
rialto_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn new_partial(
|
||||
config: &Configuration,
|
||||
) -> Result<
|
||||
sc_service::PartialComponents<
|
||||
FullClient,
|
||||
FullBackend,
|
||||
FullSelectChain,
|
||||
sp_consensus::DefaultImportQueue<Block, FullClient>,
|
||||
sc_transaction_pool::FullPool<Block, FullClient>,
|
||||
(
|
||||
sc_consensus_aura::AuraBlockImport<
|
||||
Block,
|
||||
FullClient,
|
||||
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
|
||||
AuraPair,
|
||||
>,
|
||||
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
),
|
||||
>,
|
||||
ServiceError,
|
||||
> {
|
||||
if config.keystore_remote.is_some() {
|
||||
return Err(ServiceError::Other("Remote Keystores are not supported.".to_string()));
|
||||
}
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||
config.transaction_pool.clone(),
|
||||
config.role.is_authority().into(),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
);
|
||||
|
||||
let (grandpa_block_import, grandpa_link) =
|
||||
sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain.clone())?;
|
||||
|
||||
let aura_block_import =
|
||||
sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone());
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import.clone(),
|
||||
Some(Box::new(grandpa_block_import)),
|
||||
client.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_essential_handle(),
|
||||
config.prometheus_registry(),
|
||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
|
||||
)?;
|
||||
|
||||
Ok(sc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
task_manager,
|
||||
import_queue,
|
||||
keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
inherent_data_providers,
|
||||
other: (aura_block_import, grandpa_link),
|
||||
})
|
||||
}
|
||||
|
||||
fn remote_keystore(_url: &str) -> Result<Arc<LocalKeystore>, &'static str> {
|
||||
// FIXME: here would the concrete keystore be built,
|
||||
// must return a concrete type (NOT `LocalKeystore`) that
|
||||
// implements `CryptoStore` and `SyncCryptoStore`
|
||||
Err("Remote Keystore not supported.")
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let sc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
mut task_manager,
|
||||
import_queue,
|
||||
mut keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
inherent_data_providers,
|
||||
other: (block_import, grandpa_link),
|
||||
} = new_partial(&config)?;
|
||||
|
||||
if let Some(url) = &config.keystore_remote {
|
||||
match remote_keystore(url) {
|
||||
Ok(k) => keystore_container.set_remote_keystore(k),
|
||||
Err(e) => {
|
||||
return Err(ServiceError::Other(format!(
|
||||
"Error hooking up remote keystore for {}: {}",
|
||||
url, e
|
||||
)))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
.push(sc_finality_grandpa::grandpa_peers_set_config());
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: &config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
import_queue,
|
||||
on_demand: None,
|
||||
block_announce_validator_builder: None,
|
||||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
sc_service::build_offchain_workers(
|
||||
&config,
|
||||
backend.clone(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
let role = config.role.clone();
|
||||
let force_authoring = config.force_authoring;
|
||||
let backoff_authoring_blocks: Option<()> = None;
|
||||
let name = config.network.node_name.clone();
|
||||
let enable_grandpa = !config.disable_grandpa;
|
||||
let prometheus_registry = config.prometheus_registry().cloned();
|
||||
|
||||
let rpc_extensions_builder = {
|
||||
use bp_message_lane::{LaneId, MessageNonce};
|
||||
use bp_runtime::{InstanceId, MILLAU_BRIDGE_INSTANCE};
|
||||
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
|
||||
use sp_core::storage::StorageKey;
|
||||
|
||||
// This struct is here to ease update process.
|
||||
|
||||
/// Rialto runtime from message-lane RPC point of view.
|
||||
struct RialtoMessageLaneKeys;
|
||||
|
||||
impl pallet_message_lane_rpc::Runtime for RialtoMessageLaneKeys {
|
||||
fn message_key(&self, instance: &InstanceId, lane: &LaneId, nonce: MessageNonce) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
MILLAU_BRIDGE_INSTANCE => Some(rialto_runtime::millau_messages::message_key(lane, nonce)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn outbound_lane_data_key(&self, instance: &InstanceId, lane: &LaneId) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
MILLAU_BRIDGE_INSTANCE => Some(rialto_runtime::millau_messages::outbound_lane_data_key(lane)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn inbound_lane_data_key(&self, instance: &InstanceId, lane: &LaneId) -> Option<StorageKey> {
|
||||
match *instance {
|
||||
MILLAU_BRIDGE_INSTANCE => Some(rialto_runtime::millau_messages::inbound_lane_data_key(lane)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use pallet_message_lane_rpc::{MessageLaneApi, MessageLaneRpcHandler};
|
||||
use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler};
|
||||
use sc_rpc::DenyUnsafe;
|
||||
use substrate_frame_rpc_system::{FullSystem, SystemApi};
|
||||
|
||||
let backend = backend.clone();
|
||||
let client = client.clone();
|
||||
let pool = transaction_pool.clone();
|
||||
|
||||
let justification_stream = grandpa_link.justification_stream();
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
let shared_voter_state = sc_finality_grandpa::SharedVoterState::empty();
|
||||
|
||||
let finality_proof_provider =
|
||||
GrandpaFinalityProofProvider::new_for_service(backend.clone(), Some(shared_authority_set.clone()));
|
||||
|
||||
Box::new(move |_, subscription_executor| {
|
||||
let mut io = jsonrpc_core::IoHandler::default();
|
||||
io.extend_with(SystemApi::to_delegate(FullSystem::new(
|
||||
client.clone(),
|
||||
pool.clone(),
|
||||
DenyUnsafe::No,
|
||||
)));
|
||||
io.extend_with(GrandpaApi::to_delegate(GrandpaRpcHandler::new(
|
||||
shared_authority_set.clone(),
|
||||
shared_voter_state.clone(),
|
||||
justification_stream.clone(),
|
||||
subscription_executor,
|
||||
finality_proof_provider.clone(),
|
||||
)));
|
||||
io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new(
|
||||
backend.clone(),
|
||||
Arc::new(RialtoMessageLaneKeys),
|
||||
)));
|
||||
|
||||
io
|
||||
})
|
||||
};
|
||||
|
||||
let (_rpc_handlers, telemetry_connection_notifier) = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
network: network.clone(),
|
||||
client: client.clone(),
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
task_manager: &mut task_manager,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
rpc_extensions_builder,
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
backend,
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
config,
|
||||
telemetry_span: None,
|
||||
})?;
|
||||
|
||||
if role.is_authority() {
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool,
|
||||
prometheus_registry.as_ref(),
|
||||
);
|
||||
|
||||
let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
|
||||
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
client.clone(),
|
||||
select_chain,
|
||||
block_import,
|
||||
proposer,
|
||||
network.clone(),
|
||||
inherent_data_providers,
|
||||
force_authoring,
|
||||
backoff_authoring_blocks,
|
||||
keystore_container.sync_keystore(),
|
||||
can_author_with,
|
||||
)?;
|
||||
|
||||
// the AURA authoring task is considered essential, i.e. if it
|
||||
// fails we take down the service with it.
|
||||
task_manager.spawn_essential_handle().spawn_blocking("aura", aura);
|
||||
}
|
||||
|
||||
// if the node isn't actively participating in consensus then it doesn't
|
||||
// need a keystore, regardless of which protocol we use below.
|
||||
let keystore = if role.is_authority() {
|
||||
Some(keystore_container.sync_keystore())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let grandpa_config = sc_finality_grandpa::Config {
|
||||
// FIXME #1578 make this available through chainspec
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
justification_period: 512,
|
||||
name: Some(name),
|
||||
observer_enabled: false,
|
||||
keystore,
|
||||
is_authority: role.is_authority(),
|
||||
};
|
||||
|
||||
if enable_grandpa {
|
||||
// start the full GRANDPA voter
|
||||
// NOTE: non-authorities could run the GRANDPA observer protocol, but at
|
||||
// this point the full voter should provide better guarantees of block
|
||||
// and vote data availability than the observer. The observer has not
|
||||
// been tested extensively yet and having most nodes in a network run it
|
||||
// could lead to finality stalls.
|
||||
let grandpa_config = sc_finality_grandpa::GrandpaParams {
|
||||
config: grandpa_config,
|
||||
link: grandpa_link,
|
||||
network,
|
||||
telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),
|
||||
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
|
||||
prometheus_registry,
|
||||
shared_voter_state: SharedVoterState::empty(),
|
||||
};
|
||||
|
||||
// the GRANDPA voter task is considered infallible, i.e.
|
||||
// if it fails we take down the service with it.
|
||||
task_manager
|
||||
.spawn_essential_handle()
|
||||
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
|
||||
}
|
||||
|
||||
network_starter.start_network();
|
||||
Ok(task_manager)
|
||||
}
|
||||
|
||||
/// Builds a new service for a light client.
|
||||
pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let (client, backend, keystore_container, mut task_manager, on_demand) =
|
||||
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
.push(sc_finality_grandpa::grandpa_peers_set_config());
|
||||
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
|
||||
config.transaction_pool.clone(),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
on_demand.clone(),
|
||||
));
|
||||
|
||||
let (grandpa_block_import, _) =
|
||||
sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?;
|
||||
|
||||
let aura_block_import =
|
||||
sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone());
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import,
|
||||
Some(Box::new(grandpa_block_import)),
|
||||
client.clone(),
|
||||
InherentDataProviders::new(),
|
||||
&task_manager.spawn_essential_handle(),
|
||||
config.prometheus_registry(),
|
||||
sp_consensus::NeverCanAuthor,
|
||||
)?;
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: &config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
import_queue,
|
||||
on_demand: Some(on_demand.clone()),
|
||||
block_announce_validator_builder: None,
|
||||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
sc_service::build_offchain_workers(
|
||||
&config,
|
||||
backend.clone(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
remote_blockchain: Some(backend.remote_blockchain()),
|
||||
transaction_pool,
|
||||
task_manager: &mut task_manager,
|
||||
on_demand: Some(on_demand),
|
||||
rpc_extensions_builder: Box::new(|_, _| ()),
|
||||
config,
|
||||
client,
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
backend,
|
||||
network,
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
telemetry_span: None,
|
||||
})?;
|
||||
|
||||
network_starter.start_network();
|
||||
|
||||
Ok(task_manager)
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
[package]
|
||||
name = "rialto-runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
homepage = "https://substrate.dev"
|
||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
hex-literal = "0.3"
|
||||
libsecp256k1 = { version = "0.3.4", optional = true, default-features = false, features = ["hmac"] }
|
||||
serde = { version = "1.0.123", optional = true, features = ["derive"] }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-currency-exchange = { path = "../../../primitives/currency-exchange", default-features = false }
|
||||
bp-eth-poa = { path = "../../../primitives/ethereum-poa", default-features = false }
|
||||
bp-header-chain = { path = "../../../primitives/header-chain", default-features = false }
|
||||
bp-message-dispatch = { path = "../../../primitives/message-dispatch", default-features = false }
|
||||
bp-message-lane = { path = "../../../primitives/message-lane", default-features = false }
|
||||
bp-millau = { path = "../../../primitives/millau", default-features = false }
|
||||
bp-rialto = { path = "../../../primitives/rialto", default-features = false }
|
||||
bp-runtime = { path = "../../../primitives/runtime", default-features = false }
|
||||
bridge-runtime-common = { path = "../../runtime-common", default-features = false }
|
||||
pallet-bridge-eth-poa = { path = "../../../modules/ethereum", default-features = false }
|
||||
pallet-bridge-call-dispatch = { path = "../../../modules/call-dispatch", default-features = false }
|
||||
pallet-bridge-currency-exchange = { path = "../../../modules/currency-exchange", default-features = false }
|
||||
pallet-finality-verifier = { path = "../../../modules/finality-verifier", default-features = false }
|
||||
pallet-substrate-bridge = { path = "../../../modules/substrate", default-features = false }
|
||||
pallet-message-lane = { path = "../../../modules/message-lane", default-features = false }
|
||||
pallet-shift-session-manager = { path = "../../../modules/shift-session-manager", default-features = false }
|
||||
|
||||
# Substrate Dependencies
|
||||
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false, optional = true }
|
||||
frame-executive = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-session = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-sudo = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-block-builder = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
libsecp256k1 = { version = "0.3.4", features = ["hmac"] }
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "2.0.0" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"bp-currency-exchange/std",
|
||||
"bp-eth-poa/std",
|
||||
"bp-header-chain/std",
|
||||
"bp-message-dispatch/std",
|
||||
"bp-message-lane/std",
|
||||
"bp-millau/std",
|
||||
"bp-rialto/std",
|
||||
"bp-runtime/std",
|
||||
"bridge-runtime-common/std",
|
||||
"codec/std",
|
||||
"frame-benchmarking/std",
|
||||
"frame-executive/std",
|
||||
"frame-support/std",
|
||||
"frame-system-rpc-runtime-api/std",
|
||||
"frame-system/std",
|
||||
"pallet-aura/std",
|
||||
"pallet-balances/std",
|
||||
"pallet-bridge-eth-poa/std",
|
||||
"pallet-bridge-call-dispatch/std",
|
||||
"pallet-bridge-currency-exchange/std",
|
||||
"pallet-finality-verifier/std",
|
||||
"pallet-grandpa/std",
|
||||
"pallet-message-lane/std",
|
||||
"pallet-randomness-collective-flip/std",
|
||||
"pallet-shift-session-manager/std",
|
||||
"pallet-substrate-bridge/std",
|
||||
"pallet-sudo/std",
|
||||
"pallet-timestamp/std",
|
||||
"pallet-transaction-payment/std",
|
||||
"serde",
|
||||
"sp-api/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-aura/std",
|
||||
"sp-core/std",
|
||||
"sp-finality-grandpa/std",
|
||||
"sp-inherents/std",
|
||||
"sp-io/std",
|
||||
"sp-offchain/std",
|
||||
"sp-runtime/std",
|
||||
"sp-session/std",
|
||||
"sp-std/std",
|
||||
"sp-transaction-pool/std",
|
||||
"sp-trie/std",
|
||||
"sp-version/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"bridge-runtime-common/runtime-benchmarks",
|
||||
"frame-benchmarking",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"libsecp256k1",
|
||||
"pallet-bridge-currency-exchange/runtime-benchmarks",
|
||||
"pallet-bridge-eth-poa/runtime-benchmarks",
|
||||
"pallet-message-lane/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use wasm_builder_runner::WasmBuilder;
|
||||
|
||||
fn main() {
|
||||
WasmBuilder::new()
|
||||
.with_current_project()
|
||||
.with_wasm_builder_from_crates("1.0.11")
|
||||
.export_heap_base()
|
||||
.import_memory()
|
||||
.build()
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright 2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! We want to use a different validator configuration for benchmarking than what's used in Kovan
|
||||
//! or in our Rialto test network. However, we can't configure a new validator set on the fly which
|
||||
//! means we need to wire the runtime together like this
|
||||
|
||||
use pallet_bridge_eth_poa::{ValidatorsConfiguration, ValidatorsSource};
|
||||
use sp_std::vec;
|
||||
|
||||
pub use crate::kovan::{
|
||||
genesis_header, genesis_validators, BridgeAuraConfiguration, FinalityVotesCachingInterval, PruningStrategy,
|
||||
};
|
||||
|
||||
frame_support::parameter_types! {
|
||||
pub BridgeValidatorsConfiguration: pallet_bridge_eth_poa::ValidatorsConfiguration = bench_validator_config();
|
||||
}
|
||||
|
||||
fn bench_validator_config() -> ValidatorsConfiguration {
|
||||
ValidatorsConfiguration::Multi(vec![
|
||||
(0, ValidatorsSource::List(vec![[1; 20].into()])),
|
||||
(1, ValidatorsSource::Contract([3; 20].into(), vec![[1; 20].into()])),
|
||||
])
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Support for PoA -> Substrate native tokens exchange.
|
||||
//!
|
||||
//! If you want to exchange native PoA tokens for native Substrate
|
||||
//! chain tokens, you need to:
|
||||
//! 1) send some PoA tokens to `LOCK_FUNDS_ADDRESS` address on PoA chain. Data field of
|
||||
//! the transaction must be SCALE-encoded id of Substrate account that will receive
|
||||
//! funds on Substrate chain;
|
||||
//! 2) wait until the 'lock funds' transaction is mined on PoA chain;
|
||||
//! 3) wait until the block containing the 'lock funds' transaction is finalized on PoA chain;
|
||||
//! 4) wait until the required PoA header and its finality are provided
|
||||
//! to the PoA -> Substrate bridge module (it can be provided by you);
|
||||
//! 5) receive tokens by providing proof-of-inclusion of PoA transaction.
|
||||
|
||||
use bp_currency_exchange::{
|
||||
Error as ExchangeError, LockFundsTransaction, MaybeLockFundsTransaction, Result as ExchangeResult,
|
||||
};
|
||||
use bp_eth_poa::{transaction_decode_rlp, RawTransaction, RawTransactionReceipt};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::RuntimeDebug;
|
||||
use hex_literal::hex;
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
/// Ethereum address where locked PoA funds must be sent to.
|
||||
pub const LOCK_FUNDS_ADDRESS: [u8; 20] = hex!("DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF");
|
||||
|
||||
/// Ethereum transaction inclusion proof.
|
||||
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug)]
|
||||
pub struct EthereumTransactionInclusionProof {
|
||||
/// Hash of the block with transaction.
|
||||
pub block: sp_core::H256,
|
||||
/// Index of the transaction within the block.
|
||||
pub index: u64,
|
||||
/// The proof itself (right now it is all RLP-encoded transactions of the block +
|
||||
/// RLP-encoded receipts of all transactions of the block).
|
||||
pub proof: Vec<(RawTransaction, RawTransactionReceipt)>,
|
||||
}
|
||||
|
||||
/// We uniquely identify transfer by the pair (sender, nonce).
|
||||
///
|
||||
/// The assumption is that this pair will never appear more than once in
|
||||
/// transactions included into finalized blocks. This is obviously true
|
||||
/// for any existing eth-like chain (that keep current tx format), because
|
||||
/// otherwise transaction can be replayed over and over.
|
||||
#[derive(Encode, Decode, PartialEq, RuntimeDebug)]
|
||||
pub struct EthereumTransactionTag {
|
||||
/// Account that has locked funds.
|
||||
pub account: [u8; 20],
|
||||
/// Lock transaction nonce.
|
||||
pub nonce: sp_core::U256,
|
||||
}
|
||||
|
||||
/// Eth transaction from runtime perspective.
|
||||
pub struct EthTransaction;
|
||||
|
||||
impl MaybeLockFundsTransaction for EthTransaction {
|
||||
type Transaction = RawTransaction;
|
||||
type Id = EthereumTransactionTag;
|
||||
type Recipient = crate::AccountId;
|
||||
type Amount = crate::Balance;
|
||||
|
||||
fn parse(
|
||||
raw_tx: &Self::Transaction,
|
||||
) -> ExchangeResult<LockFundsTransaction<Self::Id, Self::Recipient, Self::Amount>> {
|
||||
let tx = transaction_decode_rlp(raw_tx).map_err(|_| ExchangeError::InvalidTransaction)?;
|
||||
|
||||
// we only accept transactions sending funds directly to the pre-configured address
|
||||
if tx.unsigned.to != Some(LOCK_FUNDS_ADDRESS.into()) {
|
||||
frame_support::debug::trace!(
|
||||
target: "runtime",
|
||||
"Failed to parse fund locks transaction. Invalid peer recipient: {:?}",
|
||||
tx.unsigned.to,
|
||||
);
|
||||
|
||||
return Err(ExchangeError::InvalidTransaction);
|
||||
}
|
||||
|
||||
let mut recipient_raw = sp_core::H256::default();
|
||||
match tx.unsigned.payload.len() {
|
||||
32 => recipient_raw.as_fixed_bytes_mut().copy_from_slice(&tx.unsigned.payload),
|
||||
len => {
|
||||
frame_support::debug::trace!(
|
||||
target: "runtime",
|
||||
"Failed to parse fund locks transaction. Invalid recipient length: {}",
|
||||
len,
|
||||
);
|
||||
|
||||
return Err(ExchangeError::InvalidRecipient);
|
||||
}
|
||||
}
|
||||
let amount = tx.unsigned.value.low_u128();
|
||||
|
||||
if tx.unsigned.value != amount.into() {
|
||||
frame_support::debug::trace!(
|
||||
target: "runtime",
|
||||
"Failed to parse fund locks transaction. Invalid amount: {}",
|
||||
tx.unsigned.value,
|
||||
);
|
||||
|
||||
return Err(ExchangeError::InvalidAmount);
|
||||
}
|
||||
|
||||
Ok(LockFundsTransaction {
|
||||
id: EthereumTransactionTag {
|
||||
account: *tx.sender.as_fixed_bytes(),
|
||||
nonce: tx.unsigned.nonce,
|
||||
},
|
||||
recipient: crate::AccountId::from(*recipient_raw.as_fixed_bytes()),
|
||||
amount,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Prepares everything required to bench claim of funds locked by given transaction.
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub(crate) fn prepare_environment_for_claim<T: pallet_bridge_eth_poa::Config<I>, I: frame_support::traits::Instance>(
|
||||
transactions: &[(RawTransaction, RawTransactionReceipt)],
|
||||
) -> bp_eth_poa::H256 {
|
||||
use bp_eth_poa::compute_merkle_root;
|
||||
use pallet_bridge_eth_poa::{
|
||||
test_utils::{insert_dummy_header, validator_utils::validator, HeaderBuilder},
|
||||
BridgeStorage, Storage,
|
||||
};
|
||||
|
||||
let mut storage = BridgeStorage::<T, I>::new();
|
||||
let header = HeaderBuilder::with_parent_number_on_runtime::<T, I>(0)
|
||||
.transactions_root(compute_merkle_root(transactions.iter().map(|(tx, _)| tx)))
|
||||
.receipts_root(compute_merkle_root(transactions.iter().map(|(_, receipt)| receipt)))
|
||||
.sign_by(&validator(0));
|
||||
let header_id = header.compute_id();
|
||||
insert_dummy_header(&mut storage, header);
|
||||
storage.finalize_and_prune_headers(Some(header_id), 0);
|
||||
|
||||
header_id.hash
|
||||
}
|
||||
|
||||
/// Prepare signed ethereum lock-funds transaction.
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
pub(crate) fn prepare_ethereum_transaction(
|
||||
recipient: &crate::AccountId,
|
||||
editor: impl Fn(&mut bp_eth_poa::UnsignedTransaction),
|
||||
) -> (RawTransaction, RawTransactionReceipt) {
|
||||
use bp_eth_poa::{signatures::SignTransaction, Receipt, TransactionOutcome};
|
||||
|
||||
// prepare tx for OpenEthereum private dev chain:
|
||||
// chain id is 0x11
|
||||
// sender secret is 0x4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7
|
||||
let chain_id = 0x11;
|
||||
let signer = secp256k1::SecretKey::parse(&hex!(
|
||||
"4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7"
|
||||
))
|
||||
.unwrap();
|
||||
let recipient_raw: &[u8; 32] = recipient.as_ref();
|
||||
let mut eth_tx = bp_eth_poa::UnsignedTransaction {
|
||||
nonce: 0.into(),
|
||||
to: Some(LOCK_FUNDS_ADDRESS.into()),
|
||||
value: 100.into(),
|
||||
gas: 100_000.into(),
|
||||
gas_price: 100_000.into(),
|
||||
payload: recipient_raw.to_vec(),
|
||||
};
|
||||
editor(&mut eth_tx);
|
||||
(
|
||||
eth_tx.sign_by(&signer, Some(chain_id)),
|
||||
Receipt {
|
||||
outcome: TransactionOutcome::StatusCode(1),
|
||||
gas_used: Default::default(),
|
||||
log_bloom: Default::default(),
|
||||
logs: Vec::new(),
|
||||
}
|
||||
.rlp(),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use hex_literal::hex;
|
||||
|
||||
fn ferdie() -> crate::AccountId {
|
||||
hex!("1cbd2d43530a44705ad088af313e18f80b53ef16b36177cd4b77b846f2a5f07c").into()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_transaction_accepted() {
|
||||
assert_eq!(
|
||||
EthTransaction::parse(&prepare_ethereum_transaction(&ferdie(), |_| {}).0),
|
||||
Ok(LockFundsTransaction {
|
||||
id: EthereumTransactionTag {
|
||||
account: hex!("00a329c0648769a73afac7f9381e08fb43dbea72"),
|
||||
nonce: 0.into(),
|
||||
},
|
||||
recipient: ferdie(),
|
||||
amount: 100,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_transaction_rejected() {
|
||||
assert_eq!(
|
||||
EthTransaction::parse(&Vec::new()),
|
||||
Err(ExchangeError::InvalidTransaction),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transaction_with_invalid_peer_recipient_rejected() {
|
||||
assert_eq!(
|
||||
EthTransaction::parse(
|
||||
&prepare_ethereum_transaction(&ferdie(), |tx| {
|
||||
tx.to = None;
|
||||
})
|
||||
.0
|
||||
),
|
||||
Err(ExchangeError::InvalidTransaction),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transaction_with_invalid_recipient_rejected() {
|
||||
assert_eq!(
|
||||
EthTransaction::parse(
|
||||
&prepare_ethereum_transaction(&ferdie(), |tx| {
|
||||
tx.payload.clear();
|
||||
})
|
||||
.0
|
||||
),
|
||||
Err(ExchangeError::InvalidRecipient),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transaction_with_invalid_amount_rejected() {
|
||||
assert_eq!(
|
||||
EthTransaction::parse(
|
||||
&prepare_ethereum_transaction(&ferdie(), |tx| {
|
||||
tx.value = sp_core::U256::from(u128::max_value()) + sp_core::U256::from(1);
|
||||
})
|
||||
.0
|
||||
),
|
||||
Err(ExchangeError::InvalidAmount),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::exchange::EthereumTransactionInclusionProof;
|
||||
|
||||
use bp_eth_poa::{Address, AuraHeader, RawTransaction, U256};
|
||||
use bp_header_chain::InclusionProofVerifier;
|
||||
use frame_support::RuntimeDebug;
|
||||
use hex_literal::hex;
|
||||
use pallet_bridge_eth_poa::{
|
||||
AuraConfiguration, ChainTime as TChainTime, PruningStrategy as BridgePruningStrategy, ValidatorsConfiguration,
|
||||
ValidatorsSource,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
frame_support::parameter_types! {
|
||||
pub const FinalityVotesCachingInterval: Option<u64> = Some(16);
|
||||
pub BridgeAuraConfiguration: AuraConfiguration =
|
||||
kovan_aura_configuration();
|
||||
pub BridgeValidatorsConfiguration: ValidatorsConfiguration =
|
||||
kovan_validators_configuration();
|
||||
}
|
||||
|
||||
/// Max number of finalized headers to keep. It is equivalent of ~24 hours of
|
||||
/// finalized blocks on current Kovan chain.
|
||||
const FINALIZED_HEADERS_TO_KEEP: u64 = 20_000;
|
||||
|
||||
/// Aura engine configuration for Kovan chain.
|
||||
pub fn kovan_aura_configuration() -> AuraConfiguration {
|
||||
AuraConfiguration {
|
||||
empty_steps_transition: u64::max_value(),
|
||||
strict_empty_steps_transition: 0,
|
||||
validate_step_transition: 0x16e360,
|
||||
validate_score_transition: 0x41a3c4,
|
||||
two_thirds_majority_transition: u64::max_value(),
|
||||
min_gas_limit: 0x1388.into(),
|
||||
max_gas_limit: U256::max_value(),
|
||||
maximum_extra_data_size: 0x20,
|
||||
}
|
||||
}
|
||||
|
||||
/// Validators configuration for Kovan chain.
|
||||
pub fn kovan_validators_configuration() -> ValidatorsConfiguration {
|
||||
ValidatorsConfiguration::Multi(vec![
|
||||
(0, ValidatorsSource::List(genesis_validators())),
|
||||
(
|
||||
10960440,
|
||||
ValidatorsSource::List(vec![
|
||||
hex!("00D6Cc1BA9cf89BD2e58009741f4F7325BAdc0ED").into(),
|
||||
hex!("0010f94b296a852aaac52ea6c5ac72e03afd032d").into(),
|
||||
hex!("00a0a24b9f0e5ec7aa4c7389b8302fd0123194de").into(),
|
||||
]),
|
||||
),
|
||||
(
|
||||
10960500,
|
||||
ValidatorsSource::Contract(
|
||||
hex!("aE71807C1B0a093cB1547b682DC78316D945c9B8").into(),
|
||||
vec![
|
||||
hex!("d05f7478c6aa10781258c5cc8b4f385fc8fa989c").into(),
|
||||
hex!("03801efb0efe2a25ede5dd3a003ae880c0292e4d").into(),
|
||||
hex!("a4df255ecf08bbf2c28055c65225c9a9847abd94").into(),
|
||||
hex!("596e8221a30bfe6e7eff67fee664a01c73ba3c56").into(),
|
||||
hex!("faadface3fbd81ce37b0e19c0b65ff4234148132").into(),
|
||||
],
|
||||
),
|
||||
),
|
||||
])
|
||||
}
|
||||
|
||||
/// Genesis validators set of Kovan chain.
|
||||
pub fn genesis_validators() -> Vec<Address> {
|
||||
vec![
|
||||
hex!("00D6Cc1BA9cf89BD2e58009741f4F7325BAdc0ED").into(),
|
||||
hex!("00427feae2419c15b89d1c21af10d1b6650a4d3d").into(),
|
||||
hex!("4Ed9B08e6354C70fE6F8CB0411b0d3246b424d6c").into(),
|
||||
hex!("0020ee4Be0e2027d76603cB751eE069519bA81A1").into(),
|
||||
hex!("0010f94b296a852aaac52ea6c5ac72e03afd032d").into(),
|
||||
hex!("007733a1FE69CF3f2CF989F81C7b4cAc1693387A").into(),
|
||||
hex!("00E6d2b931F55a3f1701c7389d592a7778897879").into(),
|
||||
hex!("00e4a10650e5a6D6001C38ff8E64F97016a1645c").into(),
|
||||
hex!("00a0a24b9f0e5ec7aa4c7389b8302fd0123194de").into(),
|
||||
]
|
||||
}
|
||||
|
||||
/// Genesis header of the Kovan chain.
|
||||
pub fn genesis_header() -> AuraHeader {
|
||||
AuraHeader {
|
||||
parent_hash: Default::default(),
|
||||
timestamp: 0,
|
||||
number: 0,
|
||||
author: Default::default(),
|
||||
transactions_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(),
|
||||
uncles_hash: hex!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347").into(),
|
||||
extra_data: vec![],
|
||||
state_root: hex!("2480155b48a1cea17d67dbfdfaafe821c1d19cdd478c5358e8ec56dec24502b2").into(),
|
||||
receipts_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(),
|
||||
log_bloom: Default::default(),
|
||||
gas_used: Default::default(),
|
||||
gas_limit: 6000000.into(),
|
||||
difficulty: 131072.into(),
|
||||
seal: vec![
|
||||
vec![128],
|
||||
vec![
|
||||
184, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
],
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
/// Kovan headers pruning strategy.
|
||||
///
|
||||
/// We do not prune unfinalized headers because exchange module only accepts
|
||||
/// claims from finalized headers. And if we're pruning unfinalized headers, then
|
||||
/// some claims may never be accepted.
|
||||
#[derive(Default, RuntimeDebug)]
|
||||
pub struct PruningStrategy;
|
||||
|
||||
impl BridgePruningStrategy for PruningStrategy {
|
||||
fn pruning_upper_bound(&mut self, _best_number: u64, best_finalized_number: u64) -> u64 {
|
||||
best_finalized_number.saturating_sub(FINALIZED_HEADERS_TO_KEEP)
|
||||
}
|
||||
}
|
||||
|
||||
/// PoA Header timestamp verification against `Timestamp` pallet.
|
||||
#[derive(Default, RuntimeDebug)]
|
||||
pub struct ChainTime;
|
||||
|
||||
impl TChainTime for ChainTime {
|
||||
fn is_timestamp_ahead(&self, timestamp: u64) -> bool {
|
||||
let now = super::Timestamp::now();
|
||||
timestamp > now
|
||||
}
|
||||
}
|
||||
|
||||
/// The Kovan Blockchain as seen by the runtime.
|
||||
pub struct KovanBlockchain;
|
||||
|
||||
impl InclusionProofVerifier for KovanBlockchain {
|
||||
type Transaction = RawTransaction;
|
||||
type TransactionInclusionProof = EthereumTransactionInclusionProof;
|
||||
|
||||
fn verify_transaction_inclusion_proof(proof: &Self::TransactionInclusionProof) -> Option<Self::Transaction> {
|
||||
let is_transaction_finalized =
|
||||
crate::BridgeKovan::verify_transaction_finalized(proof.block, proof.index, &proof.proof);
|
||||
|
||||
if !is_transaction_finalized {
|
||||
return None;
|
||||
}
|
||||
|
||||
proof.proof.get(proof.index as usize).map(|(tx, _)| tx.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn pruning_strategy_keeps_enough_headers() {
|
||||
assert_eq!(
|
||||
PruningStrategy::default().pruning_upper_bound(100_000, 10_000),
|
||||
0,
|
||||
"10_000 <= 20_000 => nothing should be pruned yet",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PruningStrategy::default().pruning_upper_bound(100_000, 20_000),
|
||||
0,
|
||||
"20_000 <= 20_000 => nothing should be pruned yet",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PruningStrategy::default().pruning_upper_bound(100_000, 30_000),
|
||||
10_000,
|
||||
"20_000 <= 30_000 => we're ready to prune first 10_000 headers",
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,254 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Everything required to serve Millau <-> Rialto message lanes.
|
||||
|
||||
use crate::Runtime;
|
||||
|
||||
use bp_message_lane::{
|
||||
source_chain::TargetHeaderChain,
|
||||
target_chain::{ProvedMessages, SourceHeaderChain},
|
||||
InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessageLaneParameter,
|
||||
};
|
||||
use bp_runtime::{InstanceId, MILLAU_BRIDGE_INSTANCE};
|
||||
use bridge_runtime_common::messages::{self, ChainWithMessageLanes, MessageBridge};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
weights::{DispatchClass, Weight, WeightToFeePolynomial},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_runtime::{FixedPointNumber, FixedU128};
|
||||
use sp_std::{convert::TryFrom, ops::RangeInclusive};
|
||||
|
||||
parameter_types! {
|
||||
/// Millau to Rialto conversion rate. Initially we treat both tokens as equal.
|
||||
storage MillauToRialtoConversionRate: FixedU128 = 1.into();
|
||||
}
|
||||
|
||||
/// Storage key of the Rialto -> Millau message in the runtime storage.
|
||||
pub fn message_key(lane: &LaneId, nonce: MessageNonce) -> StorageKey {
|
||||
pallet_message_lane::storage_keys::message_key::<Runtime, <Rialto as ChainWithMessageLanes>::MessageLaneInstance>(
|
||||
lane, nonce,
|
||||
)
|
||||
}
|
||||
|
||||
/// Storage key of the Rialto -> Millau message lane state in the runtime storage.
|
||||
pub fn outbound_lane_data_key(lane: &LaneId) -> StorageKey {
|
||||
pallet_message_lane::storage_keys::outbound_lane_data_key::<<Rialto as ChainWithMessageLanes>::MessageLaneInstance>(
|
||||
lane,
|
||||
)
|
||||
}
|
||||
|
||||
/// Storage key of the Millau -> Rialto message lane state in the runtime storage.
|
||||
pub fn inbound_lane_data_key(lane: &LaneId) -> StorageKey {
|
||||
pallet_message_lane::storage_keys::inbound_lane_data_key::<
|
||||
Runtime,
|
||||
<Rialto as ChainWithMessageLanes>::MessageLaneInstance,
|
||||
>(lane)
|
||||
}
|
||||
|
||||
/// Message payload for Rialto -> Millau messages.
|
||||
pub type ToMillauMessagePayload = messages::source::FromThisChainMessagePayload<WithMillauMessageBridge>;
|
||||
|
||||
/// Message verifier for Rialto -> Millau messages.
|
||||
pub type ToMillauMessageVerifier = messages::source::FromThisChainMessageVerifier<WithMillauMessageBridge>;
|
||||
|
||||
/// Message payload for Millau -> Rialto messages.
|
||||
pub type FromMillauMessagePayload = messages::target::FromBridgedChainMessagePayload<WithMillauMessageBridge>;
|
||||
|
||||
/// Encoded Rialto Call as it comes from Millau.
|
||||
pub type FromMillauEncodedCall = messages::target::FromBridgedChainEncodedMessageCall<WithMillauMessageBridge>;
|
||||
|
||||
/// Call-dispatch based message dispatch for Millau -> Rialto messages.
|
||||
pub type FromMillauMessageDispatch = messages::target::FromBridgedChainMessageDispatch<
|
||||
WithMillauMessageBridge,
|
||||
crate::Runtime,
|
||||
pallet_bridge_call_dispatch::DefaultInstance,
|
||||
>;
|
||||
|
||||
/// Messages proof for Millau -> Rialto messages.
|
||||
pub type FromMillauMessagesProof = messages::target::FromBridgedChainMessagesProof<bp_millau::Hash>;
|
||||
|
||||
/// Messages delivery proof for Rialto -> Millau messages.
|
||||
pub type ToMillauMessagesDeliveryProof = messages::source::FromBridgedChainMessagesDeliveryProof<bp_millau::Hash>;
|
||||
|
||||
/// Millau <-> Rialto message bridge.
|
||||
#[derive(RuntimeDebug, Clone, Copy)]
|
||||
pub struct WithMillauMessageBridge;
|
||||
|
||||
impl MessageBridge for WithMillauMessageBridge {
|
||||
const INSTANCE: InstanceId = MILLAU_BRIDGE_INSTANCE;
|
||||
|
||||
const RELAYER_FEE_PERCENT: u32 = 10;
|
||||
|
||||
type ThisChain = Rialto;
|
||||
type BridgedChain = Millau;
|
||||
|
||||
fn maximal_extrinsic_size_on_target_chain() -> u32 {
|
||||
bp_millau::max_extrinsic_size()
|
||||
}
|
||||
|
||||
fn weight_limits_of_message_on_bridged_chain(_message_payload: &[u8]) -> RangeInclusive<Weight> {
|
||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||
let upper_limit = messages::target::maximal_incoming_message_dispatch_weight(bp_millau::max_extrinsic_weight());
|
||||
|
||||
// we're charging for payload bytes in `WithMillauMessageBridge::weight_of_delivery_transaction` function
|
||||
//
|
||||
// this bridge may be used to deliver all kind of messages, so we're not making any assumptions about
|
||||
// minimal dispatch weight here
|
||||
|
||||
0..=upper_limit
|
||||
}
|
||||
|
||||
fn weight_of_delivery_transaction(message_payload: &[u8]) -> Weight {
|
||||
let message_payload_len = u32::try_from(message_payload.len())
|
||||
.map(Into::into)
|
||||
.unwrap_or(Weight::MAX);
|
||||
let extra_bytes_in_payload =
|
||||
message_payload_len.saturating_sub(pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH.into());
|
||||
messages::transaction_weight_without_multiplier(
|
||||
bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
|
||||
message_payload_len.saturating_add(bp_rialto::EXTRA_STORAGE_PROOF_SIZE as _),
|
||||
extra_bytes_in_payload
|
||||
.saturating_mul(bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT)
|
||||
.saturating_add(bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT),
|
||||
)
|
||||
}
|
||||
|
||||
fn weight_of_delivery_confirmation_transaction_on_this_chain() -> Weight {
|
||||
let inbounded_data_size: Weight =
|
||||
InboundLaneData::<bp_millau::AccountId>::encoded_size_hint(bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, 1)
|
||||
.map(Into::into)
|
||||
.unwrap_or(Weight::MAX);
|
||||
|
||||
messages::transaction_weight_without_multiplier(
|
||||
bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
|
||||
inbounded_data_size.saturating_add(bp_millau::EXTRA_STORAGE_PROOF_SIZE as _),
|
||||
bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT,
|
||||
)
|
||||
}
|
||||
|
||||
fn this_weight_to_this_balance(weight: Weight) -> bp_rialto::Balance {
|
||||
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight)
|
||||
}
|
||||
|
||||
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_millau::Balance {
|
||||
// we're using the same weights in both chains now
|
||||
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight) as _
|
||||
}
|
||||
|
||||
fn bridged_balance_to_this_balance(bridged_balance: bp_millau::Balance) -> bp_rialto::Balance {
|
||||
bp_rialto::Balance::try_from(MillauToRialtoConversionRate::get().saturating_mul_int(bridged_balance))
|
||||
.unwrap_or(bp_rialto::Balance::MAX)
|
||||
}
|
||||
}
|
||||
|
||||
/// Rialto chain from message lane point of view.
|
||||
#[derive(RuntimeDebug, Clone, Copy)]
|
||||
pub struct Rialto;
|
||||
|
||||
impl messages::ChainWithMessageLanes for Rialto {
|
||||
type Hash = bp_rialto::Hash;
|
||||
type AccountId = bp_rialto::AccountId;
|
||||
type Signer = bp_rialto::AccountSigner;
|
||||
type Signature = bp_rialto::Signature;
|
||||
type Call = crate::Call;
|
||||
type Weight = Weight;
|
||||
type Balance = bp_rialto::Balance;
|
||||
|
||||
type MessageLaneInstance = crate::WithMillauMessageLaneInstance;
|
||||
}
|
||||
|
||||
impl messages::ThisChainWithMessageLanes for Rialto {
|
||||
fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
|
||||
*lane == LaneId::default()
|
||||
}
|
||||
|
||||
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
||||
MessageNonce::MAX
|
||||
}
|
||||
}
|
||||
|
||||
/// Millau chain from message lane point of view.
|
||||
#[derive(RuntimeDebug, Clone, Copy)]
|
||||
pub struct Millau;
|
||||
|
||||
impl messages::ChainWithMessageLanes for Millau {
|
||||
type Hash = bp_millau::Hash;
|
||||
type AccountId = bp_millau::AccountId;
|
||||
type Signer = bp_millau::AccountSigner;
|
||||
type Signature = bp_millau::Signature;
|
||||
type Call = (); // unknown to us
|
||||
type Weight = Weight;
|
||||
type Balance = bp_millau::Balance;
|
||||
|
||||
type MessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||
}
|
||||
|
||||
impl TargetHeaderChain<ToMillauMessagePayload, bp_millau::AccountId> for Millau {
|
||||
type Error = &'static str;
|
||||
// The proof is:
|
||||
// - hash of the header this proof has been created with;
|
||||
// - the storage proof of one or several keys;
|
||||
// - id of the lane we prove state of.
|
||||
type MessagesDeliveryProof = ToMillauMessagesDeliveryProof;
|
||||
|
||||
fn verify_message(payload: &ToMillauMessagePayload) -> Result<(), Self::Error> {
|
||||
messages::source::verify_chain_message::<WithMillauMessageBridge>(payload)
|
||||
}
|
||||
|
||||
fn verify_messages_delivery_proof(
|
||||
proof: Self::MessagesDeliveryProof,
|
||||
) -> Result<(LaneId, InboundLaneData<bp_rialto::AccountId>), Self::Error> {
|
||||
messages::source::verify_messages_delivery_proof::<WithMillauMessageBridge, Runtime>(proof)
|
||||
}
|
||||
}
|
||||
|
||||
impl SourceHeaderChain<bp_millau::Balance> for Millau {
|
||||
type Error = &'static str;
|
||||
// The proof is:
|
||||
// - hash of the header this proof has been created with;
|
||||
// - the storage proof of one or several keys;
|
||||
// - id of the lane we prove messages for;
|
||||
// - inclusive range of messages nonces that are proved.
|
||||
type MessagesProof = FromMillauMessagesProof;
|
||||
|
||||
fn verify_messages_proof(
|
||||
proof: Self::MessagesProof,
|
||||
messages_count: u32,
|
||||
) -> Result<ProvedMessages<Message<bp_millau::Balance>>, Self::Error> {
|
||||
messages::target::verify_messages_proof::<WithMillauMessageBridge, Runtime>(proof, messages_count)
|
||||
}
|
||||
}
|
||||
|
||||
/// Rialto -> Millau message lane pallet parameters.
|
||||
#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq)]
|
||||
pub enum RialtoToMillauMessageLaneParameter {
|
||||
/// The conversion formula we use is: `RialtoTokens = MillauTokens * conversion_rate`.
|
||||
MillauToRialtoConversionRate(FixedU128),
|
||||
}
|
||||
|
||||
impl MessageLaneParameter for RialtoToMillauMessageLaneParameter {
|
||||
fn save(&self) {
|
||||
match *self {
|
||||
RialtoToMillauMessageLaneParameter::MillauToRialtoConversionRate(ref conversion_rate) => {
|
||||
MillauToRialtoConversionRate::set(conversion_rate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
// Copyright 2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Configuration parameters for the Rialto PoA chain.
|
||||
|
||||
use crate::exchange::EthereumTransactionInclusionProof;
|
||||
|
||||
use bp_eth_poa::{Address, AuraHeader, RawTransaction, U256};
|
||||
use bp_header_chain::InclusionProofVerifier;
|
||||
use frame_support::RuntimeDebug;
|
||||
use hex_literal::hex;
|
||||
use pallet_bridge_eth_poa::{
|
||||
AuraConfiguration, ChainTime as TChainTime, PruningStrategy as TPruningStrategy, ValidatorsConfiguration,
|
||||
ValidatorsSource,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
frame_support::parameter_types! {
|
||||
pub const FinalityVotesCachingInterval: Option<u64> = Some(8);
|
||||
pub BridgeAuraConfiguration: AuraConfiguration =
|
||||
aura_configuration();
|
||||
pub BridgeValidatorsConfiguration: ValidatorsConfiguration =
|
||||
validators_configuration();
|
||||
}
|
||||
|
||||
/// Max number of finalized headers to keep.
|
||||
const FINALIZED_HEADERS_TO_KEEP: u64 = 5_000;
|
||||
|
||||
/// Aura engine configuration for Rialto chain.
|
||||
pub fn aura_configuration() -> AuraConfiguration {
|
||||
AuraConfiguration {
|
||||
empty_steps_transition: 0xfffffffff,
|
||||
strict_empty_steps_transition: 0,
|
||||
validate_step_transition: 0,
|
||||
validate_score_transition: 0,
|
||||
two_thirds_majority_transition: u64::max_value(),
|
||||
min_gas_limit: 0x1388.into(),
|
||||
max_gas_limit: U256::max_value(),
|
||||
maximum_extra_data_size: 0x20,
|
||||
}
|
||||
}
|
||||
|
||||
/// Validators configuration for Rialto PoA chain.
|
||||
pub fn validators_configuration() -> ValidatorsConfiguration {
|
||||
ValidatorsConfiguration::Single(ValidatorsSource::List(genesis_validators()))
|
||||
}
|
||||
|
||||
/// Genesis validators set of Rialto PoA chain.
|
||||
pub fn genesis_validators() -> Vec<Address> {
|
||||
vec![
|
||||
hex!("005e714f896a8b7cede9d38688c1a81de72a58e4").into(),
|
||||
hex!("007594304039c2937a12220338aab821d819f5a4").into(),
|
||||
hex!("004e7a39907f090e19b0b80a277e77b72b22e269").into(),
|
||||
]
|
||||
}
|
||||
|
||||
/// Genesis header of the Rialto PoA chain.
|
||||
///
|
||||
/// To obtain genesis header from a running node, invoke:
|
||||
/// ```bash
|
||||
/// $ http localhost:8545 jsonrpc=2.0 id=1 method=eth_getBlockByNumber params:='["earliest", false]' -v
|
||||
/// ```
|
||||
pub fn genesis_header() -> AuraHeader {
|
||||
AuraHeader {
|
||||
parent_hash: Default::default(),
|
||||
timestamp: 0,
|
||||
number: 0,
|
||||
author: Default::default(),
|
||||
transactions_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(),
|
||||
uncles_hash: hex!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347").into(),
|
||||
extra_data: vec![],
|
||||
state_root: hex!("a992d04c791620ed7ed96555a80cf0568355bb4bee2656f46899a4372f25f248").into(),
|
||||
receipts_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(),
|
||||
log_bloom: Default::default(),
|
||||
gas_used: Default::default(),
|
||||
gas_limit: 0x222222.into(),
|
||||
difficulty: 0x20000.into(),
|
||||
seal: vec![vec![0x80], {
|
||||
let mut vec = vec![0xb8, 0x41];
|
||||
vec.resize(67, 0);
|
||||
vec
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
/// Rialto PoA headers pruning strategy.
|
||||
///
|
||||
/// We do not prune unfinalized headers because exchange module only accepts
|
||||
/// claims from finalized headers. And if we're pruning unfinalized headers, then
|
||||
/// some claims may never be accepted.
|
||||
#[derive(Default, RuntimeDebug)]
|
||||
pub struct PruningStrategy;
|
||||
|
||||
impl TPruningStrategy for PruningStrategy {
|
||||
fn pruning_upper_bound(&mut self, _best_number: u64, best_finalized_number: u64) -> u64 {
|
||||
best_finalized_number.saturating_sub(FINALIZED_HEADERS_TO_KEEP)
|
||||
}
|
||||
}
|
||||
|
||||
/// ChainTime provider
|
||||
#[derive(Default)]
|
||||
pub struct ChainTime;
|
||||
|
||||
impl TChainTime for ChainTime {
|
||||
fn is_timestamp_ahead(&self, timestamp: u64) -> bool {
|
||||
let now = super::Timestamp::now();
|
||||
timestamp > now
|
||||
}
|
||||
}
|
||||
|
||||
/// The Rialto PoA Blockchain as seen by the runtime.
|
||||
pub struct RialtoBlockchain;
|
||||
|
||||
impl InclusionProofVerifier for RialtoBlockchain {
|
||||
type Transaction = RawTransaction;
|
||||
type TransactionInclusionProof = EthereumTransactionInclusionProof;
|
||||
|
||||
fn verify_transaction_inclusion_proof(proof: &Self::TransactionInclusionProof) -> Option<Self::Transaction> {
|
||||
let is_transaction_finalized =
|
||||
crate::BridgeRialtoPoA::verify_transaction_finalized(proof.block, proof.index, &proof.proof);
|
||||
|
||||
if !is_transaction_finalized {
|
||||
return None;
|
||||
}
|
||||
|
||||
proof.proof.get(proof.index as usize).map(|(tx, _)| tx.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn genesis_hash_matches() {
|
||||
assert_eq!(
|
||||
genesis_header().compute_hash(),
|
||||
hex!("1468e1a0fa20d30025a5a0f87e1cced4fdc393b84b7d2850b11ca5863db482cb").into(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pruning_strategy_keeps_enough_headers() {
|
||||
assert_eq!(
|
||||
PruningStrategy::default().pruning_upper_bound(100_000, 1_000),
|
||||
0,
|
||||
"1_000 <= 5_000 => nothing should be pruned yet",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PruningStrategy::default().pruning_upper_bound(100_000, 5_000),
|
||||
0,
|
||||
"5_000 <= 5_000 => nothing should be pruned yet",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PruningStrategy::default().pruning_upper_bound(100_000, 10_000),
|
||||
5_000,
|
||||
"5_000 <= 10_000 => we're ready to prune first 5_000 headers",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
[package]
|
||||
name = "bridge-runtime-common"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
homepage = "https://substrate.dev"
|
||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
ed25519-dalek = { version = "1.0", default-features = false, optional = true }
|
||||
hash-db = { version = "0.15.2", default-features = false }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-message-dispatch = { path = "../../primitives/message-dispatch", default-features = false }
|
||||
bp-message-lane = { path = "../../primitives/message-lane", default-features = false }
|
||||
bp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
pallet-bridge-call-dispatch = { path = "../../modules/call-dispatch", default-features = false }
|
||||
pallet-message-lane = { path = "../../modules/message-lane", default-features = false }
|
||||
pallet-substrate-bridge = { path = "../../modules/substrate", default-features = false }
|
||||
|
||||
# Substrate dependencies
|
||||
|
||||
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-state-machine = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false, optional = true }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"bp-message-dispatch/std",
|
||||
"bp-message-lane/std",
|
||||
"bp-runtime/std",
|
||||
"codec/std",
|
||||
"frame-support/std",
|
||||
"hash-db/std",
|
||||
"pallet-bridge-call-dispatch/std",
|
||||
"pallet-message-lane/std",
|
||||
"pallet-substrate-bridge/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"sp-state-machine/std",
|
||||
"sp-std/std",
|
||||
"sp-trie/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"ed25519-dalek/u64_backend",
|
||||
"pallet-message-lane/runtime-benchmarks",
|
||||
"pallet-substrate-bridge/runtime-benchmarks",
|
||||
"sp-state-machine",
|
||||
]
|
||||
@@ -0,0 +1,183 @@
|
||||
# Helpers for Message Lane Module Integration
|
||||
|
||||
The [`messages`](./src/messages.rs) module of this crate contains a bunch of helpers for integrating
|
||||
message lane module into your runtime. Basic prerequisites of these helpers are:
|
||||
- we're going to bridge Substrate-based chain with another Substrate-based chain;
|
||||
- both chains have [message lane module](../../modules/message-lane/README.md), Substrate bridge
|
||||
module and the [call dispatch module](../../modules/call-dispatch/README.md);
|
||||
- all message lanes are identical and may be used to transfer the same messages;
|
||||
- the messages sent over the bridge are dispatched using
|
||||
[call dispatch module](../../modules/call-dispatch/README.md);
|
||||
- the messages are `pallet_bridge_call_dispatch::MessagePayload` structures, where `call` field is
|
||||
encoded `Call` of the target chain. This means that the `Call` is opaque to the
|
||||
[message lane module](../../modules/message-lane/README.md) instance at the source chain.
|
||||
It is pre-encoded by the message submitter;
|
||||
- all proofs in the [message lane module](../../modules/message-lane/README.md) transactions are
|
||||
based on the storage proofs from the bridged chain: storage proof of the outbound message (value
|
||||
from the `pallet_message_lane::Store::MessagePayload` map), storage proof of the outbound lane
|
||||
state (value from the `pallet_message_lane::Store::OutboundLanes` map) and storage proof of the
|
||||
inbound lane state (value from the `pallet_message_lane::Store::InboundLanes` map);
|
||||
- storage proofs are built at the finalized headers of the corresponding chain. So all message lane
|
||||
transactions with proofs are verifying storage proofs against finalized chain headers from
|
||||
Substrate bridge module.
|
||||
|
||||
**IMPORTANT NOTE**: after reading this document, you may refer to our test runtimes
|
||||
([rialto_messages.rs](../millau/runtime/src/rialto_messages.rs) and/or
|
||||
[millau_messages.rs](../rialto/runtime/src/millau_messages.rs)) to see how to use these helpers.
|
||||
|
||||
## Contents
|
||||
- [`MessageBridge` Trait](#messagebridge-trait)
|
||||
- [`ChainWithMessageLanes` Trait ](#chainwithmessagelanes-trait)
|
||||
- [Helpers for the Source Chain](#helpers-for-the-source-chain)
|
||||
- [Helpers for the Target Chain](#helpers-for-the-target-chain)
|
||||
|
||||
## `MessageBridge` Trait
|
||||
|
||||
The essence of your integration will be a struct that implements a `MessageBridge` trait. Let's
|
||||
review every method and give some implementation hints here:
|
||||
|
||||
- `MessageBridge::maximal_extrinsic_size_on_target_chain`: you will need to return the maximal
|
||||
extrinsic size of the target chain from this function. This may be the constant that is updated
|
||||
when your runtime is upgraded, or you may use the
|
||||
[message lane parameters functionality](../../modules/message-lane/README.md#Non-Essential-Functionality)
|
||||
to allow the pallet owner to update this value more frequently (you may also want to use this
|
||||
functionality for all constants that are used in other methods described below).
|
||||
|
||||
- `MessageBridge::weight_limits_of_message_on_bridged_chain`: you'll need to return a range of
|
||||
dispatch weights that the outbound message may take at the target chain. Please keep in mind that
|
||||
our helpers assume that the message is an encoded call of the target chain. But we never decode
|
||||
this call at the source chain. So you can't simply get dispatch weight from pre-dispatch
|
||||
information. Instead there are two options to prepare this range: if you know which calls are to
|
||||
be sent over your bridge, then you may just return weight ranges for these particular calls.
|
||||
Otherwise, if you're going to accept all kinds of calls, you may just return range `[0; maximal
|
||||
incoming message dispatch weight]`. If you choose the latter, then you shall remember that the
|
||||
delivery transaction itself has some weight, so you can't accept messages with weight equal to
|
||||
maximal weight of extrinsic at the target chain. In our test chains, we reject all messages that
|
||||
have declared dispatch weight larger than 50% of the maximal bridged extrinsic weight.
|
||||
|
||||
- `MessageBridge::weight_of_delivery_transaction`: you will need to return the maximal weight of the
|
||||
delivery transaction that delivers a given message to the target chain. There are three main
|
||||
things to notice:
|
||||
|
||||
1. weight, returned from this function is then used to compute the fee that the
|
||||
message sender needs to pay for the delivery transaction. So it shall not be a simple dispatch
|
||||
weight of delivery call - it should be the "weight" of the transaction itself, including per-byte
|
||||
"weight", "weight" of signed extras and etc.
|
||||
1. the delivery transaction brings storage proof of
|
||||
the message, not the message itself. So your transaction will include extra bytes. We suggest
|
||||
computing the size of single empty value storage proof at the source chain, increase this value a
|
||||
bit and hardcode it in the source chain runtime code. This size then must be added to the size of
|
||||
payload and included in the weight computation;
|
||||
1. before implementing this function, please take
|
||||
a look at the
|
||||
[weight formula of delivery transaction](../../modules/message-lane/README.md#Weight-of-receive_messages_proof-call).
|
||||
It adds some extra weight for every additional byte of the proof (everything above
|
||||
`pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH`), so it's not trivial. Even better, please
|
||||
refer to [our implementation](../millau/runtime/src/rialto_messages.rs) for test chains for
|
||||
details.
|
||||
|
||||
- `MessageBridge::weight_of_delivery_confirmation_transaction_on_this_chain`: you'll need to return
|
||||
the maximal weight of a single message delivery confirmation transaction on this chain. All points
|
||||
from the previous paragraph are also relevant here.
|
||||
|
||||
- `MessageBridge::this_weight_to_this_balance`: this function needs to convert weight units into fee
|
||||
units on this chain. Most probably this can be done by calling
|
||||
`pallet_transaction_payment::Config::WeightToFee::calc()` for passed weight.
|
||||
|
||||
- `MessageBridge::bridged_weight_to_bridged_balance`: this function needs to convert weight units
|
||||
into fee units on the target chain. The best case is when you have the same conversion formula on
|
||||
both chains - then you may just call the same formula from the previous paragraph. Otherwise,
|
||||
you'll need to hardcode this formula into your runtime.
|
||||
|
||||
- `MessageBridge::bridged_balance_to_this_balance`: this may be the easiest method to implement and
|
||||
the hardest to maintain at the same time. If you don't have any automatic methods to determine
|
||||
conversion rate, then you'll probably need to maintain it by yourself (by updating conversion
|
||||
rate, stored in runtime storage). This means that if you're too late with an update, then you risk
|
||||
to accept messages with lower-than-expected fee. So it may be wise to have some reserve in this
|
||||
conversion rate, even if that means larger delivery and dispatch fees.
|
||||
|
||||
## `ChainWithMessageLanes` Trait
|
||||
|
||||
Apart from its methods, `MessageBridge` also has two associated types that are implementing the
|
||||
`ChainWithMessageLanes` trait. One is for this chain and the other is for the bridged chain. The
|
||||
trait is quite simple and can easily be implemented - you just need to specify types used at the
|
||||
corresponding chain. There are two exceptions, though. Both may be changed in the future. Here they
|
||||
are:
|
||||
|
||||
- `ChainWithMessageLanes::Call`: it isn't a good idea to reference bridged chain runtime from your
|
||||
runtime (cyclic references + maintaining on upgrades). So you can't know the type of bridged chain
|
||||
call in your runtime. This type isn't actually used at this chain, so you may use `()` instead.
|
||||
|
||||
- `ChainWithMessageLanes::MessageLaneInstance`: this is used to compute runtime storage keys. There
|
||||
may be several instances of message lane pallet, included in the Runtime. Every instance stores
|
||||
messages and these messages stored under different keys. When we are verifying storage proofs from
|
||||
the bridged chain, we should know which instance we're talking to. This is fine, but there's
|
||||
significant inconvenience with that - this chain runtime must have the same message lane pallet
|
||||
instance. This does not necessarily mean that we should use the same instance on both chains -
|
||||
this instance may be used to bridge with another chain/instance, or may not be used at all.
|
||||
|
||||
## Helpers for the Source Chain
|
||||
|
||||
The helpers for the Source Chain reside in the `source` submodule of the
|
||||
[`messages`](./src/messages.rs) module. The structs are: `FromThisChainMessagePayload`,
|
||||
`FromBridgedChainMessagesDeliveryProof`, `FromThisChainMessageVerifier`. And the helper functions
|
||||
are: `maximal_message_size`, `verify_chain_message`, `verify_messages_delivery_proof` and
|
||||
`estimate_message_dispatch_and_delivery_fee`.
|
||||
|
||||
`FromThisChainMessagePayload` is a message that the sender sends through our bridge. It is the
|
||||
`pallet_bridge_call_dispatch::MessagePayload`, where `call` field is encoded target chain call. So
|
||||
at this chain we don't see internals of this call - we just know its size.
|
||||
|
||||
`FromThisChainMessageVerifier` is an implementation of `bp_message_lane::LaneMessageVerifier`. It
|
||||
has following checks in its `verify_message` method:
|
||||
|
||||
1. it'll verify that the used outbound lane is enabled in our runtime;
|
||||
|
||||
1. it'll reject messages if there are too many undelivered outbound messages at this lane. The
|
||||
sender need to wait while relayers will do their work before sending the message again;
|
||||
|
||||
1. it'll reject a message if it has the wrong dispatch origin declared. Like if the submitter is not
|
||||
the root of this chain, but it tries to dispatch the message at the target chain using
|
||||
`pallet_bridge_call_dispatch::CallOrigin::SourceRoot` origin. Or he has provided wrong signature
|
||||
in the `pallet_bridge_call_dispatch::CallOrigin::TargetAccount` origin;
|
||||
|
||||
1. it'll reject a message if the delivery and dispatch fee that the submitter wants to pay is lesser
|
||||
than the fee that is computed using the `estimate_message_dispatch_and_delivery_fee` function.
|
||||
|
||||
`estimate_message_dispatch_and_delivery_fee` returns a minimal fee that the submitter needs to pay
|
||||
for sending a given message. The fee includes: payment for the delivery transaction at the target
|
||||
chain, payment for delivery confirmation transaction on this chain, payment for `Call` dispatch at
|
||||
the target chain and relayer interest.
|
||||
|
||||
`FromBridgedChainMessagesDeliveryProof` holds the lane identifier and the storage proof of this
|
||||
inbound lane state at the bridged chain. This also holds the hash of the target chain header, that
|
||||
was used to generate this storage proof. The proof is verified by the
|
||||
`verify_messages_delivery_proof`, which simply checks that the target chain header is finalized
|
||||
(using Substrate bridge module) and then reads the inbound lane state from the proof.
|
||||
|
||||
`verify_chain_message` function checks that the message may be delivered to the bridged chain. There
|
||||
are two main checks:
|
||||
|
||||
1. that the message size is less than or equal to the `2/3` of maximal extrinsic size at the target
|
||||
chain. We leave `1/3` for signed extras and for the storage proof overhead;
|
||||
|
||||
1. that the message dispatch weight is less than or equal to the `1/2` of maximal normal extrinsic
|
||||
weight at the target chain. We leave `1/2` for the delivery transaction overhead.
|
||||
|
||||
## Helpers for the Target Chain
|
||||
|
||||
The helpers for the target chain reside in the `target` submodule of the
|
||||
[`messages`](./src/messages.rs) module. The structs are: `FromBridgedChainMessagePayload`,
|
||||
`FromBridgedChainMessagesProof`, `FromBridgedChainMessagesProof`. And the helper functions are:
|
||||
`maximal_incoming_message_dispatch_weight`, `maximal_incoming_message_size` and
|
||||
`verify_messages_proof`.
|
||||
|
||||
`FromBridgedChainMessagePayload` corresponds to the `FromThisChainMessagePayload` at the bridged
|
||||
chain. We expect that messages with this payload are stored in the `OutboundMessages` storage map of
|
||||
the [message lane module](../../modules/message-lane/README.md). This map is used to build
|
||||
`FromBridgedChainMessagesProof`. The proof holds the lane id, range of message nonces included in
|
||||
the proof, storage proof of `OutboundMessages` entries and the hash of bridged chain header that has
|
||||
been used to build the proof. Additionally, there's storage proof may contain the proof of outbound
|
||||
lane state. It may be required to prune `relayers` entries at this chain (see
|
||||
[message lane module documentation](../../modules/message-lane/README.md#What-about-other-Constants-in-the-Message-Lane-Module-Configuration-Trait)
|
||||
for details). This proof is verified by the `verify_messages_proof` function.
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Common types/functions that may be used by runtimes of all bridged chains.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub mod messages;
|
||||
pub mod messages_benchmarking;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,224 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common 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.
|
||||
|
||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Everything required to run benchmarks of message-lanes, based on
|
||||
//! `bridge_runtime_common::messages` implementation.
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use crate::messages::{
|
||||
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, AccountIdOf, BalanceOf,
|
||||
BridgedChain, HashOf, MessageBridge, ThisChain,
|
||||
};
|
||||
|
||||
use bp_message_lane::{LaneId, MessageData, MessageKey, MessagePayload};
|
||||
use codec::Encode;
|
||||
use ed25519_dalek::{PublicKey, SecretKey, Signer, KEYPAIR_LENGTH, SECRET_KEY_LENGTH};
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_message_lane::benchmarking::{MessageDeliveryProofParams, MessageProofParams, ProofSize};
|
||||
use sp_core::Hasher;
|
||||
use sp_runtime::traits::Header;
|
||||
use sp_std::prelude::*;
|
||||
use sp_trie::{record_all_keys, trie_types::TrieDBMut, Layout, MemoryDB, Recorder, TrieMut};
|
||||
|
||||
/// Generate ed25519 signature to be used in `pallet_brdige_call_dispatch::CallOrigin::TargetAccount`.
|
||||
///
|
||||
/// Returns public key of the signer and the signature itself.
|
||||
pub fn ed25519_sign(target_call: &impl Encode, source_account_id: &impl Encode) -> ([u8; 32], [u8; 64]) {
|
||||
// key from the repo example (https://docs.rs/ed25519-dalek/1.0.1/ed25519_dalek/struct.SecretKey.html)
|
||||
let target_secret = SecretKey::from_bytes(&[
|
||||
157, 097, 177, 157, 239, 253, 090, 096, 186, 132, 074, 244, 146, 236, 044, 196, 068, 073, 197, 105, 123, 050,
|
||||
105, 025, 112, 059, 172, 003, 028, 174, 127, 096,
|
||||
])
|
||||
.expect("harcoded key is valid");
|
||||
let target_public: PublicKey = (&target_secret).into();
|
||||
|
||||
let mut target_pair_bytes = [0u8; KEYPAIR_LENGTH];
|
||||
target_pair_bytes[..SECRET_KEY_LENGTH].copy_from_slice(&target_secret.to_bytes());
|
||||
target_pair_bytes[SECRET_KEY_LENGTH..].copy_from_slice(&target_public.to_bytes());
|
||||
let target_pair = ed25519_dalek::Keypair::from_bytes(&target_pair_bytes).expect("hardcoded pair is valid");
|
||||
|
||||
let mut signature_message = Vec::new();
|
||||
target_call.encode_to(&mut signature_message);
|
||||
source_account_id.encode_to(&mut signature_message);
|
||||
let target_origin_signature = target_pair
|
||||
.try_sign(&signature_message)
|
||||
.expect("Ed25519 try_sign should not fail in benchmarks");
|
||||
|
||||
(target_public.to_bytes(), target_origin_signature.to_bytes())
|
||||
}
|
||||
|
||||
/// Prepare proof of messages for the `receive_messages_proof` call.
|
||||
pub fn prepare_message_proof<B, H, R, MM, ML, MH>(
|
||||
params: MessageProofParams,
|
||||
make_bridged_message_storage_key: MM,
|
||||
make_bridged_outbound_lane_data_key: ML,
|
||||
make_bridged_header: MH,
|
||||
message_dispatch_weight: Weight,
|
||||
message_payload: MessagePayload,
|
||||
) -> (FromBridgedChainMessagesProof<HashOf<BridgedChain<B>>>, Weight)
|
||||
where
|
||||
B: MessageBridge,
|
||||
H: Hasher,
|
||||
R: pallet_substrate_bridge::Config,
|
||||
<R::BridgedChain as bp_runtime::Chain>::Hash: Into<HashOf<BridgedChain<B>>>,
|
||||
MM: Fn(MessageKey) -> Vec<u8>,
|
||||
ML: Fn(LaneId) -> Vec<u8>,
|
||||
MH: Fn(H::Out) -> <R::BridgedChain as bp_runtime::Chain>::Header,
|
||||
{
|
||||
// prepare Bridged chain storage with messages and (optionally) outbound lane state
|
||||
let message_count = params
|
||||
.message_nonces
|
||||
.end()
|
||||
.saturating_sub(*params.message_nonces.start())
|
||||
+ 1;
|
||||
let mut storage_keys = Vec::with_capacity(message_count as usize + 1);
|
||||
let mut root = Default::default();
|
||||
let mut mdb = MemoryDB::default();
|
||||
{
|
||||
let mut trie = TrieDBMut::<H>::new(&mut mdb, &mut root);
|
||||
|
||||
// insert messages
|
||||
for nonce in params.message_nonces.clone() {
|
||||
let message_key = MessageKey {
|
||||
lane_id: params.lane,
|
||||
nonce,
|
||||
};
|
||||
let message_data = MessageData {
|
||||
fee: BalanceOf::<BridgedChain<B>>::from(0),
|
||||
payload: message_payload.clone(),
|
||||
};
|
||||
let storage_key = make_bridged_message_storage_key(message_key);
|
||||
trie.insert(&storage_key, &message_data.encode())
|
||||
.map_err(|_| "TrieMut::insert has failed")
|
||||
.expect("TrieMut::insert should not fail in benchmarks");
|
||||
storage_keys.push(storage_key);
|
||||
}
|
||||
|
||||
// insert outbound lane state
|
||||
if let Some(outbound_lane_data) = params.outbound_lane_data {
|
||||
let storage_key = make_bridged_outbound_lane_data_key(params.lane);
|
||||
trie.insert(&storage_key, &outbound_lane_data.encode())
|
||||
.map_err(|_| "TrieMut::insert has failed")
|
||||
.expect("TrieMut::insert should not fail in benchmarks");
|
||||
storage_keys.push(storage_key);
|
||||
}
|
||||
}
|
||||
root = grow_trie(root, &mut mdb, params.size);
|
||||
|
||||
// generate storage proof to be delivered to This chain
|
||||
let mut proof_recorder = Recorder::<H::Out>::new();
|
||||
record_all_keys::<Layout<H>, _>(&mdb, &root, &mut proof_recorder)
|
||||
.map_err(|_| "record_all_keys has failed")
|
||||
.expect("record_all_keys should not fail in benchmarks");
|
||||
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
||||
|
||||
// prepare Bridged chain header and insert it into the Substrate pallet
|
||||
let bridged_header = make_bridged_header(root);
|
||||
let bridged_header_hash = bridged_header.hash();
|
||||
pallet_substrate_bridge::initialize_for_benchmarks::<R>(bridged_header);
|
||||
|
||||
(
|
||||
FromBridgedChainMessagesProof {
|
||||
bridged_header_hash: bridged_header_hash.into(),
|
||||
storage_proof,
|
||||
lane: params.lane,
|
||||
nonces_start: *params.message_nonces.start(),
|
||||
nonces_end: *params.message_nonces.end(),
|
||||
},
|
||||
message_dispatch_weight
|
||||
.checked_mul(message_count)
|
||||
.expect("too many messages requested by benchmark"),
|
||||
)
|
||||
}
|
||||
|
||||
/// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call.
|
||||
pub fn prepare_message_delivery_proof<B, H, R, ML, MH>(
|
||||
params: MessageDeliveryProofParams<AccountIdOf<ThisChain<B>>>,
|
||||
make_bridged_inbound_lane_data_key: ML,
|
||||
make_bridged_header: MH,
|
||||
) -> FromBridgedChainMessagesDeliveryProof<HashOf<BridgedChain<B>>>
|
||||
where
|
||||
B: MessageBridge,
|
||||
H: Hasher,
|
||||
R: pallet_substrate_bridge::Config,
|
||||
<R::BridgedChain as bp_runtime::Chain>::Hash: Into<HashOf<BridgedChain<B>>>,
|
||||
ML: Fn(LaneId) -> Vec<u8>,
|
||||
MH: Fn(H::Out) -> <R::BridgedChain as bp_runtime::Chain>::Header,
|
||||
{
|
||||
// prepare Bridged chain storage with inbound lane state
|
||||
let storage_key = make_bridged_inbound_lane_data_key(params.lane);
|
||||
let mut root = Default::default();
|
||||
let mut mdb = MemoryDB::default();
|
||||
{
|
||||
let mut trie = TrieDBMut::<H>::new(&mut mdb, &mut root);
|
||||
trie.insert(&storage_key, ¶ms.inbound_lane_data.encode())
|
||||
.map_err(|_| "TrieMut::insert has failed")
|
||||
.expect("TrieMut::insert should not fail in benchmarks");
|
||||
}
|
||||
root = grow_trie(root, &mut mdb, params.size);
|
||||
|
||||
// generate storage proof to be delivered to This chain
|
||||
let mut proof_recorder = Recorder::<H::Out>::new();
|
||||
record_all_keys::<Layout<H>, _>(&mdb, &root, &mut proof_recorder)
|
||||
.map_err(|_| "record_all_keys has failed")
|
||||
.expect("record_all_keys should not fail in benchmarks");
|
||||
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
||||
|
||||
// prepare Bridged chain header and insert it into the Substrate pallet
|
||||
let bridged_header = make_bridged_header(root);
|
||||
let bridged_header_hash = bridged_header.hash();
|
||||
pallet_substrate_bridge::initialize_for_benchmarks::<R>(bridged_header);
|
||||
|
||||
FromBridgedChainMessagesDeliveryProof {
|
||||
bridged_header_hash: bridged_header_hash.into(),
|
||||
storage_proof,
|
||||
lane: params.lane,
|
||||
}
|
||||
}
|
||||
|
||||
/// Populate trie with dummy keys+values until trie has at least given size.
|
||||
fn grow_trie<H: Hasher>(mut root: H::Out, mdb: &mut MemoryDB<H>, trie_size: ProofSize) -> H::Out {
|
||||
let (iterations, leaf_size, minimal_trie_size) = match trie_size {
|
||||
ProofSize::Minimal(_) => return root,
|
||||
ProofSize::HasLargeLeaf(size) => (1, size, size),
|
||||
ProofSize::HasExtraNodes(size) => (8, 1, size),
|
||||
};
|
||||
|
||||
let mut key_index = 0;
|
||||
loop {
|
||||
// generate storage proof to be delivered to This chain
|
||||
let mut proof_recorder = Recorder::<H::Out>::new();
|
||||
record_all_keys::<Layout<H>, _>(mdb, &root, &mut proof_recorder)
|
||||
.map_err(|_| "record_all_keys has failed")
|
||||
.expect("record_all_keys should not fail in benchmarks");
|
||||
let size: usize = proof_recorder.drain().into_iter().map(|n| n.data.len()).sum();
|
||||
if size > minimal_trie_size as _ {
|
||||
return root;
|
||||
}
|
||||
|
||||
let mut trie = TrieDBMut::<H>::from_existing(mdb, &mut root)
|
||||
.map_err(|_| "TrieDBMut::from_existing has failed")
|
||||
.expect("TrieDBMut::from_existing should not fail in benchmarks");
|
||||
for _ in 0..iterations {
|
||||
trie.insert(&key_index.encode(), &vec![42u8; leaf_size as _])
|
||||
.map_err(|_| "TrieMut::insert has failed")
|
||||
.expect("TrieMut::insert should not fail in benchmarks");
|
||||
key_index += 1;
|
||||
}
|
||||
trie.commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
# This template contains all of the possible sections and their default values
|
||||
|
||||
# Note that all fields that take a lint level have these possible values:
|
||||
# * deny - An error will be produced and the check will fail
|
||||
# * warn - A warning will be produced, but the check will not fail
|
||||
# * allow - No warning or error will be produced, though in some cases a note
|
||||
# will be
|
||||
|
||||
# The values provided in this template are the default values that will be used
|
||||
# when any section or field is not specified in your own configuration
|
||||
|
||||
# If 1 or more target triples (and optionally, target_features) are specified,
|
||||
# only the specified targets will be checked when running `cargo deny check`.
|
||||
# This means, if a particular package is only ever used as a target specific
|
||||
# dependency, such as, for example, the `nix` crate only being used via the
|
||||
# `target_family = "unix"` configuration, that only having windows targets in
|
||||
# this list would mean the nix crate, as well as any of its exclusive
|
||||
# dependencies not shared by any other crates, would be ignored, as the target
|
||||
# list here is effectively saying which targets you are building for.
|
||||
targets = [
|
||||
# The triple can be any string, but only the target triples built in to
|
||||
# rustc (as of 1.40) can be checked against actual config expressions
|
||||
#{ triple = "x86_64-unknown-linux-musl" },
|
||||
# You can also specify which target_features you promise are enabled for a
|
||||
# particular target. target_features are currently not validated against
|
||||
# the actual valid features supported by the target architecture.
|
||||
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] },
|
||||
]
|
||||
|
||||
# This section is considered when running `cargo deny check advisories`
|
||||
# More documentation for the advisories section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
|
||||
[advisories]
|
||||
# The path where the advisory database is cloned/fetched into
|
||||
db-path = "~/.cargo/advisory-db"
|
||||
# The url of the advisory database to use
|
||||
db-urls = ["https://github.com/rustsec/advisory-db"]
|
||||
# The lint level for security vulnerabilities
|
||||
vulnerability = "deny"
|
||||
# The lint level for unmaintained crates
|
||||
unmaintained = "warn"
|
||||
# The lint level for crates that have been yanked from their source registry
|
||||
yanked = "warn"
|
||||
# The lint level for crates with security notices. Note that as of
|
||||
# 2019-12-17 there are no security notice advisories in
|
||||
# https://github.com/rustsec/advisory-db
|
||||
notice = "warn"
|
||||
# A list of advisory IDs to ignore. Note that ignored advisories will still
|
||||
# output a note when they are encountered.
|
||||
ignore = [
|
||||
# yaml-rust < clap. Not feasible to upgrade and also not possible to trigger in practice.
|
||||
"RUSTSEC-2018-0006",
|
||||
# We need to wait until Substrate updates their `wasmtime` dependency to fix this.
|
||||
# TODO: See issue #676: https://github.com/paritytech/parity-bridges-common/issues/676
|
||||
"RUSTSEC-2021-0013",
|
||||
# We need to wait until Substrate updates their `libp2p` dependency to fix this.
|
||||
# TODO: See issue #681: https://github.com/paritytech/parity-bridges-common/issues/681
|
||||
"RUSTSEC-2020-0123",
|
||||
# We need to wait until Substrate updates their `hyper` dependency to fix this.
|
||||
# TODO: See issue #710: https://github.com/paritytech/parity-bridges-common/issues/681
|
||||
"RUSTSEC-2021-0020",
|
||||
]
|
||||
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
|
||||
# lower than the range specified will be ignored. Note that ignored advisories
|
||||
# will still output a note when they are encountered.
|
||||
# * None - CVSS Score 0.0
|
||||
# * Low - CVSS Score 0.1 - 3.9
|
||||
# * Medium - CVSS Score 4.0 - 6.9
|
||||
# * High - CVSS Score 7.0 - 8.9
|
||||
# * Critical - CVSS Score 9.0 - 10.0
|
||||
#severity-threshold =
|
||||
|
||||
# This section is considered when running `cargo deny check licenses`
|
||||
# More documentation for the licenses section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
|
||||
[licenses]
|
||||
# The lint level for crates which do not have a detectable license
|
||||
unlicensed = "deny"
|
||||
# List of explictly allowed licenses
|
||||
# See https://spdx.org/licenses/ for list of possible licenses
|
||||
# [possible values: any SPDX 3.7 short identifier (+ optional exception)].
|
||||
allow = [
|
||||
"BlueOak-1.0.0"
|
||||
]
|
||||
# List of explictly disallowed licenses
|
||||
# See https://spdx.org/licenses/ for list of possible licenses
|
||||
# [possible values: any SPDX 3.7 short identifier (+ optional exception)].
|
||||
deny = [
|
||||
#"Nokia",
|
||||
]
|
||||
# Lint level for licenses considered copyleft
|
||||
copyleft = "allow"
|
||||
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
|
||||
# * both - The license will be approved if it is both OSI-approved *AND* FSF
|
||||
# * either - The license will be approved if it is either OSI-approved *OR* FSF
|
||||
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF
|
||||
# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved
|
||||
# * neither - This predicate is ignored and the default lint level is used
|
||||
allow-osi-fsf-free = "either"
|
||||
# Lint level used when no other predicates are matched
|
||||
# 1. License isn't in the allow or deny lists
|
||||
# 2. License isn't copyleft
|
||||
# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither"
|
||||
default = "deny"
|
||||
# The confidence threshold for detecting a license from license text.
|
||||
# The higher the value, the more closely the license text must be to the
|
||||
# canonical license text of a valid SPDX license file.
|
||||
# [possible values: any between 0.0 and 1.0].
|
||||
confidence-threshold = 0.9
|
||||
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
|
||||
# aren't accepted for every possible crate as with the normal allow list
|
||||
exceptions = [
|
||||
# Each entry is the crate and version constraint, and its specific allow
|
||||
# list
|
||||
#{ allow = ["Zlib"], name = "adler32", version = "*" },
|
||||
]
|
||||
|
||||
# Some crates don't have (easily) machine readable licensing information,
|
||||
# adding a clarification entry for it allows you to manually specify the
|
||||
# licensing information
|
||||
[[licenses.clarify]]
|
||||
# The name of the crate the clarification applies to
|
||||
name = "ring"
|
||||
# THe optional version constraint for the crate
|
||||
#version = "*"
|
||||
# The SPDX expression for the license requirements of the crate
|
||||
expression = "OpenSSL"
|
||||
# One or more files in the crate's source used as the "source of truth" for
|
||||
# the license expression. If the contents match, the clarification will be used
|
||||
# when running the license check, otherwise the clarification will be ignored
|
||||
# and the crate will be checked normally, which may produce warnings or errors
|
||||
# depending on the rest of your configuration
|
||||
license-files = [
|
||||
# Each entry is a crate relative path, and the (opaque) hash of its contents
|
||||
{ path = "LICENSE", hash = 0xbd0eed23 }
|
||||
]
|
||||
[[licenses.clarify]]
|
||||
name = "webpki"
|
||||
expression = "ISC"
|
||||
license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]
|
||||
|
||||
[licenses.private]
|
||||
# If true, ignores workspace crates that aren't published, or are only
|
||||
# published to private registries
|
||||
ignore = false
|
||||
# One or more private registries that you might publish crates to, if a crate
|
||||
# is only published to private registries, and ignore is true, the crate will
|
||||
# not have its license(s) checked
|
||||
registries = [
|
||||
#"https://sekretz.com/registry
|
||||
]
|
||||
|
||||
# This section is considered when running `cargo deny check bans`.
|
||||
# More documentation about the 'bans' section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
|
||||
[bans]
|
||||
# Lint level for when multiple versions of the same crate are detected
|
||||
multiple-versions = "warn"
|
||||
# The graph highlighting used when creating dotgraphs for crates
|
||||
# with multiple versions
|
||||
# * lowest-version - The path to the lowest versioned duplicate is highlighted
|
||||
# * simplest-path - The path to the version with the fewest edges is highlighted
|
||||
# * all - Both lowest-version and simplest-path are used
|
||||
highlight = "lowest-version"
|
||||
# List of crates that are allowed. Use with care!
|
||||
allow = [
|
||||
#{ name = "ansi_term", version = "=0.11.0" },
|
||||
]
|
||||
# List of crates to deny
|
||||
deny = [
|
||||
{ name = "parity-util-mem", version = "<0.6" }
|
||||
# Each entry the name of a crate and a version range. If version is
|
||||
# not specified, all versions will be matched.
|
||||
]
|
||||
# Certain crates/versions that will be skipped when doing duplicate detection.
|
||||
skip = [
|
||||
#{ name = "ansi_term", version = "=0.11.0" },
|
||||
]
|
||||
# Similarly to `skip` allows you to skip certain crates during duplicate
|
||||
# detection. Unlike skip, it also includes the entire tree of transitive
|
||||
# dependencies starting at the specified crate, up to a certain depth, which is
|
||||
# by default infinite
|
||||
skip-tree = [
|
||||
#{ name = "ansi_term", version = "=0.11.0", depth = 20 },
|
||||
]
|
||||
|
||||
# This section is considered when running `cargo deny check sources`.
|
||||
# More documentation about the 'sources' section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
|
||||
[sources]
|
||||
# Lint level for what to happen when a crate from a crate registry that is not
|
||||
# in the allow list is encountered
|
||||
unknown-registry = "deny"
|
||||
# Lint level for what to happen when a crate from a git repository that is not
|
||||
# in the allow list is encountered
|
||||
unknown-git = "allow"
|
||||
# List of URLs for allowed crate registries. Defaults to the crates.io index
|
||||
# if not specified. If it is specified but empty, no registries are allowed.
|
||||
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
|
||||
# List of URLs for allowed Git repositories
|
||||
allow-git = []
|
||||
@@ -0,0 +1,32 @@
|
||||
# Image with dependencies required to build projects from the bridge repo.
|
||||
#
|
||||
# This image is meant to be used as a building block when building images for
|
||||
# the various components in the bridge repo, such as nodes and relayers.
|
||||
FROM ubuntu:xenial
|
||||
|
||||
ENV LAST_DEPS_UPDATE 2020-12-21
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update && \
|
||||
apt-get install -y curl ca-certificates && \
|
||||
apt-get install -y cmake pkg-config libssl-dev git clang libclang-dev
|
||||
|
||||
ENV LAST_CERTS_UPDATE 2020-12-21
|
||||
|
||||
RUN update-ca-certificates && \
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
ENV LAST_RUST_UPDATE 2020-12-21
|
||||
|
||||
RUN rustup update stable && \
|
||||
rustup install nightly && \
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
||||
|
||||
RUN rustc -vV && \
|
||||
cargo -V && \
|
||||
gcc -v && \
|
||||
g++ -v && \
|
||||
cmake --version
|
||||
|
||||
ENV RUST_BACKTRACE 1
|
||||
@@ -0,0 +1,250 @@
|
||||
# Bridge Deployments
|
||||
|
||||
## Requirements
|
||||
Make sure to install `docker` and `docker-compose` to be able to run and test bridge deployments. If
|
||||
for whatever reason you can't or don't want to use Docker, you can find some scripts for running the
|
||||
bridge [here](https://github.com/svyatonik/parity-bridges-common.test).
|
||||
|
||||
## Networks
|
||||
One of the building blocks we use for our deployments are _networks_. A network is a collection of
|
||||
homogenous blockchain nodes. We have Docker Compose files for each network that we want to bridge.
|
||||
Each of the compose files found in the `./networks` folder is able to independently spin up a
|
||||
network like so:
|
||||
|
||||
```bash
|
||||
docker-compose -f ./networks/rialto.yml up
|
||||
```
|
||||
|
||||
After running this command we would have a network of several nodes producing blocks.
|
||||
|
||||
## Bridges
|
||||
A _bridge_ is a way for several _networks_ to connect to one another. Bridge deployments have their
|
||||
own Docker Compose files which can be found in the `./bridges` folder. These Compose files typically
|
||||
contain bridge relayers, which are services external to blockchain nodes, and other components such
|
||||
as testing infrastructure, or user interfaces.
|
||||
|
||||
Unlike the network Compose files, these *cannot* be deployed on their own. They must be combined
|
||||
with different networks.
|
||||
|
||||
In general, we can deploy the bridge using `docker-compose up` in the following way:
|
||||
|
||||
```bash
|
||||
docker-compose -f <bridge>.yml \
|
||||
-f <network_1>.yml \
|
||||
-f <network_2>.yml \
|
||||
-f <monitoring>.yml up
|
||||
```
|
||||
|
||||
If you want to see how the Compose commands are actually run, check out the source code of the
|
||||
[`./run.sh`](./run.sh).
|
||||
|
||||
One thing worth noting is that we have a _monitoring_ Compose file. This adds support for Prometheus
|
||||
and Grafana. We cover these in more details in the [Monitoring](#monitoring) section. At the moment
|
||||
the monitoring Compose file is _not_ optional, and must be included for bridge deployments.
|
||||
|
||||
### Running and Updating Deployments
|
||||
We currently support two bridge deployments
|
||||
1. Ethereum PoA to Rialto Substrate
|
||||
2. Rialto Substrate to Millau Substrate
|
||||
|
||||
These bridges can be deployed using our [`./run.sh`](./run.sh) script.
|
||||
|
||||
The first argument it takes is the name of the bridge you want to run. Right now we only support two
|
||||
bridges: `poa-rialto` and `rialto-millau`.
|
||||
|
||||
```bash
|
||||
./run.sh poa-rialto
|
||||
```
|
||||
|
||||
If you add a second `update` argument to the script it will pull the latest images from Docker Hub
|
||||
and restart the deployment.
|
||||
|
||||
```bash
|
||||
./run.sh rialto-millau update
|
||||
```
|
||||
|
||||
You can also bring down a deployment using the script with the `stop` argument.
|
||||
|
||||
```bash
|
||||
./run.sh poa-rialto stop
|
||||
```
|
||||
|
||||
### Adding Deployments
|
||||
We need two main things when adding a new deployment. First, the new network which we want to
|
||||
bridge. A compose file for the network should be added in the `/networks/` folder. Secondly we'll
|
||||
need a new bridge Compose file in `./bridges/`. This should configure the bridge relayer nodes
|
||||
correctly for the two networks, and add any additional components needed for the deployment. If you
|
||||
want you can also add support in the `./run` script for the new deployment. While recommended it's
|
||||
not strictly required.
|
||||
|
||||
## General Notes
|
||||
|
||||
Rialto authorities are named: `Alice`, `Bob`, `Charlie`, `Dave`, `Eve`.
|
||||
Rialto-PoA authorities are named: `Arthur`, `Bertha`, `Carlos`.
|
||||
Millau authorities are named: `Alice`, `Bob`, `Charlie`, `Dave`, `Eve`.
|
||||
|
||||
Both authorities and following accounts have enough funds (for test purposes) on corresponding Substrate chains:
|
||||
|
||||
- on Rialto: `Ferdie`, `George`, `Harry`.
|
||||
- on Millau: `Ferdie`, `George`, `Harry`.
|
||||
|
||||
Names of accounts on Substrate (Rialto and Millau) chains may be prefixed with `//` and used as
|
||||
seeds for the `sr25519` keys. This seed may also be used in the signer argument in Substrate
|
||||
and PoA relays. Example:
|
||||
|
||||
```bash
|
||||
./substrate-relay relay-headers rialto-to-millau \
|
||||
--rialto-host rialto-node-alice \
|
||||
--rialto-port 9944 \
|
||||
--millau-host millau-node-alice \
|
||||
--millau-port 9944 \
|
||||
--rialto-signer //Harry \
|
||||
--prometheus-host=0.0.0.0
|
||||
```
|
||||
|
||||
Some accounts are used by bridge components. Using these accounts to sign other transactions
|
||||
is not recommended, because this may lead to nonces conflict.
|
||||
|
||||
Following accounts are used when `poa-rialto` bridge is running:
|
||||
|
||||
- Rialto's `Alice` signs relay transactions with new Rialto-PoA headers;
|
||||
- Rialto's `Bob` signs relay transactions with Rialto-PoA -> Rialto currency exchange proofs.
|
||||
- Rialto-PoA's `Arthur`: signs relay transactions with new Rialto headers;
|
||||
- Rialto-PoA's `Bertha`: signs currency exchange transactions.
|
||||
|
||||
Following accounts are used when `rialto-millau` bridge is running:
|
||||
|
||||
- Millau's `Charlie` signs relay transactions with new Rialto headers;
|
||||
- Rialto's `Charlie` signs relay transactions with new Millau headers;
|
||||
- Millau's `Dave` signs Millau transactions which contain messages for Rialto;
|
||||
- Rialto's `Dave` signs Rialto transactions which contain messages for Millau;
|
||||
- Millau's `Eve` signs relay transactions with message delivery confirmations from Rialto to Millau;
|
||||
- Rialto's `Eve` signs relay transactions with messages from Millau to Rialto;
|
||||
- Millau's `Ferdie` signs relay transactions with messages from Rialto to Millau;
|
||||
- Rialto's `Ferdie` signs relay transactions with message delivery confirmations from Millau to Rialto.
|
||||
|
||||
### Docker Usage
|
||||
When the network is running you can query logs from individual nodes using:
|
||||
|
||||
```bash
|
||||
docker logs rialto_poa-node-bertha_1 -f
|
||||
```
|
||||
|
||||
To kill all left over containers and start the network from scratch next time:
|
||||
```bash
|
||||
docker ps -a --format "{{.ID}}" | xargs docker rm # This removes all containers!
|
||||
```
|
||||
|
||||
### Docker Compose Usage
|
||||
If you're not familiar with how to use `docker-compose` here are some useful commands you'll need
|
||||
when interacting with the bridge deployments:
|
||||
|
||||
```bash
|
||||
docker-compose pull # Get the latest images from the Docker Hub
|
||||
docker-compose build # This is going to build images
|
||||
docker-compose up # Start all the nodes
|
||||
docker-compose up -d # Start the nodes in detached mode.
|
||||
docker-compose down # Stop the network.
|
||||
```
|
||||
|
||||
Note that for the you'll need to add the appropriate `-f` arguments that were mentioned in the
|
||||
[Bridges](#bridges) section. You can read more about using multiple Compose files
|
||||
[here](https://docs.docker.com/compose/extends/#multiple-compose-files). One thing worth noting is
|
||||
that the _order_ the compose files are specified in matters. A different order will result in a
|
||||
different configuration.
|
||||
|
||||
You can sanity check the final config like so:
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.yml -f docker-compose.override.yml config > docker-compose.merged.yml
|
||||
```
|
||||
|
||||
## Docker and Git Deployment
|
||||
It is also possible to avoid using images from the Docker Hub and instead build
|
||||
containers from Git. There are two ways to build the images this way.
|
||||
|
||||
### Git Repo
|
||||
If you have cloned the bridges repo you can build local Docker images by running the following
|
||||
command at the top level of the repo:
|
||||
|
||||
```bash
|
||||
docker build . -t local/<project_you're_building> --build-arg=PROJECT=<project>
|
||||
```
|
||||
|
||||
This will build a local image of a particular component with a tag of
|
||||
`local/<project_you're_building>`. This tag can be used in Docker Compose files.
|
||||
|
||||
You can configure the build using using Docker
|
||||
[build arguments](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg).
|
||||
Here are the arguments currently supported:
|
||||
- `BRIDGE_REPO`: Git repository of the bridge node and relay code
|
||||
- `BRIDGE_HASH`: Commit hash within that repo (can also be a branch or tag)
|
||||
- `ETHEREUM_REPO`: Git repository of the OpenEthereum client
|
||||
- `ETHEREUM_HASH`: Commit hash within that repo (can also be a branch or tag)
|
||||
- `PROJECT`: Project to build withing bridges repo. Can be one of:
|
||||
- `rialto-bridge-node`
|
||||
- `millau-bridge-node`
|
||||
- `ethereum-poa-relay`
|
||||
- `substrate-relay`
|
||||
|
||||
### GitHub Actions
|
||||
We have a nightly job which runs and publishes Docker images for the different nodes and relayers to
|
||||
the [ParityTech Docker Hub](https://hub.docker.com/u/paritytech) organization. These images are used
|
||||
for our ephemeral (temporary) test networks. Additionally, any time a tag in the form of `v*` is
|
||||
pushed to GitHub the publishing job is run. This will build all the components (nodes, relayers) and
|
||||
publish them.
|
||||
|
||||
With images built using either method, all you have to do to use them in a deployment is change the
|
||||
`image` field in the existing Docker Compose files to point to the tag of the image you want to use.
|
||||
|
||||
### Monitoring
|
||||
[Prometheus](https://prometheus.io/) is used by the bridge relay to monitor information such as system
|
||||
resource use, and block data (e.g the best blocks it knows about). In order to visualize this data
|
||||
a [Grafana](https://grafana.com/) dashboard can be used.
|
||||
|
||||
As part of the Rialto `docker-compose` setup we spin up a Prometheus server and Grafana dashboard. The
|
||||
Prometheus server connects to the Prometheus data endpoint exposed by the bridge relay. The Grafana
|
||||
dashboard uses the Prometheus server as its data source.
|
||||
|
||||
The default port for the bridge relay's Prometheus data is `9616`. The host and port can be
|
||||
configured though the `--prometheus-host` and `--prometheus-port` flags. The Prometheus server's
|
||||
dashboard can be accessed at `http://localhost:9090`. The Grafana dashboard can be accessed at
|
||||
`http://localhost:3000`. Note that the default log-in credentials for Grafana are `admin:admin`.
|
||||
|
||||
### Environment Variables
|
||||
Here is an example `.env` file which is used for production deployments and network updates. For
|
||||
security reasons it is not kept as part of version control. When deploying a network this
|
||||
file should be correctly populated and kept in the appropriate [`bridges`](`./bridges`) deployment
|
||||
folder.
|
||||
|
||||
The `UI_SUBSTRATE_PROVIDER` variable lets you define the url of the Substrate node that the user
|
||||
interface will connect to. `UI_ETHEREUM_PROVIDER` is used only as a guidance for users to connect
|
||||
Metamask to the right Ethereum network. `UI_EXPECTED_ETHEREUM_NETWORK_ID` is used by
|
||||
the user interface as a fail safe to prevent users from connecting their Metamask extension to an
|
||||
unexpected network.
|
||||
|
||||
```bash
|
||||
GRAFANA_ADMIN_PASS=admin_pass
|
||||
GRAFANA_SERVER_ROOT_URL=%(protocol)s://%(domain)s:%(http_port)s/
|
||||
GRAFANA_SERVER_DOMAIN=server.domain.io
|
||||
MATRIX_ACCESS_TOKEN="access-token"
|
||||
WITH_PROXY=1 # Optional
|
||||
UI_SUBSTRATE_PROVIDER=ws://localhost:9944
|
||||
UI_ETHEREUM_PROVIDER=http://localhost:8545
|
||||
UI_EXPECTED_ETHEREUM_NETWORK_ID=105
|
||||
```
|
||||
|
||||
### UI
|
||||
|
||||
Use [wss://rialto.bridges.test-installations.parity.io/](https://polkadot.js.org/apps/)
|
||||
as a custom endpoint for [https://polkadot.js.org/apps/](https://polkadot.js.org/apps/).
|
||||
|
||||
### Polkadot.js UI
|
||||
|
||||
To teach the UI decode our custom types used in the pallet, go to: `Settings -> Developer`
|
||||
and import the [`./types.json`](./types.json)
|
||||
|
||||
## Scripts
|
||||
|
||||
The are some bash scripts in `scripts` folder that allow testing `Relay`
|
||||
without running the entire network within docker. Use if needed for development.
|
||||
@@ -0,0 +1,26 @@
|
||||
FROM node:12 as build-deps
|
||||
|
||||
# install tools and dependencies
|
||||
RUN set -eux; \
|
||||
apt-get install -y git
|
||||
|
||||
# clone UI repo
|
||||
RUN cd /usr/src/ && git clone https://github.com/paritytech/bridge-ui.git
|
||||
WORKDIR /usr/src/bridge-ui
|
||||
RUN yarn
|
||||
ARG SUBSTRATE_PROVIDER
|
||||
ARG ETHEREUM_PROVIDER
|
||||
ARG EXPECTED_ETHEREUM_NETWORK_ID
|
||||
|
||||
ENV SUBSTRATE_PROVIDER $SUBSTRATE_PROVIDER
|
||||
ENV ETHEREUM_PROVIDER $ETHEREUM_PROVIDER
|
||||
ENV EXPECTED_ETHEREUM_NETWORK_ID $EXPECTED_ETHEREUM_NETWORK_ID
|
||||
|
||||
RUN yarn build:docker
|
||||
|
||||
# Stage 2 - the production environment
|
||||
FROM nginx:1.12
|
||||
COPY --from=build-deps /usr/src/bridge-ui/nginx/*.conf /etc/nginx/conf.d/
|
||||
COPY --from=build-deps /usr/src/bridge-ui/dist /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
- name: 'default'
|
||||
orgId: 1
|
||||
folder: ''
|
||||
type: file
|
||||
options:
|
||||
path: '/etc/grafana/provisioning/dashboards'
|
||||
+474
@@ -0,0 +1,474 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 7,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"id": 2,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Exchange_best_block_numbers",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "Best {{type}} block",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Best finalized blocks",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 5,
|
||||
"x": 7,
|
||||
"y": 0
|
||||
},
|
||||
"id": 12,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Exchange_processed_blocks",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Number of processed blocks since last restart",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"links": []
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 9,
|
||||
"w": 6,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 6,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Exchange_system_average_load",
|
||||
"interval": "",
|
||||
"legendFormat": "Average system load in last {{over}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Average System Load",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 9,
|
||||
"w": 6,
|
||||
"x": 18,
|
||||
"y": 0
|
||||
},
|
||||
"id": 8,
|
||||
"options": {
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Exchange_process_cpu_usage_percentage",
|
||||
"interval": "",
|
||||
"legendFormat": "1 CPU = 100",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Relay Process CPU Usage",
|
||||
"type": "gauge"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 10,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 7
|
||||
},
|
||||
"id": 14,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Exchange_processed_transactions",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "{{type}} transactions",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Number of processed transactions since last restart",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"links": []
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 9
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 10,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Exchange_process_memory_usage_bytes / 1024 / 1024",
|
||||
"interval": "",
|
||||
"legendFormat": "Process memory, MB",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Memory Usage for Relay Process",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 26,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-5m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": [
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
]
|
||||
},
|
||||
"timezone": "",
|
||||
"title": "Ethereum PoA to Rialto Exchange Dashboard",
|
||||
"uid": "relay-poa-to-rialto-exchange",
|
||||
"version": 1
|
||||
}
|
||||
+694
@@ -0,0 +1,694 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"alert": {
|
||||
"alertRuleTags": {},
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
"params": [
|
||||
5
|
||||
],
|
||||
"type": "gt"
|
||||
},
|
||||
"operator": {
|
||||
"type": "and"
|
||||
},
|
||||
"query": {
|
||||
"params": [
|
||||
"A",
|
||||
"5m",
|
||||
"now"
|
||||
]
|
||||
},
|
||||
"reducer": {
|
||||
"params": [],
|
||||
"type": "min"
|
||||
},
|
||||
"type": "query"
|
||||
}
|
||||
],
|
||||
"executionErrorState": "alerting",
|
||||
"for": "5m",
|
||||
"frequency": "5m",
|
||||
"handler": 1,
|
||||
"message": "",
|
||||
"name": "Synced Header Difference is Over 5 (Ethereum PoA to Rialto)",
|
||||
"noDataState": "no_data",
|
||||
"notifications": []
|
||||
},
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "Shows how many headers behind the target chain is from the source chain.",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 14,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max(Ethereum_to_Substrate_Sync_best_block_numbers{node=\"source\"}) - max(Ethereum_to_Substrate_Sync_best_block_numbers{node=\"target\"})",
|
||||
"format": "table",
|
||||
"instant": false,
|
||||
"interval": "",
|
||||
"legendFormat": "",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Difference Between Source and Target Headers",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"alert": {
|
||||
"alertRuleTags": {},
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
"params": [
|
||||
5
|
||||
],
|
||||
"type": "lt"
|
||||
},
|
||||
"operator": {
|
||||
"type": "and"
|
||||
},
|
||||
"query": {
|
||||
"params": [
|
||||
"A",
|
||||
"2m",
|
||||
"now"
|
||||
]
|
||||
},
|
||||
"reducer": {
|
||||
"params": [],
|
||||
"type": "min"
|
||||
},
|
||||
"type": "query"
|
||||
}
|
||||
],
|
||||
"executionErrorState": "alerting",
|
||||
"for": "3m",
|
||||
"frequency": "5m",
|
||||
"handler": 1,
|
||||
"name": "No New Headers (Ethereum PoA to Rialto)",
|
||||
"noDataState": "no_data",
|
||||
"notifications": []
|
||||
},
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "How many headers has the relay synced from the source node in the last 2 mins?",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 16,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max_over_time(Ethereum_to_Substrate_Sync_best_block_numbers{node=\"source\"}[2m])-min_over_time(Ethereum_to_Substrate_Sync_best_block_numbers{node=\"source\"}[2m])",
|
||||
"interval": "",
|
||||
"legendFormat": "Number of Ethereum PoA Headers Synced on Rialto",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "lt",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Headers Synced on Rialto (Last 2 Mins)",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {
|
||||
"align": null
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 8
|
||||
},
|
||||
"id": 2,
|
||||
"interval": "5s",
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Sync_best_block_numbers",
|
||||
"format": "time_series",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"intervalFactor": 1,
|
||||
"legendFormat": "Best Known Header on {{node}} Node",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Best Blocks according to Relay",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 6,
|
||||
"x": 12,
|
||||
"y": 8
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 6,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Sync_system_average_load",
|
||||
"interval": "",
|
||||
"legendFormat": "Average system load in last {{over}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Average System Load",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 6,
|
||||
"x": 18,
|
||||
"y": 8
|
||||
},
|
||||
"id": 12,
|
||||
"options": {
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg_over_time(Ethereum_to_Substrate_Sync_process_cpu_usage_percentage[1m])",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "1 CPU = 100",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Relay Process CPU Usage ",
|
||||
"type": "gauge"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 10,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Sync_blocks_in_state",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "{{state}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Queued Headers in Relay",
|
||||
"type": "bargauge"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 16
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 10,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Ethereum_to_Substrate_Sync_process_memory_usage_bytes / 1024 / 1024",
|
||||
"interval": "",
|
||||
"legendFormat": "Process memory, MB",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Memory Usage for Relay Process",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 26,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-5m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": [
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
]
|
||||
},
|
||||
"timezone": "",
|
||||
"title": "Ethereum PoA to Rialto Header Sync Dashboard",
|
||||
"uid": "relay-poa-to-rialto-headers",
|
||||
"version": 1
|
||||
}
|
||||
+694
@@ -0,0 +1,694 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"alert": {
|
||||
"alertRuleTags": {},
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
"params": [
|
||||
5
|
||||
],
|
||||
"type": "gt"
|
||||
},
|
||||
"operator": {
|
||||
"type": "and"
|
||||
},
|
||||
"query": {
|
||||
"params": [
|
||||
"A",
|
||||
"5m",
|
||||
"now"
|
||||
]
|
||||
},
|
||||
"reducer": {
|
||||
"params": [],
|
||||
"type": "min"
|
||||
},
|
||||
"type": "query"
|
||||
}
|
||||
],
|
||||
"executionErrorState": "alerting",
|
||||
"for": "5m",
|
||||
"frequency": "5m",
|
||||
"handler": 1,
|
||||
"message": "",
|
||||
"name": "Synced Header Difference is Over 5 (Rialto to Ethereum PoA)",
|
||||
"noDataState": "no_data",
|
||||
"notifications": []
|
||||
},
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "Shows how many headers behind the target chain is from the source chain.",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 14,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max(Substrate_to_Ethereum_Sync_best_block_numbers{node=\"source\"}) - max(Substrate_to_Ethereum_Sync_best_block_numbers{node=\"target\"})",
|
||||
"format": "table",
|
||||
"instant": false,
|
||||
"interval": "",
|
||||
"legendFormat": "",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Difference Between Source and Target Headers",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"alert": {
|
||||
"alertRuleTags": {},
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
"params": [
|
||||
5
|
||||
],
|
||||
"type": "lt"
|
||||
},
|
||||
"operator": {
|
||||
"type": "and"
|
||||
},
|
||||
"query": {
|
||||
"params": [
|
||||
"A",
|
||||
"2m",
|
||||
"now"
|
||||
]
|
||||
},
|
||||
"reducer": {
|
||||
"params": [],
|
||||
"type": "min"
|
||||
},
|
||||
"type": "query"
|
||||
}
|
||||
],
|
||||
"executionErrorState": "alerting",
|
||||
"for": "3m",
|
||||
"frequency": "5m",
|
||||
"handler": 1,
|
||||
"name": "No New Headers (Rialto to Ethereum PoA)",
|
||||
"noDataState": "no_data",
|
||||
"notifications": []
|
||||
},
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "How many headers has the relay synced from the source node in the last 2 mins?",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 16,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max_over_time(Substrate_to_Ethereum_Sync_best_block_numbers{node=\"source\"}[2m])-min_over_time(Substrate_to_Ethereum_Sync_best_block_numbers{node=\"source\"}[2m])",
|
||||
"interval": "",
|
||||
"legendFormat": "Number of Rialto Headers Synced on Ethereum PoA",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "lt",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Headers Synced on Ethereum PoA (Last 2 Mins)",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {
|
||||
"align": null
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 8
|
||||
},
|
||||
"id": 2,
|
||||
"interval": "5s",
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Substrate_to_Ethereum_Sync_best_block_numbers",
|
||||
"format": "time_series",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"intervalFactor": 1,
|
||||
"legendFormat": "Best Known Header on {{node}} Node",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Best Blocks according to Relay",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 6,
|
||||
"x": 12,
|
||||
"y": 8
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 6,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Substrate_to_Ethereum_Sync_system_average_load",
|
||||
"interval": "",
|
||||
"legendFormat": "Average system load in last {{over}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Average System Load",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 6,
|
||||
"x": 18,
|
||||
"y": 8
|
||||
},
|
||||
"id": 12,
|
||||
"options": {
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg_over_time(Substrate_to_Ethereum_Sync_process_cpu_usage_percentage[1m])",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "1 CPU = 100",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Relay Process CPU Usage ",
|
||||
"type": "gauge"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 10,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Substrate_to_Ethereum_Sync_blocks_in_state",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "{{state}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Queued Headers in Relay",
|
||||
"type": "bargauge"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 16
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 10,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Substrate_to_Ethereum_Sync_process_memory_usage_bytes / 1024 / 1024",
|
||||
"interval": "",
|
||||
"legendFormat": "Process memory, MB",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Memory Usage for Relay Process",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 26,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-5m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": [
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
]
|
||||
},
|
||||
"timezone": "",
|
||||
"title": "Rialto to Ethereum PoA Header Sync Dashboard",
|
||||
"uid": "relay-rialto-to-poa-headers",
|
||||
"version": 1
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
# list of datasources to insert/update depending
|
||||
# whats available in the database
|
||||
datasources:
|
||||
# <string, required> name of the datasource. Required
|
||||
- name: Prometheus
|
||||
# <string, required> datasource type. Required
|
||||
type: prometheus
|
||||
# <string, required> access mode. direct or proxy. Required
|
||||
access: proxy
|
||||
# <int> org id. will default to orgId 1 if not specified
|
||||
orgId: 1
|
||||
# <string> url
|
||||
url: http://prometheus-metrics:9090
|
||||
# <bool> mark as default datasource. Max one per org
|
||||
isDefault: true
|
||||
version: 1
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
notifiers:
|
||||
- name: Matrix
|
||||
type: webhook
|
||||
uid: notifier1
|
||||
is_default: true
|
||||
send_reminder: true
|
||||
frequency: 1h
|
||||
disable_resolve_message: false
|
||||
settings:
|
||||
url: http://grafana-matrix-notifier:4567/hook?rule=bridge
|
||||
http_method: POST
|
||||
|
||||
delete_notifiers:
|
||||
- name: Matrix
|
||||
uid: notifier1
|
||||
@@ -0,0 +1,24 @@
|
||||
scrape_configs:
|
||||
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
||||
- job_name: 'poa_to_rialto_relay_node'
|
||||
|
||||
# Override the global default and scrape targets from this job every 15 seconds.
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['relay-headers-poa-to-rialto:9616']
|
||||
|
||||
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
||||
- job_name: 'poa_exchange_rialto_relay_node'
|
||||
|
||||
# Override the global default and scrape targets from this job every 15 seconds.
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['relay-poa-exchange-rialto:9616']
|
||||
|
||||
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
||||
- job_name: 'rialto_to_poa_relay_node'
|
||||
|
||||
# Override the global default and scrape targets from this job every 15 seconds.
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['relay-headers-rialto-to-poa:9616']
|
||||
@@ -0,0 +1,92 @@
|
||||
# This Compose file should be built using the Rialto and Eth-PoA node
|
||||
# compose files. Otherwise it won't work.
|
||||
|
||||
version: '3.5'
|
||||
services:
|
||||
# We override these nodes to make sure we have the correct chain config for this network.
|
||||
poa-node-arthur: &poa-node
|
||||
volumes:
|
||||
- ./bridges/poa-rialto/poa-config:/config
|
||||
poa-node-bertha:
|
||||
<<: *poa-node
|
||||
poa-node-carlos:
|
||||
<<: *poa-node
|
||||
|
||||
# We provide an override for this particular node since this is a public facing
|
||||
# node which we use to connect from things like Polkadot JS Apps.
|
||||
rialto-node-charlie:
|
||||
environment:
|
||||
VIRTUAL_HOST: rialto.bridges.test-installations.parity.io,wss.rialto.brucke.link
|
||||
VIRTUAL_PORT: 9944
|
||||
LETSENCRYPT_HOST: rialto.bridges.test-installations.parity.io,wss.rialto.brucke.link
|
||||
LETSENCRYPT_EMAIL: admin@parity.io
|
||||
|
||||
relay-headers-poa-to-rialto: ð-poa-relay
|
||||
image: paritytech/ethereum-poa-relay
|
||||
entrypoint: /entrypoints/relay-headers-poa-to-rialto-entrypoint.sh
|
||||
volumes:
|
||||
- ./bridges/poa-rialto/entrypoints:/entrypoints
|
||||
environment:
|
||||
RUST_LOG: rpc=trace,bridge=trace
|
||||
ports:
|
||||
- "9616:9616"
|
||||
depends_on: &all-nodes
|
||||
- poa-node-arthur
|
||||
- poa-node-bertha
|
||||
- poa-node-carlos
|
||||
- rialto-node-alice
|
||||
- rialto-node-bob
|
||||
- rialto-node-charlie
|
||||
- rialto-node-dave
|
||||
- rialto-node-eve
|
||||
|
||||
relay-poa-exchange-rialto:
|
||||
<<: *eth-poa-relay
|
||||
entrypoint: /entrypoints/relay-poa-exchange-rialto-entrypoint.sh
|
||||
ports:
|
||||
- "9716:9616"
|
||||
|
||||
relay-headers-rialto-to-poa:
|
||||
<<: *eth-poa-relay
|
||||
entrypoint: /entrypoints/relay-headers-rialto-to-poa-entrypoint.sh
|
||||
ports:
|
||||
- "9816:9616"
|
||||
|
||||
poa-exchange-tx-generator:
|
||||
<<: *eth-poa-relay
|
||||
entrypoint: /entrypoints/poa-exchange-tx-generator-entrypoint.sh
|
||||
environment:
|
||||
EXCHANGE_GEN_MIN_AMOUNT_FINNEY: ${EXCHANGE_GEN_MIN_AMOUNT_FINNEY:-1}
|
||||
EXCHANGE_GEN_MAX_AMOUNT_FINNEY: ${EXCHANGE_GEN_MAX_AMOUNT_FINNEY:-100000}
|
||||
EXCHANGE_GEN_MAX_SUBMIT_DELAY_S: ${EXCHANGE_GEN_MAX_SUBMIT_DELAY_S:-60}
|
||||
ports:
|
||||
- "9916:9616"
|
||||
depends_on:
|
||||
- relay-headers-poa-to-rialto
|
||||
- relay-headers-rialto-to-poa
|
||||
|
||||
front-end:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./bridges/poa-rialto/Front-end.Dockerfile
|
||||
args:
|
||||
SUBSTRATE_PROVIDER: ${UI_SUBSTRATE_PROVIDER:-ws://localhost:9944}
|
||||
ETHEREUM_PROVIDER: ${UI_ETHEREUM_PROVIDER:-http://localhost:8545}
|
||||
EXPECTED_ETHEREUM_NETWORK_ID: ${UI_EXPECTED_ETHEREUM_NETWORK_ID:-105}
|
||||
ports:
|
||||
- "8080:80"
|
||||
|
||||
# Note: These are being overridden from the top level `monitoring` compose file.
|
||||
prometheus-metrics:
|
||||
volumes:
|
||||
- ./bridges/poa-rialto/dashboard/prometheus/:/etc/prometheus/
|
||||
depends_on: *all-nodes
|
||||
|
||||
grafana-dashboard:
|
||||
volumes:
|
||||
- ./bridges/poa-rialto/dashboard/grafana/provisioning/:/etc/grafana/provisioning/
|
||||
environment:
|
||||
VIRTUAL_HOST: dashboard.rialto.bridges.test-installations.parity.io,grafana.rialto.brucke.link
|
||||
VIRTUAL_PORT: 3000
|
||||
LETSENCRYPT_HOST: dashboard.rialto.bridges.test-installations.parity.io,grafana.rialto.brucke.link
|
||||
LETSENCRYPT_EMAIL: admin@parity.io
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/bin/bash
|
||||
|
||||
# THIS SCRIPT IS NOT INTENDED FOR USE IN PRODUCTION ENVIRONMENT
|
||||
#
|
||||
# This scripts periodically calls relay binary to generate PoA -> Substrate
|
||||
# exchange transaction from hardcoded PoA senders (assuming they have
|
||||
# enough funds) to hardcoded Substrate recipients.
|
||||
|
||||
set -eu
|
||||
|
||||
# Path to relay binary
|
||||
RELAY_BINARY_PATH=${RELAY_BINARY_PATH:-./ethereum-poa-relay}
|
||||
# Ethereum node host
|
||||
ETH_HOST=${ETH_HOST:-poa-node-arthur}
|
||||
# Ethereum node port
|
||||
ETH_PORT=${ETH_PORT:-8545}
|
||||
# Ethereum chain id
|
||||
ETH_CHAIN_ID=${ETH_CHAIN_ID:-105}
|
||||
|
||||
# All possible Substrate recipients (hex-encoded public keys)
|
||||
SUB_RECIPIENTS=(
|
||||
# Alice (5GrwvaEF...)
|
||||
"d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"\
|
||||
# Bob (5FHneW46...)
|
||||
"8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48"\
|
||||
# Charlie (5FLSigC9...)
|
||||
"90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22"\
|
||||
# Dave (5DAAnrj7...)
|
||||
"306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc20"\
|
||||
# Eve (5HGjWAeF...)
|
||||
"e659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e"\
|
||||
# Ferdie (5CiPPseX...)
|
||||
"1cbd2d43530a44705ad088af313e18f80b53ef16b36177cd4b77b846f2a5f07c"
|
||||
)
|
||||
# All possible Ethereum signers (hex-encoded private keys)
|
||||
# (note that we're tracking nonce here => sender must not send concurrent transactions)
|
||||
ETH_SIGNERS=(
|
||||
# Bertha account (0x007594304039c2937a12220338aab821d819f5a4) and its current nonce (unknown by default)
|
||||
"bc10e0f21e33456ade82182dd1ebdbdd89bca923d4e4adbd90fb5b44d7098cbe" ""
|
||||
)
|
||||
# Minimal exchange amount (in finney)
|
||||
MIN_EXCHANGE_AMOUNT_FINNEY=${EXCHANGE_GEN_MIN_AMOUNT_FINNEY:-1} # 0.1 ETH
|
||||
# Maximal exchange amount (in finney)
|
||||
MAX_EXCHANGE_AMOUNT_FINNEY=${EXCHANGE_GEN_MAX_AMOUNT_FINNEY:-100000} # 100 ETH
|
||||
# Max delay before submitting transactions (s)
|
||||
MAX_SUBMIT_DELAY_S=${EXCHANGE_GEN_MAX_SUBMIT_DELAY_S:-60}
|
||||
|
||||
while true
|
||||
do
|
||||
# sleep some time
|
||||
SUBMIT_DELAY_S=`shuf -i 0-$MAX_SUBMIT_DELAY_S -n 1`
|
||||
echo "Sleeping $SUBMIT_DELAY_S seconds..."
|
||||
sleep $SUBMIT_DELAY_S
|
||||
|
||||
# select recipient
|
||||
SUB_RECIPIENTS_MAX_INDEX=$((${#SUB_RECIPIENTS[@]} - 1))
|
||||
SUB_RECIPIENT_INDEX=`shuf -i 0-$SUB_RECIPIENTS_MAX_INDEX -n 1`
|
||||
SUB_RECIPIENT=${SUB_RECIPIENTS[$SUB_RECIPIENT_INDEX]}
|
||||
|
||||
# select signer
|
||||
ETH_SIGNERS_MAX_INDEX=$(((${#ETH_SIGNERS[@]} - 1) / 2))
|
||||
ETH_SIGNERS_INDEX=`shuf -i 0-$ETH_SIGNERS_MAX_INDEX -n 1`
|
||||
ETH_SIGNER_INDEX=$(($ETH_SIGNERS_INDEX * 2))
|
||||
ETH_SIGNER_NONCE_INDEX=$(($ETH_SIGNER_INDEX + 1))
|
||||
ETH_SIGNER=${ETH_SIGNERS[$ETH_SIGNER_INDEX]}
|
||||
ETH_SIGNER_NONCE=${ETH_SIGNERS[$ETH_SIGNER_NONCE_INDEX]}
|
||||
if [ -z $ETH_SIGNER_NONCE ]; then
|
||||
ETH_SIGNER_NONCE_ARG=
|
||||
else
|
||||
ETH_SIGNER_NONCE_ARG=`printf -- "--eth-nonce=%s" $ETH_SIGNER_NONCE`
|
||||
fi
|
||||
|
||||
# select amount
|
||||
EXCHANGE_AMOUNT_FINNEY=`shuf -i $MIN_EXCHANGE_AMOUNT_FINNEY-$MAX_EXCHANGE_AMOUNT_FINNEY -n 1`
|
||||
EXCHANGE_AMOUNT_ETH=`printf "%s000" $EXCHANGE_AMOUNT_FINNEY`
|
||||
|
||||
# submit transaction
|
||||
echo "Sending $EXCHANGE_AMOUNT_ETH from PoA:$ETH_SIGNER to Substrate:$SUB_RECIPIENT. Nonce: $ETH_SIGNER_NONCE"
|
||||
set -x
|
||||
SUBMIT_OUTPUT=`$RELAY_BINARY_PATH 2>&1 eth-submit-exchange-tx \
|
||||
--sub-recipient=$SUB_RECIPIENT \
|
||||
--eth-host=$ETH_HOST \
|
||||
--eth-port=$ETH_PORT \
|
||||
--eth-chain-id=$ETH_CHAIN_ID \
|
||||
--eth-signer=$ETH_SIGNER \
|
||||
--eth-amount=$EXCHANGE_AMOUNT_ETH \
|
||||
$ETH_SIGNER_NONCE_ARG`
|
||||
set +x
|
||||
|
||||
# update sender nonce
|
||||
SUBMIT_OUTPUT_RE='nonce: ([0-9]+)'
|
||||
if [[ $SUBMIT_OUTPUT =~ $SUBMIT_OUTPUT_RE ]]; then
|
||||
ETH_SIGNER_NONCE=${BASH_REMATCH[1]}
|
||||
ETH_SIGNERS[$ETH_SIGNER_NONCE_INDEX]=$(($ETH_SIGNER_NONCE + 1))
|
||||
else
|
||||
echo "Missing nonce in relay response: $SUBMIT_OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -xeu
|
||||
|
||||
sleep 3
|
||||
curl -v http://poa-node-arthur:8545/api/health
|
||||
curl -v http://poa-node-bertha:8545/api/health
|
||||
curl -v http://poa-node-carlos:8545/api/health
|
||||
curl -v http://rialto-node-alice:9933/health
|
||||
curl -v http://rialto-node-bob:9933/health
|
||||
curl -v http://rialto-node-charlie:9933/health
|
||||
|
||||
/home/user/ethereum-poa-relay eth-to-sub \
|
||||
--sub-host rialto-node-alice \
|
||||
--eth-host poa-node-arthur \
|
||||
--prometheus-host=0.0.0.0
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -xeu
|
||||
|
||||
sleep 10
|
||||
|
||||
curl -v http://rialto-node-bob:9933/health
|
||||
curl -v http://poa-node-bertha:8545/api/health
|
||||
|
||||
# Try to deploy contracts first
|
||||
# networkID = 0x69
|
||||
# Arthur's key.
|
||||
/home/user/ethereum-poa-relay eth-deploy-contract \
|
||||
--eth-chain-id 105 \
|
||||
--eth-signer 0399dbd15cf6ee8250895a1f3873eb1e10e23ca18e8ed0726c63c4aea356e87d \
|
||||
--sub-host rialto-node-bob \
|
||||
--eth-host poa-node-bertha || echo "Failed to deploy contracts."
|
||||
|
||||
sleep 10
|
||||
echo "Starting SUB -> ETH relay"
|
||||
/home/user/ethereum-poa-relay sub-to-eth \
|
||||
--eth-contract c9a61fb29e971d1dabfd98657969882ef5d0beee \
|
||||
--eth-chain-id 105 \
|
||||
--eth-signer 0399dbd15cf6ee8250895a1f3873eb1e10e23ca18e8ed0726c63c4aea356e87d \
|
||||
--sub-host rialto-node-bob \
|
||||
--eth-host poa-node-bertha \
|
||||
--prometheus-host=0.0.0.0
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -xeu
|
||||
|
||||
sleep 3
|
||||
curl -v http://poa-node-arthur:8545/api/health
|
||||
curl -v http://poa-node-bertha:8545/api/health
|
||||
curl -v http://poa-node-carlos:8545/api/health
|
||||
curl -v http://rialto-node-alice:9933/health
|
||||
curl -v http://rialto-node-bob:9933/health
|
||||
curl -v http://rialto-node-charlie:9933/health
|
||||
|
||||
/home/user/ethereum-poa-relay eth-exchange-sub \
|
||||
--sub-host rialto-node-alice \
|
||||
--sub-signer //Bob \
|
||||
--eth-host poa-node-arthur \
|
||||
--prometheus-host=0.0.0.0
|
||||
+1
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"dd04f316-bc9d-2deb-4a34-51014cd5f34f","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"aa91e6f0e6cf48208be4a1bcf15c6f30"},"ciphertext":"6e057599b13a87e8181bb39a40e14848fdc97958d493ddfa6bb1260350f69328","kdf":"pbkdf2","kdfparams":{"c":10240,"dklen":32,"prf":"hmac-sha256","salt":"79dd8c09c5c066b830179a2558a51efca6d97c0db2c4128090a01835786823c5"},"mac":"8f8b8e2c9de29ec8eefc54a60055e30ae7ff4dd4a367eaf38880edb887da771e"},"address":"005e714f896a8b7cede9d38688c1a81de72a58e4","name":"","meta":"{}"}
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"6d1e690f-0b52-35f7-989b-46100e7c65ed","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"a5b4d0466834e75c9fd29c6cbbac57ad"},"ciphertext":"102ac328cbe66d8cb8515c42e3268776a9be4419a5cb7b79852860b1e691c15b","kdf":"pbkdf2","kdfparams":{"c":10240,"dklen":32,"prf":"hmac-sha256","salt":"e8daf2e70086b0cacf925d368fd3f60cada1285e39a42c4cc73c135368cfdbef"},"mac":"1bc3b750900a1143c64ba9e677d69e1093aab47cb003ba09f3cd595a3b422db5"},"address":"007594304039c2937a12220338aab821d819f5a4","name":"","meta":"{}"}
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"ffaebba1-f1b9-8758-7034-0314040b1396","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"97f124bc8a7bf55d00eb2755c2b50364"},"ciphertext":"b87827816f33d2bef2dc3102a8a7744b86912f8ace10e45cb282a13487769ed2","kdf":"pbkdf2","kdfparams":{"c":10240,"dklen":32,"prf":"hmac-sha256","salt":"3114c67a05bff7831d112083f566b176bfc874aea160eebadbe5564e406ee85c"},"mac":"e9bfe8fd6f612bc036bb57659297fc03db022264f5086a1b5726972d3ab6f64a"},"address":"004e7a39907f090e19b0b80a277e77b72b22e269","name":"","meta":"{}"}
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"ef9eb431-dc73-cf31-357e-736f64febe68","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"7077f1c4170d9fc2e05c5956be32fb51"},"ciphertext":"a053be448768d984257aeb8f9c7913e3f54c6e6e741accad9f09dd70c2d9828c","kdf":"pbkdf2","kdfparams":{"c":10240,"dklen":32,"prf":"hmac-sha256","salt":"12580aa4624040970301e7474d3f9b2a93552bfe9ea2517f7119ccf8e91ebd0d"},"mac":"796dbb48adcfc09041fe39121632801d9f950d3c73dd47105180d8097d4f4491"},"address":"00eed42bf93b498f28acd21d207427a14074defe","name":"","meta":"{}"}
|
||||
@@ -0,0 +1 @@
|
||||
password
|
||||
@@ -0,0 +1,20 @@
|
||||
[parity]
|
||||
chain = "/config/poa.json"
|
||||
keys_path = "/config/keys"
|
||||
no_persistent_txqueue = true
|
||||
|
||||
[account]
|
||||
password = ["/config/pass"]
|
||||
|
||||
[network]
|
||||
reserved_peers = "/config/reserved"
|
||||
|
||||
[rpc]
|
||||
apis = ["all"]
|
||||
cors = ["moz-extension://*", "chrome-extension://*"]
|
||||
|
||||
[mining]
|
||||
force_sealing = true
|
||||
|
||||
[misc]
|
||||
unsafe_expose = true
|
||||
@@ -0,0 +1,184 @@
|
||||
{
|
||||
"name": "BridgePoa",
|
||||
"engine": {
|
||||
"authorityRound": {
|
||||
"params": {
|
||||
"stepDuration": 10,
|
||||
"validators": {
|
||||
"list": [
|
||||
"0x005e714f896a8b7cede9d38688c1a81de72a58e4",
|
||||
"0x007594304039c2937a12220338aab821d819f5a4",
|
||||
"0x004e7a39907f090e19b0b80a277e77b72b22e269"
|
||||
]
|
||||
},
|
||||
"validateScoreTransition": 0,
|
||||
"validateStepTransition": 0,
|
||||
"maximumUncleCountTransition": 0,
|
||||
"maximumUncleCount": 0,
|
||||
"emptyStepsTransition": "0xfffffffff",
|
||||
"maximumEmptySteps": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"params": {
|
||||
"accountStartNonce": "0x0",
|
||||
"eip1014Transition": "0x0",
|
||||
"eip1052Transition": "0x0",
|
||||
"eip140Transition": "0x0",
|
||||
"eip145Transition": "0x0",
|
||||
"eip150Transition": "0x0",
|
||||
"eip155Transition": "0x0",
|
||||
"eip160Transition": "0x0",
|
||||
"eip161abcTransition": "0x0",
|
||||
"eip161dTransition": "0x0",
|
||||
"eip211Transition": "0x0",
|
||||
"eip214Transition": "0x0",
|
||||
"eip658Transition": "0x0",
|
||||
"eip98Transition": "0x7fffffffffffff",
|
||||
"gasLimitBoundDivisor": "0x0400",
|
||||
"maxCodeSize": 24576,
|
||||
"maxCodeSizeTransition": "0x0",
|
||||
"maximumExtraDataSize": "0x20",
|
||||
"minGasLimit": "0x1388",
|
||||
"networkID" : "0x69",
|
||||
"validateChainIdTransition": "0x0",
|
||||
"validateReceiptsTransition": "0x0"
|
||||
},
|
||||
"genesis": {
|
||||
"seal": {
|
||||
"authorityRound": {
|
||||
"step": "0x0",
|
||||
"signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
}
|
||||
},
|
||||
"difficulty": "0x20000",
|
||||
"author": "0x0000000000000000000000000000000000000000",
|
||||
"timestamp": "0x00",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"extraData": "0x",
|
||||
"gasLimit": "0x222222"
|
||||
},
|
||||
"accounts": {
|
||||
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
|
||||
"0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } },
|
||||
"0000000000000000000000000000000000000006": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "alt_bn128_add",
|
||||
"pricing": {
|
||||
"0": {
|
||||
"price": { "alt_bn128_const_operations": { "price": 500 }}
|
||||
},
|
||||
"0x7fffffffffffff": {
|
||||
"info": "EIP 1108 transition",
|
||||
"price": { "alt_bn128_const_operations": { "price": 150 }}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000007": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "alt_bn128_mul",
|
||||
"pricing": {
|
||||
"0": {
|
||||
"price": { "alt_bn128_const_operations": { "price": 40000 }}
|
||||
},
|
||||
"0x7fffffffffffff": {
|
||||
"info": "EIP 1108 transition",
|
||||
"price": { "alt_bn128_const_operations": { "price": 6000 }}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000008": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "alt_bn128_pairing",
|
||||
"pricing": {
|
||||
"0": {
|
||||
"price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }}
|
||||
},
|
||||
"0x7fffffffffffff": {
|
||||
"info": "EIP 1108 transition",
|
||||
"price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000009": {
|
||||
"builtin": {
|
||||
"name": "blake2_f",
|
||||
"activate_at": "0xd751a5",
|
||||
"pricing": {
|
||||
"blake2_f": {
|
||||
"gas_per_round": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000010": {
|
||||
"builtin": {
|
||||
"name": "parse_substrate_header",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000011": {
|
||||
"builtin": {
|
||||
"name": "get_substrate_header_signal",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000012": {
|
||||
"builtin": {
|
||||
"name": "verify_substrate_finality_proof",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000013": {
|
||||
"builtin": {
|
||||
"name": "my_test",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x005e714f896a8b7cede9d38688c1a81de72a58e4": {
|
||||
"balance": "1606938044258990275541962092341162602522202993782792835301376",
|
||||
"nonce": "0x1"
|
||||
},
|
||||
"0x007594304039c2937a12220338aab821d819f5a4": {
|
||||
"balance": "1606938044258990275541962092341162602522202993782792835301376",
|
||||
"nonce": "0x1"
|
||||
},
|
||||
"0x004e7a39907f090e19b0b80a277e77b72b22e269": {
|
||||
"balance": "1606938044258990275541962092341162602522202993782792835301376",
|
||||
"nonce": "0x1"
|
||||
},
|
||||
"0x00eed42bf93b498f28acd21d207427a14074defe": {
|
||||
"balance": "1606938044258990275541962092341162602522202993782792835301376",
|
||||
"nonce": "0x1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
enode://543d0874df46dff238d62547160f9d11e3d21897d7041bbbe46a04d2ee56d9eaf108f2133c0403159624f7647198e224d0755d23ad0e1a50c0912973af6e8a8a@poa-node-arthur:30303
|
||||
enode://710de70733e88a24032e53054985f7239e37351f5f3335a468a1a78a3026e9f090356973b00262c346a6608403df2c7107fc4def2cfe4995ea18a41292b9384f@poa-node-bertha:30303
|
||||
enode://943525f415b9482f1c49bd39eb979e4e2b406f4137450b0553bffa5cba2928e25ff89ef70f7325aad8a75dbb5955eaecc1aee7ac55d66bcaaa07c8ea58adb23a@poa-node-carlos:30303
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
- name: 'default'
|
||||
orgId: 1
|
||||
folder: ''
|
||||
type: file
|
||||
options:
|
||||
path: '/etc/grafana/provisioning/dashboards'
|
||||
+694
@@ -0,0 +1,694 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"alert": {
|
||||
"alertRuleTags": {},
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
"params": [
|
||||
5
|
||||
],
|
||||
"type": "gt"
|
||||
},
|
||||
"operator": {
|
||||
"type": "and"
|
||||
},
|
||||
"query": {
|
||||
"params": [
|
||||
"A",
|
||||
"5m",
|
||||
"now"
|
||||
]
|
||||
},
|
||||
"reducer": {
|
||||
"params": [],
|
||||
"type": "min"
|
||||
},
|
||||
"type": "query"
|
||||
}
|
||||
],
|
||||
"executionErrorState": "alerting",
|
||||
"for": "5m",
|
||||
"frequency": "5m",
|
||||
"handler": 1,
|
||||
"message": "",
|
||||
"name": "Synced Header Difference is Over 5 (Millau to Rialto)",
|
||||
"noDataState": "no_data",
|
||||
"notifications": []
|
||||
},
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "Shows how many headers behind the target chain is from the source chain.",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 14,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max(Millau_to_Rialto_Sync_best_block_numbers{node=\"source\"}) - max(Millau_to_Rialto_Sync_best_block_numbers{node=\"target\"})",
|
||||
"format": "table",
|
||||
"instant": false,
|
||||
"interval": "",
|
||||
"legendFormat": "",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Difference Between Source and Target Headers",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"alert": {
|
||||
"alertRuleTags": {},
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
"params": [
|
||||
5
|
||||
],
|
||||
"type": "lt"
|
||||
},
|
||||
"operator": {
|
||||
"type": "and"
|
||||
},
|
||||
"query": {
|
||||
"params": [
|
||||
"A",
|
||||
"2m",
|
||||
"now"
|
||||
]
|
||||
},
|
||||
"reducer": {
|
||||
"params": [],
|
||||
"type": "min"
|
||||
},
|
||||
"type": "query"
|
||||
}
|
||||
],
|
||||
"executionErrorState": "alerting",
|
||||
"for": "3m",
|
||||
"frequency": "5m",
|
||||
"handler": 1,
|
||||
"name": "No New Headers (Millau to Rialto)",
|
||||
"noDataState": "no_data",
|
||||
"notifications": []
|
||||
},
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "How many headers has the relay synced from the source node in the last 2 mins?",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 16,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max_over_time(Millau_to_Rialto_Sync_best_block_numbers{node=\"source\"}[2m])-min_over_time(Millau_to_Rialto_Sync_best_block_numbers{node=\"source\"}[2m])",
|
||||
"interval": "",
|
||||
"legendFormat": "Number of Millau Headers Synced on Rialto",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "lt",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Headers Synced on Rialto (Last 2 Mins)",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {
|
||||
"align": null
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 8
|
||||
},
|
||||
"id": 2,
|
||||
"interval": "5s",
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Millau_to_Rialto_Sync_best_block_numbers",
|
||||
"format": "time_series",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"intervalFactor": 1,
|
||||
"legendFormat": "Best Known Header on {{node}} Node",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Best Blocks according to Relay",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 6,
|
||||
"x": 12,
|
||||
"y": 8
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 6,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Millau_to_Rialto_Sync_system_average_load",
|
||||
"interval": "",
|
||||
"legendFormat": "Average system load in last {{over}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Average System Load",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 6,
|
||||
"x": 18,
|
||||
"y": 8
|
||||
},
|
||||
"id": 12,
|
||||
"options": {
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg_over_time(Millau_to_Rialto_Sync_process_cpu_usage_percentage[1m])",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "1 CPU = 100",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Relay Process CPU Usage ",
|
||||
"type": "gauge"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 10,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Millau_to_Rialto_Sync_blocks_in_state",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "{{state}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Queued Headers in Relay",
|
||||
"type": "bargauge"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 16
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 10,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Millau_to_Rialto_Sync_process_memory_usage_bytes / 1024 / 1024",
|
||||
"interval": "",
|
||||
"legendFormat": "Process memory, MB",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Memory Usage for Relay Process",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 26,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-5m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": [
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
]
|
||||
},
|
||||
"timezone": "",
|
||||
"title": "Millau to Rialto Header Sync Dashboard",
|
||||
"uid": "relay-millau-to-rialto-headers",
|
||||
"version": 1
|
||||
}
|
||||
+1137
File diff suppressed because it is too large
Load Diff
+694
@@ -0,0 +1,694 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"alert": {
|
||||
"alertRuleTags": {},
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
"params": [
|
||||
5
|
||||
],
|
||||
"type": "gt"
|
||||
},
|
||||
"operator": {
|
||||
"type": "and"
|
||||
},
|
||||
"query": {
|
||||
"params": [
|
||||
"A",
|
||||
"5m",
|
||||
"now"
|
||||
]
|
||||
},
|
||||
"reducer": {
|
||||
"params": [],
|
||||
"type": "min"
|
||||
},
|
||||
"type": "query"
|
||||
}
|
||||
],
|
||||
"executionErrorState": "alerting",
|
||||
"for": "5m",
|
||||
"frequency": "5m",
|
||||
"handler": 1,
|
||||
"message": "",
|
||||
"name": "Synced Header Difference is Over 5 (Rialto to Millau)",
|
||||
"noDataState": "no_data",
|
||||
"notifications": []
|
||||
},
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "Shows how many headers behind the target chain is from the source chain.",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 14,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max(Rialto_to_Millau_Sync_best_block_numbers{node=\"source\"}) - max(Rialto_to_Millau_Sync_best_block_numbers{node=\"target\"})",
|
||||
"format": "table",
|
||||
"instant": false,
|
||||
"interval": "",
|
||||
"legendFormat": "",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Difference Between Source and Target Headers",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"alert": {
|
||||
"alertRuleTags": {},
|
||||
"conditions": [
|
||||
{
|
||||
"evaluator": {
|
||||
"params": [
|
||||
5
|
||||
],
|
||||
"type": "lt"
|
||||
},
|
||||
"operator": {
|
||||
"type": "and"
|
||||
},
|
||||
"query": {
|
||||
"params": [
|
||||
"A",
|
||||
"2m",
|
||||
"now"
|
||||
]
|
||||
},
|
||||
"reducer": {
|
||||
"params": [],
|
||||
"type": "min"
|
||||
},
|
||||
"type": "query"
|
||||
}
|
||||
],
|
||||
"executionErrorState": "alerting",
|
||||
"for": "3m",
|
||||
"frequency": "5m",
|
||||
"handler": 1,
|
||||
"name": "No New Headers (Rialto to Millau)",
|
||||
"noDataState": "no_data",
|
||||
"notifications": []
|
||||
},
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "How many headers has the relay synced from the source node in the last 2 mins?",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 16,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "max_over_time(Rialto_to_Millau_Sync_best_block_numbers{node=\"source\"}[2m])-min_over_time(Rialto_to_Millau_Sync_best_block_numbers{node=\"source\"}[2m])",
|
||||
"interval": "",
|
||||
"legendFormat": "Number of Rialto Headers Synced on Millau",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "lt",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Headers Synced on Millau (Last 2 Mins)",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {
|
||||
"align": null
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 8
|
||||
},
|
||||
"id": 2,
|
||||
"interval": "5s",
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Rialto_to_Millau_Sync_best_block_numbers",
|
||||
"format": "time_series",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"intervalFactor": 1,
|
||||
"legendFormat": "Best Known Header on {{node}} Node",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Best Blocks according to Relay",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 6,
|
||||
"x": 12,
|
||||
"y": 8
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 6,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Rialto_to_Millau_Sync_system_average_load",
|
||||
"interval": "",
|
||||
"legendFormat": "Average system load in last {{over}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [
|
||||
{
|
||||
"colorMode": "critical",
|
||||
"fill": true,
|
||||
"line": true,
|
||||
"op": "gt",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Average System Load",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 6,
|
||||
"x": 18,
|
||||
"y": 8
|
||||
},
|
||||
"id": 12,
|
||||
"options": {
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg_over_time(Rialto_to_Millau_Sync_process_cpu_usage_percentage[1m])",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "1 CPU = 100",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Relay Process CPU Usage ",
|
||||
"type": "gauge"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 10,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true
|
||||
},
|
||||
"pluginVersion": "7.1.3",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Rialto_to_Millau_Sync_blocks_in_state",
|
||||
"instant": true,
|
||||
"interval": "",
|
||||
"legendFormat": "{{state}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Queued Headers in Relay",
|
||||
"type": "bargauge"
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Prometheus",
|
||||
"description": "",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 16
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 10,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"percentage": false,
|
||||
"pluginVersion": "7.1.3",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "Rialto_to_Millau_Sync_process_memory_usage_bytes / 1024 / 1024",
|
||||
"interval": "",
|
||||
"legendFormat": "Process memory, MB",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Memory Usage for Relay Process",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 26,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-5m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": [
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
]
|
||||
},
|
||||
"timezone": "",
|
||||
"title": "Rialto to Millau Header Sync Dashboard",
|
||||
"uid": "relay-rialto-to-millau-headers",
|
||||
"version": 1
|
||||
}
|
||||
+1137
File diff suppressed because it is too large
Load Diff
+16
@@ -0,0 +1,16 @@
|
||||
# list of datasources to insert/update depending
|
||||
# whats available in the database
|
||||
datasources:
|
||||
# <string, required> name of the datasource. Required
|
||||
- name: Prometheus
|
||||
# <string, required> datasource type. Required
|
||||
type: prometheus
|
||||
# <string, required> access mode. direct or proxy. Required
|
||||
access: proxy
|
||||
# <int> org id. will default to orgId 1 if not specified
|
||||
orgId: 1
|
||||
# <string> url
|
||||
url: http://prometheus-metrics:9090
|
||||
# <bool> mark as default datasource. Max one per org
|
||||
isDefault: true
|
||||
version: 1
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
notifiers:
|
||||
- name: Matrix
|
||||
type: webhook
|
||||
uid: notifier1
|
||||
is_default: true
|
||||
send_reminder: true
|
||||
frequency: 1h
|
||||
disable_resolve_message: false
|
||||
settings:
|
||||
url: http://grafana-matrix-notifier:4567/hook?rule=bridge
|
||||
http_method: POST
|
||||
|
||||
delete_notifiers:
|
||||
- name: Matrix
|
||||
uid: notifier1
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
scrape_configs:
|
||||
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
||||
- job_name: 'millau_to_rialto_headers_relay_node'
|
||||
|
||||
# Override the global default and scrape targets from this job every 15 seconds.
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['relay-headers-millau-to-rialto:9616']
|
||||
|
||||
- job_name: 'rialto_to_millau_headers_relay_node'
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['relay-headers-rialto-to-millau:9616']
|
||||
|
||||
- job_name: 'millau_to_rialto_messages_relay_node'
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['relay-messages-millau-to-rialto:9616']
|
||||
|
||||
- job_name: 'rialto_to_millau_messages_relay_node'
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['relay-messages-rialto-to-millau:9616']
|
||||
@@ -0,0 +1,97 @@
|
||||
version: '3.5'
|
||||
services:
|
||||
# We provide overrides for these particular nodes since they are public facing
|
||||
# nodes which we use to connect from things like Polkadot JS Apps.
|
||||
rialto-node-charlie:
|
||||
environment:
|
||||
VIRTUAL_HOST: wss.rialto.brucke.link
|
||||
VIRTUAL_PORT: 9944
|
||||
LETSENCRYPT_HOST: wss.rialto.brucke.link
|
||||
LETSENCRYPT_EMAIL: admin@parity.io
|
||||
|
||||
millau-node-charlie:
|
||||
environment:
|
||||
VIRTUAL_HOST: wss.millau.brucke.link
|
||||
VIRTUAL_PORT: 9944
|
||||
LETSENCRYPT_HOST: wss.millau.brucke.link
|
||||
LETSENCRYPT_EMAIL: admin@parity.io
|
||||
|
||||
relay-headers-millau-to-rialto: &sub-bridge-relay
|
||||
image: paritytech/substrate-relay
|
||||
entrypoint: /entrypoints/relay-headers-millau-to-rialto-entrypoint.sh
|
||||
volumes:
|
||||
- ./bridges/rialto-millau/entrypoints:/entrypoints
|
||||
environment:
|
||||
RUST_LOG: rpc=trace,bridge=trace
|
||||
ports:
|
||||
- "9616:9616"
|
||||
depends_on: &all-nodes
|
||||
- millau-node-alice
|
||||
- millau-node-bob
|
||||
- millau-node-charlie
|
||||
- millau-node-dave
|
||||
- millau-node-eve
|
||||
- rialto-node-alice
|
||||
- rialto-node-bob
|
||||
- rialto-node-charlie
|
||||
- rialto-node-dave
|
||||
- rialto-node-eve
|
||||
|
||||
relay-headers-rialto-to-millau:
|
||||
<<: *sub-bridge-relay
|
||||
entrypoint: /entrypoints/relay-headers-rialto-to-millau-entrypoint.sh
|
||||
ports:
|
||||
- "9716:9616"
|
||||
|
||||
relay-messages-millau-to-rialto:
|
||||
<<: *sub-bridge-relay
|
||||
entrypoint: /entrypoints/relay-messages-millau-to-rialto-entrypoint.sh
|
||||
environment:
|
||||
RUST_LOG: rpc=trace,bridge=trace,jsonrpsee=trace,soketto=trace
|
||||
ports:
|
||||
- "9816:9616"
|
||||
depends_on:
|
||||
- relay-headers-millau-to-rialto
|
||||
- relay-headers-rialto-to-millau
|
||||
|
||||
relay-messages-millau-to-rialto-generator:
|
||||
<<: *sub-bridge-relay
|
||||
entrypoint: /entrypoints/relay-messages-to-rialto-generator-entrypoint.sh
|
||||
environment:
|
||||
RUST_LOG: rpc=trace,bridge=trace,jsonrpsee=trace,soketto=trace
|
||||
ports:
|
||||
- "9916:9616"
|
||||
depends_on:
|
||||
- relay-messages-millau-to-rialto
|
||||
|
||||
relay-messages-rialto-to-millau:
|
||||
<<: *sub-bridge-relay
|
||||
entrypoint: /entrypoints/relay-messages-rialto-to-millau-entrypoint.sh
|
||||
ports:
|
||||
- "10016:9616"
|
||||
depends_on:
|
||||
- relay-headers-millau-to-rialto
|
||||
- relay-headers-rialto-to-millau
|
||||
|
||||
relay-messages-rialto-to-millau-generator:
|
||||
<<: *sub-bridge-relay
|
||||
entrypoint: /entrypoints/relay-messages-to-millau-generator-entrypoint.sh
|
||||
ports:
|
||||
- "10116:9616"
|
||||
depends_on:
|
||||
- relay-messages-rialto-to-millau
|
||||
|
||||
# Note: These are being overridden from the top level `monitoring` compose file.
|
||||
grafana-dashboard:
|
||||
environment:
|
||||
VIRTUAL_HOST: grafana.millau.brucke.link,grafana.rialto.brucke.link
|
||||
VIRTUAL_PORT: 3000
|
||||
LETSENCRYPT_HOST: grafana.millau.brucke.link,grafana.rialto.brucke.link
|
||||
LETSENCRYPT_EMAIL: admin@parity.io
|
||||
volumes:
|
||||
- ./bridges/rialto-millau/dashboard/grafana/provisioning/:/etc/grafana/provisioning/
|
||||
|
||||
prometheus-metrics:
|
||||
volumes:
|
||||
- ./bridges/rialto-millau/dashboard/prometheus/:/etc/prometheus/
|
||||
depends_on: *all-nodes
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -xeu
|
||||
|
||||
sleep 3
|
||||
curl -v http://millau-node-alice:9933/health
|
||||
curl -v http://rialto-node-alice:9933/health
|
||||
|
||||
/home/user/substrate-relay init-bridge millau-to-rialto \
|
||||
--millau-host millau-node-alice \
|
||||
--millau-port 9944 \
|
||||
--rialto-host rialto-node-alice \
|
||||
--rialto-port 9944 \
|
||||
--rialto-signer //Alice
|
||||
|
||||
# Give chain a little bit of time to process initialization transaction
|
||||
sleep 6
|
||||
/home/user/substrate-relay relay-headers millau-to-rialto \
|
||||
--millau-host millau-node-alice \
|
||||
--millau-port 9944 \
|
||||
--rialto-host rialto-node-alice \
|
||||
--rialto-port 9944 \
|
||||
--rialto-signer //Charlie \
|
||||
--prometheus-host=0.0.0.0
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -xeu
|
||||
|
||||
sleep 3
|
||||
curl -v http://millau-node-alice:9933/health
|
||||
curl -v http://rialto-node-alice:9933/health
|
||||
|
||||
/home/user/substrate-relay init-bridge rialto-to-millau \
|
||||
--millau-host millau-node-alice \
|
||||
--millau-port 9944 \
|
||||
--rialto-host rialto-node-alice \
|
||||
--rialto-port 9944 \
|
||||
--millau-signer //Alice
|
||||
|
||||
# Give chain a little bit of time to process initialization transaction
|
||||
sleep 6
|
||||
/home/user/substrate-relay relay-headers rialto-to-millau \
|
||||
--millau-host millau-node-alice \
|
||||
--millau-port 9944 \
|
||||
--rialto-host rialto-node-alice \
|
||||
--rialto-port 9944 \
|
||||
--millau-signer //Charlie \
|
||||
--prometheus-host=0.0.0.0
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
set -xeu
|
||||
|
||||
sleep 3
|
||||
curl -v http://millau-node-bob:9933/health
|
||||
curl -v http://rialto-node-bob:9933/health
|
||||
|
||||
MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000}
|
||||
|
||||
/home/user/substrate-relay relay-messages millau-to-rialto \
|
||||
--lane $MESSAGE_LANE \
|
||||
--millau-host millau-node-bob \
|
||||
--millau-port 9944 \
|
||||
--millau-signer //Eve \
|
||||
--rialto-host rialto-node-bob \
|
||||
--rialto-port 9944 \
|
||||
--rialto-signer //Eve \
|
||||
--prometheus-host=0.0.0.0
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
set -xeu
|
||||
|
||||
sleep 3
|
||||
curl -v http://millau-node-bob:9933/health
|
||||
curl -v http://rialto-node-bob:9933/health
|
||||
|
||||
MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000}
|
||||
|
||||
/home/user/substrate-relay relay-messages rialto-to-millau \
|
||||
--lane $MESSAGE_LANE \
|
||||
--rialto-host rialto-node-bob \
|
||||
--rialto-port 9944 \
|
||||
--rialto-signer //Ferdie \
|
||||
--millau-host millau-node-bob \
|
||||
--millau-port 9944 \
|
||||
--millau-signer //Ferdie \
|
||||
--prometheus-host=0.0.0.0
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# THIS SCRIPT IS NOT INTENDED FOR USE IN PRODUCTION ENVIRONMENT
|
||||
#
|
||||
# This scripts periodically calls the Substrate relay binary to generate messages. These messages
|
||||
# are sent from the Rialto network to the Millau network.
|
||||
|
||||
set -eu
|
||||
|
||||
# Max delay before submitting transactions (s)
|
||||
MAX_SUBMIT_DELAY_S=${MSG_EXCHANGE_GEN_MAX_SUBMIT_DELAY_S:-30}
|
||||
MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000}
|
||||
FERDIE_ADDR=5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL
|
||||
|
||||
SHARED_CMD="/home/user/substrate-relay send-message rialto-to-millau"
|
||||
SHARED_HOST="--rialto-host rialto-node-bob --rialto-port 9944"
|
||||
DAVE_SIGNER="--rialto-signer //Dave --millau-signer //Dave"
|
||||
|
||||
SEND_MESSAGE="$SHARED_CMD $SHARED_HOST $DAVE_SIGNER"
|
||||
|
||||
# Sleep a bit between messages
|
||||
rand_sleep() {
|
||||
SUBMIT_DELAY_S=`shuf -i 0-$MAX_SUBMIT_DELAY_S -n 1`
|
||||
echo "Sleeping $SUBMIT_DELAY_S seconds..."
|
||||
sleep $SUBMIT_DELAY_S
|
||||
}
|
||||
|
||||
while true
|
||||
do
|
||||
rand_sleep
|
||||
echo "Sending Remark from Rialto to Millau using Target Origin"
|
||||
$SEND_MESSAGE \
|
||||
--lane $MESSAGE_LANE \
|
||||
--origin Target \
|
||||
remark
|
||||
|
||||
rand_sleep
|
||||
echo "Sending Transfer from Rialto to Millau using Target Origin"
|
||||
$SEND_MESSAGE \
|
||||
--lane $MESSAGE_LANE \
|
||||
--origin Target \
|
||||
transfer \
|
||||
--amount 1000000000 \
|
||||
--recipient $FERDIE_ADDR
|
||||
|
||||
rand_sleep
|
||||
echo "Sending Remark from Rialto to Millau using Source Origin"
|
||||
$SEND_MESSAGE \
|
||||
--lane $MESSAGE_LANE \
|
||||
--origin Source \
|
||||
remark
|
||||
|
||||
rand_sleep
|
||||
echo "Sending Transfer from Rialto to Millau using Source Origin"
|
||||
$SEND_MESSAGE \
|
||||
--lane $MESSAGE_LANE \
|
||||
--origin Source \
|
||||
transfer \
|
||||
--amount 1000000000 \
|
||||
--recipient $FERDIE_ADDR
|
||||
done
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# THIS SCRIPT IS NOT INTENDED FOR USE IN PRODUCTION ENVIRONMENT
|
||||
#
|
||||
# This scripts periodically calls the Substrate relay binary to generate messages. These messages
|
||||
# are sent from the Millau network to the Rialto network.
|
||||
|
||||
set -eu
|
||||
|
||||
# Max delay before submitting transactions (s)
|
||||
MAX_SUBMIT_DELAY_S=${MSG_EXCHANGE_GEN_MAX_SUBMIT_DELAY_S:-30}
|
||||
MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000}
|
||||
FERDIE_ADDR=5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL
|
||||
|
||||
SHARED_CMD=" /home/user/substrate-relay send-message millau-to-rialto"
|
||||
SHARED_HOST="--millau-host millau-node-bob --millau-port 9944"
|
||||
DAVE_SIGNER="--rialto-signer //Dave --millau-signer //Dave"
|
||||
|
||||
SEND_MESSAGE="$SHARED_CMD $SHARED_HOST $DAVE_SIGNER"
|
||||
|
||||
# Sleep a bit between messages
|
||||
rand_sleep() {
|
||||
SUBMIT_DELAY_S=`shuf -i 0-$MAX_SUBMIT_DELAY_S -n 1`
|
||||
echo "Sleeping $SUBMIT_DELAY_S seconds..."
|
||||
sleep $SUBMIT_DELAY_S
|
||||
}
|
||||
|
||||
while true
|
||||
do
|
||||
rand_sleep
|
||||
echo "Sending Remark from Millau to Rialto using Target Origin"
|
||||
$SEND_MESSAGE \
|
||||
--lane $MESSAGE_LANE \
|
||||
--origin Target \
|
||||
remark
|
||||
|
||||
rand_sleep
|
||||
echo "Sending Transfer from Millau to Rialto using Target Origin"
|
||||
$SEND_MESSAGE \
|
||||
--lane $MESSAGE_LANE \
|
||||
--origin Target \
|
||||
transfer \
|
||||
--amount 1000000000 \
|
||||
--recipient $FERDIE_ADDR
|
||||
|
||||
rand_sleep
|
||||
echo "Sending Remark from Millau to Rialto using Source Origin"
|
||||
$SEND_MESSAGE \
|
||||
--lane $MESSAGE_LANE \
|
||||
--origin Source \
|
||||
remark
|
||||
|
||||
rand_sleep
|
||||
echo "Sending Transfer from Millau to Rialto using Source Origin"
|
||||
$SEND_MESSAGE \
|
||||
--lane $MESSAGE_LANE \
|
||||
--origin Source \
|
||||
transfer \
|
||||
--amount 1000000000 \
|
||||
--recipient $FERDIE_ADDR
|
||||
done
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"dd04f316-bc9d-2deb-4a34-51014cd5f34f","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"aa91e6f0e6cf48208be4a1bcf15c6f30"},"ciphertext":"6e057599b13a87e8181bb39a40e14848fdc97958d493ddfa6bb1260350f69328","kdf":"pbkdf2","kdfparams":{"c":10240,"dklen":32,"prf":"hmac-sha256","salt":"79dd8c09c5c066b830179a2558a51efca6d97c0db2c4128090a01835786823c5"},"mac":"8f8b8e2c9de29ec8eefc54a60055e30ae7ff4dd4a367eaf38880edb887da771e"},"address":"005e714f896a8b7cede9d38688c1a81de72a58e4","name":"","meta":"{}"}
|
||||
@@ -0,0 +1 @@
|
||||
password
|
||||
@@ -0,0 +1,17 @@
|
||||
[parity]
|
||||
chain = "./deployments/dev/poa-config/poa.json"
|
||||
keys_path = "./deployments/dev/poa-config/keys"
|
||||
no_persistent_txqueue = true
|
||||
|
||||
[account]
|
||||
password = ["./deployments/dev/poa-config/pass"]
|
||||
|
||||
[rpc]
|
||||
apis = ["all"]
|
||||
cors = ["moz-extension://*", "chrome-extension://*"]
|
||||
|
||||
[mining]
|
||||
force_sealing = true
|
||||
|
||||
[misc]
|
||||
unsafe_expose = true
|
||||
@@ -0,0 +1,178 @@
|
||||
{
|
||||
"name": "BridgePoa",
|
||||
"engine": {
|
||||
"authorityRound": {
|
||||
"params": {
|
||||
"stepDuration": 10,
|
||||
"validators": {
|
||||
"list": [
|
||||
"0x005e714f896a8b7cede9d38688c1a81de72a58e4"
|
||||
]
|
||||
},
|
||||
"validateScoreTransition": 0,
|
||||
"validateStepTransition": 0,
|
||||
"maximumUncleCountTransition": 0,
|
||||
"maximumUncleCount": 0,
|
||||
"emptyStepsTransition": "0xfffffffff",
|
||||
"maximumEmptySteps": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"params": {
|
||||
"accountStartNonce": "0x0",
|
||||
"eip1014Transition": "0x0",
|
||||
"eip1052Transition": "0x0",
|
||||
"eip140Transition": "0x0",
|
||||
"eip145Transition": "0x0",
|
||||
"eip150Transition": "0x0",
|
||||
"eip155Transition": "0x0",
|
||||
"eip160Transition": "0x0",
|
||||
"eip161abcTransition": "0x0",
|
||||
"eip161dTransition": "0x0",
|
||||
"eip211Transition": "0x0",
|
||||
"eip214Transition": "0x0",
|
||||
"eip658Transition": "0x0",
|
||||
"eip98Transition": "0x7fffffffffffff",
|
||||
"gasLimitBoundDivisor": "0x0400",
|
||||
"maxCodeSize": 24576,
|
||||
"maxCodeSizeTransition": "0x0",
|
||||
"maximumExtraDataSize": "0x20",
|
||||
"minGasLimit": "0x1388",
|
||||
"networkID" : "0x69",
|
||||
"validateChainIdTransition": "0x0",
|
||||
"validateReceiptsTransition": "0x0"
|
||||
},
|
||||
"genesis": {
|
||||
"seal": {
|
||||
"authorityRound": {
|
||||
"step": "0x0",
|
||||
"signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
}
|
||||
},
|
||||
"difficulty": "0x20000",
|
||||
"author": "0x0000000000000000000000000000000000000000",
|
||||
"timestamp": "0x00",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"extraData": "0x",
|
||||
"gasLimit": "0x222222"
|
||||
},
|
||||
"accounts": {
|
||||
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
|
||||
"0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } },
|
||||
"0000000000000000000000000000000000000006": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "alt_bn128_add",
|
||||
"pricing": {
|
||||
"0": {
|
||||
"price": { "alt_bn128_const_operations": { "price": 500 }}
|
||||
},
|
||||
"0x7fffffffffffff": {
|
||||
"info": "EIP 1108 transition",
|
||||
"price": { "alt_bn128_const_operations": { "price": 150 }}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000007": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "alt_bn128_mul",
|
||||
"pricing": {
|
||||
"0": {
|
||||
"price": { "alt_bn128_const_operations": { "price": 40000 }}
|
||||
},
|
||||
"0x7fffffffffffff": {
|
||||
"info": "EIP 1108 transition",
|
||||
"price": { "alt_bn128_const_operations": { "price": 6000 }}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000008": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "alt_bn128_pairing",
|
||||
"pricing": {
|
||||
"0": {
|
||||
"price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }}
|
||||
},
|
||||
"0x7fffffffffffff": {
|
||||
"info": "EIP 1108 transition",
|
||||
"price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000009": {
|
||||
"builtin": {
|
||||
"name": "blake2_f",
|
||||
"activate_at": "0xd751a5",
|
||||
"pricing": {
|
||||
"blake2_f": {
|
||||
"gas_per_round": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000010": {
|
||||
"builtin": {
|
||||
"name": "parse_substrate_header",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000011": {
|
||||
"builtin": {
|
||||
"name": "get_substrate_header_signal",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000012": {
|
||||
"builtin": {
|
||||
"name": "verify_substrate_finality_proof",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x0000000000000000000000000000000000000013": {
|
||||
"builtin": {
|
||||
"name": "my_test",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0x005e714f896a8b7cede9d38688c1a81de72a58e4": {
|
||||
"balance": "1606938044258990275541962092341162602522202993782792835301376",
|
||||
"nonce": "0x1"
|
||||
},
|
||||
"0x007594304039c2937a12220338aab821d819f5a4": {
|
||||
"balance": "1606938044258990275541962092341162602522202993782792835301376",
|
||||
"nonce": "0x1"
|
||||
},
|
||||
"0x004e7a39907f090e19b0b80a277e77b72b22e269": {
|
||||
"balance": "1606938044258990275541962092341162602522202993782792835301376",
|
||||
"nonce": "0x1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -xeu
|
||||
|
||||
# This will allow us to run whichever binary the user wanted
|
||||
# with arguments passed through `docker run`
|
||||
# e.g `docker run -it rialto-bridge-node-dev --dev --tmp`
|
||||
/home/user/$PROJECT $@
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A script for relaying Millau headers to the Rialto chain.
|
||||
#
|
||||
# Will not work unless both the Rialto and Millau are running (see `run-rialto-node.sh`
|
||||
# and `run-millau-node.sh).
|
||||
|
||||
RUST_LOG=bridge=debug \
|
||||
./target/debug/substrate-relay init-bridge millau-to-rialto \
|
||||
--millau-host localhost \
|
||||
--millau-port 9945 \
|
||||
--rialto-host localhost \
|
||||
--rialto-port 9944 \
|
||||
--rialto-signer //Alice \
|
||||
|
||||
sleep 5
|
||||
RUST_LOG=bridge=debug \
|
||||
./target/debug/substrate-relay relay-headers millau-to-rialto \
|
||||
--millau-host localhost \
|
||||
--millau-port 9945 \
|
||||
--rialto-host localhost \
|
||||
--rialto-port 9944 \
|
||||
--rialto-signer //Alice \
|
||||
--prometheus-host=0.0.0.0
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A script for relaying Rialto headers to the Millau chain.
|
||||
#
|
||||
# Will not work unless both the Rialto and Millau are running (see `run-rialto-node.sh`
|
||||
# and `run-millau-node.sh).
|
||||
|
||||
RUST_LOG=bridge=debug \
|
||||
./target/debug/substrate-relay init-bridge rialto-to-millau \
|
||||
--millau-host localhost \
|
||||
--millau-port 9945 \
|
||||
--rialto-host localhost \
|
||||
--rialto-port 9944 \
|
||||
--millau-signer //Alice \
|
||||
|
||||
sleep 5
|
||||
RUST_LOG=bridge=debug \
|
||||
./target/debug/substrate-relay relay-headers rialto-to-millau \
|
||||
--millau-host localhost \
|
||||
--millau-port 9945 \
|
||||
--rialto-host localhost \
|
||||
--rialto-port 9944 \
|
||||
--millau-signer //Alice \
|
||||
--prometheus-host=0.0.0.0
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run a development instance of the Millau Substrate bridge node.
|
||||
|
||||
RUST_LOG=runtime=trace \
|
||||
./target/debug/millau-bridge-node --dev --tmp \
|
||||
--rpc-cors=all --unsafe-rpc-external --unsafe-ws-external \
|
||||
--port 33044 --rpc-port 9934 --ws-port 9945 \
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run a development instance of the Rialto Substrate bridge node.
|
||||
|
||||
RUST_LOG=runtime=trace \
|
||||
./target/debug/rialto-bridge-node --dev --tmp \
|
||||
--rpc-cors=all --unsafe-rpc-external --unsafe-ws-external \
|
||||
--port 33033 --rpc-port 9933 --ws-port 9944 \
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user