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

Feat/sync with master v1.56.2 #298

Merged
merged 13 commits into from
Apr 2, 2025
Merged

Feat/sync with master v1.56.2 #298

merged 13 commits into from
Apr 2, 2025

Conversation

aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Apr 2, 2025

  • Syncing dev branch with master with the latest changes in v1.56.2 release

Summary by CodeRabbit

  • Chores

    • Enhanced continuous integration and linting configurations for more efficient issue reporting and streamlined code checks.
    • Upgraded tooling commands to support improved development practices.
  • Refactor

    • Improved transaction processing to support dynamic gas pricing and unified broadcasting—resulting in clearer, JSON-formatted offline signing outputs.
    • Adjusted market data formatting to ensure values are consistently rounded up for enhanced precision.

aarmoa added 13 commits January 23, 2025 13:19
…ple_script

fix/fix_stream_prices_example_script
* fix: fixed the manual TX generation and signing to receive the gas price

* fix: solve issues in pre-commit workflow caused by using deprecated components

* fix: solve issues in pre-commit workflow caused by using deprecated components
Copy link

coderabbitai bot commented Apr 2, 2025

Walkthrough

This pull request updates several GitHub Actions workflows, linter configurations, and build targets while refactoring parts of the core client and example code. Changes include modifications to cache and lint settings, upgrading action versions, and standardizing type usage in chain transaction functions. In addition, file handling in examples has been updated and import statements reordered for clarity.

Changes

Files Change Summary
.github/workflows/golangci-lint.yml, .github/workflows/pre-commit.yml Updated GitHub Actions workflows: switched lint configuration (only-new-issues from false to true) with caching options removed; upgraded actions/checkout (v3 → master) and pre-commit/action (v2.0.2 → v3.0.1).
.golangci.yml Restructured linter configuration: replaced skip-dirs with an issues section, updated revive key (enableAllRules to enable-all-rules), and added new revive rules (add-constant, line-length-limit).
Makefile Added new lint targets (lint, lint-last-commit, lint-master) with the GOPROXY set to direct and updated the .PHONY declaration accordingly.
client/chain/chain.go, client/chain/chain_test_support.go Updated usage of context from client.Context to sdkclient.Context; added a gasPrice parameter to BuildSignedTx; introduced a new BroadcastSignedTx method; and adjusted error handling.
client/core/market.go Modified NotionalToChainFormat methods to apply a ceiling (Ceil()) to the value before conversion for all market types.
examples/chain/8_OfflineSigning/example.go, examples/exchange/oracle/1_StreamPrices/example.go Refactored file operations to use the os package, updated network and gas parameters in offline signing, and standardized oracleType to lowercase in the streaming example.
typeddata/typed_data.go Reorganized import statements for improved clarity.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChainClient
    participant BlockchainNode

    User->>ChainClient: Request transaction build (with messages, gasPrice)
    ChainClient->>ChainClient: BuildSignedTx (using sdkclient.Context)
    ChainClient->>ChainClient: Validate & prepare transaction
    User->>ChainClient: Request broadcast (with broadcastMode)
    ChainClient->>BlockchainNode: BroadcastSignedTx(txBytes, broadcastMode)
    BlockchainNode-->>ChainClient: Return transaction response
    ChainClient-->>User: Deliver BroadcastTxResponse
Loading

Possibly related PRs

Poem

I’m a little rabbit, leaping through the code,
Hopping on updates on this winding road.
Linting, building, with tweaks so bright,
My carrot days are looking light!
ASCII hops and joyful bytes,
Celebrating changes with delight.
🐰🌟

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

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

@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 (4)
.github/workflows/pre-commit.yml (1)

11-11: Caution: Using a branch reference for checkout action
The update from a fixed version (previously v3) to using actions/checkout@master means the workflow will always pull the latest commit from the master branch of the action. This can lead to unanticipated changes if the master branch is updated with breaking changes. Please verify that using a branch reference instead of a stable version tag aligns with your reproducibility and stability requirements.

