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

chore: update dependencies and refactor for no-std #132

Merged
merged 1 commit into from
Feb 6, 2025
Merged

Conversation

shuhuiluo
Copy link
Owner

@shuhuiluo shuhuiluo commented Feb 6, 2025

Streamline dependencies and improve error handling by replacing generic with specific error types. Restructure feature flags (parse_price, extensions) to improve modularity and no-std compatibility. Bump SDK version to 3.6.0 and consolidate documentation for better clarity.

Summary by CodeRabbit

  • New Features
    • Introduced a new price parsing option that delivers improved error reporting.
  • Documentation
    • Revamped the documentation with clearer code sample formatting and integrated guide content.
  • Refactor
    • Streamlined APIs for token operations with more explicit error handling.
  • Chores
    • Upgraded the software version to 3.6.0 with optimized dependency and build configurations.

Streamline dependencies and improve error handling by replacing generic with specific error types. Restructure feature flags (`parse_price`, `extensions`) to improve modularity and `no-std` compatibility. Bump SDK version to `3.6.0` and consolidate documentation for better clarity.
Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Walkthrough

This pull request introduces a new GitHub Actions build step to explicitly compile with the std feature. It updates the package version and dependency configurations in Cargo.toml, reorganizes feature sets, and adds a new parse_price feature. Additionally, documentation formatting in README.md is adjusted, along with minor modifications across several source files—such as improved error handling, removal of obsolete comments, and additional imports for testing utilities.

Changes

File(s) Summary
.github/workflows/rust.yml Added a new "Build with std feature" step to run cargo build --features std between the existing "Build" and "Build with extensions" steps.
Cargo.toml Bumped package version from 3.5.1 to 3.6.0; updated dependency signatures (added default-features = false), reorganized features, and added the new parse_price feature.
README.md Reformatted a code snippet to disable syntax highlighting, with no changes to logic.
src/entities/pool.rs
src/entities/tick_list_data_provider.rs
src/entities/trade.rs
Removed a redundant TODO comment in pool methods; added an import for alloc::vec in tests; changed the hash set type and removed an unused import in trade logic.
src/extensions/position.rs
src/extensions/price_tick_conversions.rs
Updated function signatures to use specific Error types; improved error handling (using anyhow in price parsing).
src/lib.rs Replaced inline documentation with an inclusion of README content and adjusted conditional compilation attributes for test configurations.
src/multicall.rs
src/tests.rs
src/utils/sqrt_price_math.rs
Added imports and a public export for alloc::vec to support vector creation within test modules.
src/utils/swap_math.rs
src/utils/types.rs
Simplified syntax in the swap logic and updated the BigDecimal import to be sourced from a different module.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant CI as GitHub Actions
    Dev->>CI: Push commit
    CI->>CI: Run "Build" step (cargo build)
    CI->>CI: Run "Build with std feature" (cargo build --features std)
    CI->>CI: Run "Build with extensions" step
    CI->>Dev: Report build status
Loading

Possibly related PRs

Poem

In circuits of code, we now advance with flair,
With std explicit, our builds are declared fair.
Dependencies refined like equations precise,
Each test and doc aligned—an engineer's vice.
With every commit, logic sings in pure array,
Bazinga! Our software stands, unyielding all the way.

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 426ccc3 and c177ed2.

📒 Files selected for processing (14)
  • .github/workflows/rust.yml (1 hunks)
  • Cargo.toml (2 hunks)
  • README.md (1 hunks)
  • src/entities/pool.rs (0 hunks)
  • src/entities/tick_list_data_provider.rs (1 hunks)
  • src/entities/trade.rs (2 hunks)
  • src/extensions/position.rs (5 hunks)
  • src/extensions/price_tick_conversions.rs (4 hunks)
  • src/lib.rs (1 hunks)
  • src/multicall.rs (1 hunks)
  • src/tests.rs (1 hunks)
  • src/utils/sqrt_price_math.rs (1 hunks)
  • src/utils/swap_math.rs (1 hunks)
  • src/utils/types.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • src/entities/pool.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Rust Tests
🔇 Additional comments (17)
src/tests.rs (1)

5-5: Bazinga! This change is theoretically sound.

The addition of pub(crate) use alloc::vec is a logical step in achieving no-std compatibility, making the vector functionality available to other test modules within the crate.

src/entities/tick_list_data_provider.rs (1)

20-20: As expected, a perfectly logical addition.

The import of alloc::vec in the test module aligns with the theoretical framework of no-std compatibility.

src/multicall.rs (1)

59-59: This modification exhibits remarkable consistency.

The addition of alloc::vec maintains the theoretical consistency of no-std support across the test modules.

src/utils/sqrt_price_math.rs (1)

475-475: Fascinating! A slight variation in import syntax, yet equally valid.

The direct import of Vec from alloc::vec demonstrates an acceptable alternative approach to achieving no-std compatibility.

src/lib.rs (2)

1-1: Bazinga! Excellent documentation strategy.

Including the README.md content as documentation ensures a single source of truth for project documentation.


