-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from hypersign-protocol/3-node-network
Running Node locally and using Docker
- Loading branch information
Showing
634 changed files
with
274,914 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM golang:1.16-alpine | ||
|
||
# Set up dependencies | ||
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 jq | ||
|
||
# Set working directory for the build | ||
WORKDIR /usr/local/app | ||
|
||
# Add source files | ||
COPY . . | ||
|
||
# Install minimum necessary dependencies, build persistenceCore, remove packages | ||
RUN apk add --no-cache $PACKAGES && make build | ||
|
||
# Install ca-certificates | ||
RUN apk add --update ca-certificates | ||
|
||
# Run hid-noded by default, omit entrypoint to ease using container with cli | ||
RUN bash ./scripts/docker-node/setup.sh | ||
|
||
# Entry for containers | ||
ENTRYPOINT [ "bash", "./scripts/docker-node/start.sh" ] | ||
|
||
# Expose Ports | ||
EXPOSE 26657 1317 9090 9091 26656 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') | ||
COMMIT := $(shell git rev-parse --short HEAD) | ||
|
||
GOBIN = $(shell go env GOPATH)/bin | ||
|
||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=hid-node \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName=hid-node \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) | ||
|
||
BUILD_FLAGS := -ldflags '$(ldflags)' | ||
|
||
export GO111MODULE=on | ||
|
||
############################################################################### | ||
### Build ### | ||
############################################################################### | ||
|
||
build: go.sum | ||
go build -mod=readonly $(BUILD_FLAGS) -o ${GOBIN}/hid-noded ./cmd/hid-noded | ||
|
||
go.sum: go.mod | ||
@echo "--> Ensure dependencies have not been modified" | ||
@go mod verify | ||
|
||
############################################################################### | ||
### Proto ### | ||
############################################################################### | ||
|
||
proto-build: | ||
./scripts/protocgen.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
echo "Setting up Chain." | ||
|
||
# Setting up config files | ||
rm -rf /usr/local/app/node1 | ||
|
||
|
||
# Make directories for hid-node config | ||
mkdir /usr/local/app/node1 | ||
|
||
# Init node | ||
hid-noded init --chain-id=hidnode node1 --home=/usr/local/app/node1 &> /dev/null | ||
|
||
# Create key for the node | ||
hid-noded keys add node1 --keyring-backend=test --home=/usr/local/app/node1 &> /dev/null | ||
|
||
# change staking denom to uhid | ||
cat /usr/local/app/node1/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="uhid"' > /usr/local/app/node1/config/tmp_genesis.json && mv /usr/local/app/node1/config/tmp_genesis.json /usr/local/app/node1/config/genesis.json | ||
|
||
# create validator node with tokens | ||
hid-noded add-genesis-account $(hid-noded keys show node1 -a --keyring-backend=test --home=/usr/local/app/node1) 100000000000uhid,100000000000stake --home=/usr/local/app/node1 | ||
hid-noded gentx node1 500000000uhid --keyring-backend=test --home=/usr/local/app/node1 --chain-id=hidnode | ||
hid-noded collect-gentxs --home=/usr/local/app/node1 | ||
|
||
# update crisis variable to uhid | ||
cat /usr/local/app/node1/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="uhid"' > /usr/local/app/node1/config/tmp_genesis.json && mv /usr/local/app/node1/config/tmp_genesis.json /usr/local/app/node1/config/genesis.json | ||
|
||
# udpate gov genesis | ||
cat /usr/local/app/node1/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="uhid"' > /usr/local/app/node1/config/tmp_genesis.json && mv /usr/local/app/node1/config/tmp_genesis.json /usr/local/app/node1/config/genesis.json | ||
|
||
# update mint genesis | ||
cat /usr/local/app/node1/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="uhid"' > /usr/local/app/node1/config/tmp_genesis.json && mv /usr/local/app/node1/config/tmp_genesis.json /usr/local/app/node1/config/genesis.json | ||
|
||
# change app.toml values | ||
sed -i -E '104s/enable = false/enable = true/' /usr/local/app/node1/config/app.toml | ||
sed -i -E '107s/swagger = false/swagger = true/' /usr/local/app/node1/config/app.toml | ||
|
||
|
||
# change config.toml values | ||
sed -i -E 's|tcp://127.0.0.1:26658|tcp://0.0.0.0:26658|g' /usr/local/app/node1/config/config.toml | ||
sed -i -E 's|tcp://127.0.0.1:26657|tcp://0.0.0.0:26657|g' /usr/local/app/node1/config/config.toml | ||
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' /usr/local/app/node1/config/config.toml | ||
sed -i -E 's|addr_book_strict = true|addr_book_strict = false|g' /usr/local/app/node1/config/config.toml | ||
sed -i -E 's|cors_allowed_origins = \[\]|cors_allowed_origins = \[\"\*\"\]|g' /usr/local/app/node1/config/config.toml | ||
|
||
echo "Chain Setup is done." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# Start all three nodes | ||
hid-noded start --home=/usr/local/app/node1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# LocalNet | ||
|
||
## Port Configuration | ||
|
||
- RPC: `:26657` | ||
- P2P: `:26656` | ||
- REST Server:`:1317` | ||
|
||
## Prerequisite | ||
|
||
Install the following: | ||
|
||
- golang (ver 1.17+): https://go.dev/doc/install | ||
- jq (`sudo apt-get install jq`) | ||
- tmux (`sudo apt-get install tmux`) | ||
|
||
## Running the locanet | ||
|
||
- Setup the config files and install `hid-node` binary if it doesn't exists: | ||
- `sh setup.sh` | ||
|
||
- Run the localnet | ||
- `sh start.sh` | ||
|
||
- To display the logs of each node, run the following in a seperate terminal: | ||
|
||
Node1: `tmux a -t node1`<br> | ||
|
||
## Stop the localnet | ||
|
||
```sh | ||
sh stop.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# Download the binary if it doesn't exist | ||
hid-noded &> /dev/null | ||
|
||
RET_VAL=$? | ||
if [ ${RET_VAL} -ne 0 ]; then | ||
URL_PATH="https://github.com/hypersign-protocol/hid-node/releases/download/latest/" | ||
FILE_NAME="hid-node_latest_linux_amd64.tar.gz" | ||
DOWNLOAD_URL="${URL_PATH}${FILE_NAME}" | ||
echo "hid-noded binary doesn't exist, installing......" | ||
sleep 2 | ||
wget ${DOWNLOAD_URL} | ||
tar -xvzf hid-node_latest_linux_amd64.tar.gz | ||
mv hid-noded $(go env GOPATH)/bin/ | ||
rm -rf ${FILE_NAME} | ||
fi | ||
|
||
# Setting up config files | ||
rm -rf $HOME/.hid-node/ | ||
|
||
|
||
# Make directories for hid-node config | ||
mkdir $HOME/.hid-node | ||
mkdir $HOME/.hid-node/node1 | ||
|
||
# Init node | ||
hid-noded init --chain-id=hidnode node1 --home=$HOME/.hid-node/node1 | ||
|
||
# Create key for the node | ||
hid-noded keys add node1 --keyring-backend=test --home=$HOME/.hid-node/node1 | ||
|
||
# change staking denom to uhid | ||
cat $HOME/.hid-node/node1/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="uhid"' > $HOME/.hid-node/node1/config/tmp_genesis.json && mv $HOME/.hid-node/node1/config/tmp_genesis.json $HOME/.hid-node/node1/config/genesis.json | ||
|
||
# create validator node with tokens | ||
hid-noded add-genesis-account $(hid-noded keys show node1 -a --keyring-backend=test --home=$HOME/.hid-node/node1) 100000000000uhid,100000000000stake --home=$HOME/.hid-node/node1 | ||
hid-noded gentx node1 500000000uhid --keyring-backend=test --home=$HOME/.hid-node/node1 --chain-id=hidnode | ||
hid-noded collect-gentxs --home=$HOME/.hid-node/node1 | ||
|
||
# update crisis variable to uhid | ||
cat $HOME/.hid-node/node1/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="uhid"' > $HOME/.hid-node/node1/config/tmp_genesis.json && mv $HOME/.hid-node/node1/config/tmp_genesis.json $HOME/.hid-node/node1/config/genesis.json | ||
|
||
# udpate gov genesis | ||
cat $HOME/.hid-node/node1/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="uhid"' > $HOME/.hid-node/node1/config/tmp_genesis.json && mv $HOME/.hid-node/node1/config/tmp_genesis.json $HOME/.hid-node/node1/config/genesis.json | ||
|
||
# update mint genesis | ||
cat $HOME/.hid-node/node1/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="uhid"' > $HOME/.hid-node/node1/config/tmp_genesis.json && mv $HOME/.hid-node/node1/config/tmp_genesis.json $HOME/.hid-node/node1/config/genesis.json | ||
|
||
# change app.toml values | ||
sed -i -E '104s/enable = false/enable = true/' $HOME/.hid-node/node1/config/app.toml | ||
sed -i -E '107s/swagger = false/swagger = true/' $HOME/.hid-node/node1/config/app.toml | ||
|
||
|
||
# change config.toml values | ||
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $HOME/.hid-node/node1/config/config.toml | ||
sed -i -E 's|addr_book_strict = true|addr_book_strict = false|g' $HOME/.hid-node/node1/config/config.toml | ||
sed -i -E 's|cors_allowed_origins = \[\]|cors_allowed_origins = \[\"\*\"\]|g' $HOME/.hid-node/node1/config/config.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# Start all three nodes | ||
tmux new -s node1 -d hid-noded start --home=$HOME/.hid-node/node1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
tmux kill-session -t node1 |
Oops, something went wrong.