Skip to content

Commit

Permalink
Fix issue import validator for evmos based chain + Add docs setup too…
Browse files Browse the repository at this point in the history
…ls (#22)
  • Loading branch information
VictorTrustyDev authored Jun 25, 2022
1 parent fdb168d commit 41d23f9
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 86 deletions.
66 changes: 66 additions & 0 deletions Install-Required-Tools-on-Ubuntu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
I use `Ubuntu 22.04 LTS` machine for development purpose so I will provide some command lines that helps you install tools required by scripts within this repo

Update system first `sudo apt-get update -y`

- Go 1.18.3
> cd /tmp
> wget https://go.dev/dl/go1.18.3.linux-amd64.tar.gz
> sudo tar -zxvf go1.18.3.linux-amd64.tar.gz -C /usr/local/
> mkdir ~/go
> echo -e "\nexport GOPATH=\\$HOME/go\nexport PATH=\\$PATH:/usr/local/go/bin:\\$GOPATH/bin" >> ~/.bashrc
- jq
> sudo apt-get install jq -y
- yq & tomlq
> sudo apt update -y && sudo apt install python3-pip -y && pip3 install yq
- docker
> sudo apt-get update -y
> sudo apt-get install ca-certificates curl gnupg lsb-release -y
> sudo mkdir -p /etc/apt/keyrings
> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
> echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
> sudo apt-get update -y
> sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
> sudo groupadd docker
> sudo usermod -aG docker $USER
- docker-compose
> mkdir -p ~/.docker/cli-plugins/
> curl -SL https://github.com/docker/compose/releases/download/v2.6.0/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
> chmod +x ~/.docker/cli-plugins/docker-compose
> sudo ln -s ~/.docker/cli-plugins/docker-compose /usr/bin/docker-compose
- Rust
> curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- psql (PostgreSQL client)
> sudo apt install postgresql-client -y
- NodeJS
> curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
> sudo bash /tmp/nodesource_setup.sh
> sudo apt-get install -y nodejs
- hasura-cli
> curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
#### Remember to relog to all new PATH update takes effect
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Not only EVMOS, you can use this script to build for other chains like cosmos,..
- [docker](https://docs.docker.com/engine/install/) & [docker compose](https://docs.docker.com/compose/install/)
- Node JS to build & run Big Dipper 2.0 for Cosmos based chains
- PostgreSQL client (psql) for postgres 12.5 to setup Big Dipper
- [Hasura cli](https://hasura.io/docs/latest/graphql/core/hasura-cli/install-hasura-cli/) for bdjuno

You can find commands to install the above tools [here](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/Install-Required-Tools-on-Ubuntu.md)

I created all of the following samples on an Ubuntu 22.04 LTS machine with 4 CPU 16 GB RAM. It can run
- 2 [EVMOS](https://github.com/evmos/evmos/tree/v5.0.0) chains
Expand All @@ -37,7 +40,7 @@ without any performance issue (CPU ~20-80% per core, ram ~50% via htop)
- You can change their version by updating file [env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh)
- This sample is using keyring `test`, you may need to change to `file` for secure your test env if needed in [env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh)
- You can create `override-env.sh` file and override values of [env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh)
- The [sample.cosmos-and-evmos.override-env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/sample.cosmos-and-evmos.override-env.sh) file contains example which tell you how to override variables of [env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh) and make the chain 1 use cosmos source, rename it to `override-env.sh` to make it effectives
- The [sample.cosmos-and-evmos.override-env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/sample.cosmos-and-evmos.override-env.sh) file contains example which tell you how to override variables of [env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh) and make the chain 1 use Cosmos (gaia) source, rename it to `override-env.sh` to make it effectives
- The [sample.expose-big-dipper-ui.override-env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/sample.expose-big-dipper-ui.override-env.sh) file contains example which tell you how to override variables of [env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh) and make the block explorer UI (Big Dipper 2.0) accessible from outside world, rename it to `override-env.sh` to make it effectives

#### Default ports used in these samples
Expand Down
91 changes: 37 additions & 54 deletions blockchain-in-docker/1_prepare-genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,43 +33,20 @@ else
fi

if [ "$CHAIN_TYPE" = "evmos" ]; then
if [ "$VALIDATOR_IMPORT_TYPE" = "private_key" ] || [ "$VALIDATOR_IMPORT_TYPE" = "pk" ]; then
echo
else
echo "Chain type 'evmos' only supports validator import type = 'private_key' (check variable 'CHAIN_${CHAIN_NO}_VALIDATOR_IMPORT_TYPE') due to bug of daemon can not import seed phrase programatically via command line"
exit 1
fi

if [ "$HD_COINTYPE" -ne "60" ]; then
echo "Chain type 'evmos' requires coin type 60 (check variable 'CHAIN_${CHAIN_NO}_COINTYPE')"
fi
else
if [ "$VALIDATOR_IMPORT_TYPE" = "seed" ] || [ "$VALIDATOR_IMPORT_TYPE" = "seed_phrase" ] || [ "$VALIDATOR_IMPORT_TYPE" = "sp" ]; then
echo
else
echo "Chain type 'cosmos' only supports validator import type = 'seed_phrase' (check variable 'CHAIN_${CHAIN_NO}_VALIDATOR_IMPORT_TYPE') because the daemon does not support 'unsafe-import-eth-key' command"
exit 1
fi
fi

if [ "$KEYRING" = "file" ]; then
echo "Keyring: file"
elif [ "$KEYRING" = "test" ]; then
echo "Keyring: test **WARNING** only use keyring-backend=test for development purpose"
echo "Keyring: test **WARNING** only use keyring-backend=test for development purpose on local machine or you must secure your cloud env by whitelist some IP addresses, otherwise someone will take all your token, even tho it's only a test env"
else
echo "Non supported keyring mode = $KEYRING, only support 'file' & 'test'"
exit 1
fi

if [ "$VALIDATOR_IMPORT_TYPE" = "private_key" ] || [ "$VALIDATOR_IMPORT_TYPE" = "pk" ]; then
export VALIDATOR_IMPORT_MODE=1
elif [ "$VALIDATOR_IMPORT_TYPE" = "seed" ] || [ "$VALIDATOR_IMPORT_TYPE" = "seed_phrase" ] || [ "$VALIDATOR_IMPORT_TYPE" = "sp" ]; then
export VALIDATOR_IMPORT_MODE=2
else
echo "Non supported validator import type = $VALIDATOR_IMPORT_TYPE, only support ('private_key' or 'pk') & ('seed' or 'seed_phrase' or 'sp')"
exit 1
fi

# Binary
export BINARY="$GOPATH/bin/$DAEMON_BINARY_NAME"

Expand Down Expand Up @@ -110,48 +87,54 @@ $BINARY init $MONIKER --chain-id $CHAIN_ID --home $VAL_HOME_3 > /dev/null 2>&1
[ $? -eq 0 ] || { echo "Err: Failed to init pseudo chain for node 2"; exit 1; }

# Import validator keys
echo 'Import validator keys'
if [ $VALIDATOR_IMPORT_MODE -eq 1 ]; then # mode private_key
if [ "$KEYRING" = "test" ]; then
echo "- Validator 1, key name '$VAL_1_KEY_NAME'"
$BINARY keys unsafe-import-eth-key "$VAL_1_KEY_NAME" "$VAL_1_PRIVATE_KEY" --keyring-backend "test" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 2, key name '$VAL_2_KEY_NAME'"
$BINARY keys unsafe-import-eth-key "$VAL_2_KEY_NAME" "$VAL_2_PRIVATE_KEY" --keyring-backend "test" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 3, key name '$VAL_3_KEY_NAME'"
$BINARY keys unsafe-import-eth-key "$VAL_3_KEY_NAME" "$VAL_3_PRIVATE_KEY" --keyring-backend "test" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
else
echo "- Validator 1, key name '$VAL_1_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD'"
(echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys unsafe-import-eth-key "$VAL_1_KEY_NAME" "$VAL_1_PRIVATE_KEY" --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 2, key name '$VAL_2_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD'"
(echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys unsafe-import-eth-key "$VAL_2_KEY_NAME" "$VAL_2_PRIVATE_KEY" --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 3, key name '$VAL_3_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD'"
(echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys unsafe-import-eth-key "$VAL_3_KEY_NAME" "$VAL_3_PRIVATE_KEY" --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
fi
elif [ $VALIDATOR_IMPORT_MODE -eq 2 ]; then # mode seed_phrase
if [ "$KEYRING" = "test" ]; then
echo "Import validator keys for chain no $CHAIN_NO id $CHAIN_ID"
if [ "$KEYRING" = "test" ]; then
echo "- Validator 1, key name '$VAL_1_KEY_NAME'"
( echo "$VAL_1_SEED"; ) | $BINARY keys add "$VAL_1_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 2, key name '$VAL_2_KEY_NAME'"
( echo "$VAL_2_SEED"; ) | $BINARY keys add "$VAL_2_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 3, key name '$VAL_3_KEY_NAME'"
( echo "$VAL_3_SEED"; ) | $BINARY keys add "$VAL_3_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
else
if [ "$CHAIN_TYPE" = "evmos" ]; then
echo "- Validator 1, key name '$VAL_1_KEY_NAME'"
( echo "$VAL_1_SEED"; ) | $BINARY keys add "$VAL_1_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1"
echo "** Due to evmos daemon bug, it is not possible to import seed & encryption password automatically at the same time, please copy & paste the following seed:"
echo "___"
echo "$VAL_1_SEED"
echo "___"
echo "and encryption password '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD' to encrypt seed phrase"
echo "of validator 1"
$BINARY keys add "$VAL_1_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 2, key name '$VAL_2_KEY_NAME'"
( echo "$VAL_2_SEED"; ) | $BINARY keys add "$VAL_2_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1"
echo "** Due to evmos daemon bug, it is not possible to import seed & encryption password automatically at the same time, please copy & paste the following seed:"
echo "___"
echo "$VAL_2_SEED"
echo "___"
echo "and encryption password '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD' to encrypt seed phrase"
echo "of validator 2"
$BINARY keys add "$VAL_2_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 3, key name '$VAL_3_KEY_NAME'"
( echo "$VAL_3_SEED"; ) | $BINARY keys add "$VAL_3_KEY_NAME" --recover --keyring-backend "test" --home "$VAL_HOME_1"
echo "** Due to evmos daemon bug, it is not possible to import seed & encryption password automatically at the same time, please copy & paste the following seed:"
echo "___"
echo "$VAL_3_SEED"
echo "___"
echo "and encryption password '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD' to encrypt seed phrase"
echo "of validator 3"
$BINARY keys add "$VAL_3_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
else
echo "- Validator 1, key name '$VAL_1_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD', seed phase '$VAL_1_SEED'"
( echo "$VAL_1_SEED"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys add "$VAL_1_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 2, key name '$VAL_2_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD'"
echo "- Validator 2, key name '$VAL_2_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD', seed phase '$VAL_2_SEED'"
( echo "$VAL_2_SEED"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys add "$VAL_2_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
echo "- Validator 3, key name '$VAL_3_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD'"
echo "- Validator 3, key name '$VAL_3_KEY_NAME', encryption password: '$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD', seed phase '$VAL_3_SEED'"
( echo "$VAL_3_SEED"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; echo "$VAL_KEYRING_FILE_ENCRYPTION_PASSWORD"; ) | $BINARY keys add "$VAL_3_KEY_NAME" --recover --keyring-backend "file" --home "$VAL_HOME_1"
[ $? -eq 0 ] || { echo "ERR: Failed to import"; exit 1; }
fi
Expand Down
13 changes: 6 additions & 7 deletions blockchain-in-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ Now you can [follow this sample](https://github.com/VictorTrustyDev/EVMOS-sample
+ evmosvaloper1wuqvcpuunf7r5rg7xutqddhw55grfzc7ewkz9a
+ 50m EVMOS
+ 7k coin staked
+ Addr: evmos1wuqvcpuunf7r5rg7xutqddhw55grfzc75qejyq
+ Private key: FC3F58B007A017166DE5A340C7A2641EB37CF37081D6F9013636CEBFBAF7B1FE
+ EVMOS wallet addr: evmos1wuqvcpuunf7r5rg7xutqddhw55grfzc75qejyq
+ Mnemonic: spoil senior door access upset floor decorate shield high punch senior tape pigeon base slogan height clever buffalo cat report poem weapon labor satoshi
+ ETH private key: FC3F58B007A017166DE5A340C7A2641EB37CF37081D6F9013636CEBFBAF7B1FE
+ Key name: val1
+ evmosvaloper1zxgt4pwzzsv02z24g80lc5rhtsp0prw046yxss
+ 50m EVMOS
+ 3k coin staked
+ Addr: evmos1zxgt4pwzzsv02z24g80lc5rhtsp0prw0c5tk3d
+ Private key: 0172DC491B5ACD04DD378D3FD8FD9F41A0D701E070941474FADECD72E1E085B9
+ EVMOS wallet addr: evmos1zxgt4pwzzsv02z24g80lc5rhtsp0prw0c5tk3d
+ Mnemonic: width produce brush hour horse retreat play flag fresh broken measure culture scare broken erupt pilot buzz embody depend topic behind rigid fan battle
+ ETH private key: 0172DC491B5ACD04DD378D3FD8FD9F41A0D701E070941474FADECD72E1E085B9
+ Key name: val2
+ evmosvaloper1vcy9v4jp0sd4hysqqcuwleytxre3ms4cmv5ajl
+ 50m EVMOS
+ 3k coin staked
+ Addr: evmos1vcy9v4jp0sd4hysqqcuwleytxre3ms4ckzmdnz
+ Private key: E0D83C6054597638469CC91A46F14B7F62705297912524059629E4674302928F
+ EVMOS wallet addr: evmos1vcy9v4jp0sd4hysqqcuwleytxre3ms4ckzmdnz
+ Mnemonic: stage grid emotion thumb safe myth chair dizzy beyond casual select polar hover retire master neglect shift zero trigger section token replace truly father
+ ETH private key: E0D83C6054597638469CC91A46F14B7F62705297912524059629E4674302928F
+ Key name: val3

### IV. Customization
Expand All @@ -72,7 +72,6 @@ Here are some of them:
| `CHAIN_2_TYPE` | evmos | Chain type of chain 2 |
| `CHAIN_2_COINTYPE` | 60 | [HD key derivation path](https://docs.evmos.org/users/technical_concepts/accounts.html) for chain 2's accounts |


Performance: 2 chains created by this sample can run in parallel smoothly in a 4 Core 4 Gb RAM machine

This sample is using keyring-backend is `test`, you may need to change to `file` ([env.sh](https://github.com/VictorTrustyDev/EVMOS-sample-scripts/blob/main/env.sh)) to secure your test env if needed
8 changes: 0 additions & 8 deletions blockchain-in-docker/_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ if [ "$CHAIN_NO" = "1" ]; then
export MIN_DENOM_SYMBOL="$CHAIN_1_MIN_DENOM_SYMBOL"
export GAS_DENOM_SYMBOL="$CHAIN_1_GAS_DENOM_SYMBOL"
export VAL_1_SEED="$VAL_1_CHAIN_1_SEED"
export VAL_1_PRIVATE_KEY="$VAL_1_CHAIN_1_PRIVATE_KEY"
export VAL_2_SEED="$VAL_2_CHAIN_1_SEED"
export VAL_2_PRIVATE_KEY="$VAL_2_CHAIN_1_PRIVATE_KEY"
export VAL_3_SEED="$VAL_3_CHAIN_1_SEED"
export VAL_3_PRIVATE_KEY="$VAL_3_CHAIN_1_PRIVATE_KEY"
export VALIDATOR_IMPORT_TYPE="$CHAIN_1_VALIDATOR_IMPORT_TYPE"
export ACCOUNT_PREFIX="$CHAIN_1_ACCOUNT_PREFIX"
export EVMOS_CLAIM_MODULE_ACCOUNT="$EVMOS_CHAIN_1_CLAIM_MODULE_ACCOUNT"
elif [ "$CHAIN_NO" = "2" ]; then
Expand All @@ -34,12 +30,8 @@ elif [ "$CHAIN_NO" = "2" ]; then
export MIN_DENOM_SYMBOL="$CHAIN_2_MIN_DENOM_SYMBOL"
export GAS_DENOM_SYMBOL="$CHAIN_2_GAS_DENOM_SYMBOL"
export VAL_1_SEED="$VAL_1_CHAIN_2_SEED"
export VAL_1_PRIVATE_KEY="$VAL_1_CHAIN_2_PRIVATE_KEY"
export VAL_2_SEED="$VAL_2_CHAIN_2_SEED"
export VAL_2_PRIVATE_KEY="$VAL_2_CHAIN_2_PRIVATE_KEY"
export VAL_3_SEED="$VAL_3_CHAIN_2_SEED"
export VAL_3_PRIVATE_KEY="$VAL_3_CHAIN_2_PRIVATE_KEY"
export VALIDATOR_IMPORT_TYPE="$CHAIN_2_VALIDATOR_IMPORT_TYPE"
export ACCOUNT_PREFIX="$CHAIN_2_ACCOUNT_PREFIX"
export EVMOS_CLAIM_MODULE_ACCOUNT="$EVMOS_CHAIN_2_CLAIM_MODULE_ACCOUNT"
fi
Expand Down
Loading

0 comments on commit 41d23f9

Please sign in to comment.