2-2: Fascinating conditional compilation modification.

The updated cfg_attr ensures proper no_std support while allowing extensions during testing. This is a theoretically sound approach to feature management.

src/utils/types.rs (1)

3-3: Logical import consolidation.

Importing BigDecimal from uniswap_sdk_core::prelude reduces external dependencies, which is consistent with our goal of dependency streamlining.

src/extensions/price_tick_conversions.rs (2)

46-46: Excellent feature flag implementation.

The parse_price feature flag properly isolates this functionality, adhering to the principle of modular feature management.


52-52: Superior error handling implementation.

The switch to anyhow::Result and proper error propagation with the ? operator significantly improves error handling robustness.

Also applies to: 60-62

src/extensions/position.rs (1)

12-12: Theoretically sound error type specification.

The explicit Result<T, Error> return types and TransportError import provide better error handling clarity and type safety.

Also applies to: 265-265, 363-363

Cargo.toml (3)

42-47: Excellent addition of the parse_price feature!

The new feature logically groups related dependencies (anyhow, regex) and maintains proper feature hierarchy by depending on 'extensions' and 'std'.


48-58: Comprehensive std feature organization.

The std feature now properly enables std support for all relevant dependencies. The use of the ? operator in feature flags like alloy?/std is particularly elegant as it makes the feature optional.


3-3: Verify semantic versioning compliance for version bump.

The version increment from 3.5.1 to 3.6.0 suggests new functionality. Based on the changes in the PR, particularly the addition of the parse_price feature, this appears to be a correct minor version bump.

✅ Verification successful

🌐 Web query:

What constitutes a minor version bump in semantic versioning?

💡 Result:

A minor version bump in semantic versioning occurs when **backwards-compatible functionality is added** to a software project without introducing breaking changes[2][4][5]. Here's how it works:

### Key Criteria for Minor Version Increments
- **New features added**: Introducing functionality that doesn’t break existing API usage[2][5].
- **Deprecations**: Marking existing API elements for future removal (without deleting them yet)[5].
- **Internal improvements**: Substantial non-breaking codebase changes (optional)[4].

### Rules from SemVer Specifications
1. Minor versions (**Y** in `X.Y.Z`) are reset to `0` when:
   - A major version (X) is incremented[4][5].
2. Patch versions (**Z**) reset to `0` after a minor bump[4][5].

### Example Workflow
| Current Version | Change Type             | New Version |
|-----------------|-------------------------|-------------|
| `1.2.4`         | Add search API feature  | `1.3.0`     |
| `2.0.1`         | Deprecate old auth method | `2.1.0`   |

### Edge Case Clarification
- Removing deprecated functionality **always requires a major version bump**, even if previously marked for removal in an earlier minor release[1][5]. For example:
  - Deprecate feature X in `1.5.0` (minor bump)
  - Remove feature X in `2.0.0` (major bump)

This system ensures developers can safely update dependencies while understanding compatibility risks through version numbers[2][5].

Citations:

- 1: https://github.com/semver/semver/issues/712
- 2: https://arjancodes.com/blog/how-to-implement-semantic-versioning-in-software-projects/
- 3: https://gatk.broadinstitute.org/hc/en-us/articles/360035890651-Version-numbers
- 4: https://semver.org/spec/v1.0.0.html
- 5: https://semver.org
- 6: https://gitversion.net/docs/reference/version-increments
- 7: https://semver.org/spec/v2.0.0-rc.1.html
- 8: https://discourse.julialang.org/t/questions-on-the-versioning-semantics-of-julia-packages/109926

Semantic Versioning Compliance Verified

The version bump from 3.5.1 to 3.6.0 is semver-compliant since the new functionality—the addition of the parse_price feature—represents a backward-compatible feature enhancement.

.github/workflows/rust.yml (1)

62-63: Logical placement of std feature build step!

The addition of this step ensures that the std feature compiles correctly. Its placement between the default build and extensions build follows a natural progression of complexity.

README.md (1)

74-89: Appropriate use of rust,ignore attribute.

The addition of the 'ignore' attribute to the code block is correct as this example contains async code that can't be validated by rustdoc.

src/entities/trade.rs (1)

3-3: Excellent migration to alloy_primitives HashSet!

The switch from FxHashSet to HashSet from alloy_primitives aligns with the crate's move towards standardization on alloy primitives. This change maintains functionality while reducing external dependencies.

Also applies to: 191-191

src/utils/swap_math.rs (1)

169-173: Simplified Default Value Assignment for sqrt_price_limit_x96

Using unwrap_or with an inline if...else cleans up the code nicely without altering its logic. Although unwrap_or eagerly computes the default value, here it involves only trivial arithmetic on constants—hardly a performance concern. Bazinga!

src/extensions/price_tick_conversions.rs Show resolved Hide resolved
src/extensions/position.rs Show resolved Hide resolved
@shuhuiluo shuhuiluo merged commit 23218ec into master Feb 6, 2025
3 checks passed
@shuhuiluo shuhuiluo deleted the no-std branch February 6, 2025 03:41
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