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!: (x/gov) store an index of proposals that are in voting period #13576

Merged
merged 48 commits into from
Oct 26, 2022

Conversation

facundomedica
Copy link
Member

@facundomedica facundomedica commented Oct 18, 2022

Description

Now we keep track of proposals that are in voting period in a separate store. This way we only have to read a single byte to know if a vote can get accepted.

Thanks @AmauryM for coming up with a better way to do it :)

Closes: #12688


Author 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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@facundomedica facundomedica changed the title (x/gov) feat: move parts of Proposal into separate storages feat: (x/gov) move parts of Proposal into separate storages Oct 18, 2022
@facundomedica facundomedica changed the title feat: (x/gov) move parts of Proposal into separate storages feat!: (x/gov) move parts of Proposal into separate storages Oct 18, 2022
x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/abci.go Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Oct 18, 2022

Codecov Report

Merging #13576 (8707966) into main (2418c3e) will decrease coverage by 0.09%.
The diff coverage is 78.37%.

❗ Current head 8707966 differs from pull request most recent head aa1ed8b. Consider uploading reports for the commit aa1ed8b to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13576      +/-   ##
==========================================
- Coverage   54.89%   54.79%   -0.10%     
==========================================
  Files         655      655              
  Lines       56239    56182      -57     
==========================================
- Hits        30870    30786      -84     
- Misses      22845    22871      +26     
- Partials     2524     2525       +1     
Impacted Files Coverage Δ
x/gov/types/keys.go 88.88% <0.00%> (-3.42%) ⬇️
x/gov/migrations/v4/store.go 81.63% <70.00%> (-8.03%) ⬇️
x/gov/keeper/proposal.go 81.81% <100.00%> (+0.64%) ⬆️
x/gov/keeper/vote.go 95.06% <100.00%> (-0.12%) ⬇️
x/gov/migrations/v4/keys.go 100.00% <100.00%> (ø)
x/distribution/simulation/operations.go 80.64% <0.00%> (-9.68%) ⬇️
crypto/keys/internal/ecdsa/privkey.go 81.13% <0.00%> (-1.89%) ⬇️
x/auth/tx/builder.go 80.19% <0.00%> (-1.46%) ⬇️
baseapp/baseapp.go 75.12% <0.00%> (ø)
types/mempool/nonce.go

x/gov/abci.go Fixed Show fixed Hide fixed
x/gov/types/keys.go Outdated Show resolved Hide resolved
@@ -87,6 +87,12 @@ func (q Keeper) Proposals(c context.Context, req *v1.QueryProposalsRequest) (*v1
return nil, status.Error(codes.Internal, err.Error())
}

// Populate contents given that we are iterating the store keys and not using
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder. If this is used by a CW contract. Maybe we extend the request type to include a field include_content? This way a client can indicate if they want content or not to save gas costs.

x/gov/keeper/proposal.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added the C:CLI label Oct 24, 2022
@facundomedica facundomedica changed the title feat!: (x/gov) move parts of Proposal into separate storages feat!: (x/gov) store an index of proposals that are in voting period Oct 24, 2022
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

lgtm, pending spec update (which is not blocking)

ActiveProposalQueuePrefix = []byte{0x01}
InactiveProposalQueuePrefix = []byte{0x02}
ProposalIDKey = []byte{0x03}
VotingPeriodProposalKeyPrefix = []byte{0x04}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update the spec/README.md file too? Just add some info about this new state

Copy link
Member Author

Choose a reason for hiding this comment

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

Doing it now, ty! As a note I think the store section is not entirely accurate (or at least not very easy to understand), but I'll that there and re-visit later.

@facundomedica facundomedica enabled auto-merge (squash) October 26, 2022 14:37
@facundomedica facundomedica merged commit 91ca57b into main Oct 26, 2022
@facundomedica facundomedica deleted the facu/gov-storage branch October 26, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x/gov: Change proposal state storage, so votes do not read static data
5 participants