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

add implementations to support gov-tx-proposal #240

Merged

Conversation

leonz789
Copy link
Contributor

@leonz789 leonz789 commented Nov 10, 2024

Description

gov module need those two interface from dogfood(/staking-module) to calculate power of votes to complete proposal.

Changes

  • set base-fee to 10hua in local_node.sh for easy test

Closes #XXX

Summary by CodeRabbit

  • New Features

    • Introduced new parameters for local node configuration, including a base fee setting.
    • Enhanced error handling and user prompts for configuration overwrites in the local node setup.
  • Improvements

    • Clarified functionality of the Delegation method to focus on self-delegation.
    • Added comments to methods for better understanding and future implementation guidance regarding multi-asset staking.
  • Bug Fixes

    • Improved error logging for USD value calculations in the staking interface.

Copy link
Contributor

coderabbitai bot commented Nov 10, 2024

Warning

Rate limit exceeded

@leonz789 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f85271b and 280ba21.

Walkthrough

The changes in this pull request involve modifications to the local_node.sh script and the impl_sdk.go file. The script now includes a new parameter for setting the base fee in the genesis configuration and updates various module parameters. In impl_sdk.go, the Keeper struct's methods have been clarified, particularly regarding self-delegation and USD value calculations, with TODO comments indicating future implementation needs.

Changes

File Path Change Summary
local_node.sh Introduced base fee parameter in genesis config, modified various jq commands to set parameters for crisis, governance, EVM, and assets, and maintained error handling and structure.
x/dogfood/keeper/impl_sdk.go Updated Delegation method for self-delegation clarity, added comments to IterateBondedValidatorsByPower, marked TotalBondedTokens and IterateDelegations with TODO comments for future implementation.

Suggested reviewers

  • cloud8little
  • trestinlsd
  • mikebraver
  • TimmyExogenous
  • adu-web3
  • bwhour

🐇 In the code we hop and play,
With fees and tokens on display.
A little tweak, a comment here,
Our local node, we hold so dear!
So let’s configure, set it right,
For a brighter coding night! 🌙


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.

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: 0

🧹 Outside diff range and nitpick comments (4)
x/dogfood/keeper/impl_sdk.go (2)

143-143: Enhance the documentation clarity.

While the note explains that this is not a universal delegation function, it would be helpful to explicitly mention which modules/cases this is designed for (e.g., governance module for voting power calculation).


Line range hint 236-247: Critical: Implement required governance module interfaces.

The current implementation with panic will break governance operations. These methods are essential for voting power calculation:

  1. TotalBondedTokens: Required to calculate the total voting power
  2. IterateDelegations: Required to calculate individual delegation voting power

The TODO comments provide good implementation guidance, but these methods need to be implemented before the governance module can function correctly. This contradicts the PR objective of supporting governance voting power calculation.

Would you like help implementing these methods according to the TODO comments? I can provide a detailed implementation that:

  • Calculates total bonded power compatible with multi-asset staking
  • Computes delegation shares based on USD power
local_node.sh (2)

Line range hint 266-267: Consider documenting the governance timing parameters.

The governance parameters have been adjusted for local testing:

  • max_deposit_period: 172800s → 30s
  • voting_period: 172800s → 30s

While these changes are appropriate for testing, consider adding a comment explaining these are test-specific values and what the production values should be.

+  # Note: These are test-specific values. Production values should be:
+  # max_deposit_period: 172800s (48 hours)
+  # voting_period: 172800s (48 hours)
   sed -i.bak 's/"max_deposit_period": "172800s"/"max_deposit_period": "30s"/g' "$HOMEDIR"/config/genesis.json
   sed -i.bak 's/"voting_period": "172800s"/"voting_period": "30s"/g' "$HOMEDIR"/config/genesis.json

Line range hint 1-324: Ensure error handling for jq commands.

The script uses numerous jq commands for JSON manipulation but doesn't check their success. Consider adding error checking for critical operations.

+  # Function to handle jq command failures
+  handle_jq_error() {
+    if [ $? -ne 0 ]; then
+      echo "Error: Failed to modify genesis file with jq command"
+      exit 1
+    fi
+  }

   # Example usage:
   jq '.app_state["feemarket"]["params"]["base_fee"]="10"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
