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

feat: create a x/gov tutorial #1217

Merged
merged 13 commits into from
Sep 19, 2022
28 changes: 23 additions & 5 deletions tutorials/understanding-gov/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The proposer is not obliged to submit the totality of the deposit amount. Other

</HighlightBox>

* **Voting period:** After the minimum deposit is reached, the proposal enters the voting period. During this period, users can vote on the proposal. The voting period is a parameter of individual chains. For instance, the Cosmos Hub has a `2 weeks` voting period.
* **Voting period:** After the minimum deposit is reached, the proposal enters the voting period. During this period, users can vote on the proposal. The voting period is a parameter of individual chains. For instance, the Cosmos Hub has a [`2 weeks` voting period](https://mintscan.io/cosmos/parameters).

* **Quorum:** Quorum is defined as the minimum percentage of voting power that needs to be cast on a proposal for the result to be valid. If the quorum is not reached, the proposal is rejected.

Expand Down Expand Up @@ -187,8 +187,8 @@ Then, replace the generated metadata field with the IPFS CID.

The `draft-proposal` command has now generated two files:

* **draft_metadata.json**
* **draft_proposal.json**
* **draft_metadata.json**
* **draft_proposal.json**

The content of `draft_metadata.json` contains the information you have just entered:

Expand Down Expand Up @@ -231,7 +231,7 @@ $ simd tx gov submit-proposal draft_proposal.json --from alice --keyring-backend
The command outputs a transaction hash. You can use it to query the proposal:
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved

```sh
$ simd query tx 3447C74EE19EF5E4B413547F1809C1E2026A7B7A8281366F88174F37D87F7060 --output json
$ simd query tx D8F1165AAB343EB9416F1DF3D30F2883D26E1125AED733878C590E60256ED9C9
```

## View and vote on proposals
Expand Down Expand Up @@ -300,7 +300,25 @@ $ simd tx gov vote 1 yes --from alice --keyring-backend test
$ simd tx gov vote 1 no --from bob --keyring-backend test
```

<!-- TODO -->
After waiting the voting period, you can see that the proposal passed.
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved

```sh
$ simd query gov proposal 1 --output json | jq .status
```

This is because the governance proposal weight the votes given the amount of token staked. Alice had staked tokens, while Bob had no token staked. So Bob's vote was not took into consideration in the tally of the result.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is because the governance proposal weight the votes given the amount of token staked. Alice had staked tokens, while Bob had no token staked. So Bob's vote was not took into consideration in the tally of the result.
This is because the governance proposal weights each vote by the amount of tokens staked. Alice owns staked tokens, while Bob has no staked tokens. So Bob's vote was not taken into consideration in the tally of the result.

Do you want to put a word about what Alice can do with her staked tokens after voting? In particular if the voting period is longer than the unstaking period?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean by this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Alice votes Yes with 1 million ATOM.
  • Alice unstakes her million ATOM and waits 3 weeks.
  • Alice sends her million to Bob.
  • Bob votes Yes with 1 million ATOM.

This should not be allowed. It was possible because the voting period was longer than the unsticking period.

Copy link
Member Author

@julienrbrt julienrbrt Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it! However, this is a non issue because the vote weight is calculated at vote tally. So only Bob's vote will be counted in that case (if he staked).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmh, I don't like O(n) actions in blockchain 🤣
Are you sure there is nothing like intermediate tally, and when unstaking, your vote is updated on all proposals?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is why tally takes some time (and sometimes there are no blocks for x seconds due to that): https://github.com/cosmos/cosmos-sdk/blob/main/x/gov/keeper/tally.go#L37-L73

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol


```sh
$ simd query staking delegations $ALICE
$ simd query staking delegations $BOB
```

After a proposal execution, the deposit is refunded (unless a majority of `No with veto`). You can check the balance of Alice and Bob with the following commands:
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved

```sh
$ simd query bank balances $ALICE
$ simd query bank balances $BOB
```

## 🎉 Congratulations 🎉

Expand Down