-
Notifications
You must be signed in to change notification settings - Fork 609
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
Add upgrade proposal script to localOsmosis #4510
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.