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
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ WORKDIR /parity-bridges-common

COPY . .

USER root
RUN rustup toolchain uninstall stable && \
rustup toolchain uninstall nightly && \
rustup toolchain install stable && \
rustup toolchain install nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly
ARG PROJECT=substrate-relay
RUN cargo build --release --verbose -p ${PROJECT} && \
strip ./target/release/${PROJECT}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ To run a Rialto node for example, you can use the following command:

```bash
docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 \
-it paritytech/rialto-bridge-node --dev --tmp \
-it local/rialto-bridge-node --dev --tmp \
--rpc-cors=all --unsafe-rpc-external --unsafe-ws-external
```

Expand Down
23 changes: 9 additions & 14 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,33 +795,28 @@ impl_runtime_apis! {
}

impl bp_rialto::RialtoFinalityApi<Block> for Runtime {
fn best_finalized() -> (bp_rialto::BlockNumber, bp_rialto::Hash) {
let header = BridgeRialtoGrandpa::best_finalized();
(header.number, header.hash())
fn best_finalized() -> Option<(bp_rialto::BlockNumber, bp_rialto::Hash)> {
BridgeRialtoGrandpa::best_finalized().map(|header| (header.number, header.hash()))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think we could use the new HeaderIdProvider::id() in these implementations. Could we also return an Option<HeaderId> here ? Or are we limited to basic types like tuples for the values returned by the API methods ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - I think it could be done. Thank you!

}
}

impl bp_westend::WestendFinalityApi<Block> for Runtime {
fn best_finalized() -> (bp_westend::BlockNumber, bp_westend::Hash) {
let header = BridgeWestendGrandpa::best_finalized();
(header.number, header.hash())
fn best_finalized() -> Option<(bp_westend::BlockNumber, bp_westend::Hash)> {
BridgeWestendGrandpa::best_finalized().map(|header| (header.number, header.hash()))
}
}

impl bp_rialto_parachain::RialtoParachainFinalityApi<Block> for Runtime {
fn best_finalized() -> (bp_rialto::BlockNumber, bp_rialto::Hash) {
fn best_finalized() -> Option<(bp_rialto::BlockNumber, bp_rialto::Hash)> {
// the parachains finality pallet is never decoding parachain heads, so it is
// only done in the integration code
use bp_rialto_parachain::RIALTO_PARACHAIN_ID;
let best_rialto_parachain_head = pallet_bridge_parachains::Pallet::<
let encoded_head = pallet_bridge_parachains::Pallet::<
Runtime,
WithRialtoParachainsInstance,
>::best_parachain_head(RIALTO_PARACHAIN_ID.into())
.and_then(|encoded_header| bp_rialto_parachain::Header::decode(&mut &encoded_header.0[..]).ok());
match best_rialto_parachain_head {
Some(head) => (*head.number(), head.hash()),
None => (Default::default(), Default::default()),
}
>::best_parachain_head(RIALTO_PARACHAIN_ID.into())?;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would use bp_rialto_parachain::RIALTO_PARACHAIN_ID directly and remove the use statement above.

let head = bp_rialto_parachain::Header::decode(&mut &encoded_head.0[..]).ok()?;
Some((*head.number(), head.hash()))
}
}

Expand Down
5 changes: 2 additions & 3 deletions bin/rialto-parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,8 @@ impl_runtime_apis! {
}

impl bp_millau::MillauFinalityApi<Block> for Runtime {
fn best_finalized() -> (bp_millau::BlockNumber, bp_millau::Hash) {
let header = BridgeMillauGrandpa::best_finalized();
(header.number, header.hash())
fn best_finalized() -> Option<(bp_millau::BlockNumber, bp_millau::Hash)> {
BridgeMillauGrandpa::best_finalized().map(|header| (header.number, header.hash()))
}
}

Expand Down
5 changes: 2 additions & 3 deletions bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,8 @@ impl_runtime_apis! {
}

impl bp_millau::MillauFinalityApi<Block> for Runtime {
fn best_finalized() -> (bp_millau::BlockNumber, bp_millau::Hash) {
let header = BridgeMillauGrandpa::best_finalized();
(header.number, header.hash())
fn best_finalized() -> Option<(bp_millau::BlockNumber, bp_millau::Hash)> {
BridgeMillauGrandpa::best_finalized().map(|header| (header.number, header.hash()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion deployments/bridges/rialto-millau/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
LETSENCRYPT_EMAIL: admin@parity.io

relay-millau-rialto: &sub-bridge-relay
image: paritytech/substrate-relay
image: local/substrate-relay
entrypoint: /entrypoints/relay-millau-rialto-entrypoint.sh
volumes:
- ./bridges/rialto-millau/entrypoints:/entrypoints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ rand_sleep() {

# last time when we have been asking for conversion rate update
LAST_CONVERSION_RATE_UPDATE_TIME=0
# current conversion rate
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these scripts look very similar. I wonder if we could move the common logic in a function that's accessible to all. Just saying, but probably it's not worth doing now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - it has became complicated with that conversion rate override stuff, but we'll probably would need to remove it soon (it isn't usable in the XCM infra). But overall idea looks good (if there's enough code that may be shared)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #1526 for this

CONVERSION_RATE=metric
# conversion rate override argument
CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric"

# start sending large messages immediately
LARGE_MESSAGES_TIME=0
Expand All @@ -46,30 +46,32 @@ do
# ask for latest conversion rate. We're doing that because otherwise we'll be facing
# bans from the conversion rate provider
if [ $SECONDS -ge $LAST_CONVERSION_RATE_UPDATE_TIME ]; then
CONVERSION_RATE=metric
LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + 300))
CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric"
CONVERSION_RATE_UPDATE_DELAY=`shuf -i 300-600 -n 1`
LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + $CONVERSION_RATE_UPDATE_DELAY))
fi

# send regular message
echo "Sending Message from Rialto to Millau"
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override $CONVERSION_RATE raw 010109030419A8 2>&1`
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE $CONVERSION_RATE_OVERRIDE raw 010109030419A8 2>&1`
echo $SEND_MESSAGE_OUTPUT
if [ "$CONVERSION_RATE" = "metric" ]; then
if [ "$CONVERSION_RATE_OVERRIDE" = "--conversion-rate-override metric" ]; then
ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)"
if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then
CONVERSION_RATE=${BASH_REMATCH[1]}
echo "Read updated conversion rate: $CONVERSION_RATE"
CONVERSION_RATE_OVERRIDE="--conversion-rate-override $CONVERSION_RATE"
else
echo "Unable to find conversion rate in send-message output"
exit 1
echo "Error: unable to find conversion rate in send-message output. Will keep using on-chain rate"
CONVERSION_RATE_OVERRIDE=""
fi
fi

if [ ! -z $SECONDARY_MESSAGE_LANE ]; then
echo "Sending Message from Rialto to Millau using secondary lane: $SECONDARY_MESSAGE_LANE"
$SEND_MESSAGE \
--lane $SECONDARY_MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
raw 010109030419A8
fi

Expand All @@ -81,7 +83,7 @@ do
echo "Sending Maximal Size Message from Rialto to Millau"
$SEND_MESSAGE \
--lane $MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
sized max
fi

Expand All @@ -93,7 +95,7 @@ do
do
$SEND_MESSAGE \
--lane $MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
raw 010109030419A8
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ rand_sleep() {

# last time when we have been asking for conversion rate update
LAST_CONVERSION_RATE_UPDATE_TIME=0
# current conversion rate
CONVERSION_RATE=metric
# conversion rate override argument
CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric"

# start sending large messages immediately
LARGE_MESSAGES_TIME=0
Expand All @@ -46,30 +46,32 @@ do
# ask for latest conversion rate. We're doing that because otherwise we'll be facing
# bans from the conversion rate provider
if [ $SECONDS -ge $LAST_CONVERSION_RATE_UPDATE_TIME ]; then
CONVERSION_RATE=metric
LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + 300))
CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric"
CONVERSION_RATE_UPDATE_DELAY=`shuf -i 300-600 -n 1`
LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + $CONVERSION_RATE_UPDATE_DELAY))
fi

# send regular message
echo "Sending Message from Millau to Rialto"
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override $CONVERSION_RATE raw 010109020419A8 2>&1`
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE $CONVERSION_RATE_OVERRIDE raw 010109020419A8 2>&1`
echo $SEND_MESSAGE_OUTPUT
if [ "$CONVERSION_RATE" = "metric" ]; then
if [ "$CONVERSION_RATE_OVERRIDE" = "--conversion-rate-override metric" ]; then
ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)"
if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then
CONVERSION_RATE=${BASH_REMATCH[1]}
echo "Read updated conversion rate: $CONVERSION_RATE"
CONVERSION_RATE_OVERRIDE="--conversion-rate-override $CONVERSION_RATE"
else
echo "Unable to find conversion rate in send-message output"
exit 1
echo "Error: unable to find conversion rate in send-message output. Will keep using on-chain rate"
CONVERSION_RATE_OVERRIDE=""
fi
fi

if [ ! -z $SECONDARY_MESSAGE_LANE ]; then
echo "Sending Message from Millau to Rialto using secondary lane: $SECONDARY_MESSAGE_LANE"
$SEND_MESSAGE \
--lane $SECONDARY_MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
raw 010109020419A8
fi

Expand All @@ -81,7 +83,7 @@ do
echo "Sending Maximal Size Message from Millau to Rialto"
$SEND_MESSAGE \
--lane $MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
sized max
fi

Expand All @@ -92,7 +94,7 @@ do
do
$SEND_MESSAGE \
--lane $MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
raw 010109020419A8
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
LETSENCRYPT_EMAIL: admin@parity.io

relay-millau-rialto-parachain: &sub-bridge-relay
image: paritytech/substrate-relay
image: local/substrate-relay
entrypoint: /entrypoints/relay-millau-rialto-parachain-entrypoint.sh
volumes:
- ./bridges/rialto-parachain-millau/entrypoints:/entrypoints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ rand_sleep() {

# last time when we have been asking for conversion rate update
LAST_CONVERSION_RATE_UPDATE_TIME=0
# current conversion rate
CONVERSION_RATE=metric
# conversion rate override argument
CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric"

# start sending large messages immediately
LARGE_MESSAGES_TIME=0
Expand All @@ -44,22 +44,23 @@ do
# ask for latest conversion rate. We're doing that because otherwise we'll be facing
# bans from the conversion rate provider
if [ $SECONDS -ge $LAST_CONVERSION_RATE_UPDATE_TIME ]; then
CONVERSION_RATE=metric
LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + 300))
CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric"
CONVERSION_RATE_UPDATE_DELAY=`shuf -i 300-600 -n 1`
LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + $CONVERSION_RATE_UPDATE_DELAY))
fi

