-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add script to submit software-upgrade proposal * Update README.md * Update README.md * Remove unused function (cherry picked from commit 0bbe4f5) Co-authored-by: Niccolo Raspa <[email protected]>
- Loading branch information
1 parent
bc8aa38
commit 6d765e9
Showing
2 changed files
with
153 additions
and
1 deletion.
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,103 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# Validator mnemonic of the validator that will make the proposal and vote on it | ||
# it should have enough voting power to pass the proposal | ||
VALIDATOR_MNEMONIC="bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort" | ||
|
||
OSMOSIS_HOME=$HOME/.osmosisd-local/ | ||
RPC_NODE=http://localhost:26657/ | ||
|
||
# Default upgrade version | ||
UPGRADE_VERSION=${1:-"v15"} | ||
|
||
# Paramters | ||
KEY=val | ||
PROPOSAL_DEPOSIT=1600000000uosmo | ||
TX_FEES=1000uosmo | ||
|
||
# Define ANSI escape sequences for colors | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # No Color | ||
|
||
# Get chain info | ||
get_chain_info() { | ||
echo | ||
echo "${YELLOW}Getting chain info...${NC}" | ||
CHAIN_ID=$(curl -s localhost:26657/status | jq -r '.result.node_info.network') | ||
|
||
ABCI_INFO=$(curl -s localhost:26657/abci_info) | ||
CURRENT_HEIGHT=$(echo "$ABCI_INFO" | jq -r .result.response.last_block_height) | ||
UPGRADE_HEIGHT=$((CURRENT_HEIGHT + 50)) | ||
UPGRADE_INFO="" | ||
|
||
echo "CHAIN_ID: $CHAIN_ID" | ||
echo "CURRENT_HEIGHT: $CURRENT_HEIGHT" | ||
echo "UPGRADE_HEIGHT: $UPGRADE_HEIGHT" | ||
echo "UPGRADE_VERSION: $UPGRADE_VERSION" | ||
} | ||
|
||
# Make proposal and get proposal ID | ||
make_proposal() { | ||
echo | ||
echo "${YELLOW}Creating software-upgrade proposal...${NC}" | ||
OSMOSIS_CMD="osmosisd tx gov submit-proposal software-upgrade \ | ||
$UPGRADE_VERSION \ | ||
--title \"$UPGRADE_VERSION Upgrade\" \ | ||
--description \"$UPGRADE_VERSION Upgrade\" \ | ||
--upgrade-height $UPGRADE_HEIGHT \ | ||
--upgrade-info \"$UPGRADE_INFO\" \ | ||
--chain-id $CHAIN_ID \ | ||
--deposit $PROPOSAL_DEPOSIT \ | ||
--from $KEY \ | ||
--fees $TX_FEES \ | ||
--keyring-backend test \ | ||
-b block \ | ||
--node $RPC_NODE \ | ||
--home $OSMOSIS_HOME \ | ||
--yes \ | ||
-o json" | ||
|
||
PROPOSAL_JSON=$(eval "$OSMOSIS_CMD") | ||
PROPOSAL_ID=$(echo "$PROPOSAL_JSON" | jq -r '.logs[0].events[] | select(.type == "submit_proposal") | .attributes[] | select(.key == "proposal_id") | .value') | ||
} | ||
|
||
|
||
# Query proposal | ||
query_proposal() { | ||
osmosisd q gov proposal $PROPOSAL_ID \ | ||
--node $RPC_NODE \ | ||
-o json | jq | ||
} | ||
|
||
# Vote on proposal | ||
vote_on_proposal() { | ||
echo | ||
echo "${YELLOW}Voting on proposal $PROPOSAL_ID...${NC}" | ||
OSMOSIS_CMD="osmosisd tx gov vote $PROPOSAL_ID yes \ | ||
--from $KEY \ | ||
--chain-id $CHAIN_ID \ | ||
--fees $TX_FEES \ | ||
--node $RPC_NODE \ | ||
--home $OSMOSIS_HOME \ | ||
--yes \ | ||
--keyring-backend test \ | ||
-o json" | ||
|
||
# Execute the command and capture the output | ||
VOTE_OUTPUT=$(eval "$OSMOSIS_CMD") | ||
echo $VOTE_OUTPUT | jq | ||
|
||
} | ||
|
||
|
||
# Main function | ||
main() { | ||
get_chain_info | ||
make_proposal | ||
query_proposal | ||
vote_on_proposal | ||
} | ||
|
||
# Run main function | ||
main |