-
Notifications
You must be signed in to change notification settings - Fork 251
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: update x/gov
module parsing
#652
Conversation
… validators status proposals snapshots
…urned from the msg when refetching proposal
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.
Cuz I'm not familiar with bdjuno enough, you will see questions more than comments 😂 And wonder if there are anyone else to approve the changes but if not I can help approve if needed 🙏
database/schema/08-gov.sql
Outdated
@@ -29,7 +29,7 @@ CREATE TABLE proposal_deposit | |||
amount COIN[], | |||
timestamp TIMESTAMP, | |||
height BIGINT NOT NULL, | |||
CONSTRAINT unique_deposit UNIQUE (proposal_id, depositor_address) | |||
CONSTRAINT unique_deposit UNIQUE (proposal_id, depositor_address, amount) |
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.
Does it mean in a proposal it is indeed not possible to have multiple deposits with the same amount from the same depositor address? Or this change is simply taking advantage of indexing? @@
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.
I added this because sometimes the same address will pay the deposit in more than one txs (eg first deposit 100 DARIC, and later deposit 400 DARIC in a different tx) and right now only the latest deposit will be stored for given address inside the proposal_deposit
table so by updating this constraint we can store all deposits correctly
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.
Also, I just updated it and added timestamp to the unique_deposit
constraint to handle the edge cases where address can pay the same amount of deposit twice in different txs (eg. deposit 100 DARIC first, later deposit 100 DARIC again)
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.
In this case can we also store the txHash
and use it as a unique constraint? 🤔 It sounds more like a unique identifier for a proposal deposit instead of relying on timestamp and amount?
Or if txn timestamp must be unique across deposits and txns, we can remove amount
from the unique constraint?
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.
Ok I added transaction_hash
to proposal_deposit
table and updated unique_deposit
constraint. I didn't create the reference to message table because genesis deposits doesn't contain tx hash details, so proposal deposits stored from genesis file will have empty string inside transaction_hash
column
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.
(not change request) I see that we actually use UPSERT (i.e. INSERT ON CONFLICT UPDATE) quite intensively in this project. In general if we are certain about an operation is going to be an UPDATE, it's always better to use UPDATE
statement directly so psql will not bother attempting to insert and receive an error @@
database/schema/08-gov.sql
Outdated
@@ -29,7 +29,7 @@ CREATE TABLE proposal_deposit | |||
amount COIN[], | |||
timestamp TIMESTAMP, | |||
height BIGINT NOT NULL, | |||
CONSTRAINT unique_deposit UNIQUE (proposal_id, depositor_address) | |||
CONSTRAINT unique_deposit UNIQUE (proposal_id, depositor_address, amount) |
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.
In this case can we also store the txHash
and use it as a unique constraint? 🤔 It sounds more like a unique identifier for a proposal deposit instead of relying on timestamp and amount?
Or if txn timestamp must be unique across deposits and txns, we can remove amount
from the unique constraint?
Closes: #XXXX [BDU-11](https://forbole.atlassian.net/browse/BDU-11) [BDU-771](https://forbole.atlassian.net/browse/BDU-771) [BDU-1077](https://forbole.atlassian.net/browse/BDU-1077) Changes: `gov` module: - Added handler on every block to check and update proposal status if `active_proposal` event has been emitted inside the EndBlockEvents - Added periodic operations to update `proposal staking pool snapshots` every 5 mins - Added periodic operations to update `proposal tally results` every 5 mins - Added handler to update `tally results` for given proposal on every `MsgVote` and `MsgVoteWeighted` msgs - Added handler for rpc error `rpc error returning code = NotFound desc = proposal x doesn't exist` returned from node sometimes when processing `MsgSubmitProposal` msg and querying the node for proposal details - Added amount to `unique_deposit` constraint to allow to store different deposits from the same address for the same proposal - Added `weight` column to `proposal_vote` table and added `option` to `unique_vote` constraint - Added handler for `MsgVoteWeighted` msgs to correctly store votes in db - Removed `auth` module from expected modules `staking` module: - Added periodic operations to update validators statuses, voting power and proposal validators status snapshots every 5 mins - Added handler to update validators statuses, voting powers and proposals validators status snapshots when there is a VP change on `MsgDelegate`, `MsgBeginRedelegate` and `MsgUndelegate` msgs --- *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch - [x] provided a link to the relevant issue or specification - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) [BDU-11]: https://forbole.atlassian.net/browse/BDU-11?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [BDU-771]: https://forbole.atlassian.net/browse/BDU-771?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [BDU-1077]: https://forbole.atlassian.net/browse/BDU-1077?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Description
Closes: #XXXX
BDU-11
BDU-771
BDU-1077
Changes:
gov
module:active_proposal
event has been emitted inside the EndBlockEventsproposal staking pool snapshots
every 5 minsproposal tally results
every 5 minstally results
for given proposal on everyMsgVote
andMsgVoteWeighted
msgsrpc error returning code = NotFound desc = proposal x doesn't exist
returned from node sometimes when processingMsgSubmitProposal
msg and querying the node for proposal detailsunique_deposit
constraint to allow to store different deposits from the same address for the same proposalweight
column toproposal_vote
table and addedoption
tounique_vote
constraintMsgVoteWeighted
msgs to correctly store votes in dbauth
module from expected modulesstaking
module:MsgDelegate
,MsgBeginRedelegate
andMsgUndelegate
msgsAuthor Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change