# send regular message
echo "Sending Message from RialtoParachain to Millau"
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override $CONVERSION_RATE raw 010109030419A8 2>&1`
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE $CONVERSION_RATE_OVERRIDE raw 010109030419A8 2>&1`
echo $SEND_MESSAGE_OUTPUT
if [ "$CONVERSION_RATE" = "metric" ]; then
if [ "$CONVERSION_RATE_OVERRIDE" = "--conversion-rate-override metric" ]; then
ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)"
if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then
CONVERSION_RATE=${BASH_REMATCH[1]}
echo "Read updated conversion rate: $CONVERSION_RATE"
CONVERSION_RATE_OVERRIDE="--conversion-rate-override $CONVERSION_RATE"
else
echo "Unable to find conversion rate in send-message output"
exit 1
echo "Error: unable to find conversion rate in send-message output. Will keep using on-chain rate"
CONVERSION_RATE_OVERRIDE=""
fi
fi

Expand All @@ -71,7 +72,7 @@ do
echo "Sending Maximal Size Message from RialtoParachain to Millau"
$SEND_MESSAGE \
--lane $MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
sized max
fi

Expand All @@ -82,7 +83,7 @@ do
do
$SEND_MESSAGE \
--lane $MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
raw 010109030419A8
done
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ rand_sleep() {

# last time when we have been asking for conversion rate update
LAST_CONVERSION_RATE_UPDATE_TIME=0
# current conversion rate
CONVERSION_RATE=metric
# conversion rate override argument
CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric"

# start sending large messages immediately
LARGE_MESSAGES_TIME=0
Expand All @@ -44,22 +44,24 @@ do
# ask for latest conversion rate. We're doing that because otherwise we'll be facing
# bans from the conversion rate provider
if [ $SECONDS -ge $LAST_CONVERSION_RATE_UPDATE_TIME ]; then
CONVERSION_RATE=metric
LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + 300))
CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric"
CONVERSION_RATE_UPDATE_DELAY=`shuf -i 300-600 -n 1`
LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + $CONVERSION_RATE_UPDATE_DELAY))
fi

