Skip to content

Commit

Permalink
chore: add script initializing simd (#110)
Browse files Browse the repository at this point in the history
* chore: add script initializing simd
  • Loading branch information
Woosang Son authored Apr 5, 2021
1 parent 817809a commit 37fc9d1
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 23 deletions.
47 changes: 24 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,29 @@ ifeq ($(LEDGER_ENABLED),true)
endif
endif

ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
build_tags += gcc
# DB backend selection
ifeq (,$(filter $(LBM_BUILD_OPTIONS), cleveldb rocksdb boltdb badgerdb))
BUILD_TAGS += goleveldb
else
ifeq (cleveldb,$(findstring cleveldb,$(LBM_BUILD_OPTIONS)))
BUILD_TAGS += gcc cleveldb
ldflags += -X github.com/line/lbm-sdk/v2/types.DBBackend=cleveldb
endif
ifeq (badgerdb,$(findstring badgerdb,$(LBM_BUILD_OPTIONS)))
BUILD_TAGS += badgerdb
ldflags += -X github.com/line/lbm-sdk/v2/types.DBBackend=badgerdb
endif
ifeq (rocksdb,$(findstring rocksdb,$(LBM_BUILD_OPTIONS)))
CGO_ENABLED=1
BUILD_TAGS += rocksdb
ldflags += -X github.com/line/lbm-sdk/v2/types.DBBackend=rocksdb
endif
ifeq (boltdb,$(findstring boltdb,$(LBM_BUILD_OPTIONS)))
BUILD_TAGS += boltdb
ldflags += -X github.com/line/lbm-sdk/v2/types.DBBackend=boltdb
endif
endif

build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

Expand All @@ -60,34 +80,15 @@ ldflags = -X github.com/line/lbm-sdk/v2/version.Name=sim \
-X github.com/line/lbm-sdk/v2/version.Commit=$(COMMIT) \
-X "github.com/line/lbm-sdk/v2/version.BuildTags=$(build_tags_comma_sep)"

# DB backend selection
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/line/lbm-sdk/v2/types.DBBackend=cleveldb
endif
ifeq (badgerdb,$(findstring badgerdb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/line/lbm-sdk/v2/types.DBBackend=badgerdb
endif
# handle rocksdb
ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS)))
CGO_ENABLED=1
BUILD_TAGS += rocksdb
ldflags += -X github.com/line/lbm-sdk/v2/types.DBBackend=rocksdb
endif
# handle boltdb
ifeq (boltdb,$(findstring boltdb,$(COSMOS_BUILD_OPTIONS)))
BUILD_TAGS += boltdb
ldflags += -X github.com/line/lbm-sdk/v2/types.DBBackend=boltdb
endif

ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
ifeq (,$(findstring nostrip,$(LBM_BUILD_OPTIONS)))
ldflags += -w -s
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# check for nostrip option
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
ifeq (,$(findstring nostrip,$(LBM_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
endif

Expand Down
88 changes: 88 additions & 0 deletions init_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/sh

display_usage() {
echo "\nMissing $1 parameter. Please check if all parameters were specified."
echo "\nUsage: ./run_node [CHAIN_ID]"
echo "\nExample: ./init_node $BINARY test-chain-id 26657 26656 6060 9090 \n"
exit 1
}

KEYRING=--keyring-backend="test"
SILENT=1

redirect() {
if [ "$SILENT" -eq 1 ]; then
"$@" > /dev/null 2>&1
else
"$@"
fi
}

BINARY=simd
CHAINID=$1
CHAINDIR=~/.simapp
RPCPORT=26657
P2PPORT=26656
PROFPORT=6060
GRPCPORT=9090

if [ -z "$1" ]; then
display_usage "[CHAIN_ID]"
fi

echo "Creating $BINARY instance: home=$CHAINDIR | chain-id=$CHAINID | p2p=:$P2PPORT | rpc=:$RPCPORT | profiling=:$PROFPORT | grpc=:$GRPCPORT"

# Add dir for chain, exit if error
if ! mkdir -p $CHAINDIR 2>/dev/null; then
echo "Failed to create chain folder. Aborting..."
exit 1
fi

# Build genesis file incl account for passed address
coins="100000000000stake,100000000000ukrw"
delegate="100000000000stake"

redirect $BINARY --home $CHAINDIR --chain-id $CHAINID init $CHAINID
sleep 1
$BINARY --home $CHAINDIR keys add validator $KEYRING --output json > $CHAINDIR/validator_seed.json 2> /dev/null
sleep 1
$BINARY --home $CHAINDIR keys add user $KEYRING --recover --output json < user_mnemonic > $CHAINDIR/key_seed.json 2> /dev/null
sleep 1
redirect $BINARY --home $CHAINDIR add-genesis-account $($BINARY --home $CHAINDIR keys $KEYRING show user -a) $coins
sleep 1
redirect $BINARY --home $CHAINDIR add-genesis-account $($BINARY --home $CHAINDIR keys $KEYRING show validator -a) $coins
sleep 1
redirect $BINARY --home $CHAINDIR gentx validator $delegate $KEYRING --chain-id $CHAINID
sleep 1
redirect $BINARY --home $CHAINDIR collect-gentxs
sleep 1

# Check platform
platform='unknown'
unamestr=`uname`
if [ "$unamestr" = 'Linux' ]; then
platform='linux'
fi

# Set proper defaults and change ports (use a different sed for Mac or Linux)
echo "Change settings in config.toml file..."
if [ $platform = 'linux' ]; then
sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/config/config.toml
sed -i 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/config/config.toml
sed -i 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/config/config.toml
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/config/config.toml
sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/config/config.toml
sed -i 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/config/config.toml
sed -i 's/pruning = "default"/pruning = "nothing"/g' $CHAINDIR/config/app.toml
# sed -i '' 's#index-events = \[\]#index-events = \["message.action","send_packet.packet_src_channel","send_packet.packet_sequence"\]#g' $CHAINDIR/config/app.toml
else
sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/config/config.toml
sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/config/config.toml
sed -i '' 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/config/config.toml
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/config/config.toml
sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/config/config.toml
sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/config/config.toml
sed -i '' 's/pruning = "default"/pruning = "nothing"/g' $CHAINDIR/config/app.toml
# sed -i '' 's#index-events = \[\]#index-events = \["message.action","send_packet.packet_src_channel","send_packet.packet_sequence"\]#g' $CHAINDIR/config/app.toml
fi

1 change: 1 addition & 0 deletions user_mnemonic
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trend cancel uncle tired that room day emerge source march laugh wall govern maple assume slab near omit hood item twice now aisle cube

0 comments on commit 37fc9d1

Please sign in to comment.