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

Fix decoding of gov props with a ParameterChangeProposal in them. #2198

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

SpicyLemon
Copy link
Contributor

@SpicyLemon SpicyLemon commented Oct 24, 2024

Description

Currently on testnet (running v1.20.0-rc2 or -rc3):

  • If you do a provenanced query gov proposals you'll get Error: rpc error: code = Unknown desc = runtime error: invalid memory address or nil pointer dereference: panic.
  • If you do provenanced query gov proposal 133, you get Error: rpc error: code = Unknown desc = rpc error: code = Internal desc = collections: encoding error: value decode: no concrete type registered for type URL /cosmos.params.v1beta1.ParameterChangeProposal against interface *v1beta1.Content: unknown request.

This is because several gov props (4, 14, 18, 23, 47, 49, 50, 86, 94, 103, 104, 133) have a ParameterChangeProposal in them. In v1.20, we completely removed the params module. With that, we stopped registering its types with the various codecs. But those gov props are stored in state, so we still need to be able to do stuff with them.

This PR registers the params module stuff with the codecs again, so that those old gov props can be read again.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Added relevant changelog entries under .changelog/unreleased (see Adding Changes).
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Summary by CodeRabbit

  • New Features

    • Introduced a registration mechanism for legacy governance properties, enhancing compatibility with older data formats.
    • Added functionality for managing parameter change proposals within the governance module.
  • Bug Fixes

    • Improved the system's ability to interpret and process older governance properties.
  • Tests

    • Added a new test case to validate the creation and serialization of parameter change proposals.

…ChangeProposal in it because that type isn't being registered anymore.
…ov props with a ParameterChangeProposal in them.
@SpicyLemon SpicyLemon requested a review from a team as a code owner October 24, 2024 19:01
Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

This pull request introduces a registration mechanism for parameter types with codecs, enabling the reading of legacy governance properties. Key modifications include the integration of a new paramprops module in the app.go file, which registers legacy codecs and interfaces. Additionally, a new test function is added in app_test.go to validate the creation and serialization of parameter change proposals. These changes enhance the application's ability to manage governance parameters while maintaining compatibility with older data formats.

Changes

File Change Summary
.changelog/unreleased/bug-fixes/2198-fix-gov-props.md Introduces a registration mechanism for parameter types with codecs for legacy governance properties.
app/app.go Integrates paramprops module; registers legacy amino codec and interfaces; updates comments.
app/app_test.go Adds TestParamChangeInGovProp to test parameter change proposal creation and serialization.

Possibly related PRs

Suggested reviewers

  • iramiller
  • Taztingo

🐇 In the meadow, I hop and play,
New features bloom, bright as the day.
Parameters dance, in codecs they twirl,
Governance strong, watch the flags unfurl!
With tests in place, all's set to go,
Hooray for the changes, let's put on a show! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@SpicyLemon SpicyLemon enabled auto-merge (squash) October 24, 2024 19:03
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
app/app_test.go (1)

472-475: Consider using constants for time durations.

The time durations (1 minute, 3500 milliseconds, 48 hours) could be defined as constants at the package level for better maintainability and reusability.

+const (
+    depositPeriod     = 1 * time.Minute
+    votingStartDelay  = 3500 * time.Millisecond
+    votingPeriod      = 48 * time.Hour
+)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 75e9089 and 48b8891.

📒 Files selected for processing (3)
  • .changelog/unreleased/bug-fixes/2198-fix-gov-props.md (1 hunks)
  • app/app.go (2 hunks)
  • app/app_test.go (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changelog/unreleased/bug-fixes/2198-fix-gov-props.md
🔇 Additional comments (4)
app/app_test.go (2)

8-8: LGTM! Required imports added for parameter change proposal testing.

The new imports are necessary for handling time-based operations, codec types, governance types, and parameter change proposals.

Also applies to: 20-20, 28-29


448-528: LGTM! Well-structured test for parameter change proposal decoding.

The test comprehensively validates the encoding/decoding of parameter change proposals, directly addressing the issue described in the PR objectives.

app/app.go (2)

101-101: LGTM: Import required for legacy parameter types.

The import of paramprops package is necessary to handle legacy governance proposals containing parameter changes, even though the params module has been removed.


790-793: LGTM: Codec registration enables reading legacy parameter change proposals.

The registration of legacy amino codec and interfaces for parameter change proposals is necessary to decode existing governance proposals, even though the params module has been removed. The comment clearly explains the rationale.

Let's verify that these are the only parameter-related types being registered:

✅ Verification successful

The search results confirm that these are the only parameter-related codec registrations in the codebase. Let me verify the specific paramprops package usage to ensure it's properly scoped.


LGTM: Parameter proposal codec registration is correctly implemented

The verification confirms that:

  • The paramprops package is only used for codec registration in app.go and for testing parameter change proposals in app_test.go
  • The import is properly marked with a nolint comment explaining its necessity for legacy type registration
  • The usage is minimal and focused only on handling existing governance proposals
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other parameter-related type registrations
# Test: Search for param-related codec registrations. Expect: Only the two we added.

rg -i 'param.*register.*(?:amino|interface)' --type go

Length of output: 178


Script:

#!/bin/bash
# Check the imports and usage of paramprops package
rg -g '*.go' 'paramprops' -A 2

Length of output: 965

app/app_test.go Show resolved Hide resolved
@SpicyLemon SpicyLemon merged commit 66e7eb0 into main Oct 24, 2024
34 checks passed
@SpicyLemon SpicyLemon deleted the dwedul/fix-gov-props branch October 24, 2024 20:12
SpicyLemon added a commit that referenced this pull request Oct 24, 2024
)

