Skip to content

Commit 8de9c5c

Browse files
Big Dipper (#10)
1 parent 3c948a1 commit 8de9c5c

File tree

18 files changed

+267
-61
lines changed

18 files changed

+267
-61
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ override-env.sh
55

66
EVMOS-source-code*/
77
Hermes-source-code/
8-
bdjuno-source-code/
8+
bdjuno-source-code*/
9+
bd2-source-code*/
910

1011
*genesis.json
1112
*config.toml

README.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,44 @@ I wrote hundred lines of comments which explains every steps in each script file
88
- [yq + tomlq (build on top of jq)](https://github.com/kislyuk/yq)
99
- [Rust 1.60+](https://www.rust-lang.org/tools/install) (for Hermes - IBC relayer)
1010
- [docker](https://docs.docker.com/engine/install/) & [docker compose](https://docs.docker.com/compose/install/)
11+
- Node JS (for Big Dipper 2.0 Cosmos)
1112

12-
I created all of the following samples on an Ubuntu 22.04 LTS machine with 4 CPU 4 GB RAM. It can run
13-
- 2 EVMOS networks
14-
- 1 Hermes as IBC relayer to connect them
15-
- 2 bdjuno as block explorer's backend
16-
- 2 hasura as graphql service
13+
I created all of the following samples on an Ubuntu 22.04 LTS machine with 4 CPU 16 GB RAM. It can run
14+
- 2 [EVMOS](https://github.com/evmos/evmos/tree/v5.0.0) networks
15+
- 1 [Hermes](https://github.com/informalsystems/ibc-rs/tree/v0.15.0) as IBC relayer to connect them
16+
- 2 [bdjuno & hasura](https://github.com/forbole/bdjuno/tree/chains/evmos/mainnet) as block explorer's backend & graphql service
17+
- 2 [Big Dipper 2.0](https://github.com/forbole/big-dipper-2.0-cosmos/tree/chains/evmos) as block explorer's backend
1718

18-
without any performance issue (CPU ~20% per core, ram ~45% via htop).
19+
without any performance issue (CPU ~20-80% per core, ram ~50% via htop).
1920

2021
### List of samples:
2122
- [Script to build EVMOS networks and run with docker compose](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/evmos-on-docker)
2223
- [Script to build & setup Hermes as an IBC relayer](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/hermes-as-ibc-relayer)
23-
- [Script to setup bdjuno (back-end of Big Dipper block explorer) with hasura as graphql service](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/bdjuno)
24-
- [(Comming soon) Script to setup [Big Dipper 2.0 For Cosmos] (front-end of Big Dipper block explorer)](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/bd2)
24+
- [Script to setup Big Dipper (backend bdjuno with hasura as graphql service & frontend Big Dipper 2.0 for Cosmos based chains)](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/big-dipper-as-block-explorer)
2525

2626
### Software versions:
2727

2828
- [Evmos v5.0.0](https://github.com/evmos/evmos/tree/v5.0.0)
2929
- [Hermes v0.15.0](https://github.com/informalsystems/ibc-rs/tree/v0.15.0)
30+
- [bdjuno branch evmos](https://github.com/forbole/bdjuno/tree/chains/evmos/mainnet)
31+
- [Big Dipper 2.0 for Cosmos chains branch evmos](https://github.com/forbole/big-dipper-2.0-cosmos/tree/chains/evmos)
3032

31-
You can change version EVMOS and Hermes by updating file [env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh)
33+
You can change their version by updating file [env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh)
3234
- This sample is using keyring `test`, you may need to change to `file` for secure your test env if needed
33-
- You can create `override-env.sh` file and override values there (git ignores this file)
35+
- You can create `override-env.sh` file and override values there
3436

3537
#### Default ports used in these samples
3638

3739
| Sample name | Port No. for network 1 | Port No. for network 2 | Desc |
3840
| --- | --- | --- | --- |
39-
| EVMOS on docker | 26657 | 36657 | RPC |
40-
| EVMOS on docker | 8545 | 18545 | Json RPC |
41-
| EVMOS on docker | 1317 | 11317 | REST API |
41+
| EVMOS on docker | 26657 | 36657 | **RPC** |
42+
| EVMOS on docker | 8545 | 18545 | **Json RPC** |
43+
| EVMOS on docker | 1317 | 11317 | **REST API** |
4244
| EVMOS on docker | 9090 | 19090 | gRPC |
4345
| EVMOS on docker | 26656 | 36656 | P2P |
44-
| bdjuno | 8080 | 8082 | Hasura's graphql service |
45-
| bdjuno | 3000 | 3002 | bdjuno hasura action base |
46+
| Big Dipper as Block Explorer | 3800 | 3802 | **Big Dipper front end** |
47+
| Big Dipper as Block Explorer | 8080 | 8082 | Hasura's graphql service |
48+
| Big Dipper as Block Explorer | 3000 | 3002 | bdjuno hasura action base |
4649

4750
#### Default service name & container name used in these samples
4851
| Sample name | Name for network 1 | Name for network 2 | Desc |
@@ -51,6 +54,7 @@ You can change version EVMOS and Hermes by updating file [env.sh](https://github
5154
| EVMOS on docker | vtevmos11 | vtevmos21 | Node 1 (validator 2) of EVMOS network run via docker-compose |
5255
| EVMOS on docker | vtevmos12 | vtevmos22 | Node 2 (validator 3) of EVMOS network run via docker-compose |
5356
| Hermes as IBC relayer | (hermes-svc as a shared service) | (hermes-svc as a shared service) | Hermes connects both networks (Debian* daemon service) |
54-
| bdjuno | bdjuno-svc1 | bdjuno-svc2 | bdjuno app (Debian* daemon service) |
55-
| bdjuno | bdjdb1 | bdjdb2 | bdjuno & hasura database |
56-
| bdjuno | bdjhasura1 | bdjhasura2 | Hasura graphql service |
57+
| Big Dipper as Block Explorer | bdjuno-svc1 | bdjuno-svc2 | bdjuno app (Debian* daemon service) |
58+
| Big Dipper as Block Explorer | bdjdb1 | bdjdb2 | bdjuno & hasura database (docker) |
59+
| Big Dipper as Block Explorer | bdjhasura1 | bdjhasura2 | Hasura graphql service (docker) |
60+
| Big Dipper as Block Explorer | bd2-svc1 | bd2-svc2 | Big Dipper front end (Debian* daemon service) |

bd2/README.md

Whitespace-only changes.

bdjuno/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

bdjuno/cleanup.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.bdjuno*/

bdjuno/1_install-bdjuno.sh renamed to big-dipper-as-block-explorer/1_install-bdjuno.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if [ -f "./_config.sh" ]; then
1515
source "./_config.sh"
1616
else
1717
echo "ERR: Wrong working directory"
18-
echo "ERR: Scripts must be executed within [bdjuno] directory"
18+
echo "ERR: Scripts must be executed within [big-dipper-as-block-explorer] directory"
1919
exit 1
2020
fi
2121

bdjuno/2_install-bdjuno.sh renamed to big-dipper-as-block-explorer/2_install-bdjuno.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if [ -f "./_config.sh" ]; then
1212
source "./_config.sh"
1313
else
1414
echo "ERR: Wrong working directory"
15-
echo "ERR: Scripts must be executed within [bdjuno] directory"
15+
echo "ERR: Scripts must be executed within [big-dipper-as-block-explorer] directory"
1616
exit 1
1717
fi
1818

@@ -75,7 +75,10 @@ if [ $DISABLE_SYSTEMCTL -eq 0 ]; then
7575
echo "sudo vi $SERVICE_FILE"
7676
echo
7777

78+
CUR_DIR=$(pwd)
79+
cd "$BD_HOME"
7880
WORKING_DIR=$(pwd)
81+
cd "$CUR_DIR"
7982

8083
SCRIPT_CONTENT="[Unit]
8184
\nDescription=BDJuno parser
@@ -84,6 +87,7 @@ if [ $DISABLE_SYSTEMCTL -eq 0 ]; then
8487
8588
\n[Service]
8689
\nUser=$USER
90+
\nWorkingDirectory=$WORKING_DIR
8791
\nExecStart=$BD_BINARY start --home $BD_HOME
8892
\nRestart=always
8993
\nRestartSec=3

bdjuno/3_install-hasura.sh renamed to big-dipper-as-block-explorer/3_install-hasura.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if [ -f "./_config.sh" ]; then
1515
source "./_config.sh"
1616
else
1717
echo "ERR: Wrong working directory"
18-
echo "ERR: Scripts must be executed within [bdjuno] directory"
18+
echo "ERR: Scripts must be executed within [big-dipper-as-block-explorer] directory"
1919
exit 1
2020
fi
2121

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/bin/bash
2+
3+
command -v npm > /dev/null 2>&1 || { echo >&2 "npm is required"; exit 1; }
4+
5+
source ../env.sh
6+
7+
CHAIN_NO=$1
8+
9+
if [ -f "./override-env.sh" ]; then
10+
source "./override-env.sh"
11+
fi
12+
13+
if [ -f "./_config.sh" ]; then
14+
source "./_config.sh"
15+
else
16+
echo "ERR: Wrong working directory"
17+
echo "ERR: Scripts must be executed within [big-dipper-as-block-explorer] directory"
18+
exit 1
19+
fi
20+
21+
# Validate input
22+
if [ "$CHAIN_NO" = "1" ]; then
23+
echo "Network 1"
24+
elif [ "$CHAIN_NO" = "2" ]; then
25+
echo "Network 2"
26+
else
27+
echo 'Missing or incorrect chain no as first argument, valid input is 1 or 2'
28+
echo 'For example:'
29+
echo " $0 1"
30+
echo " or: $0 2"
31+
exit 1
32+
fi
33+
34+
# Stop service if exists
35+
[ $DISABLE_SYSTEMCTL -eq 0 ] && {
36+
echo "Stopping $BD2_SERVICE_NAME service";
37+
sudo systemctl stop $BD2_SERVICE_NAME > /dev/null 2>&1;
38+
sudo systemctl disable $BD2_SERVICE_NAME > /dev/null 2>&1;
39+
}
40+
41+
# Check Big Dipper 2.0 source
42+
if [ -d "$BD2_SOURCE_DIR" ]; then
43+
echo "Big Dipper 2.0 repo was downloaded"
44+
else
45+
echo "Downloading Big Dipper 2.0 source code from branch $BD2_BRANCH"
46+
git clone "https://github.com/forbole/big-dipper-2.0-cosmos.git" --branch "$BD2_BRANCH" --single-branch "$BD2_SOURCE_DIR"
47+
48+
if [ $? -ne 0 ]; then
49+
echo "Git clone Big Dipper 2.0 from branch $BD2_BRANCH was failed"
50+
exit 1
51+
fi
52+
fi
53+
54+
# npm environment variables
55+
NPM_ENV="$BD2_SOURCE_DIR/.env"
56+
echo "Setting up file $NPM_ENV"
57+
echo -e "
58+
NEXT_PUBLIC_GRAPHQL_URL=http://$BD2_PUBLIC_DOMAIN:$BD_HASURA_PORT/v1/graphql
59+
\nNEXT_PUBLIC_GRAPHQL_WS=ws://$BD2_PUBLIC_DOMAIN:$BD_HASURA_PORT/v1/graphql
60+
\nNODE_ENV=test
61+
\nPORT=$BD2_PORT
62+
\nNEXT_PUBLIC_URL=http://$BD2_PUBLIC_DOMAIN:$BD2_PORT
63+
\nNEXT_PUBLIC_RPC_WEBSOCKET=ws://$BD2_PUBLIC_RPC_26657/websocket
64+
\nNEXT_PUBLIC_CHAIN_TYPE=mainnet
65+
" > "$NPM_ENV"
66+
67+
# BD2 chain config
68+
BD2_CHAIN_CONFIG_MAINNET="$BD2_SOURCE_DIR/src/configs/chain_config.mainnet.json"
69+
BD2_CHAIN_CONFIG_TESTNET="$BD2_SOURCE_DIR/src/configs/chain_config.testnet.json"
70+
BD2_CHAIN_CONFIG_TMP="$BD2_SOURCE_DIR/src/configs/tmp_chain_config.json"
71+
echo "Setting up file mainnet chain config"
72+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.title="'$DENOM_SYMBOL' Block Explorer"' > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
73+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.network="'$CHAIN_ID'"' > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
74+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.prefix["consensus"]="'$DENOM_SYMBOL'valcons"' > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
75+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.prefix["validator"]="'$DENOM_SYMBOL'valoper"' > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
76+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.prefix["account"]="'$ACCOUNT_PREFIX'"' > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
77+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.primaryTokenUnit="'$MIN_DENOM_SYMBOL'"' > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
78+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.votingPowerTokenUnit="'$MIN_DENOM_SYMBOL'"' > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
79+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.tokenUnits["'$MIN_DENOM_SYMBOL'"]["display"]="'$DENOM_SYMBOL'"' > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
80+
cat "$BD2_CHAIN_CONFIG_MAINNET" | jq '.tokenUnits["'$MIN_DENOM_SYMBOL'"]["exponent"]='$DENOM_EXPONENT > $BD2_CHAIN_CONFIG_TMP && mv $BD2_CHAIN_CONFIG_TMP $BD2_CHAIN_CONFIG_MAINNET
81+
echo "Setting up file testnet chain config"
82+
cp "$BD2_CHAIN_CONFIG_MAINNET" "$BD2_CHAIN_CONFIG_TESTNET"
83+
84+
# BD2 codegen config
85+
BD2_CODEGEN_YML="$BD2_SOURCE_DIR/codegen.yml"
86+
BD2_CODEGEN_YML_TMP="$BD2_SOURCE_DIR/tmp_codegen.yml"
87+
echo "Setting up file $BD2_CODEGEN_YML"
88+
cat "$BD2_CODEGEN_YML" | yq '.generates["./src/graphql/types/general_types.tsx"]["schema"]="http://'$BD2_PUBLIC_DOMAIN':'$BD_HASURA_PORT'/v1/graphql"' -Y > "$BD2_CODEGEN_YML_TMP" && mv "$BD2_CODEGEN_YML_TMP" "$BD2_CODEGEN_YML"
89+
90+
CUR_DIR=$(pwd)
91+
cd "$BD2_SOURCE_DIR"
92+
WORKING_DIR=$(pwd)
93+
# Build
94+
## Install graphql-codegen
95+
npm i -D @graphql-codegen/cli > /dev/null 2>&1
96+
[ $? -eq 0 ] || { echo "Failed to install @graphql-codegen/cli"; exit 1; }
97+
## Gen code
98+
echo 'Generating code'
99+
npm run graphql:codegen
100+
[ $? -eq 0 ] || { echo "Failed to run graphql:codegen"; exit 1; }
101+
#echo 'Build'
102+
#npm run build
103+
#[ $? -eq 0 ] || { echo "Failed to build"; exit 1; }
104+
105+
cd "$CUR_DIR"
106+
107+
# Re-Start service
108+
if [ $DISABLE_SYSTEMCTL -eq 0 ]; then
109+
SERVICE_FILE="/etc/systemd/system/$BD2_SERVICE_NAME.service"
110+
echo
111+
if [ -f "$SERVICE_FILE" ]; then
112+
echo "You are ready to restart $BD2_SERVICE_NAME service (sudo systemctl restart $BD2_SERVICE_NAME)"
113+
114+
[ $EXTRA_FUNC -eq 1 ] && sudo systemctl start $BD2_SERVICE_NAME
115+
else
116+
echo "You can paste the following content to $SERVICE_FILE file to create a daemon service"
117+
echo "sudo vi $SERVICE_FILE"
118+
echo
119+
120+
SCRIPT_CONTENT="[Unit]
121+
\nDescription=Big Dipper 2.0 for $DENOM_SYMBOL chain (network $CHAIN_NO)
122+
\nAfter=network-online.target
123+
124+
\n[Service]
125+
\nUser=$USER
126+
\nWorkingDirectory=$WORKING_DIR
127+
\nExecStart=$(which npm) run dev
128+
\nRestart=always
129+
\nRestartSec=3
130+
\nLimitNOFILE=4096
131+
132+
\n[Install]
133+
\nWantedBy=multi-user.target"
134+
echo -e $SCRIPT_CONTENT
135+
echo
136+
echo "sudo systemctl enable $BD2_SERVICE_NAME"
137+
echo "sudo systemctl start $BD2_SERVICE_NAME"
138+
139+
[ $EXTRA_FUNC -eq 1 ] && {
140+
echo 'Creating service '$BD2_SERVICE_NAME;
141+
echo -e $SCRIPT_CONTENT | sudo tee $SERVICE_FILE > /dev/null;
142+
sudo systemctl daemon-reload;
143+
sudo systemctl enable $BD2_SERVICE_NAME;
144+
sudo systemctl start $BD2_SERVICE_NAME;
145+
sudo journalctl -fu $BD2_SERVICE_NAME;
146+
}
147+
fi
148+
else
149+
echo "OK, you can run it now"
150+
echo "Hint: npm run dev"
151+
fi

0 commit comments

Comments
 (0)