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

[Persistence] Optimize gov params schema (Issue #76) #139

Merged

Conversation

deblasis
Copy link
Contributor

@deblasis deblasis commented Aug 1, 2022

Description

Currently WIP and paused because of #76 (comment)

This PR changes the schema for params, adds flags (to be implemented) and aims at improving the way we update the values.

It should also improve maintainability by:

  • centralizing Gov schema related metadata into the protobuf by attaching metadata to it. (see gov.proto)
  • using generics for get/set methods

Fixes issue/76

Type of change

Please mark the options that are relevant.

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation
  • Other (<REPLACE_ME_WITH_DETAILS>)

How Has This Been Tested?

[Not needed for integration PR]

Describe the tests and that you ran to verify your changes. If applicable, provide steps to reproduce. Bonus points for images and videos or gifs.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested my changes using the available tooling
  • If applicable, I have made corresponding changes to related or global README
  • If applicable, I have added added new diagrams using mermaid.js
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • I have documented flags and their differences with params as per comment

persistence/db.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
@Olshansk Olshansk added core Core infrastructure - protocol related persistence Persistence specific changes code health Nice to have code improvement labels Aug 1, 2022
@Olshansk Olshansk added this to the V1 Persistence Foundation milestone Aug 1, 2022
Makefile Outdated Show resolved Hide resolved
shared/types/genesis/proto/gov.proto Show resolved Hide resolved
persistence/db.go Outdated Show resolved Hide resolved
persistence/db.go Outdated Show resolved Hide resolved
persistence/gov.go Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
@Olshansk
Copy link
Member

Olshansk commented Aug 1, 2022

I did a quick first review (will do an in-depth one next time) but this is frikkin awesome!

I think we should continue moving forward with it and the changes are well contained enough that I don't think the conflicts with deprecating persistence will be that bad. CC @andrewnguyen22

@deblasis
Copy link
Contributor Author

deblasis commented Aug 2, 2022

Thanks @Olshansk! I have caught up with main and updated a few things but I will dive deeper and also test the parts I didn't test yet (Get/Set) after your next in-depth look and which should give me more clarity around how to use enabled and snapshotting 🙂.

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

Left additional comments throughout the PR (some impacting the rest of the DB).

At a high-level, the summary of the architectural changes is:

  • shared/modules/persistence_module.go needs to be modified to accept a height for each Get call - Eventually I want to simplify that too, but we can do that later
  • Remove the nullify query altogether - it's legacy and we can add it back later
  • Params should now have an enabled field but flags should
  • Flags are not used in the database yet, but we already use it for v0 and I think most of the foundation we need for it in v1 is already in this PR.

Let me know if you need any more details and we can jump on a call!

Makefile Outdated Show resolved Hide resolved
persistence/db.go Show resolved Hide resolved
persistence/db.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
Updated also with  so it doesn't show up in our makefile help since
it is an internal command basically
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

tl;dr Almost :shipit:. Please hold off on squashing and merging

I've re-reviewed this whole PR and just left a couple of minor final NITs.

Overall, I really like the change and it'll make it much easier to both add and extend on our param+flag logic.

Going to approve this change but please hold off on @andrewnguyen22's review before submitting. After he take a look, we'll also need to make a call on whether we want to submit this before or after #140 as there will definitely be conflicts, but I'm sure we can figure it out.

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

Unapprove to avoid accidental merge.

@Olshansk Olshansk self-requested a review August 8, 2022 23:24
@deblasis
Copy link
Contributor Author

deblasis commented Aug 9, 2022

Unapprove to avoid accidental merge.

This gave me the inspiration needed for this #160 and consequently #161

persistence/gov.go Outdated Show resolved Hide resolved
utility/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Outdated Show resolved Hide resolved
persistence/schema/gov.go Show resolved Hide resolved
shared/modules/persistence_module.go Outdated Show resolved Hide resolved
@Olshansk Olshansk added the do not merge Prevent merging even with sufficient approvals label Aug 11, 2022
@Olshansk
Copy link
Member

@andrewnguyen22
Copy link
Contributor

andrewnguyen22 commented Aug 14, 2022

I think that makes sense.

But let's talk offline per #128

EDIT: The one blocker I see here are that I'm not sure 'flags' were ever documented as asked in here

@Olshansk
Copy link
Member

@deblasis We're likely going to merge #140 soon, so just a heads up that it'll require a fair amount of conflict resolution.

Otherwise, the only blocker here after synching with @andrewnguyen22 is adding some documentation explaining the different between flags and params. There is an FAQ section under persistence/README.md, so I think that'd be a good spot to add it.

@deblasis
Copy link
Contributor Author

@deblasis We're likely going to merge #140 soon, so just a heads up that it'll require a fair amount of conflict resolution.

ACK. No problem, I subscribed to that issue so I have been quietly stalking you guys and I saw this coming soon my way 🙂

Otherwise, the only blocker here after synching with @andrewnguyen22 is adding some documentation explaining the different between flags and params. There is an FAQ section under persistence/README.md, so I think that'd be a good spot to add it.

Cool, will do, thanks @Olshansk !
(updated PR checklist)

@@ -145,6 +145,12 @@ For example, on macOS, you can check for this with `lsof -i:5432` and kill the a
**Q**: Why not use an ORM?
**A**: We are trying to keep the module small and lean initially but are ope
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that the sentence here is truncated :)