* Write a unit test that fails to parse a gov proposal with a ParameterChangeProposal in it because that type isn't being registered anymore.

* Register the params module stuff with the codecs since there's some gov props with a ParameterChangeProposal in them.

* Add changelog entry.
SpicyLemon added a commit that referenced this pull request Oct 24, 2024
…tion events), #2196 (timeout_commit), #2197 (recordspec cmd), #2198 (ParameterChangeProposal) #2199 (wasm build-address cmd). (#2200)

* Suppress scope value owner migration events. (#2195)

* Create a no-op event manager and use that during the metadata module migration.

* Do not suppress the events for a testnet upgrade since they were emitted when the migration ran on testnet.

* Add changelog entry.

* Update all the spec proto links to reference v1.20.0 (#2192)

* Update all the spec proto links to reference v1.20.0 (instead of 1.19.0).

* Add changelog entry.

* When prepping a release, combine the dependency bump changelog entries. (#2181)

* Add a note to get-dep-changes to alert folks that changing those formats might break other things.

* Create an awk script that will combine dependency changelog entries. Update prep-release to use it. Also apply a couple fixes that are alread in the release branch (and will be in main shortly). Also tweak the step 4 and 5 names to provide more context, and fix the verbose output header when recombining the sections.

* Add changelog entry.

* Clarify the new comment in get-dep-changes.sh.

* Update stuff that uses or talks about RELEASE_NOTES.md because it should actually be RELEASE_CHANGELOG.md. The SDK uses _NOTES but only puts a blurb in there, so it's not a changelog. But we include a changelog, so it makes sense to keep it named that way.

* Fix the `query metadata recordspec` command when given a rec-spec-id. (#2197)

* [2148]: Fix the query metadata recordspec command to correctly use the RecordSpecification query (instead of RecordSpecificationsForContractSpecification) when provided a record specification id.

* [2148]: Add changelog entry.

* Fix decoding of gov props with a ParameterChangeProposal in them. (#2198)

* Write a unit test that fails to parse a gov proposal with a ParameterChangeProposal in it because that type isn't being registered anymore.

* Register the params module stuff with the codecs since there's some gov props with a ParameterChangeProposal in them.

* Add changelog entry.

* Hard-code consensus.timeout_commit to 3.5s for mainnet. (#2196)

* [2121]: Change the default consensus timeout value to 3.5 seconds.

* [2121]: Hard-code the consensus.timeout_commit value.

* [2121]: Fix TestIsTestnetFlagSet to not be affected by existing env vars.

* [2121]: Fix a couple unit tests that broke when I changed the default commit timout.

* [2121]: Only hard-code the timeout commit on non-testnets.

* [2121]: Change the default back to 1.5s for faster default testnets.

* [2121]: Fix the TestPreUpgradeCmd that broke because of the hard-coded timeout commit.

* [2121]: Add some unit tests that make sure the consensus timeout commit value is behaving as expected.

* [2121]: Add changelog entry.

* [2121]: When forcing the timeout_commit to be 3.5 seconds, also force the skip flag to be false.

* [2121]: Update warnAboutSettings: Evaluate the timeout commit and skip-timeout-commit fields separately. Issue a warning if skip-timeout-commit is true. Issue a warning if the timeout commit is not exactly what we want it to be.

* Fix: Add node flag to WASM queries (build-address) (#2199)
@coderabbitai coderabbitai bot mentioned this pull request Oct 25, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants