Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion deployments/bridges/common/generate_messages.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

SECONDARY_EXTRA_ARGS=${SECONDARY_EXTRA_ARGS:-""}

trap "echo Exiting... TERM; exit $?" TERM

# 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
sleep $SUBMIT_DELAY_S & wait $!
NOW=`date "+%Y-%m-%d %H:%M:%S"`
echo "Woke up at $NOW"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sleep 15
# we need tip around `526186677695 - 17800827994 = 508_385_849_701`. Let's round it
# up to `1_000_000_000_000`.

/home/user/substrate-relay resubmit-transactions millau \
exec /home/user/substrate-relay resubmit-transactions millau \
--target-host millau-node-alice \
--target-port 9944 \
--target-signer //RialtoParachain.MessagesSender \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RIALTO_PARACHAIN_RELAY_ACCOUNT=${EXT_RIALTO_PARACHAIN_RELAY_ACCOUNT:-//Millau.He
# Give chain a little bit of time to process initialization transaction
sleep 6

/home/user/substrate-relay relay-headers-and-messages millau-rialto-parachain \
exec /home/user/substrate-relay relay-headers-and-messages millau-rialto-parachain \
--millau-host millau-node-alice \
--millau-port 9944 \
--millau-signer $MILLAU_RELAY_ACCOUNT \
Expand Down
2 changes: 2 additions & 0 deletions deployments/monitoring/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
- "3000:3000"
depends_on:
- prometheus-metrics
# SIGTERM won't work because of our custom entrypoint. Should be ok to use SIGKILL.
stop_signal: SIGKILL
entrypoint: sh -c "echo 'sleeping for 10m' && sleep 600 && /run.sh"

grafana-matrix-notifier:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -xeu

trap "echo Exiting... TERM; exit $?" TERM

/home/user/rialto-bridge-node build-spec \
--chain local \
--raw \
Expand All @@ -11,4 +13,4 @@ set -xeu
# by the container running this script. If this script ends, the volume will be detached
# and our chain spec will be lost when it'll go online again. Hence the never-ending
# script which keeps volume online until container is stopped.
tail -f /dev/null
tail -f /dev/null & wait $!
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -xeu

sleep 15

/home/user/substrate-relay register-parachain rialto-parachain \
exec /home/user/substrate-relay register-parachain rialto-parachain \
--parachain-host rialto-parachain-collator-alice \
--parachain-port 9944 \
--relaychain-host rialto-node-alice \
Expand Down
1 change: 1 addition & 0 deletions deployments/ui/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ services:
LETSENCRYPT_EMAIL: admin@parity.io
CHAIN_1_SUBSTRATE_PROVIDER: ${UI_CHAIN_1:-ws://localhost:9944}
CHAIN_2_SUBSTRATE_PROVIDER: ${UI_CHAIN_2:-ws://localhost:19944}
stop_signal: SIGKILL
ports:
- "8080:80"
2 changes: 2 additions & 0 deletions relays/bin-substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ log = "0.4.17"
num-format = "0.4"
num-traits = "0.2"
structopt = "0.3"
signal-hook = "0.3.14"
signal-hook-async-std = "0.2.2"
strum = { version = "0.21.0", features = ["derive"] }

# Bridge dependencies
Expand Down
36 changes: 34 additions & 2 deletions relays/bin-substrate/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

use std::convert::TryInto;

use async_std::prelude::*;
use codec::{Decode, Encode};
use futures::{select, FutureExt};
use signal_hook::consts::*;
use signal_hook_async_std::Signals;
use structopt::{clap::arg_enum, StructOpt};
use strum::{EnumString, EnumVariantNames};

Expand All @@ -37,6 +41,9 @@ mod relay_messages;
mod relay_parachains;
mod resubmit_transactions;

/// The target that will be used when publishing logs related to this pallet.
pub const LOG_TARGET: &str = "bridge";

/// Parse relay CLI args.
pub fn parse_args() -> Command {
Command::from_args()
Expand Down Expand Up @@ -100,8 +107,7 @@ impl Command {
}

/// Run the command.
pub async fn run(self) -> anyhow::Result<()> {
self.init_logger();
async fn do_run(self) -> anyhow::Result<()> {
match self {
Self::RelayHeaders(arg) => arg.run().await?,
Self::RelayMessages(arg) => arg.run().await?,
Expand All @@ -114,6 +120,32 @@ impl Command {
}
Ok(())
}

/// Run the command.
pub async fn run(self) {
self.init_logger();

let exit_signals = match Signals::new([SIGINT, SIGTERM]) {
Ok(signals) => signals,
Err(e) => {
log::error!(target: LOG_TARGET, "Could not register exit signals: {}", e);
return
},
};
let run = self.do_run().fuse();
futures::pin_mut!(exit_signals, run);

select! {
signal = exit_signals.next().fuse() => {
log::info!(target: LOG_TARGET, "Received exit signal {:?}", signal);
},
result = run => {
if let Err(e) = result {
log::error!(target: LOG_TARGET, "substrate-relay: {}", e);
}
},
}
}
}

arg_enum! {
Expand Down
5 changes: 1 addition & 4 deletions relays/bin-substrate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,5 @@ mod cli;
fn main() {
let command = cli::parse_args();
let run = command.run();
let result = async_std::task::block_on(run);
if let Err(error) = result {
log::error!(target: "bridge", "substrate-relay: {}", error);
}
async_std::task::block_on(run);
}