Squashed 'bridges/' content from commit 062554430

git-subtree-dir: bridges
git-subtree-split: 0625544309ff299307f7e110f252f04eac383102
This commit is contained in:
Branislav Kontur
2022-12-01 22:32:52 +01:00
commit d2b7ee2575
357 changed files with 79920 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
PAT_GPL="^// Copyright.*If not, see <http://www.gnu.org/licenses/>\.$"
PAT_OTHER="^// Copyright"
SCRIPTS_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
for f in $(find . -type f | egrep '\.(c|cpp|rs)$'); do
HEADER=$(head -16 $f)
if [[ $HEADER =~ $PAT_GPL ]]; then
BODY=$(tail -n +17 $f)
cat $SCRIPTS_DIR/license_header > temp
echo "$BODY" >> temp
mv temp $f
elif [[ $HEADER =~ $PAT_OTHER ]]; then
echo "Other license was found do nothing"
else
echo "$f was missing header"
cat $SCRIPTS_DIR/license_header $f > temp
mv temp $f
fi
done
+7
View File
@@ -0,0 +1,7 @@
#!/bin/sh
set -eux
time docker build . -t local/substrate-relay --build-arg=PROJECT=substrate-relay
time docker build . -t local/rialto-bridge-node --build-arg=PROJECT=rialto-bridge-node
time docker build . -t local/millau-bridge-node --build-arg=PROJECT=millau-bridge-node
time docker build . -t local/rialto-parachain-collator --build-arg=PROJECT=rialto-parachain-collator
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
set -xeu
echo $CARGO_TARGET_DIR;
mkdir -p $CARGO_TARGET_DIR;
echo "Current Rust nightly version:";
rustc +nightly --version;
echo "Cached Rust nightly version:";
if [ ! -f $CARGO_TARGET_DIR/check_nightly_rust ]; then
echo "" > $CARGO_TARGET_DIR/check_nightly_rust;
fi
cat $CARGO_TARGET_DIR/check_nightly_rust;
if [[ $(cat $CARGO_TARGET_DIR/check_nightly_rust) == $(rustc +nightly --version) ]]; then
echo "The Rust nightly version has not changed";
else
echo "The Rust nightly version has changed. Clearing the cache";
rm -rf $CARGO_TARGET_DIR/*;
fi
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
# A script to dump logs from selected important docker containers
# to make it easier to analyze locally.
set -xeu
DATE=$(date +"%Y-%m-%d-%T")
LOGS_DIR="${DATE//:/-}-logs"
mkdir $LOGS_DIR
cd $LOGS_DIR
# From $ docker ps --format '{{.Names}}'
SERVICES=(\
deployments_relay-messages-millau-to-rialto-generator_1 \
deployments_relay-messages-rialto-to-millau-generator_1 \
deployments_relay-messages-millau-to-rialto-lane-00000001_1 \
deployments_relay-messages-rialto-to-millau-lane-00000001_1 \
deployments_relay-millau-rialto_1 \
deployments_relay-headers-westend-to-millau-1_1 \
deployments_relay-headers-westend-to-millau-2_1 \
deployments_relay-parachains-westend-to-millau-1_1 \
deployments_relay-parachains-westend-to-millau-1_2 \
deployments_relay-messages-millau-to-rialto-parachain-generator_1 \
deployments_relay-messages-rialto-parachain-to-millau-generator_1 \
deployments_relay-millau-rialto-parachain-1_1 \
deployments_relay-millau-rialto-parachain-2_1 \
deployments_rialto-node-alice_1 \
deployments_rialto-node-bob_1 \
deployments_millau-node-alice_1 \
deployments_millau-node-bob_1 \
deployments_rialto-parachain-collator-alice_1 \
deployments_rialto-parachain-collator-bob_1 \
deployments_relay-messages-millau-to-rialto-resubmitter_1 \
deployments_relay-messages-millau-to-rialto-parachain-resubmitter_1 \
)
for SVC in ${SERVICES[*]}
do
SHORT_NAME="${SVC//deployments_/}"
docker logs $SVC &> $SHORT_NAME.log | true
done
cd -
tar cvjf $LOGS_DIR.tar.bz2 $LOGS_DIR
+16
View File
@@ -0,0 +1,16 @@
// Copyright 2019-2021 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/>.
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# Used for manually sending a message to a running network.
#
# You could for example spin up a full network using the Docker Compose files
# we have (to make sure the message relays are running), but remove the message
# generator service. From there you may submit messages manually using this script.
# TODO: Fix demeo scripts https://github.com/paritytech/parity-bridges-common/issues/1406
MILLAU_PORT="${RIALTO_PORT:-9945}"
case "$1" in
remark)
RUST_LOG=runtime=trace,substrate-relay=trace,bridge=trace \
./target/debug/substrate-relay send-message millau-to-rialto \
--source-host localhost \
--source-port $MILLAU_PORT \
--source-signer //Alice \
raw 020419ac
;;
transfer)
RUST_LOG=runtime=trace,substrate-relay=trace,bridge=trace \
./target/debug/substrate-relay send-message millau-to-rialto \
--source-host localhost \
--source-port $MILLAU_PORT \
--source-signer //Alice \
transfer \
--amount 100000000000000 \
--recipient 5DZvVvd1udr61vL7Xks17TFQ4fi9NiagYLaBobnbPCP14ewA \
;;
*) echo "A message type is require. Supported messages: remark, transfer."; exit 1;;
esac
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# Used for manually sending a message to a running network.
#
# You could for example spin up a full network using the Docker Compose files
# we have (to make sure the message relays are running), but remove the message
# generator service. From there you may submit messages manually using this script.
# TODO: Fix demeo scripts https://github.com/paritytech/parity-bridges-common/issues/1406
RIALTO_PORT="${RIALTO_PORT:-9944}"
case "$1" in
remark)
RUST_LOG=runtime=trace,substrate-relay=trace,bridge=trace \
./target/debug/substrate-relay send-message rialto-to-millau \
--source-host localhost \
--source-port $RIALTO_PORT \
--source-signer //Bob \
raw 020419ac
;;
transfer)
RUST_LOG=runtime=trace,substrate-relay=trace,bridge=trace \
./target/debug/substrate-relay send-message rialto-to-millau \
--source-host localhost \
--source-port $RIALTO_PORT \
--source-signer //Bob \
transfer \
--amount 100000000000000 \
--recipient 5DZvVvd1udr61vL7Xks17TFQ4fi9NiagYLaBobnbPCP14ewA \
;;
*) echo "A message type is require. Supported messages: remark, transfer."; exit 1;;
esac
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
set -exu
# Set up the standardized machine and run `update-weights.sh` script.
# The system is assumed to be pristine Ubuntu 20.04 and we install
# all required dependencies.
# To avoid interruptions you might want to run this script in `screen` cause it will take a while
# to finish.
# We start off with upgrading the system
apt update && apt dist-upgrade
# and installing `git` and other required deps.
apt install -y git clang curl libssl-dev llvm libudev-dev screen
# Now we clone the repository
git clone https://github.com/paritytech/parity-bridges-common.git
cd parity-bridges-common
# Install rustup & toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
# Source config
source ~/.cargo/env
# Add nightly and WASM
rustup install nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
# Update the weights
./scripts/update-weights.sh
+55
View File
@@ -0,0 +1,55 @@
#!/bin/sh
#
# Runtime benchmarks for the `pallet-bridge-messages` and `pallet-bridge-grandpa` pallets.
#
# Run this script from root of the repo.
set -eux
time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \
--chain=dev \
--steps=50 \
--repeat=20 \
--pallet=pallet_bridge_messages \
--extrinsic=* \
--execution=wasm \
--wasm-execution=Compiled \
--heap-pages=4096 \
--output=./modules/messages/src/weights.rs \
--template=./.maintain/millau-weight-template.hbs
time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \
--chain=dev \
--steps=50 \
--repeat=20 \
--pallet=pallet_bridge_grandpa \
--extrinsic=* \
--execution=wasm \
--wasm-execution=Compiled \
--heap-pages=4096 \
--output=./modules/grandpa/src/weights.rs \
--template=./.maintain/millau-weight-template.hbs
time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \
--chain=dev \
--steps=50 \
--repeat=20 \
--pallet=pallet_bridge_parachains \
--extrinsic=* \
--execution=wasm \
--wasm-execution=Compiled \
--heap-pages=4096 \
--output=./modules/parachains/src/weights.rs \
--template=./.maintain/millau-weight-template.hbs
time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \
--chain=dev \
--steps=50 \
--repeat=20 \
--pallet=pallet_bridge_relayers \
--extrinsic=* \
--execution=wasm \
--wasm-execution=Compiled \
--heap-pages=4096 \
--output=./modules/relayers/src/weights.rs \
--template=./.maintain/millau-weight-template.hbs
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
# One-liner to update between Substrate releases
# Usage: ./update_substrate.sh 2.0.0-rc6 2.0.0
set -xeu
OLD_VERSION=$1
NEW_VERSION=$2
find . -type f -name 'Cargo.toml' -exec sed -i '' -e "s/$OLD_VERSION/$NEW_VERSION/g" {} \;