Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Stargate binary fix (#784)
Browse files Browse the repository at this point in the history
* fixed invalid chainID, subscribe nil pointer dereference and empty keyring issue

* add keyring flag in start cmd

* update init script

* add amount back in `gentx` cli
  • Loading branch information
freddyli7 authored Feb 8, 2021
1 parent e16081f commit bf2f2aa
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
12 changes: 6 additions & 6 deletions init.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

KEY="mykey"
CHAINID="ethermint-1"
CHAINID="ethermint-2"
MONIKER="localtestnet"

# remove existing daemon and client
Expand All @@ -15,13 +15,13 @@ ethermintd keys add $KEY --keyring-backend test
ethermintd init $MONIKER --chain-id $CHAINID

# Change parameter token denominations to aphoton
cat $HOME/.ethermint/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="aphoton"' > $HOME/.ethermint/config/tmp_genesis.json && mv $HOME/.ethermint/config/tmp_genesis.json $HOME/.ethermint/config/genesis.json
cat $HOME/.ethermint/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="stake"' > $HOME/.ethermint/config/tmp_genesis.json && mv $HOME/.ethermint/config/tmp_genesis.json $HOME/.ethermint/config/genesis.json
cat $HOME/.ethermint/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"' > $HOME/.ethermint/config/tmp_genesis.json && mv $HOME/.ethermint/config/tmp_genesis.json $HOME/.ethermint/config/genesis.json
cat $HOME/.ethermint/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"' > $HOME/.ethermint/config/tmp_genesis.json && mv $HOME/.ethermint/config/tmp_genesis.json $HOME/.ethermint/config/genesis.json
cat $HOME/.ethermint/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="aphoton"' > $HOME/.ethermint/config/tmp_genesis.json && mv $HOME/.ethermint/config/tmp_genesis.json $HOME/.ethermint/config/genesis.json

# increase block time (?)
cat $HOME/.ethermintd/config/genesis.json | jq '.consensus_params["block"]["time_iota_ms"]="30000"' > $HOME/.ethermintd/config/tmp_genesis.json && mv $HOME/.ethermintd/config/tmp_genesis.json $HOME/.ethermintd/config/genesis.json
cat $HOME/.ethermint/config/genesis.json | jq '.consensus_params["block"]["time_iota_ms"]="30000"' > $HOME/.ethermint/config/tmp_genesis.json && mv $HOME/.ethermint/config/tmp_genesis.json $HOME/.ethermint/config/genesis.json

if [[ $1 == "pending" ]]; then
echo "pending mode on; block times will be set to 30s."
Expand All @@ -36,10 +36,10 @@ if [[ $1 == "pending" ]]; then
fi

# Allocate genesis accounts (cosmos formatted addresses)
ethermintd add-genesis-account $KEY 100000000000000000000aphoton --keyring-backend test
ethermintd add-genesis-account $KEY 1000000000000000000aphoton,1000000000000000000stake --keyring-backend test

# Sign genesis transaction
ethermintd gentx $KEY --amount=1000000000000000000aphoton --keyring-backend test --chain-id $CHAINID
ethermintd gentx $KEY 1000000000000000000stake --amount=1000000000000000000aphoton --keyring-backend test --chain-id $CHAINID

# Collect genesis tx
ethermintd collect-gentxs
Expand All @@ -48,4 +48,4 @@ ethermintd collect-gentxs
ethermintd validate-genesis

# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
ethermintd start --pruning=nothing --rpc.unsafe --trace
ethermintd start --pruning=nothing --rpc.unsafe --keyring-backend test --trace
22 changes: 11 additions & 11 deletions scripts/integration-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ start_func() {
--p2p.laddr tcp://$IP_ADDR:$NODE_P2P_PORT"$i" --address tcp://$IP_ADDR:$NODE_PORT"$i" --rpc.laddr tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--home "$DATA_DIR$i" \
>"$DATA_DIR"/node"$i".log 2>&1 & disown

ETHERMINT_PID=$!
echo "started ethermint node, pid=$ETHERMINT_PID"
# add PID to array
Expand All @@ -125,7 +125,7 @@ start_cli_func() {
--laddr "tcp://localhost:$RPC_PORT$i" --node tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--home "$DATA_CLI_DIR$i" --read-timeout 30 --write-timeout 30 \
>"$DATA_CLI_DIR"/cli"$i".log 2>&1 & disown

ETHERMINT_CLI_PID=$!
echo "started ethermintd node, pid=$ETHERMINT_CLI_PID"
# add PID to array
Expand All @@ -151,21 +151,21 @@ echo "done sleeping"
set +e

if [[ -z $TEST || $TEST == "rpc" ]]; then

for i in $(seq 1 "$TEST_QTD"); do
HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i"
echo "going to test ethermint node $HOST_RPC ..."
MODE=$MODE HOST=$HOST_RPC go test ./tests/... -timeout=300s -v -short

RPC_FAIL=$?
done

fi

stop_func() {
ETHERMINT_PID=$i
echo "shutting down node, pid=$ETHERMINT_PID ..."

# Shutdown ethermint node
kill -9 "$ETHERMINT_PID"
wait "$ETHERMINT_PID"
Expand Down Expand Up @@ -226,7 +226,7 @@ start_func() {
--p2p.laddr tcp://$IP_ADDR:$NODE_P2P_PORT"$i" --address tcp://$IP_ADDR:$NODE_PORT"$i" --rpc.laddr tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--home "$DATA_DIR$i" \
>"$DATA_DIR"/node"$i".log 2>&1 & disown

ETHERMINT_PID=$!
echo "started ethermint node, pid=$ETHERMINT_PID"
# add PID to array
Expand All @@ -239,7 +239,7 @@ start_cli_func() {
--laddr "tcp://localhost:$RPC_PORT$i" --node tcp://$IP_ADDR:$NODE_RPC_PORT"$i" \
--home "$DATA_CLI_DIR$i" --read-timeout 30 --write-timeout 30 \
>"$DATA_CLI_DIR"/cli"$i".log 2>&1 & disown

ETHERMINT_CLI_PID=$!
echo "started ethermintd node, pid=$ETHERMINT_CLI_PID"
# add PID to array
Expand Down Expand Up @@ -275,16 +275,16 @@ if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then
else
MODE=$MODE HOST=$HOST_RPC go test ./tests/... -timeout=300s -v -short
fi

RPC_FAIL=$?
done

fi

stop_func() {
ETHERMINT_PID=$i
echo "shutting down node, pid=$ETHERMINT_PID ..."

# Shutdown ethermint node
kill -9 "$ETHERMINT_PID"
wait "$ETHERMINT_PID"
Expand Down
39 changes: 21 additions & 18 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@ import (
"runtime/pprof"
"time"

"github.com/tendermint/tendermint/rpc/client/local"

"github.com/spf13/cobra"
"google.golang.org/grpc"

"github.com/tendermint/tendermint/abci/server"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
tmos "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/rpc/client/local"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdkserver "github.com/cosmos/cosmos-sdk/server"
Expand All @@ -28,6 +21,13 @@ import (
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/tendermint/tendermint/abci/server"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
tmos "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"

"github.com/cosmos/ethermint/rpc"
"github.com/cosmos/ethermint/server/config"
Expand Down Expand Up @@ -123,6 +123,8 @@ which accepts a path for the resulting pprof file.
cmd.Flags().Uint64(sdkserver.FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval")
cmd.Flags().Uint32(sdkserver.FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep")

cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)")

// add support for all Tendermint-specific command line options
tcmd.AddNodeFlags(cmd)
return cmd
Expand Down Expand Up @@ -237,17 +239,18 @@ func startInProcess(ctx *sdkserver.Context, clientCtx client.Context, appCreator
var apiSrv *api.Server

config := config.GetConfig(ctx.Viper)
if config.API.Enable {
genDoc, err := genDocProvider()
if err != nil {
return err
}

clientCtx := clientCtx.
WithHomeDir(home).
WithChainID(genDoc.ChainID).
WithClient(local.New(tmNode))
genDoc, err := genDocProvider()
if err != nil {
return err
}

clientCtx = clientCtx.
WithHomeDir(home).
WithChainID(genDoc.ChainID).
WithClient(local.New(tmNode))

if config.API.Enable {
apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server"))
app.RegisterAPIRoutes(apiSrv, config.API)
errCh := make(chan error)
Expand Down

0 comments on commit bf2f2aa

Please sign in to comment.