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

dogfood, oracle: remove default params #293

Merged

Conversation

MaxMustermann2
Copy link
Contributor

@MaxMustermann2 MaxMustermann2 commented Jan 24, 2025

The default asset_id was added for convenience. Now that our testing infrastructure is fleshed out, it can be removed.

Similarly, the default parameters used in x/oracle have been removed and must now be manually added.

Summary by CodeRabbit

  • New Features

    • Enhanced oracle configuration with new token, chain, and source configurations.
    • Updated genesis file setup for local blockchain node.
  • Bug Fixes

    • Refined asset ID handling in dogfood parameters.
    • Simplified parameter management for oracle and dogfood modules.
  • Refactor

    • Restructured parameter initialization in multiple test utility and type files.
    • Updated default parameter configurations for oracle and dogfood modules.
    • Introduced a new function for test-specific parameter initialization.

Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

Walkthrough

This pull request introduces comprehensive modifications to the blockchain node's configuration, focusing on the genesis file and oracle parameters. The changes primarily involve restructuring how tokens, chains, sources, and rules are defined across multiple files. The modifications enhance the flexibility of parameter initialization by moving from static assignments to more dynamic append-based configurations, particularly in the oracle and dogfood modules. The changes aim to provide a more granular and extensible approach to defining blockchain node parameters.

Changes

File Change Summary
local_node.sh Updated genesis file configuration with new entries for dogfood and oracle parameters
testutil/keeper/oracle.go Modified oracle keeper initialization with new chains, tokens, sources, and rules
testutil/network/genesis_data.go Replaced direct assignments with append operations for oracle parameters
testutil/utils.go Updated oracle default parameters with new token and source configurations
x/dogfood/types/genesis_test.go Added new asset ID to genesis validation test
x/dogfood/types/params.go Changed DefaultAssetIDs from string to empty string slice
x/oracle/types/params.go Removed default entries for tokens, sources, rules, and token feeders
x/oracle/keeper/keeper_suite_test.go Updated test suite to use DefaultParamsForTest() for parameter initialization
x/oracle/keeper/msg_server_create_price_test.go Changed parameter initialization to DefaultParamsForTest()
x/oracle/keeper/msg_server_update_params_test.go Introduced DefaultParamsForTest() for consistent test parameter initialization
x/oracle/keeper/params_test.go Updated test functions to use DefaultParamsForTest()

Sequence Diagram

sequenceDiagram
    participant Genesis as Genesis Configuration
    participant Oracle as Oracle Module
    participant Dogfood as Dogfood Module
    
    Genesis->>Oracle: Configure Chains
    Genesis->>Oracle: Add Tokens
    Genesis->>Oracle: Define Sources
    Genesis->>Oracle: Create Rules
    Genesis->>Oracle: Set Token Feeders
    
    Oracle-->>Dogfood: Share Configuration
    Dogfood-->>Genesis: Validate Parameters
Loading

Possibly related PRs

Suggested Labels

Type: Tests, Type: CI

Suggested Reviewers

  • cloud8little
  • bwhour
  • trestinlsd
  • mikebraver
  • leonz789
  • TimmyExogenous

Poem

🐰 In the realm of blockchain's dance,
Parameters shift with each new glance,
Tokens and rules, a flexible art,
Where genesis configs smartly start!
A rabbit's code, both lean and bright,
Configures systems with pure delight! 🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 1

🧹 Nitpick comments (3)
testutil/network/genesis_data.go (1)

70-77: Clarify usage of empty offchain endpoint.
You’re appending a new Source named "Chainlink" with an offchain map containing an empty string. Confirm this aligns with your intended usage or add comments explaining why it’s empty.

testutil/keeper/oracle.go (2)

80-87: Explain empty offchain map for Chainlink.
An empty offchain endpoint might create potential runtime issues if you rely on it for external data. Consider specifying a placeholder URL or providing a comment clarifying future usage.


92-98: Revisit token feeder block assumptions.
StartBaseBlock: 1 and Interval: 10 can influence how quickly the feeder updates. Validate these parameters against your desired testing or production flow to avoid missed or repetitive updates.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 916eb26 and 198685d.

📒 Files selected for processing (7)
  • local_node.sh (2 hunks)
  • testutil/keeper/oracle.go (1 hunks)
  • testutil/network/genesis_data.go (1 hunks)
  • testutil/utils.go (2 hunks)
  • x/dogfood/types/genesis_test.go (1 hunks)
  • x/dogfood/types/params.go (2 hunks)
  • x/oracle/types/params.go (0 hunks)
💤 Files with no reviewable changes (1)
  • x/oracle/types/params.go
