Skip to content

Commit

Permalink
test: automated all prepared genesis.json creation process
Browse files Browse the repository at this point in the history
  • Loading branch information
psy2848048 committed Dec 1, 2022
1 parent fac1c6c commit 1224512
Show file tree
Hide file tree
Showing 19 changed files with 478 additions and 60 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:

- name: Setup network
run: |
mkdir ~/genesis
cd integration_test && docker-compose up -d
docker ps
sleep 10
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.2
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.0
Expand Down Expand Up @@ -120,7 +121,6 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
Expand Down
32 changes: 28 additions & 4 deletions integration_test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ services:
context: ../.
target: runtime

volumes:
- ~/genesis:/genesis:rw

ports:
- "8545:8545"
- "9090:9090"
- "26656:26656"

entrypoint: sh -c "MONIKER=validator1 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint.sh"
entrypoint: sh -c "MONIKER=validator1 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_master.sh"

networks:
vpcbr:
Expand All @@ -21,15 +24,22 @@ services:
node2:
container_name: xpla-localnet-validator2

volumes:
- ~/genesis:/genesis:ro

depends_on:
- node1

build:
context: ../.
target: runtime

ports:
- "8555:8555"
- "9100:9100"
- "26666:26666"

entrypoint: sh -c "MONIKER=validator2 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint.sh"
entrypoint: sh -c "MONIKER=validator2 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"

networks:
vpcbr:
Expand All @@ -38,15 +48,22 @@ services:
node3:
container_name: xpla-localnet-validator3

volumes:
- ~/genesis:/genesis:ro

depends_on:
- node1

build:
context: ../.
target: runtime

ports:
- "8565:8565"
- "9110:9110"
- "26676:26676"

entrypoint: sh -c "MONIKER=validator3 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint.sh"
entrypoint: sh -c "MONIKER=validator3 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"

networks:
vpcbr:
Expand All @@ -55,15 +72,22 @@ services:
node4:
container_name: xpla-localnet-validator4

volumes:
- ~/genesis:/genesis:ro

depends_on:
- node1

build:
context: ../.
target: runtime

ports:
- "8575:8575"
- "9120:9120"
- "26686:26686"

entrypoint: sh -c "MONIKER=validator4 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint.sh"
entrypoint: sh -c "MONIKER=validator4 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"

networks:
vpcbr:
Expand Down
84 changes: 84 additions & 0 deletions integration_test/entrypoint_master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/sh
# MONIKER=validator1|validator2|validator3|validator4 sh /opt/integration_test/entrypoint.sh

# 1. chain init
/usr/bin/xplad init $MONIKER --chain-id localtest_1-1 --home $XPLAHOME

# 2. Register the keys
# xpla1z2k85n48ydfvzslrugwzl4j2u7vtdyf3xvucmc
/usr/bin/xplad keys add validator1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator1.mnemonics
# xpla16wx7ye3ce060tjvmmpu8lm0ak5xr7gm2dp0kpt
/usr/bin/xplad keys add validator2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator2.mnemonics
# xpla1pe9mc2q72u94sn2gg52ramrt26x5efw6hr5gt4
/usr/bin/xplad keys add validator3 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator3.mnemonics
# xpla1luqjvjyns9e92h06tq6zqtw76k8xtegfcerzjr
/usr/bin/xplad keys add validator4 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator4.mnemonics
# xpla1y6gnay0pv49asun56la09jcmhg2kc949mpftvt
/usr/bin/xplad keys add user1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user1.mnemonics
# xpla1u27snswkjpenlscgvszcfjmz8uy2y5qacx0826
/usr/bin/xplad keys add user2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user2.mnemonics

# 3. Add the genesis accounts
/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator1 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME
/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator2 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME
/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator3 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME
/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator4 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME
/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show user1 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME
/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show user2 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME

# 4. Get the node keys and create gentxs
for IDX in 1 2 3 4
do
# 1) Copy the credentials
cp /opt/integration_test/validator$IDX/node_key.json $XPLAHOME/config
cp /opt/integration_test/validator$IDX/priv_validator_key.json $XPLAHOME/config