# send regular message
echo "Sending Message from Millau to RialtoParachain"
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override $CONVERSION_RATE raw 010109020419A8 2>&1`
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE $CONVERSION_RATE_OVERRIDE raw 010109020419A8 2>&1`
echo $SEND_MESSAGE_OUTPUT
if [ "$CONVERSION_RATE" = "metric" ]; then
if [ "$CONVERSION_RATE_OVERRIDE" = "--conversion-rate-override metric" ]; then
ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)"
if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then
CONVERSION_RATE=${BASH_REMATCH[1]}
echo "Read updated conversion rate: $CONVERSION_RATE"
CONVERSION_RATE_OVERRIDE="--conversion-rate-override $CONVERSION_RATE"
else
echo "Unable to find conversion rate in send-message output"
exit 1
echo "Error: unable to find conversion rate in send-message output. Will keep using on-chain rate"
CONVERSION_RATE_OVERRIDE=""
fi
fi

Expand All @@ -71,7 +73,7 @@ do
echo "Sending Maximal Size Message from RialtoParachain to Millau"
$SEND_MESSAGE \
--lane $MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
sized max
fi

Expand All @@ -82,7 +84,7 @@ do
do
$SEND_MESSAGE \
--lane $MESSAGE_LANE \
--conversion-rate-override $CONVERSION_RATE \
$CONVERSION_RATE_OVERRIDE \
raw 010109020419A8
done
fi
Expand Down
4 changes: 2 additions & 2 deletions deployments/bridges/westend-millau/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
version: '3.5'
services:
relay-headers-westend-to-millau-1:
image: paritytech/substrate-relay
image: local/substrate-relay
entrypoint: /entrypoints/relay-headers-westend-to-millau-entrypoint.sh
volumes:
- ./bridges/westend-millau/entrypoints:/entrypoints
Expand All @@ -15,7 +15,7 @@ services:
- millau-node-alice

relay-headers-westend-to-millau-2:
image: paritytech/substrate-relay
image: local/substrate-relay
entrypoint: /entrypoints/relay-headers-westend-to-millau-entrypoint.sh
volumes:
- ./bridges/westend-millau/entrypoints:/entrypoints
Expand Down
2 changes: 1 addition & 1 deletion deployments/networks/millau.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
version: '3.5'
services:
millau-node-alice: &millau-bridge-node
image: paritytech/millau-bridge-node
image: local/millau-bridge-node
entrypoint:
- /home/user/millau-bridge-node
- --execution=Native
Expand Down
Loading