-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtoken-swap-generator.sh
executable file
·49 lines (43 loc) · 1.37 KB
/
token-swap-generator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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=60
SOURCE_HOST=127.0.0.1
SOURCE_PORT=10944
TARGET_HOST=127.0.0.1
TARGET_PORT=9944
# 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
NOW=`date "+%Y-%m-%d %H:%M:%S"`
echo "Woke up at $NOW"
}
# give conversion rate updater some time to update Rialto->Millau conversion rate in Millau
# (initially rate=1 and rational relayer won't deliver any messages if it'll be changed to larger value)
sleep 180
while true
do
rand_sleep
echo "Initiating token-swap between Rialto and Millau"
./bin/substrate-relay \
swap-tokens \
millau-to-rialto \
--source-host $SOURCE_HOST \
--source-port $SOURCE_PORT \
--source-signer //WithRialtoTokenSwap \
--source-balance 100000 \
--target-host $TARGET_HOST \
--target-port $TARGET_PORT \
--target-signer //WithMillauTokenSwap \
--target-balance 200000 \
--target-to-source-conversion-rate-override metric \
--source-to-target-conversion-rate-override metric \
lock-until-block \
--blocks-before-expire 32
done