+  handle_jq_error
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b4a331e and f85271b.

⛔ Files ignored due to path filters (1)
  • x/feedistribution/types/genesis.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (2)
  • local_node.sh (1 hunks)
  • x/dogfood/keeper/impl_sdk.go (4 hunks)
🔇 Additional comments (3)
x/dogfood/keeper/impl_sdk.go (1)

Line range hint 220-225: Clarify the token calculation documentation.

The comment about 'Tokens' could be more explicit about the calculation formula. Consider:

-// the 'Tokens' is actually usd value including different types of assets * sdk.DefaultPowerReduction
+// the 'Tokens' represents the total USD value of all asset types, multiplied by sdk.DefaultPowerReduction for power calculation

Also, verify that this power calculation aligns with the governance module's expectations.

✅ Verification successful

The previous search failed because we assumed the governance module was in x/gov/. Let's first locate the correct paths and then search for power calculations.


Based on the search results, I can now generate a final response as we have sufficient information about how the token values and power calculations are used in the codebase.

Documentation accurately reflects the token calculation mechanism

The current comment is correct and aligns with the codebase implementation. Here's why:

  • The TotalBondedTokens implementation in x/dogfood/keeper/impl_sdk.go confirms this is a multi-asset staking system where tokens represent USD values
  • The code shows consistent usage of sdk.DefaultPowerReduction for power calculations across the codebase
  • The TODO comment in IterateDelegations explicitly confirms that "usd-power" is used for governance voting power calculations

The current comment succinctly captures this relationship, and the suggested change would not add meaningful clarity to the implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify how the governance module uses these token values
# Look for references to validator tokens or power in the governance module

rg -A 5 "BondedTokens|GetShares|DelegatorShares" x/gov/

Length of output: 104


Script:

#!/bin/bash
# Let's first find the governance module location and any references to validator power
fd -t f -e go . | xargs rg -l "gov"

# Then look for power calculation references
rg -A 5 "TokensFromConsensusPower|DefaultPowerReduction|BondedTokens|GetShares|DelegatorShares"

Length of output: 15517

local_node.sh (2)

133-134: LGTM: Base fee configuration added for fee market.

The addition of base fee configuration with a value of "10" is appropriate for a local testnet environment.


Line range hint 183-188: Verify dogfood module configuration aligns with governance requirements.

The dogfood module configuration includes:

  • 1-minute epoch identifier (for testing)
  • 5 epochs until unbonded
  • Minimum self-delegation of 100
  • Initial validator power of 5000

While these values are suitable for testing, we should verify they meet the governance module's requirements for voting power calculations.

✅ Verification successful

Based on the search results, I can now generate the final response:

Dogfood module configuration is compatible with governance requirements

The verification shows that voting power in the system:

  • Is calculated dynamically based on USD value of staked assets
  • Has no hardcoded dependencies on epoch duration or minimum self-delegation
  • Is updated via UpdateVotingPower at epoch boundaries for all AVS modules

The test configuration values in local_node.sh are safe to use as they only affect testing environments and don't conflict with production governance calculations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify governance module's compatibility with dogfood configuration
# Test: Check if governance module references these parameters
rg -A 5 "epochs_until_unbonded|min_self_delegation|epoch_identifier" --type go

# Test: Check if there are any hardcoded values in governance that might conflict
rg -A 5 "VotingPower|StakingPower" --type go

Length of output: 11253

@leonz789 leonz789 changed the title add todo for dogfood to support gov-tx-proposal add implementation to support gov-tx-proposal Nov 10, 2024
@leonz789 leonz789 changed the title add implementation to support gov-tx-proposal add implementations to support gov-tx-proposal Nov 10, 2024
Copy link
Contributor

@bwhour bwhour left a comment

Choose a reason for hiding this comment

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

it looks viable

@leonz789 leonz789 merged commit b74a3a8 into ExocoreNetwork:develop Dec 3, 2024
19 checks passed
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.

5 participants