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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
63c6057
(x/gov) feat: move parts of Proposal into separate storages
facundomedica Oct 18, 2022
d8219fc
fix some
facundomedica Oct 18, 2022
cb12f0e
fix others
facundomedica Oct 18, 2022
5514486
fix unit tests
facundomedica Oct 18, 2022
1d62ba4
fix unit tests
facundomedica Oct 18, 2022
4b97f7b
fix conflicts
facundomedica Oct 18, 2022
d9364d4
fix conflicts
facundomedica Oct 18, 2022
8e838f5
progress
facundomedica Oct 18, 2022
3fccb66
do not overwrite messages
facundomedica Oct 18, 2022
e2bef95
remove change
facundomedica Oct 18, 2022
82998ef
simplify methods
facundomedica Oct 19, 2022
da271d5
static data
facundomedica Oct 19, 2022
601c411
fix tests
facundomedica Oct 19, 2022
162353c
fix tests
facundomedica Oct 19, 2022
04e9308
fix tests
facundomedica Oct 19, 2022
d62d0c1
rollback some changes
facundomedica Oct 19, 2022
733f286
rollback some changes
facundomedica Oct 19, 2022
d7918b7
progress
facundomedica Oct 19, 2022
d9d339f
progress
facundomedica Oct 19, 2022
1f32225
progress
facundomedica Oct 19, 2022
b5b2ada
progress
facundomedica Oct 19, 2022
37af9c4
progress
facundomedica Oct 19, 2022
1a9a443
progress
facundomedica Oct 19, 2022
2edde57
add delete
facundomedica Oct 19, 2022
f4a128f
fix tests
facundomedica Oct 19, 2022
3f8936e
use SetProposalWithoutContents whenever possible
facundomedica Oct 19, 2022
46b087c
add migrations
facundomedica Oct 19, 2022
59dc8a7
fix godoc
facundomedica Oct 19, 2022
d7c8cd1
gofumpt
facundomedica Oct 19, 2022
78dbf6c
Merge branch 'main' into facu/gov-storage
facundomedica Oct 19, 2022
ece934d
add changelog
facundomedica Oct 19, 2022
c3af4cf
rolling back changes
facundomedica Oct 24, 2022
59434a7
rolling back changes
facundomedica Oct 24, 2022
2d07421
progress
facundomedica Oct 24, 2022
4ecb17c
progress
facundomedica Oct 24, 2022
c20b48f
progress
facundomedica Oct 24, 2022
dd38f3d
progress
facundomedica Oct 24, 2022
b6e24af
fix tests
facundomedica Oct 24, 2022
ecc8917
fix cl
facundomedica Oct 24, 2022
fc8b9d0
fix cl
facundomedica Oct 24, 2022
cd2ae66
fix
facundomedica Oct 24, 2022
ff62538
fix test error
facundomedica Oct 24, 2022
e23a08b
Merge branch 'main' into facu/gov-storage
facundomedica Oct 25, 2022
e42c114
add store key in readme
facundomedica Oct 26, 2022
97e54bd
add store key in readme
facundomedica Oct 26, 2022
0bda41c
Merge branch 'main' into facu/gov-storage
facundomedica Oct 26, 2022
8707966
Merge branch 'facu/gov-storage' of https://github.com/cosmos/cosmos-s…
facundomedica Oct 26, 2022
aa1ed8b
Merge branch 'main' into facu/gov-storage
facundomedica Oct 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
progress
  • Loading branch information
facundomedica committed Oct 19, 2022
commit d7918b7e8eed89ff5454ece90b93ff33ea41ebde
6 changes: 3 additions & 3 deletions proto/cosmos/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ message Proposal {
string metadata = 10;
}

// ProposalStaticData defines the static data of a governance proposal. This data
// is going to be stored separately from the Proposal object to avoid incurring
// ProposalContents defines the contents (static data) of a governance proposal.
// This data is stored separately from the Proposal object to avoid incurring
// into high gas costs when querying/updating the main proposal object.
message ProposalStaticData {
message ProposalContents {
repeated google.protobuf.Any messages = 1;
string metadata = 2;
}
Expand Down
19 changes: 5 additions & 14 deletions x/gov/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,13 @@ func (keeper Keeper) setProposalStaticData(ctx sdk.Context, proposalID uint64, d
store.Set(types.ProposalStaticDataKey(proposalID), bz)
}

// PopulateProposalStaticData populates the proposal's static data from the separate stores.
// PopulateProposalStaticData populates the proposal's contents from the separate store.
func (keeper Keeper) PopulateProposalStaticData(ctx sdk.Context, proposal *v1.Proposal) {
staticData, found := keeper.getProposalStaticData(ctx, proposal.Id)
if found {
proposal.Messages = staticData.Messages
proposal.Metadata = staticData.Metadata
}
}

// getProposalMessages gets the proposal's messages from the separate store.
// TODO: define if we would like this to be exported.
func (keeper Keeper) getProposalStaticData(ctx sdk.Context, proposalID uint64) (v1.ProposalStaticData, bool) {
store := ctx.KVStore(keeper.storeKey)

bz := store.Get(types.ProposalStaticDataKey(proposalID))
bz := store.Get(types.ProposalStaticDataKey(proposal.Id))
if bz == nil {
return v1.ProposalStaticData{}, false
return
}

var staticData v1.ProposalStaticData
Expand All @@ -202,7 +192,8 @@ func (keeper Keeper) getProposalStaticData(ctx sdk.Context, proposalID uint64) (
panic(err)
}

return staticData, true
proposal.Messages = staticData.Messages
proposal.Metadata = staticData.Metadata
}

// DeleteProposal deletes a proposal from store.
Expand Down