interchain-security icon indicating copy to clipboard operation
interchain-security copied to clipboard

feat: PSS - Add minimum power in top N & power shaping params to consumer chain list

Open p-offtermatt opened this issue 9 months ago • 3 comments

Description

Closes: #1821

Instead of adding a new query, I decided to go with a suggestion from @freak12techno and return the minimum power in the top N as part of the consumer chain list. I also include the power shaping params for the chain in the query (thanks to @insumity for the suggestion) since we already include the top N param there

Notes:

  • The Chain struct is not used anywhere else afaict, so this should not impact any other queries.
  • This is additional computational effort for this query. imo, we shouldn't worry about this yet; it's a query, so doesn't run on-chain. If we get evidence that this is too expensive, we can adjust, e.g. via #1840

If we decide to merge this, I will also adjust the docs PR #1859 to mention this


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

  • [x] Included the correct type prefix in the PR title
  • [x] Added ! to the type prefix if the change is state-machine breaking
  • [x] Confirmed this PR does not introduce changes requiring state migrations, OR migration code has been added to consumer and/or provider modules
  • [x] Targeted the correct branch (see PR Targeting)
  • [x] Provided a link to the relevant issue or specification
  • [x] Followed the guidelines for building SDK modules
  • [x] Included the necessary unit and integration tests
  • [x] Added a changelog entry to CHANGELOG.md
  • [x] Included comments for documenting Go code
  • [x] Updated the relevant documentation or specification
  • [x] Reviewed "Files changed" and left comments if necessary
  • [ ] Confirmed all CI checks have passed
  • [ ] If this PR is library API breaking, bump the go.mod version string of the repo, and follow through on a new major release

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 ! the type prefix if the change is state-machine breaking
  • [ ] confirmed this PR does not introduce changes requiring state migrations, OR confirmed migration code has been added to consumer and/or provider modules
  • [ ] 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

Summary by CodeRabbit

  • New Features
    • Added a new field min_power_in_top_N to the Chain message, enabling the app to consider minimum power requirements for top N chains.
  • Enhancements
    • Implemented logic to compute MinPowerInTop_N in the GetAllConsumerChains function, enhancing accuracy in chain ranking calculations.
  • Tests
    • Expanded testing coverage by mocking validator set and setting Top N parameters in TestGetAllConsumerChains to validate power-based results effectively.

p-offtermatt avatar May 07 '24 06:05 p-offtermatt

Walkthrough

Walkthrough

The updates involve introducing a new metric, min_power_in_top_N, to determine the minimum power required to be among the top N chains in the interchain security feature. These changes span across the query.proto file, keeper.go, and related tests to incorporate this new functionality effectively.

Changes

File Path Change Summary
proto/interchain_security/ccv/provider/v1/query.proto Added min_power_in_top_N field to the Chain message.
x/ccv/provider/keeper/keeper.go Updated GetAllConsumerChains to compute MinPowerInTop_N in types.Chain. Added new functions for allowlist and denylist retrieval.
x/ccv/provider/keeper/keeper_test.go Added imports and modified tests to support changes in GetAllConsumerChains.

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Add query for current minimum stake to be opted in (#1821) The changes introduce min_power_in_top_N for top chains rather than directly addressing the query for the minimal stake needed to be automatically opted in on a consumer chain as specified in the issue.

Recent Review Details

Configuration used: .coderabbit.yml Review profile: CHILL

Commits Files that changed from the base of the PR and between 07067b9526a9adc31a47cf26155d2813121b8dd3 and 919ff510d7ff7319e778c55147f4a024516d09b4.
Files selected for processing (2)
  • .changelog/unreleased/api-breaking/provider/1863-add-minimum-power-in-topN-to-consumer-chain-list.md (1 hunks)
  • .changelog/unreleased/features/provider/1863-add-minimum-power-in-topN-to-consumer-chain-list.md (1 hunks)
Additional comments not posted (1)
.changelog/unreleased/features/provider/1863-add-minimum-power-in-topN-to-consumer-chain-list.md (1)

2-2: Add a newline at the end of the file to conform to Unix text file standards.

+ 

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

coderabbitai[bot] avatar May 07 '24 06:05 coderabbitai[bot]

LGTM

Just two questions:

  1. I guess we can backport this to 4.2.x and 4.2.x-lsm?
  2. Because we already show top_N in this list-of-consumer-chains query, I think it would make sense to also show the rest of the power-shaping parameters (i.e., validator-set cap, validator-power cap, allowlist, and denylist)?

insumity avatar May 07 '24 08:05 insumity

Thanks, good points. Yes and yes, I think!

p-offtermatt avatar May 07 '24 08:05 p-offtermatt