# 2) Execute a gentx
/usr/bin/xplad gentx validator$IDX 2000000000000000000axpla \
--chain-id="localtest_1-1" \
--pubkey=$(xplad tendermint show-validator --home $XPLAHOME) \
--min-self-delegation=1 \
--moniker=validator$IDX \
--commission-rate=0.1 \
--commission-max-rate=0.2 \
--commission-max-change-rate=0.01 \
--ip="192.167.100.$IDX" \
--keyring-backend test \
--home $XPLAHOME

done

# 5. Do collect gentxs
/usr/bin/xplad collect-gentxs --home $XPLAHOME

# 6. Replace staking denom
sed -i 's/"bond_denom": "stake"/"bond_denom": "axpla"/g' $XPLAHOME/config/genesis.json
sed -i 's/"evm_denom": "aphoton",/"evm_denom": "axpla",/g' $XPLAHOME/config/genesis.json
sed -i 's/"mint_denom": "stake",/"mint_denom": "axpla",/g' $XPLAHOME/config/genesis.json
sed -i 's/"denom": "stake",/"denom": "axpla",/g' $XPLAHOME/config/genesis.json
sed -i 's/"max_gas": "-1",/"max_gas": "5000000",/g' $XPLAHOME/config/genesis.json
sed -i 's/"no_base_fee": false,/"no_base_fee": true,/g' $XPLAHOME/config/genesis.json
sed -i 's/"inflation": "0.130000000000000000",/"inflation": "0.000000000000000000",/g' $XPLAHOME/config/genesis.json
sed -i 's/"inflation_rate_change": "0.130000000000000000",/"inflation_rate_change": "0.000000000000000000",/g' $XPLAHOME/config/genesis.json
sed -i 's/"inflation_min": "0.070000000000000000",/"inflation_min": "0.000000000000000000",/g' $XPLAHOME/config/genesis.json

/usr/bin/xplad validate-genesis --home $XPLAHOME

# 7. Copy to the shared folder
cp $XPLAHOME/config/genesis.json /genesis

### ALL DONE FOR GENESIS CONFIG
### followings are for validator setting