.golangci.yml (3)

31-35: New Revive Rules Added
New rules for revive have been introduced:

  • add-constant is now explicitly disabled.
  • line-length-limit is enforced with an argument of 140.
    Please verify that these new rules (and their configurations) reflect your intended code style guidelines. It might also be helpful to add inline comments or documentation if these rules are not self-explanatory to all team members.

39-42: Expanded gocritic Enabled Tags
Additional tags have been added under gocritic.enabled-tags: diagnostic, opinionated, and experimental. While these options can provide a deeper analysis, they might also increase noise from lint warnings. Please confirm that the inclusion of these tags is intentional and that the team is prepared to handle any additional feedback generated by these checks.


48-59: New Issues Section for Linting
A new issues section has been added with exclusions and limits:

  • Excludes revive issues that mention ALL_CAPS under specified linters.
  • Excludes directories such as chain, exchange, injective_data, proto, and client/keyring/testdata.
  • Sets max-issues-per-linter to 0, which typically means no limit.
    Please double-check that these exclusions and the configuration align with your team's strategy for managing lint issues, ensuring that important warnings are not inadvertently suppressed.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 291a94f and 603c3a5.

📒 Files selected for processing (10)
  • .github/workflows/golangci-lint.yml (1 hunks)
  • .github/workflows/pre-commit.yml (1 hunks)
  • .golangci.yml (1 hunks)
  • Makefile (1 hunks)
  • client/chain/chain.go (13 hunks)
  • client/chain/chain_test_support.go (2 hunks)
  • client/core/market.go (3 hunks)
  • examples/chain/8_OfflineSigning/example.go (5 hunks)
  • examples/exchange/oracle/1_StreamPrices/example.go (2 hunks)
  • typeddata/typed_data.go (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
client/chain/chain_test_support.go (1)
exchange/exchange_rpc/pb/goadesign_goagen_injective_exchange_rpc.pb.go (3)
  • BroadcastTxResponse (854-876)
  • BroadcastTxResponse (891-891)
  • BroadcastTxResponse (906-908)
🔇 Additional comments (41)
examples/exchange/oracle/1_StreamPrices/example.go (2)

8-8: Logical addition of the strings package.

The strings package is now required for the new functionality using strings.ToLower() on line 78.


78-78: Good improvement to normalize Oracle type to lowercase.

Converting the Oracle type to lowercase ensures consistent case formatting when making the API call to StreamPrices. This change improves robustness by standardizing the input format regardless of how the Oracle type is provided in the market data.

typeddata/typed_data.go (1)

18-22: Reorganization of import statements.

This change is purely organizational, moving several Cosmos SDK imports from the end of the import block to the beginning. This sort of reordering improves readability and likely aligns with the project's code style guidelines.

Makefile (4)

154-157: Good addition of a standard lint target.

This new target sets the GOPROXY environment variable to 'direct' and runs the linter against the dev branch, helping to maintain code quality. The '--new-from-rev=dev' flag specifically focuses on changes made since branching from dev, which keeps the linting process targeted and efficient.


158-161: Useful addition of a last-commit linting target.

This target allows developers to quickly validate their most recent commit without checking the entire codebase, providing a fast feedback loop for code quality checks.


162-165: Important addition of master branch linting comparison.

This target is particularly valuable for pull requests like this one that sync with the master branch, as it specifically identifies linting issues introduced since the master branch.


166-166: Updated .PHONY declaration to include new targets.

Properly marking these targets as .PHONY ensures that Make will run the commands even if files with the same names exist, which is good practice for task-oriented targets like these.

.github/workflows/golangci-lint.yml (1)

34-34: Improved CI configuration to focus on new issues.

Changing only-new-issues to true configures the GitHub Actions workflow to report only linting issues introduced in the current pull request, rather than all pre-existing issues. This focuses code review attention on recent changes and prevents overwhelming developers with legacy issues that weren't part of their modifications.

.github/workflows/pre-commit.yml (1)

18-18: Update Pre-commit Action Version
The action has been upgraded to pre-commit/action@v3.0.1, which should provide improved features and fixes over the previous version. This change appears beneficial; please ensure that any breaking changes introduced in v3.0.1 have been reviewed.

.golangci.yml (3)

26-26: Revive Configuration Key Update
The configuration key has been updated to enable-all-rules: true (line 26). This change appears to be in line with the new settings for revive. Confirm that this modification is compatible with your current tooling and that all team members are aware of the new configuration syntax.


44-45: Updated gocritic Disabled Checks
Disabling singleCaseSwitch and deferInLoop can help reduce false positives or less useful warnings. Verify that these checks are intentionally disabled and that their exclusion does not hide real issues in your codebase.


61-62: Lint Run Configuration Update
The new run section now specifies tests: false, which will bypass linting of test files during analysis. Confirm that skipping tests is the desired behavior for your linting process and that this change will not allow problematic test code to be overlooked.

client/core/market.go (3)

45-46: Consistent change to use Ceil() for notional value calculations

The change ensures the notional value is rounded up to the next integer when converting to chain format, which guarantees sufficient funds are available for operations. This is a prudent modification that prevents potential transaction failures due to insufficient funds.


133-134: Consistent rounding approach for derivative market notional values

The modification to use Ceil() aligns with the changes in other market types, ensuring consistent handling of notional values across different market categories. This harmonized approach prevents potential discrepancies in transaction processing.


230-231: Appropriate ceiling rounding for binary option market notional values

The implementation now correctly rounds up notional values using Ceil(), which matches the approach used in other market types. This consistency is important for maintaining predictable behavior across different market structures.

examples/chain/8_OfflineSigning/example.go (8)

6-7: Added JSON encoding support for improved response handling

The addition of the JSON encoding import supports the improved response formatting implemented later in the file.


21-22: Modernized file handling with os.WriteFile

Replaced deprecated ioutil function with the recommended os.WriteFile, which simplifies the code and follows current best practices.


25-26: Simplified file reading with os.ReadFile

Updated to use the more concise os.ReadFile function instead of manual file opening and reading, reducing code complexity.


29-29: Updated network configuration to testnet

Changed from "devnet" to "testnet" with "lb" parameter, which appears to be part of aligning the example with current network configurations.


78-78: Updated marketId to current valid value

The market ID has been updated, likely to reference a currently valid market on the testnet environment.


99-99: Added dynamic gas price parameter for transaction building

Now using client.DefaultGasPrice instead of hardcoded values, which provides more flexibility and follows current API requirements for the BuildSignedTx method.


110-112: Enhanced transaction broadcasting with flexible broadcast mode

Updated to use BroadcastSignedTx with explicit broadcast mode parameter (BROADCAST_MODE_SYNC), which provides more control over how transactions are processed by the network.


116-120: Improved response handling with structured output

Added detailed transaction response output including hash and code, with proper JSON formatting for better readability. This makes the example more useful for debugging and understanding transaction results.

client/chain/chain_test_support.go (2)

80-80: Updated BuildSignedTx signature with gasPrice parameter

Added gasPrice parameter to the BuildSignedTx method signature to match the changes in the actual implementation, ensuring the mock client remains compatible with code that uses the updated API.


92-94: Added BroadcastSignedTx method to support new transaction broadcasting approach

Implemented the new BroadcastSignedTx method in the mock client, which supports the flexible broadcast mode parameter and aligns with updates to the broadcasting API in the real client implementation.

client/chain/chain.go (16)

20-46: Import statements updated for consistency and improved organization.

The updated imports maintain consistent naming conventions and better organization by:

  1. Using sdkclient alias for the Cosmos SDK client package
  2. Adding insecure GRPC credentials import
  3. Organizing InjectiveLabs imports appropriately

These changes align with the architectural changes throughout the file.


74-75: Interface method updated to use standardized SDK client types.

The return type for ClientContext() has been changed from client.Context to sdkclient.Context to standardize on Cosmos SDK client types across the codebase.


78-79: Interface method parameter type updated for consistency.

Parameter type for SimulateMsg has been changed from client.Context to sdkclient.Context for consistency with other method signatures that use the Cosmos SDK client types.


88-89: New interface method added for flexible transaction broadcasting.

A new BroadcastSignedTx method has been added to support different broadcast modes, allowing more flexibility in how transactions are broadcast to the network.


313-314: Updated struct field type for consistency with interface.

The ctx field in the chainClient struct has been updated from client.Context to sdkclient.Context to match the interface changes and maintain type consistency throughout the codebase.


359-360: Constructor parameter type updated to match struct field type.

The NewChainClient function now accepts sdkclient.Context instead of client.Context to match the updated struct field type, maintaining type consistency throughout the codebase.


558-560: Implementation return type updated to match interface.

The return type of ClientContext() implementation has been updated from client.Context to sdkclient.Context to match the interface changes and maintain type consistency.


703-728: Updated method signature and implementation for SimulateMsg.

The parameter type for SimulateMsg has been changed from client.Context to sdkclient.Context while maintaining the same functionality. This change ensures type consistency across the codebase.


730-738: BuildSignedTx implementation updated with gas price handling.

The method has been enhanced to:

  1. Accept the new gasPrice parameter
  2. Create a gas price string with the appropriate denomination
  3. Set the gas price on the transaction factory

This provides more explicit control over transaction fees.


740-782: Updated buildSignedTx with sdkclient parameter type.

The parameter type has been updated from client.Context to sdkclient.Context while preserving the same functionality, ensuring type consistency across the codebase.


784-822: Refactored SyncBroadcastSignedTx to use the new BroadcastSignedTx method.

The implementation now delegates to the new BroadcastSignedTx method with BROADCAST_MODE_SYNC mode, reducing code duplication and improving maintainability.


805-807: Updated error handling to use sdkclient.CheckCometError.

Error handling has been updated to use sdkclient.CheckCometError instead of client.CheckCometError to align with the updated import conventions.


824-841: Implemented AsyncBroadcastSignedTx to use the new BroadcastSignedTx method.

The implementation now delegates to the new BroadcastSignedTx method with BROADCAST_MODE_ASYNC mode, reducing code duplication and improving code maintainability.


828-841: Added new BroadcastSignedTx method for flexible transaction broadcasting.

This new method centralizes the broadcasting logic and supports different broadcast modes through the broadcastMode parameter. This abstraction reduces code duplication in the SyncBroadcastSignedTx and AsyncBroadcastSignedTx methods.


690-692: Updated error handling in SyncBroadcastMsg.

Error handling has been updated to use sdkclient.CheckCometError instead of client.CheckCometError to align with the updated import conventions.


85-86:

✅ Verification successful

Interface method signature extended with gas price parameter.

The BuildSignedTx method now includes a gasPrice parameter which allows more explicit control over transaction fees. This is a breaking change that requires updates in dependent code.

Please verify that all callers of this method have been updated to include the new gas price parameter.


🏁 Script executed:

#!/bin/bash
# Search for calls to BuildSignedTx to ensure they all include the new gasPrice parameter
rg "BuildSignedTx\(" --type go

Length of output: 693


Confirmed Update of Gas Price Parameter Usage

The BuildSignedTx interface now robustly includes the gasPrice parameter, and our search verifies that all callers across the codebase—such as in examples/chain/8_OfflineSigning/example.go, as well as the production and test support implementations—have been updated accordingly. No further modifications to dependent code are necessary.

@aarmoa aarmoa merged commit 1128442 into dev Apr 2, 2025
6 checks passed
@aarmoa aarmoa deleted the feat/sync_with_master_v1_56_2 branch April 2, 2025 20:13
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.

1 participant