-
Notifications
You must be signed in to change notification settings - Fork 310
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
Governance indexing #4774
Governance indexing #4774
Conversation
Slightly redundant, but the governance indexer wants this, so we can have it too.
Co-authored-by: plaidfinch <plaidfinch@users.noreply.github.com>
8b6a238
to
fc7417c
Compare
Closing in favor of the original work in #4708 which powers the governance frontend. |
/// One of the possible events that we care about. | ||
#[derive(Clone, Debug)] | ||
enum Event { | ||
ProposalSubmit { |
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.
We don't need to define an event enum here. Processing the events, as in the original code, works fine.
CREATE TABLE IF NOT EXISTS governance_proposals ( | ||
proposal_id INTEGER PRIMARY KEY, | ||
title TEXT NOT NULL, | ||
description TEXT NOT NULL, | ||
kind JSONB NOT NULL, | ||
payload JSONB, | ||
start_block_height BIGINT NOT NULL, | ||
end_block_height BIGINT NOT NULL, | ||
state JSONB NOT NULL, | ||
proposal_deposit_amount BIGINT NOT NULL, | ||
withdrawn BOOLEAN DEFAULT FALSE, | ||
withdrawal_reason TEXT | ||
); | ||
|
||
CREATE INDEX ON governance_proposals (title text_pattern_ops); | ||
CREATE INDEX ON governance_proposals (kind); | ||
CREATE INDEX ON governance_proposals (start_block_height DESC); | ||
CREATE INDEX ON governance_proposals (end_block_height DESC); | ||
CREATE INDEX ON governance_proposals (state); | ||
CREATE INDEX ON governance_proposals (withdrawn); | ||
|
||
|
||
CREATE TABLE IF NOT EXISTS governance_validator_votes ( | ||
id SERIAL PRIMARY KEY, | ||
proposal_id INTEGER NOT NULL, | ||
identity_key TEXT NOT NULL, | ||
vote JSONB NOT NULL, | ||
voting_power BIGINT NOT NULL, | ||
block_height BIGINT NOT NULL, | ||
FOREIGN KEY (proposal_id) REFERENCES governance_proposals(proposal_id) | ||
); | ||
|
||
CREATE INDEX ON governance_validator_votes (proposal_id); | ||
CREATE INDEX ON governance_validator_votes (identity_key); | ||
CREATE INDEX ON governance_validator_votes (vote); | ||
CREATE INDEX ON governance_validator_votes (voting_power); | ||
CREATE INDEX ON governance_validator_votes (block_height); | ||
|
||
|
||
CREATE TABLE IF NOT EXISTS governance_delegator_votes ( | ||
id SERIAL PRIMARY KEY, | ||
proposal_id INTEGER NOT NULL, | ||
identity_key TEXT NOT NULL, | ||
vote JSONB NOT NULL, | ||
voting_power BIGINT NOT NULL, | ||
block_height BIGINT NOT NULL, | ||
FOREIGN KEY (proposal_id) REFERENCES governance_proposals(proposal_id) | ||
); | ||
|
||
CREATE INDEX ON governance_delegator_votes (proposal_id); | ||
CREATE INDEX ON governance_delegator_votes (identity_key); | ||
CREATE INDEX ON governance_delegator_votes (vote); | ||
CREATE INDEX ON governance_delegator_votes (voting_power); | ||
CREATE INDEX ON governance_delegator_votes (block_height); | ||
|
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 doing this was already discussed in the original PR: #4708 (comment)
This should supercede #4708, now that the event changes have landed.
I took the structure in there, and munged it a bit to fit the current framework we use in the reset of the indexer code.
Checklist before requesting a review
If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: