-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from onomyprotocol/dong/gov-dev
add gov for Active Collateral module vaults
- Loading branch information
Showing
15 changed files
with
1,000 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
syntax = "proto3"; | ||
package reserve.vaults; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "reserve/vaults/tx.proto"; | ||
import "amino/amino.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
|
||
|
||
option go_package = "github.com/onomyprotocol/reserve/x/vaults/types"; | ||
|
||
|
||
message ActiveCollateralProposal { | ||
option (gogoproto.goproto_getters) = false; | ||
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; | ||
option (amino.name) = "reserve/ActiveCollateralProposal"; | ||
|
||
string title = 1; | ||
string description = 2; | ||
MsgActiveCollateral active_collateral = 3 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
message UpdatesCollateralProposal { | ||
option (gogoproto.goproto_getters) = false; | ||
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; | ||
option (amino.name) = "reserve/UpdatesCollateralProposal"; | ||
|
||
string title = 1; | ||
string description = 2; | ||
MsgUpdatesCollateral updates_collateral = 3 [(gogoproto.nullable) = false]; | ||
} |
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,13 @@ | ||
{ | ||
"messages": [{ | ||
"@type": "/reserve.vaults.MsgActiveCollateral", | ||
"denom": "atom", | ||
"authority":"onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k", | ||
"min_collateral_ratio": "0.5", | ||
"liquidation_ratio":"0.5", | ||
"max_debt":"10000" | ||
}], | ||
"deposit": "100000000stake", | ||
"title": "My proposal", | ||
"summary": "A short summary of my proposal" | ||
} |
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,137 @@ | ||
#!/bin/bash | ||
set -xeu | ||
|
||
# always returns true so set -e doesn't exit if it is not running. | ||
killall reserved || true | ||
rm -rf $HOME/.reserved/ | ||
|
||
mkdir $HOME/.reserved | ||
mkdir $HOME/.reserved/validator1 | ||
mkdir $HOME/.reserved/validator2 | ||
mkdir $HOME/.reserved/validator3 | ||
|
||
# init all three validators | ||
reserved init --chain-id=testing-1 validator1 --home=$HOME/.reserved/validator1 | ||
reserved init --chain-id=testing-1 validator2 --home=$HOME/.reserved/validator2 | ||
reserved init --chain-id=testing-1 validator3 --home=$HOME/.reserved/validator3 | ||
|
||
# create keys for all three validators | ||
mnemonic1="top toddler wrist parade hobby supply odor ginger resource copy square tell vanish pride volcano effort planet style transfer pipe wise bus tuition luxury" | ||
mnemonic2="panther giant oyster hand song region chunk coil laundry glance ball denial void ramp palm fiscal pizza soccer before upset diet valid story cement" | ||
mnemonic3="gap track crop knee galaxy square case resemble subway math moon mom casino trade finish exotic author comic gap margin elegant claw fire business" | ||
|
||
echo $mnemonic1| reserved keys add validator1 --recover --keyring-backend=test --home=$HOME/.reserved/validator1 | ||
echo $mnemonic2| reserved keys add validator2 --recover --keyring-backend=test --home=$HOME/.reserved/validator2 | ||
echo $mnemonic3| reserved keys add validator3 --recover --keyring-backend=test --home=$HOME/.reserved/validator3 | ||
|
||
# create validator node with tokens to transfer to the three other nodes | ||
reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator1 | ||
reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator1 | ||
reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator1 | ||
reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator2 | ||
reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator2 | ||
reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator2 | ||
reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator3 | ||
reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator3 | ||
reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator3 | ||
reserved genesis gentx validator1 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator1 --chain-id=testing-1 | ||
reserved genesis gentx validator2 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator2 --chain-id=testing-1 | ||
reserved genesis gentx validator3 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator3 --chain-id=testing-1 | ||
|
||
# cp validator2/config/gentx/*.json $HOME/.reserved/validator1/config/gentx/ | ||
# cp validator3/config/gentx/*.json $HOME/.reserved/validator1/config/gentx/ | ||
reserved genesis collect-gentxs --home=$HOME/.reserved/validator1 | ||
|
||
# change app.toml values | ||
VALIDATOR1_APP_TOML=$HOME/.reserved/validator1/config/app.toml | ||
VALIDATOR2_APP_TOML=$HOME/.reserved/validator2/config/app.toml | ||
VALIDATOR3_APP_TOML=$HOME/.reserved/validator3/config/app.toml | ||
|
||
# validator1 | ||
sed -i -E 's|0.0.0.0:9090|0.0.0.0:9050|g' $VALIDATOR1_APP_TOML | ||
sed -i -E 's|127.0.0.1:9090|127.0.0.1:9050|g' $VALIDATOR1_APP_TOML | ||
sed -i -E 's|minimum-gas-prices = ""|minimum-gas-prices = "0.0001stake"|g' $VALIDATOR1_APP_TOML | ||
|
||
# validator2 | ||
sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1316|g' $VALIDATOR2_APP_TOML | ||
sed -i -E 's|0.0.0.0:9090|0.0.0.0:9088|g' $VALIDATOR2_APP_TOML | ||
sed -i -E 's|0.0.0.0:9091|0.0.0.0:9089|g' $VALIDATOR2_APP_TOML | ||
sed -i -E 's|minimum-gas-prices = ""|minimum-gas-prices = "0.0001stake"|g' $VALIDATOR2_APP_TOML | ||
|
||
# validator3 | ||
sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1315|g' $VALIDATOR3_APP_TOML | ||
sed -i -E 's|0.0.0.0:9090|0.0.0.0:9086|g' $VALIDATOR3_APP_TOML | ||
sed -i -E 's|0.0.0.0:9091|0.0.0.0:9087|g' $VALIDATOR3_APP_TOML | ||
sed -i -E 's|minimum-gas-prices = ""|minimum-gas-prices = "0.0001stake"|g' $VALIDATOR3_APP_TOML | ||
|
||
# change config.toml values | ||
VALIDATOR1_CONFIG=$HOME/.reserved/validator1/config/config.toml | ||
VALIDATOR2_CONFIG=$HOME/.reserved/validator2/config/config.toml | ||
VALIDATOR3_CONFIG=$HOME/.reserved/validator3/config/config.toml | ||
|
||
|
||
# validator1 | ||
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR1_CONFIG | ||
sed -i -E 's|prometheus = false|prometheus = true|g' $VALIDATOR1_CONFIG | ||
|
||
|
||
# validator2 | ||
sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26655|g' $VALIDATOR2_CONFIG | ||
sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26654|g' $VALIDATOR2_CONFIG | ||
sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26653|g' $VALIDATOR2_CONFIG | ||
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR2_CONFIG | ||
sed -i -E 's|prometheus = false|prometheus = true|g' $VALIDATOR2_CONFIG | ||
sed -i -E 's|prometheus_listen_addr = ":26660"|prometheus_listen_addr = ":26630"|g' $VALIDATOR2_CONFIG | ||
|
||
# validator3 | ||
sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26652|g' $VALIDATOR3_CONFIG | ||
sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26651|g' $VALIDATOR3_CONFIG | ||
sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26650|g' $VALIDATOR3_CONFIG | ||
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR3_CONFIG | ||
sed -i -E 's|prometheus = false|prometheus = true|g' $VALIDATOR3_CONFIG | ||
sed -i -E 's|prometheus_listen_addr = ":26660"|prometheus_listen_addr = ":26620"|g' $VALIDATOR3_CONFIG | ||
|
||
# copy, update validator1 genesis file to validator2-3 | ||
update_test_genesis () { | ||
cat $HOME/.reserved/validator1/config/genesis.json | jq "$1" > tmp.json && mv tmp.json $HOME/.reserved/validator1/config/genesis.json | ||
} | ||
|
||
update_test_genesis '.app_state["gov"]["params"]["voting_period"] = "15s"' | ||
update_test_genesis '.app_state["gov"]["params"]["expedited_voting_period"] = "10s"' | ||
|
||
cp $HOME/.reserved/validator1/config/genesis.json $HOME/.reserved/validator2/config/genesis.json | ||
cp $HOME/.reserved/validator1/config/genesis.json $HOME/.reserved/validator3/config/genesis.json | ||
|
||
# copy tendermint node id of validator1 to persistent peers of validator2-3 | ||
node1=$(reserved tendermint show-node-id --home=$HOME/.reserved/validator1) | ||
node2=$(reserved tendermint show-node-id --home=$HOME/.reserved/validator2) | ||
node3=$(reserved tendermint show-node-id --home=$HOME/.reserved/validator3) | ||
sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$node1@localhost:26656,$node2@localhost:26656,$node3@localhost:26656\"|g" $HOME/.reserved/validator1/config/config.toml | ||
sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$node1@localhost:26656,$node2@localhost:26656,$node3@localhost:26656\"|g" $HOME/.reserved/validator2/config/config.toml | ||
sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$node1@localhost:26656,$node2@localhost:26656,$node3@localhost:26656\"|g" $HOME/.reserved/validator3/config/config.toml | ||
|
||
|
||
# # start all three validators | ||
screen -S onomy1 -t onomy1 -d -m reserved start --home=$HOME/.reserved/validator1 | ||
screen -S onomy2 -t onomy2 -d -m reserved start --home=$HOME/.reserved/validator2 | ||
screen -S onomy3 -t onomy3 -d -m reserved start --home=$HOME/.reserved/validator3 | ||
|
||
# submit proposal add usdt | ||
sleep 7 | ||
reserved q gov proposals | ||
# reserved tx gov submit-legacy-proposal active-collateral "title" "description" "atom" "10" "0.1" "10000" 10000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator1 --from validator1 -y --chain-id testing-1 --fees 20stake | ||
|
||
reserved tx gov submit-proposal ./script/proposal-1.json --home=$HOME/.reserved/validator1 --from validator1 --keyring-backend test --fees 20stake --chain-id testing-1 -y | ||
|
||
# # vote | ||
sleep 7 | ||
reserved tx gov vote 1 yes --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake | ||
reserved tx gov vote 1 yes --from validator2 --keyring-backend test --home ~/.reserved/validator2 --chain-id testing-1 -y --fees 20stake | ||
reserved tx gov vote 1 yes --from validator3 --keyring-backend test --home ~/.reserved/validator3 --chain-id testing-1 -y --fees 20stake | ||
|
||
# wait voting_perio=15s | ||
echo "========sleep==========" | ||
sleep 15 | ||
reserved q gov proposals | ||
|
||
killall reserved || true |
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
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
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,25 @@ | ||
package vaults | ||
|
||
import ( | ||
errorsmod "cosmossdk.io/errors" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" | ||
|
||
"github.com/onomyprotocol/reserve/x/vaults/keeper" | ||
"github.com/onomyprotocol/reserve/x/vaults/types" | ||
) | ||
|
||
func NewVaultsProposalHandler(k *keeper.Keeper) govtypes.Handler { | ||
return func(ctx sdk.Context, content govtypes.Content) error { | ||
switch c := content.(type) { | ||
case *types.ActiveCollateralProposal: | ||
return k.ActiveCollateralAsset(ctx, c.ActiveCollateral.Denom, c.ActiveCollateral.MinCollateralRatio, c.ActiveCollateral.LiquidationRatio, c.ActiveCollateral.MaxDebt) | ||
case *types.UpdatesCollateralProposal: | ||
return k.UpdatesCollateralAsset(ctx, c.UpdatesCollateral.Denom, c.UpdatesCollateral.MinCollateralRatio, c.UpdatesCollateral.LiquidationRatio, c.UpdatesCollateral.MaxDebt) | ||
default: | ||
return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s proposal content type: %T", types.ModuleName, c) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.