forked from Gravity-Bridge/Gravity-Bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-testnet.sh
executable file
·81 lines (75 loc) · 3.32 KB
/
run-testnet.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -eux
# your gaiad binary name
BIN=gravity
NODES=$1
set +u
TEST_TYPE=$2
ALCHEMY_ID=$3
set -u
for i in $(seq 1 $NODES);
do
# add this ip for loopback dialing
ip addr add 7.7.7.$i/32 dev eth0 || true # allowed to fail
GAIA_HOME="--home /validator$i"
# this implicitly caps us at ~6000 nodes for this sim
# note that we start on 26656 the idea here is that the first
# node (node 1) is at the expected contact address from the gentx
# faciliating automated peer exchange
if [[ "$i" -eq 1 ]]; then
# node one gets localhost so we can easily shunt these ports
# to the docker host
RPC_ADDRESS="--rpc.laddr tcp://0.0.0.0:26657"
GRPC_ADDRESS="--grpc.address 0.0.0.0:9090"
GRPC_WEB_ADDRESS="--grpc-web.address 0.0.0.0:9092"
else
# move these to another port and address, not becuase they will
# be used there, but instead to prevent them from causing problems
# you also can't duplicate the port selection against localhost
# for reasons that are not clear to me right now.
RPC_ADDRESS="--rpc.laddr tcp://7.7.7.$i:26658"
GRPC_ADDRESS="--grpc.address 7.7.7.$i:9091"
GRPC_WEB_ADDRESS="--grpc-web.address 7.7.7.$i:9093"
fi
LISTEN_ADDRESS="--address tcp://7.7.7.$i:26655"
P2P_ADDRESS="--p2p.laddr tcp://7.7.7.$i:26656"
LOG_LEVEL="--log_level info"
INVARIANTS_CHECK="--inv-check-period 1"
ARGS="$GAIA_HOME $LISTEN_ADDRESS $RPC_ADDRESS $GRPC_ADDRESS $GRPC_WEB_ADDRESS $LOG_LEVEL $INVARIANTS_CHECK $P2P_ADDRESS"
$BIN $ARGS start &> /validator$i/logs &
done
# let the cosmos chain settle before starting eth as it
# consumes a lot of processing power
sleep 10
# GETH and TEST_TYPE may be unbound
set +u
# Starts a hardhat RPC backend that is based off of a fork of Ethereum mainnet. This is useful in that we take
# over the account of a major Uniswap liquidity provider and from there we can test many things that are infeasible
# to do with a Geth backend, simply becuase reproducting that state on our testnet would be far too complex to consider
# The tradeoff here is that hardhat is an ETH dev environment and not an actual ETH implementation, as such the outputs
# may be different. These two tests have different fork block heights they rely on
if [[ $TEST_TYPE == *"ARBITRARY_LOGIC"* ]]; then
export ALCHEMY_ID=$ALCHEMY_ID
pushd /gravity/solidity
npm run solidity_test_fork &
popd
elif [[ $TEST_TYPE == *"RELAY_MARKET"* ]]; then
export ALCHEMY_ID=$ALCHEMY_ID
pushd /gravity/solidity
npm run evm_fork &
popd
# This starts a hardhat test environment with no pre-seeded state, faster to run, not accurate
elif [[ ! -z "$HARDHAT" ]]; then
pushd /gravity/solidity
npm run evm &
popd
# This starts the Geth backed testnet with no pre-seeded in state.
# Geth is what we run in CI and in general, but developers frequently
# perfer a faster experience provided by HardHat, also Mac's do not
# work correctly with the Geth backend, there is some issue where the Docker VM on Mac platforms can't get
# the right number of cpu cores and Geth goes crazy consuming all the processing power, on the other hand
# hardhat doesn't work for some tests that depend on transactions waiting for blocks, so Geth is the default
else
bash /gravity/tests/container-scripts/run-eth.sh &
fi
sleep 10