Skip to content

Commit

Permalink
Merge pull request #345 from hypersign-protocol/localnet-general-script
Browse files Browse the repository at this point in the history
Add general localnet script
  • Loading branch information
arnabghose997 committed Mar 18, 2023
2 parents 0677963 + dddc48d commit 640625e
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Hypersign Identity Network is a permissionless blockchain network to manage

Following are the prerequisites that needs to be installed:

- Golang (Installation Guide: https://go.dev/doc/install) (version: 1.18+)
- Golang (Installation Guide: https://go.dev/doc/install) (version: 1.19+)
- make

## Get started
Expand All @@ -39,13 +39,12 @@ Following are the prerequisites that needs to be installed:
2. Run the following script to setup a single-node blockchain. Please note that the following script requires `jq` to be installed.
```sh
sudo chmod +x ./scripts/localnet-single-node/setup.sh
sh ./scripts/localnet-single-node/setup.sh
bash localnet.sh
```

3. Start `hid-noded`:
```sh
hid-noded start --home ~/.hid-node
hid-noded start
```

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

# Set the binary name
BINARY=hid-noded

# Check if the binary is installed
${BINARY} &> /dev/null

RET_VAL=$?
if [ ${RET_VAL} -ne 0 ]; then
# Check the current version of hid-noded running on testnet
echo "hid-noded binary is not installed in your system. Installing now......"
HIDNODE_TESTNET_VERSION=$(curl -s https://rpc.jagrat.hypersign.id/abci_info | jq -r .result.response.version)
echo -e "\nCurrent hid-noded version running on Testnet is $HIDNODE_TESTNET_VERSION. Installing binary of version $HIDNODE_TESTNET_VERSION"
VERSION=$(echo "$HIDNODE_TESTNET_VERSION" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
SANITISED_VERSION=$(echo "$HIDNODE_TESTNET_VERSION" | sed "s/.*$VERSION/$VERSION/")

# Download binary
mkdir tmp_hid_node && cd tmp_hid_node
FILENAME=hid-noded-$SANITISED_VERSION-linux-amd64.tar.gz
wget "https://github.com/hypersign-protocol/hid-node/releases/download/v$SANITISED_VERSION/$FILENAME"
tar -C $HOME/.local/bin/ -xzf $FILENAME
cd .. && rm -rf ./tmp_hid_node
fi

# Setting up config files
rm -rf $HOME/.hid-node/

# Make directories for hid-node config
mkdir $HOME/.hid-node

# Init node
hid-noded init --chain-id=hidnode node1 --home=$HOME/.hid-node

# Change hid-node config
hid-noded configure min-gas-prices 0uhid

# Create key for the node
hid-noded keys add node1 --keyring-backend=test --home=$HOME/.hid-node

# change staking denom to uhid
cat $HOME/.hid-node/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="uhid"' > $HOME/.hid-node/config/tmp_genesis.json && mv $HOME/.hid-node/config/tmp_genesis.json $HOME/.hid-node/config/genesis.json

# update crisis variable to uhid
cat $HOME/.hid-node/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="uhid"' > $HOME/.hid-node/config/tmp_genesis.json && mv $HOME/.hid-node/config/tmp_genesis.json $HOME/.hid-node/config/genesis.json

# update gov genesis
cat $HOME/.hid-node/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="uhid"' > $HOME/.hid-node/config/tmp_genesis.json && mv $HOME/.hid-node/config/tmp_genesis.json $HOME/.hid-node/config/genesis.json
cat $HOME/.hid-node/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="50s"' > $HOME/.hid-node/config/tmp_genesis.json && mv $HOME/.hid-node/config/tmp_genesis.json $HOME/.hid-node/config/genesis.json

# update ssi genesis
cat $HOME/.hid-node/config/genesis.json | jq '.app_state["ssi"]["chain_namespace"]="testnet"' > $HOME/.hid-node/config/tmp_genesis.json && mv $HOME/.hid-node/config/tmp_genesis.json $HOME/.hid-node/config/genesis.json

# update mint genesis
cat $HOME/.hid-node/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="uhid"' > $HOME/.hid-node/config/tmp_genesis.json && mv $HOME/.hid-node/config/tmp_genesis.json $HOME/.hid-node/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) 500000000000000000uhid --home=$HOME/.hid-node --keyring-backend test
hid-noded gentx node1 50000000000000000uhid --keyring-backend=test --home=$HOME/.hid-node --chain-id=hidnode
hid-noded collect-gentxs --home=$HOME/.hid-node

# change app.toml values
sed -i -E '112s/enable = false/enable = true/' $HOME/.hid-node/config/app.toml
sed -i -E '115s/swagger = false/swagger = true/' $HOME/.hid-node/config/app.toml
sed -i -E '133s/enabled-unsafe-cors = false/enabled-unsafe-cors = true/' $HOME/.hid-node/config/app.toml


# change config.toml values
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $HOME/.hid-node/config/config.toml
sed -i -E 's|addr_book_strict = true|addr_book_strict = false|g' $HOME/.hid-node/config/config.toml
sed -i -E 's|cors_allowed_origins = \[\]|cors_allowed_origins = \[\"\*\"\]|g' $HOME/.hid-node/config/config.toml

echo -e "\nConfiguarations set, you are ready to run hid-noded now!"

echo -e "\nEnter the command 'hid-noded start' to start a single node blockchain."

0 comments on commit 640625e

Please sign in to comment.