Copy link
Member

Choose a reason for hiding this comment

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

Hahaha, I think open to suggestions is what we wanted to say 😅

Comment on lines +148 to +153
**Q**: What is a `Param` in the `Gov` schema?
**A**: It represents a value associated with a name and a height that we can reference to represent governance settings. These settings have the power of altering the behaviour of various aspects of the network.

**Q**: What is a `Flag` in the `Gov` schema?
**A**: A flag is very much alike a `Param` with the difference that it also has a boolean flag to specify if that setting is enabled or not at any point in time (height). We are discussing if we should replace the boolean flag and allow multivariate feature flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andrewnguyen22: I have added some color here about flags/params.

Everything (very little 😅) I know about flags comes from this comment #76 (comment) and subsequent conversations with @Olshansk in the form of comments to this PR.

One thing I assumed initially, that I later changed to the current code, was that flags shouldn't have a value like params but just a boolean flag. Maybe the truth is a bit of both: we should remove the enabled in flags and create logic around the value that we can define as float to handle multivariate flags later on, perhaps this would be out of scope for this PR but I am happy to change things if needed.

As things stand, these descriptions should fit, even though we are not yet using flags anywhere so I am assuming that this is very much subject to change as we iterate regardless.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the extra context. I think the flag concept will definitely evolve but the current description and implementation is more than sufficient to move forward.

@Olshansk Olshansk removed the do not merge Prevent merging even with sufficient approvals label Aug 17, 2022
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

LGTM! Let's :shipit:

I removed the do not merge, retriggered the jobs and am approving.

@deblasis What we've been doing is doing a squash-and-merge and copy-pasting the github description into the commit.

I looked at the two issues in the jobs, and they are related to our docker images and a test that's flaky in our consensus algorithm (related to the pacemaker). Will sync with @okdas on this but it doesn't block this PR.

@andrewnguyen22
Copy link
Contributor

andrewnguyen22 commented Aug 17, 2022

Why is the automation failing on this? @Olshansk

@Olshansk
Copy link
Member

Same reasons as last night:

  1. Flaky consensus test related to the pacemaker where I use timeouts. AI on @Olshansk to fix it
  2. Bad credentials to log into dockerhub to build the image. AI on @okdas.

Attaching screenshots from the link above for context. I don't think either are blockers.

Screen Shot 2022-08-17 at 9 17 30 AM

Screen Shot 2022-08-17 at 9 17 27 AM

Screen Shot 2022-08-17 at 9 17 22 AM

@Olshansk Olshansk merged commit f9ddc09 into pokt-network:main Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Nice to have code improvement core Core infrastructure - protocol related persistence Persistence specific changes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Persistence] Optimize gov params schema
3 participants