🧰 Additional context used
🪛 GitHub Actions: Tests
x/dogfood/types/genesis_test.go

[error] 658-658: Test failure: Expected error containing 'non-positive last total power' but got 'params: asset IDs: invalid parameter value: []: the genesis data supplied is invalid'

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: goreleaser
🔇 Additional comments (12)
testutil/network/genesis_data.go (3)

60-69: Ensure consistency and validate the placeholder contract address.
Appending a chain named "Ethereum" and a token named "ETH" with ContractAddress set to "0x" might be a placeholder. Confirm that chain ID 1 and "0x" are intentional for testing to avoid accidental mismatches in production.


78-81: Confirm rule configuration.
The appended rule references SourceIDs: []uint64{0}. Verify that 0 indeed correlates to the "Chainlink" source appended above and no off-by-one indexing errors exist.


82-89: Check feeder’s indexing and interval.
A new token feeder is being appended with TokenID: 1 and StartBaseBlock: 10. Ensure these indices and intervals align with other tokens’ IDs and block heights, especially since indexing starts at 1 here.

testutil/keeper/oracle.go (2)

71-79: Validate chain and token setup.
You’re appending "Ethereum" to Chains and then "ETH" to Tokens with ContractAddress: "0x". Confirm that a placeholder ContractAddress is valid in your tests and won’t interfere with real-world addresses.


88-91: Confirm source references for rules.
SourceIDs: []uint64{0} must align with the newly added "Chainlink" source. Ensure correct indexing and no off-by-one errors if more sources are appended later.

x/dogfood/types/params.go (3)

32-34: Check for empty default asset IDs.
DefaultAssetIDs = []string{} may cause validation failures if not overridden, as empty asset IDs are deemed invalid in ValidateAssetIDs(). Ensure you replace it with actual values elsewhere.


35-37: Zero minimum self-delegation is acceptable.
DefaultMinSelfDelegation = sdkmath.ZeroInt() fits within the non-negative requirement. No further action needed unless you require a strictly positive minimum for production.


66-66: DefaultParams now uses empty asset IDs.
Passing DefaultAssetIDs as an empty slice will fail unless those IDs are injected later. Verify that your runtime configuration sets valid asset IDs before usage.

x/dogfood/types/genesis_test.go (1)

41-41: ⚠️ Potential issue

Investigate pipeline failure related to new asset ID.

This newly assigned params.AssetIDs = []string{"0x0b34c4d876cd569129cf56bafabb3f9e97a4ff42_0x9ce1"} may lead to a mismatch with other code or tests, as indicated by the pipeline failure referencing “invalid parameter value: []”. Verify whether this new asset ID aligns with the rest of the codebase and ensure the genesis and test logic consistently handle non-empty lists.

testutil/utils.go (1)

206-233: Validate consistency of newly appended Oracle parameters.

These lines add a new chain, token (ETH), source (Chainlink), rule, and token feeder. Verify that:

  1. The token decimals (18) match other references (e.g., local_node.sh sets 8 in one place).
  2. No references rely on default parameters that were simultaneously removed.
local_node.sh (2)

182-208: 🛠️ Refactor suggestion

Enforce consistent token decimal usage in the Oracle configuration.

In local_node.sh, the newly configured “ETH” token is set to decimal=8, which conflicts with the code using decimal=18 in some places. Decide on the correct decimal precision and ensure it’s uniformly applied, especially if the pipeline or test relies on a specific decimal value.


168-168: ⚠️ Potential issue

Check for mismatch in dogfood asset ID.

Here, "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" differs from the test’s "0x0b34c4d876cd...". This discrepancy can trigger validation errors. Confirm which asset ID should appear across the genesis config and tests.

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.

LGTM.

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

🧹 Nitpick comments (2)
x/oracle/keeper/keeper_suite_test.go (1)

110-110: Deduplicate parameter initialization logic
You're repeating almost the same parameter initialization here and in Reset(). Consider moving the common setup steps into a shared utility method to adhere to the DRY principle, improving maintainability.

local_node.sh (1)

183-184: Consider adding a more descriptive chain description.

The chain description is set to "-", which provides no meaningful information about the Ethereum chain.

-	jq '.app_state["oracle"]["params"]["chains"][1]["desc"]="-"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
+	jq '.app_state["oracle"]["params"]["chains"][1]["desc"]="Ethereum Mainnet"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 198685d and 0964a8e.

📒 Files selected for processing (6)
  • local_node.sh (2 hunks)
  • x/dogfood/types/genesis_test.go (2 hunks)
  • x/oracle/keeper/keeper_suite_test.go (2 hunks)
  • x/oracle/keeper/msg_server_create_price_test.go (1 hunks)
  • x/oracle/keeper/msg_server_update_params_test.go (4 hunks)
  • x/oracle/keeper/params_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • x/dogfood/types/genesis_test.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: goreleaser
