Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update testnet script #201

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require (
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2
github.com/hashicorp/go-metrics v0.5.2
github.com/ory/dockertest/v3 v3.10.0
github.com/pkg/errors v0.9.1
github.com/sedaprotocol/vrf-go v0.0.0-20231211075603-e5a17bb0b87c
Expand Down Expand Up @@ -136,7 +137,6 @@ require (
github.com/hashicorp/go-getter v1.7.3 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.2 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
Expand Down
22 changes: 18 additions & 4 deletions scripts/testnet/build_genesis_state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ sleep 20

# Create group and group policy
if [ $ADD_GROUPS = true ]; then
$LOCAL_BIN tx group create-group-with-policy $ADMIN_ADDR "ipfs://not_real_metadata" "{\"name\":\"quick turnaround\",\"description\":\"\"}" $MEMBERS_JSON_FILE $POLICY_JSON_FILE --home $TMP_HOME --from $ADMIN_ADDR --keyring-backend test --chain-id $TEMP_CHAIN_ID -y
# add security group
$LOCAL_BIN tx group create-group-with-policy $ADMIN_ADDR "Security Group" "{\"name\":\"Security Group Policy\",\"description\":\"\"}" $MEMBERS_JSON_FILE $POLICY_JSON_FILE --home $TMP_HOME --from $ADMIN_ADDR --keyring-backend test --chain-id $TEMP_CHAIN_ID -y
sleep 10

# add treasury group
$LOCAL_BIN tx group create-group-with-policy $ADMIN_ADDR "Treasury Group" "{\"name\":\"Treasury Group Policy\",\"description\":\"\"}" $MEMBERS_JSON_FILE $POLICY_JSON_FILE --home $TMP_HOME --from $ADMIN_ADDR --keyring-backend test --chain-id $TEMP_CHAIN_ID -y
sleep 10
fi

Expand Down Expand Up @@ -185,12 +190,20 @@ cp $ORIGINAL_GENESIS $TMP_GENESIS # make adjustments on TMP_GENESIS until replac
# Modify group state and wasm code upload params
if [ $ADD_GROUPS = true ]; then
jq '.app_state["group"]' $EXPORTED_GENESIS > $TMP_HOME/group.tmp
GROUP_POLICY_ADDR=$(jq '.app_state["group"]["group_policies"][0]["address"]' $EXPORTED_GENESIS)
TREASURY_GROUP_POLICY_ADDR=$(jq '.app_state["group"]["group_policies"][0]["address"]' $EXPORTED_GENESIS)
SECURITY_GROUP_POLICY_ADDR=$(jq '.app_state["group"]["group_policies"][1]["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"][0]["admin"]='$SECURITY_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS
jq '.app_state["group"]["group_policies"][1]["admin"]='$SECURITY_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS
jq '.app_state["group"]["groups"][1]["admin"]='$TREASURY_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS
jq '.app_state["group"]["group_policies"][0]["admin"]='$TREASURY_GROUP_POLICY_ADDR'' $TMP_GENESIS > $TMP_TMP_GENESIS && mv $TMP_TMP_GENESIS $TMP_GENESIS

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"]=['$GROUP_POLICY_ADDR']' $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

# Modify wasm codes, contracts, and sequences.
Expand All @@ -209,5 +222,6 @@ fi
mv $TMP_GENESIS $ORIGINAL_GENESIS

# clean up
rm -rf $TMP_HOME
# rm -rf $TMP_HOME
# echo $TMP_HOME
rm chain_output.log
2 changes: 1 addition & 1 deletion scripts/testnet/config_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ CONTRACTS_VERSION=v0.0.1-rc # latest or seda-chain-contracts release version
#######################################
MEMBERS_JSON_FILE=./members.json
POLICY_JSON_FILE=./policy.json
ADMIN_SEED="mushroom energy ..."
ADMIN_SEED="mushroom energy ..." # used for creating groups - overwritten by group policy addresses anyways

#######################################
############### GITHUB ################
Expand Down
35 changes: 23 additions & 12 deletions scripts/testnet/create_genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ cat $HOME/.sedad/config/genesis.json | jq '.app_state["distribution"]["params"][
cat $HOME/.sedad/config/genesis.json | jq '.app_state["distribution"]["params"]["bonus_proposer_reward"]="0.040000000000000000"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json

# gov params
cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="180s"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["params"]["voting_period"]="180s"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["params"]["expedited_voting_period"]="150s"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["params"]["max_deposit_period"]="180s"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="432000s"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["params"]["voting_period"]="432000s"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
# cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["params"]["expedited_voting_period"]="432000s"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["params"]["max_deposit_period"]="432000s"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["gov"]["params"]["min_initial_deposit_ratio"]="0.010000000000000000"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json

# mint params
cat $HOME/.sedad/config/genesis.json | jq '.app_state["mint"]["minter"]["inflation"]="0.000000000000000000"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["mint"]["params"]["inflation_rate_change"]="0.000000000000000000"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["mint"]["params"]["inflation_max"]="0.000000000000000000"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["mint"]["params"]["inflation_min"]="0.000000000000000000"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json
cat $HOME/.sedad/config/genesis.json | jq '.app_state["mint"]["params"]["blocks_per_year"]="4204800"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json

# slashing params
Expand All @@ -60,22 +64,21 @@ cat $HOME/.sedad/config/genesis.json | jq '.app_state["slashing"]["params"]["sla
# consensus params
cat $HOME/.sedad/config/genesis.json | jq '.consensus["params"]["block"]["max_gas"]="100000000"' > $HOME/.sedad/config/tmp_genesis.json && mv $HOME/.sedad/config/tmp_genesis.json $HOME/.sedad/config/genesis.json

# TO-DO gov (intentionally adjusted for testing): voting_params.voting_period, params.voting_period, params.expedited_voting_period, min_deposit[0].amount, max_deposit_period
# TO-DO wasm params

#
# ADD GENESIS ACCOUNTS
#
for i in ${!GENESIS_ADDRESSES[@]}; do
$LOCAL_BIN add-genesis-account ${GENESIS_ADDRESSES[$i]} 100000000000000000seda
$LOCAL_BIN add-genesis-account ${GENESIS_ADDRESSES[$i]} 2000000seda --vesting-amount 1000000seda --vesting-start-time 1708610400 --vesting-end-time 1716386400 --funder $FUNDER_ADDRESS # 2M (1M nonvesting - 1M vesting)
done

set +u
if [ ! -z "$SATOSHI" ]; then
$LOCAL_BIN add-genesis-account $SATOSHI 10000000000000000000seda
$LOCAL_BIN add-genesis-account $SATOSHI 270000000seda # 270M
fi
if [ ! -z "$FAUCET" ]; then
$LOCAL_BIN add-genesis-account $FAUCET 1000000000000000000seda
$LOCAL_BIN add-genesis-account $FAUCET 700000000seda # 700M
fi
set -u

Expand All @@ -94,10 +97,18 @@ for i in ${!MONIKERS[@]}; do

VALIDATOR_ADDRESS=$($LOCAL_BIN keys show ${MONIKERS[$i]} --keyring-backend test --home $INDIVIDUAL_VAL_HOME_DIR -a)

# to create their gentx
$LOCAL_BIN add-genesis-account $VALIDATOR_ADDRESS 500000000000000000seda --home $INDIVIDUAL_VAL_HOME_DIR
# to output geneis file
$LOCAL_BIN add-genesis-account $VALIDATOR_ADDRESS 500000000000000000seda
if [ -z ${VESTING_AMOUNTS[$i]} ]; then
# to create their gentx
$LOCAL_BIN add-genesis-account $VALIDATOR_ADDRESS ${SELF_DELEGATION_AMOUNTS[$i]} --home $INDIVIDUAL_VAL_HOME_DIR
# to output geneis file
$LOCAL_BIN add-genesis-account $VALIDATOR_ADDRESS ${SELF_DELEGATION_AMOUNTS[$i]}
else
# to create their gentx
$LOCAL_BIN add-genesis-account $VALIDATOR_ADDRESS ${SELF_DELEGATION_AMOUNTS[$i]} --home $INDIVIDUAL_VAL_HOME_DIR --vesting-amount ${VESTING_AMOUNTS[$i]} --vesting-start-time 1708610400 --vesting-end-time 1716386400 --funder $FUNDER_ADDRESS
# to output geneis file
$LOCAL_BIN add-genesis-account $VALIDATOR_ADDRESS ${SELF_DELEGATION_AMOUNTS[$i]} --vesting-amount ${VESTING_AMOUNTS[$i]} --vesting-start-time 1708610400 --vesting-end-time 1716386400 --funder $FUNDER_ADDRESS
fi


$LOCAL_BIN gentx ${MONIKERS[$i]} ${SELF_DELEGATION_AMOUNTS[$i]} --moniker=${MONIKERS[$i]} --keyring-backend=test --home $INDIVIDUAL_VAL_HOME_DIR --ip=${IPS[$i]} --chain-id $CHAIN_ID

Expand Down
19 changes: 17 additions & 2 deletions scripts/testnet/members.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
{
"members": [
{
"address": "seda1g4tlruupkv9kp2n8fx5w70lscjkauy34vzutxs",
"address": "seda1ucv5709wlf9jn84ynyjzyzeavwvurmdyxat26l",
"weight": "1",
"metadata": "testnet_faucet"
"metadata": "testnet_hy"
},
{
"address": "seda1me08j60dfmxwcftpp6jq9cgeapws3e6268a8ng",
"weight": "1",
"metadata": "testnet_jasper"
},
{
"address": "seda1cz4xdt254kpl09sf3y7qh2djaf6c9zqgyfnfp9",
"weight": "1",
"metadata": "testnet_mario"
},
{
"address": "seda1jd2q0mz0vzs75tp7lyuzf9064zccddgs8utjr5",
"weight": "1",
"metadata": "testnet_franklin"
},
{
"address": "seda1xd04svzj6zj93g4eknhp6aq2yyptagcc2zeetj",
Expand Down
4 changes: 2 additions & 2 deletions scripts/testnet/policy.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"@type": "/cosmos.group.v1.ThresholdDecisionPolicy",
"threshold": "1",
"threshold": "3",
"windows": {
"voting_period": "2m",
"voting_period": "15m",
"min_execution_period": "0s"
}
}
12 changes: 6 additions & 6 deletions scripts/testnet/upload_and_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ done

SEEDS=()
for i in ${!IPS[@]}; do
SEED=$($LOCAL_BIN tendermint show-node-id --home $NODE_DIR/node$i)
SEED=$($LOCAL_BIN tendermint show-node-id --home $NODE_DIR/${MONIKERS[$i]})
SEEDS+=("$SEED@${IPS[$i]}:26656")
done

Expand All @@ -65,13 +65,13 @@ SEEDS_LIST="${list%,}"
echo $SEEDS_LIST

for i in ${!IPS[@]}; do
cp $NODE_DIR/genesis.json $NODE_DIR/node$i/config/genesis.json
cp $NODE_DIR/genesis.json $NODE_DIR/${MONIKERS[$i]}/config/genesis.json

if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/seeds = \"\"/seeds = \"${SEEDS_LIST}\"/g" $NODE_DIR/node$i/config/config.toml
sed -i '' "s/seeds = \"\"/seeds = \"${SEEDS_LIST}\"/g" $NODE_DIR/${MONIKERS[$i]}/config/config.toml
else
sed "s/seeds = \"\"/seeds = \"${SEEDS_LIST}\"/g" $NODE_DIR/node$i/config/config.toml > tmp
cat tmp > $NODE_DIR/node$i/config/config.toml
sed "s/seeds = \"\"/seeds = \"${SEEDS_LIST}\"/g" $NODE_DIR/${MONIKERS[$i]}/config/config.toml > tmp
cat tmp > $NODE_DIR/${MONIKERS[$i]}/config/config.toml
rm tmp
fi

Expand All @@ -83,7 +83,7 @@ for i in ${!IPS[@]}; do
ssh -i $SSH_KEY -t ec2-user@${IPS[$i]} 'sudo rm -rf /home/ec2-user/.sedad'

# upload node files
scp -i $SSH_KEY -r $NODE_DIR/node$i ec2-user@${IPS[$i]}:/home/ec2-user/.sedad
scp -i $SSH_KEY -r $NODE_DIR/${MONIKERS[$i]} ec2-user@${IPS[$i]}:/home/ec2-user/.sedad

# upload chain binary built for the corresponding architecture
LINUX_BIN=$NODE_DIR/sedad-amd64
Expand Down
Loading