# 1. Copy the node setting files to the node home dir
cp -r /opt/integration_test/$MONIKER/* $XPLAHOME/config

# 2. Get genesis.json from the shared
cp /genesis/genesis.json $XPLAHOME/config

# 4. check genesis.json
/usr/bin/xplad validate-genesis --home $XPLAHOME
cat $XPLAHOME/config/genesis.json

# 5. start daemon
/usr/bin/xplad start --home=$XPLAHOME
22 changes: 22 additions & 0 deletions integration_test/entrypoint_secondary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
# MONIKER=validator1|validator2|validator3|validator4 sh /opt/integration_test/entrypoint.sh

# 1. chain init
/usr/bin/xplad init $MONIKER --chain-id localtest_1-1 --home $XPLAHOME

# 2. copy the node setting files to the node home dir
cp -r /opt/integration_test/$MONIKER/* $XPLAHOME/config

# 3. register my validator & users keyfile
/usr/bin/xplad keys add $MONIKER --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/$MONIKER.mnemonics
/usr/bin/xplad keys add user1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user1.mnemonics
/usr/bin/xplad keys add user2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user2.mnemonics

# 4. get genesis.json from the shared folder
cp /genesis/genesis.json $XPLAHOME/config

# 4. check genesis.json
/usr/bin/xplad validate-genesis --home $XPLAHOME

# 5. start daemon
/usr/bin/xplad start --home=$XPLAHOME
45 changes: 0 additions & 45 deletions integration_test/setup_main_validator.sh

This file was deleted.

2 changes: 1 addition & 1 deletion integration_test/test_keys/user1.mnemonics
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bounce success option birth apple portion aunt rural episode solution hockey pencil lend session cause hedgehog slender journey system canvas decorate razor catch empty
bounce success option birth apple portion aunt rural episode solution hockey pencil lend session cause hedgehog slender journey system canvas decorate razor catch empty
2 changes: 1 addition & 1 deletion integration_test/test_keys/user2.mnemonics
Original file line number Diff line number Diff line change
@@ -1 +1 @@
second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal
second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal
2 changes: 1 addition & 1 deletion integration_test/test_keys/validator1.mnemonics
Original file line number Diff line number Diff line change
@@ -1 +1 @@
satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn
satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn
2 changes: 1 addition & 1 deletion integration_test/test_keys/validator2.mnemonics
Original file line number Diff line number Diff line change
@@ -1 +1 @@
notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius
notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius
2 changes: 1 addition & 1 deletion integration_test/test_keys/validator3.mnemonics
Original file line number Diff line number Diff line change
@@ -1 +1 @@
quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty
quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty
2 changes: 1 addition & 1 deletion integration_test/test_keys/validator4.mnemonics
Original file line number Diff line number Diff line change
@@ -1 +1 @@
symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb
symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb
83 changes: 83 additions & 0 deletions integration_test/validator1/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,89 @@ snapshot-interval = 1000
# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all).
snapshot-keep-recent = 10

###############################################################################
### EVM Configuration ###
###############################################################################

[evm]

# Tracer defines the 'vm.Tracer' type that the EVM will use when the node is run in
# debug mode. To enable tracing use the '--evm.tracer' flag when starting your node.
# Valid types are: json|struct|access_list|markdown
tracer = ""

# MaxTxGasWanted defines the gas wanted for each eth tx returned in ante handler in check tx mode.
max-tx-gas-wanted = 0

###############################################################################
### JSON RPC Configuration ###
###############################################################################

[json-rpc]

# Enable defines if the gRPC server should be enabled.
enable = true

# Address defines the EVM RPC HTTP server address to bind to.
address = "0.0.0.0:8545"

# Address defines the EVM WebSocket server address to bind to.
ws-address = "0.0.0.0:8546"

# API defines a list of JSON-RPC namespaces that should be enabled
# Example: "eth,txpool,personal,net,debug,web3"
api = "eth,net,web3"

# GasCap sets a cap on gas that can be used in eth_call/estimateGas (0=infinite). Default: 25,000,000.
gas-cap = 25000000

# EVMTimeout is the global timeout for eth_call. Default: 5s.
evm-timeout = "5s"

# TxFeeCap is the global tx-fee cap for send transaction. Default: 1eth.
txfee-cap = 1

# FilterCap sets the global cap for total number of filters that can be created
filter-cap = 200

# FeeHistoryCap sets the global cap for total number of blocks that can be fetched
feehistory-cap = 100

# LogsCap defines the max number of results can be returned from single 'eth_getLogs' query.
logs-cap = 10000

# BlockRangeCap defines the max block range allowed for 'eth_getLogs' query.
block-range-cap = 10000

# HTTPTimeout is the read/write timeout of http json-rpc server.
http-timeout = "30s"

# HTTPIdleTimeout is the idle timeout of http json-rpc server.
http-idle-timeout = "2m0s"

# AllowUnprotectedTxs restricts unprotected (non EIP155 signed) transactions to be submitted via
# the node's RPC when the global parameter is disabled.
allow-unprotected-txs = false

# MaxOpenConnections sets the maximum number of simultaneous connections
# for the server listener.
max-open-connections = 0

# EnableIndexer enables the custom transaction indexer for the EVM (ethereum transactions).
enable-indexer = false

###############################################################################
### TLS Configuration ###
###############################################################################

[tls]

# Certificate path defines the cert.pem file path for the TLS configuration.
certificate-path = ""

# Key path defines the key.pem file path for the TLS configuration.
key-path = ""

###############################################################################
### Custom Xpla Configuration ###
###############################################################################
Expand Down
3 changes: 1 addition & 2 deletions integration_test/validator1/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ external_address = ""
seeds = ""

# Comma separated list of nodes to keep persistent connections to
#persistent_peers = "[email protected]:26656,[email protected]:26656,[email protected]:26656"
persistent_peers = ""
persistent_peers = "[email protected]:26666,[email protected]:26686,[email protected]:26676"

# UPNP port forwarding
upnp = false
Expand Down
Loading

0 comments on commit 1224512

Please sign in to comment.