🔇 Additional comments (12)
x/oracle/keeper/keeper_suite_test.go (1)

76-76: Ensure valid indexing of TokenFeeders
Switching to DefaultParamsForTest() provides more consistent predefined data for these tests. However, please verify that the TokenFeeders slice always has an index [1] populated, as here you're directly referencing it without any prior checks.

x/oracle/keeper/msg_server_create_price_test.go (1)

71-71: Consistency in test parameters
Using DefaultParamsForTest() aligns with the updated approach seen in other test files. This ensures all tests run on a uniform and carefully controlled parameter set. Nice job.

x/oracle/keeper/params_test.go (2)

179-179: Centralized usage of DefaultParamsForTest()
Adopting DefaultParamsForTest() helps maintain a singular, clearly defined source of default testing parameters. This approach reduces duplication and potential inconsistencies.


285-285: Reinitialization concerns
Reassigning p = DefaultParamsForTest() resets any previous mutations to p. If your test logic relies on appended tokens or feeders from earlier operations, ensure this reset is intentional.

x/oracle/keeper/msg_server_update_params_test.go (4)

5-5: New time import
Bringing in the time package is necessary for handling jail durations in SlashingParams. This addition looks appropriate.


18-85: Introduction of DefaultParamsForTest()
Defining a dedicated function for test parameters is an excellent move. It centralizes test configurations, ensuring a consistent, reliable baseline for all test scenarios.


98-98: Uniform setup across tests
Using DefaultParamsForTest() for defaultParams aligns with the new pattern. This uniform approach simplifies maintenance and prevents divergence in test data.


186-186: Index safety
token := DefaultParamsForTest().Tokens[1] requires that DefaultParamsForTest() consistently returns at least two token entries. Confirm that adding or removing tokens in the future won't lead to an out-of-range error.

local_node.sh (4)

168-168: LGTM: Asset ID configuration for dogfood module.

The asset ID configuration aligns with the PR objective of removing default parameters, requiring manual addition of the asset ID.


186-191: Verify ETH token configuration.

The token configuration for ETH uses:

  1. A contract address of "0x" which seems incorrect for ETH
  2. An asset_id that appears to be for a different token (USDT's contract address)

Run this script to verify the ETH token configuration:


193-197: Enhance Chainlink source configuration.

The Chainlink source configuration has an empty offchain entry and no onchain configuration, which might limit its functionality.

Run this script to verify the Chainlink source configuration:


199-207: Review token feeder configuration.

The token feeder configuration appears incomplete:

  1. Uses hardcoded IDs (token_id="1", rule_id="1")
  2. Has a static interval of 10 blocks
  3. Uses end_block="0" which might need clarification

Run this script to verify the token feeder configuration:

✅ Verification successful

The token feeder configuration is valid and follows the protocol design

The configuration follows the protocol's requirements:

  • IDs starting from 1 is by design (0 is reserved)
  • Interval of 10 blocks is valid as long as MaxNonce ≤ 5 (protocol requires interval > 2*MaxNonce)
  • EndBlock=0 is a valid setting that indicates continuous operation with no end time
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify token feeder configuration
# Test: Check for token feeder configurations and their usage
# Expect: Find consistent token feeder configurations

# Search for token feeder configurations
rg -A 10 "token_feeders.*token_id" --type yaml --type json

# Search for interval configurations
rg -A 5 "interval.*10" --type yaml --type json

Length of output: 5467


Script:

#!/bin/bash
# Search for token feeder documentation and configurations
rg -l "token.*feeder" --type md
rg -A 5 "end_block.*0" --type yaml --type json

# Look for other token feeder configurations
fd -e json -e yaml -e toml | xargs rg -l "token_feeders"

# Search for rule_id patterns
rg "rule_id.*[0-9]+" --type json --type yaml

Length of output: 222


Script:

#!/bin/bash
# Search for token feeder related code and tests
rg -t go -t rust -t js "TokenFeeder" -B 2 -A 2
rg -t go -t rust -t js "token.*feeder" -i -B 2 -A 2

# Search for test files containing token feeder configurations
fd -e test.js -e test.go -e test.rs | xargs rg -l "token.*feeder" -i

# Look for struct or type definitions
ast-grep --pattern 'struct TokenFeeder {
  $$$
}'

ast-grep --pattern 'type TokenFeeder struct {
  $$$
}'

Length of output: 67101

@MaxMustermann2 MaxMustermann2 merged commit d08f17c into imua-xyz:develop Feb 5, 2025
21 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.

4 participants