-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9720fe
commit e9fb263
Showing
6 changed files
with
127 additions
and
251 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
## Testnet Deployment SCripts | ||
## Testnet Deployment Scripts | ||
|
||
These scripts generate a genesis file and deploy chain across the nodes specified in the parameters. | ||
These scripts generate a genesis file and deploy chain across nodes following the given configuration. | ||
|
||
Make sure to first create a configuration file named config.sh using the template config_example.sh and populate it with the values reflecting your environment and desired deployment settings. | ||
First, make sure to create a configuration file named `config.sh` using the template `config_example.sh`. | ||
Then, check out the tag as specified by the configuration's `CHAIN_VERSION` and run `make build`. | ||
Finally, run the scripts in the following order to generate the genesis file and deploy the chain: | ||
|
||
Run in the following order, one by one: | ||
|
||
1. `create_genesis.sh` - Validates validator files for each node and creates a genesis file. | ||
2. `build_genesis_state.sh` - Runs a chain, deploys Wasm contracts on it, and dumps the Wasm state, which is then added to a given genesis file. Must be used with at least one of the following flags: `--add-groups` and `add-wasm-contracts`. | ||
3. `upload_and_start.sh` - Uploads and runs setup_node.sh on the nodes to process necessary setups. Then uploads the validator files and genesis and restarts the nodes. | ||
1. `create_genesis.sh` - Creates a genesis file with given parameters and token allocations. | ||
2. `add_groups_to_genesis.sh` - Adds groups to the genesis file (optional). | ||
3. `upload_and_start.sh` - Uploads and runs `setup_node.sh` on the nodes. Then uploads the validator files and starts the nodes. |
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,102 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
source config.sh | ||
|
||
######################################## | ||
# PRELIMINARY CHECKS AND DOWNLOADS # | ||
######################################## | ||
ORIGINAL_GENESIS=$NODE_DIR/genesis.json | ||
if [ ! -f "$ORIGINAL_GENESIS" ]; then | ||
echo "Original genesis file not found inside node directory." | ||
exit 1 | ||
fi | ||
|
||
TMP_HOME=./tmp | ||
rm -rf $TMP_HOME | ||
|
||
TEMP_CHAIN_ID=temp-seda-chain | ||
|
||
################################### | ||
# SCRIPT BEGINS - START CHAIN # | ||
################################### | ||
$LOCAL_BIN init node0 --home $TMP_HOME --chain-id $TEMP_CHAIN_ID --default-denom aseda | ||
|
||
$LOCAL_BIN keys add deployer --home $TMP_HOME --keyring-backend test | ||
ADDR=$($LOCAL_BIN keys show deployer --home $TMP_HOME --keyring-backend test -a) | ||
$LOCAL_BIN add-genesis-account $ADDR 100000000000000000seda --home $TMP_HOME --keyring-backend test | ||
|
||
echo $ADMIN_SEED | $LOCAL_BIN keys add admin --home $TMP_HOME --keyring-backend test --recover | ||
ADMIN_ADDR=$($LOCAL_BIN keys show admin --home $TMP_HOME --keyring-backend test -a) | ||
$LOCAL_BIN add-genesis-account $ADMIN_ADDR 100000000000000000seda --home $TMP_HOME --keyring-backend test | ||
|
||
$LOCAL_BIN gentx deployer 10000000000000000seda --home $TMP_HOME --keyring-backend test --chain-id $TEMP_CHAIN_ID | ||
$LOCAL_BIN collect-gentxs --home $TMP_HOME | ||
|
||
$LOCAL_BIN start --home $TMP_HOME > chain_output.log 2>&1 & disown | ||
|
||
sleep 20 | ||
|
||
|
||
############################################### | ||
# SEND TRANSACTIONS WHILE CHAIN IS RUNNING # | ||
############################################### | ||
|
||
# Create group and group policy | ||
# SEDA Security Policy | ||
$LOCAL_BIN tx group create-group-with-policy $ADMIN_ADDR "Security Group" "{\"name\":\"Security Group Policy\",\"description\":\"\"}" $GROUP_SECURITY_MEMBERS $GROUP_SECURITY_POLICY --home $TMP_HOME --from $ADMIN_ADDR --keyring-backend test --fees 1seda --gas auto --gas-adjustment 1.5 --chain-id $TEMP_CHAIN_ID -y | ||
sleep 10 | ||
# DAO Treasury Group | ||
$LOCAL_BIN tx group create-group-with-policy $ADMIN_ADDR "Treasury Group" "{\"name\":\"Treasury Group Policy\",\"description\":\"\"}" $GROUP_TREASURY_MEMBERS $GROUP_TREASURY_POLICY --home $TMP_HOME --from $ADMIN_ADDR --keyring-backend test --fees 1seda --gas auto --gas-adjustment 1.5 --chain-id $TEMP_CHAIN_ID -y | ||
sleep 10 | ||
# OOA Group | ||
$LOCAL_BIN tx group create-group-with-policy $ADMIN_ADDR "OOA Group" "{\"name\":\"OOA Group Policy\",\"description\":\"\"}" $GROUP_OOA_MEMBERS $GROUP_OOA_POLICY --home $TMP_HOME --from $ADMIN_ADDR --keyring-backend test --fees 1seda --gas auto --gas-adjustment 1.5 --chain-id $TEMP_CHAIN_ID -y | ||
sleep 10 | ||
|
||
|
||
############################################################# | ||
# TERMINATE CHAIN PROCESS, EXPORT, AND MODIFY GIVEN GENESIS # | ||
############################################################# | ||
pkill sedad | ||
sleep 5 | ||
|
||
$LOCAL_BIN export --home $TMP_HOME > $TMP_HOME/exported | ||
python3 -m json.tool $TMP_HOME/exported > $TMP_HOME/genesis.json | ||
rm $TMP_HOME/exported | ||
|
||
|
||
EXPORTED_GENESIS=$TMP_HOME/genesis.json | ||
TMP_GENESIS=$TMP_HOME/tmp_genesis.json | ||
TMP_TMP_GENESIS=$TMP_HOME/tmp_tmp_genesis.json | ||
|
||
cp $ORIGINAL_GENESIS $TMP_GENESIS # make adjustments on TMP_GENESIS until replacing original genesis in the last step | ||
|
||
# Modify group state and wasm code upload params | ||
jq '.app_state["group"]' $EXPORTED_GENESIS > $TMP_HOME/group.tmp | ||
TREASURY_GROUP_POLICY_ADDR=$(jq '.app_state["group"]["group_policies"][0]["address"]' $EXPORTED_GENESIS) | ||
OOA_GROUP_POLICY_ADDR=$(jq '.app_state["group"]["group_policies"][1]["address"]' $EXPORTED_GENESIS) | ||
SECURITY_GROUP_POLICY_ADDR=$(jq '.app_state["group"]["group_policies"][2]["address"]' $EXPORTED_GENESIS) | ||
|
||
jq --slurpfile group $TMP_HOME/group.tmp '.app_state["group"] = $group[0]' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
|
||
# replace group policy address as group & group policy admin | ||
jq '(.app_state.group.groups[] | select(.metadata == "Security Group") .admin) |= '$SECURITY_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
jq '(.app_state.group.group_policies[] | select(.address == '$SECURITY_GROUP_POLICY_ADDR') .admin) |= '$SECURITY_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
|
||
jq '(.app_state.group.groups[] | select(.metadata == "Treasury Group") .admin) |= '$TREASURY_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
jq '(.app_state.group.group_policies[] | select(.address == '$TREASURY_GROUP_POLICY_ADDR') .admin) |= '$TREASURY_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
|
||
jq '(.app_state.group.groups[] | select(.metadata == "OOA Group") .admin) |= '$OOA_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
jq '(.app_state.group.group_policies[] | select(.address == '$OOA_GROUP_POLICY_ADDR') .admin) |= '$OOA_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
|
||
if [ "$WASM_PERMISSION_EVERYONE" != "true" ]; then | ||
jq '.app_state["wasm"]["params"]["code_upload_access"]["permission"]="AnyOfAddresses"' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
jq '.app_state["wasm"]["params"]["instantiate_default_permission"]="AnyOfAddresses"' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
jq '.app_state["wasm"]["params"]["code_upload_access"]["addresses"]=['$SECURITY_GROUP_POLICY_ADDR']' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS | ||
fi | ||
|
||
mv $TMP_GENESIS $ORIGINAL_GENESIS | ||
|
||
# clean up | ||
rm -rf $TMP_HOME | ||
rm chain_output.log |
This file was deleted.
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
Oops, something went wrong.