Skip to content

Update alloy#72

Merged
0xgleb merged 6 commits into
mainfrom
upd/alloy
Jun 7, 2025
Merged

Update alloy#72
0xgleb merged 6 commits into
mainfrom
upd/alloy

Conversation

@0xgleb
Copy link
Copy Markdown
Contributor

@0xgleb 0xgleb commented Jun 4, 2025

Motivation

We need the latest version of Alloy to upgrade to the new versions of the interpreter and orderbook. alloy-ethers-typecast and rain.erc have to be bumped up along the way.

Solution

Update alloy, alloy-ethers-typecast, and rain.erc.

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • Chores

    • Updated dependency versions for improved compatibility and stability.
    • Added a new configuration for WebAssembly compilation targeting JavaScript environments.
    • Enhanced CI workflows with concurrency controls and streamlined cache configuration.
  • Refactor

    • Simplified and improved decoding and validation logic for authoring metadata.
    • Streamlined test setup and client usage for interface support checks, reducing reliance on HTTP mocks.
  • Bug Fixes

    • Improved error handling and decoding robustness in authoring metadata functions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2025

Walkthrough

This update revises dependency versions in Cargo.toml, adjusts WebAssembly compilation settings, and refactors the crates/cli/src/meta module to use updated client types and simplified ABI decoding logic. It also modifies GitHub workflow files to add concurrency controls and removes obsolete comments, streamlining CI pipeline behavior and test setups.

Changes

Files/Paths Change Summary
.cargo/config.toml Added config to set getrandom_backend=wasm_js for wasm32-unknown-unknown target.
.github/workflows/rainix.yaml, .github/workflows/subgraph-test.yaml Added concurrency controls for CI runs; removed comments about Nix store cache size.
Cargo.toml Updated versions for alloy, alloy-ethers-typecast, and rain-erc dependencies.
crates/cli/src/meta/mod.rs Replaced ReadableClientHttp with ReadableClient, refactored interface support check, and updated test mocks.
crates/cli/src/meta/types/authoring/v1.rs Simplified ABI decode methods, removed boolean parameter, and consolidated validation logic.
crates/cli/src/meta/types/authoring/v2.rs Updated imports, removed boolean from ABI decode, and switched to new_from_http_urls for client creation.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Suite
    participant Mock as Mock Asserter
    participant Client as ReadableClient
    participant Meta as implements_i_described_by_meta_v1

    Test->>Mock: Push expected responses (success/failure)
    Test->>Client: Create mocked ReadableClient with Mock
    Test->>Meta: Call implements_i_described_by_meta_v1(Client, contract_address)
    Meta->>Client: client.read(parameters)
    Client->>Mock: Retrieve mocked response
    Meta-->>Test: Return true/false based on response
Loading

Possibly related issues

Possibly related PRs

Suggested reviewers

  • findolor
  • hardyjosh
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

@0xgleb 0xgleb self-assigned this Jun 4, 2025
@0xgleb 0xgleb changed the title Upd/alloy Update alloy Jun 7, 2025
@0xgleb 0xgleb marked this pull request as ready for review June 7, 2025 09:45
Copy link
Copy Markdown

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2e86d70 and 1d28ef5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .cargo/config.toml (1 hunks)
  • .github/workflows/rainix.yaml (1 hunks)
  • .github/workflows/subgraph-test.yaml (1 hunks)
  • Cargo.toml (1 hunks)
  • crates/cli/src/meta/mod.rs (5 hunks)
  • crates/cli/src/meta/types/authoring/v1.rs (3 hunks)
  • crates/cli/src/meta/types/authoring/v2.rs (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
crates/cli/src/meta/types/authoring/v1.rs (2)
crates/cli/src/meta/types/authoring/v2.rs (1)
  • abi_decode (93-112)
crates/cli/src/meta/mod.rs (1)
  • bytes32_to_str (907-913)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
  • GitHub Check: standard-tests (macos-latest, rainix-rs-artifacts)
  • GitHub Check: standard-tests (macos-latest, rainix-rs-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts)
  • GitHub Check: test
🔇 Additional comments (18)
.github/workflows/subgraph-test.yaml (1)

4-6: LGTM! Effective concurrency control implementation.

The concurrency configuration properly groups workflows by Git reference and cancels redundant runs for non-main branches, which will optimize CI resource usage.

.github/workflows/rainix.yaml (1)

4-6: LGTM! Consistent concurrency control pattern.

The concurrency configuration matches the pattern used in other workflows with appropriate suffix differentiation, ensuring proper resource management across CI pipelines.

Cargo.toml (1)

15-15:

Details

❓ Verification inconclusive

Verify major version upgrade compatibility across the codebase.

The alloy upgrade from 0.1.4 to 1.0.9 is a major version bump that likely introduces breaking changes. Ensure all alloy API usage throughout the codebase has been updated to match the new version.


🏁 Script executed:

#!/bin/bash
# Description: Search for alloy API usage patterns to verify compatibility with 1.0.9
# Expected: All usage should be compatible with the new version

echo "=== Searching for alloy imports and usage ==="
rg -A 3 "use alloy::" --type rust

echo -e "\n=== Searching for potential outdated alloy patterns ==="
rg "alloy::" --type rust -A 2 -B 2

echo -e "\n=== Checking for ABI decode patterns that might need updates ==="
rg "abi_decode" --type rust -A 2 -B 2

Length of output: 19608


Verify alloy 1.0.9 upgrade for breaking changes

A quick grep shows over 50 use alloy::… occurrences (macros, primitives, sol_types, json_abi, etc.) across:

  • crates/bindings/src/lib.rs
  • crates/metaboard/src/metaboard_client.rs
  • crates/cli/src/meta/… (magic.rs, mod.rs, types/, query/)
  • crates/cli/src/cli/output.rs
  • crates/cli/src/error/mod.rs

No blatant “old” API calls surfaced, but a major bump often hides subtle signature or macro-ABI shifts. Please:

  • Run cargo check/cargo test on all crates and address any compilation or test failures.
  • Manually audit any sol! macro invocations and JsonAbi calls for changed parameters or return types.
  • Confirm that error mappings (e.g., alloy::sol_types::Error) still convert cleanly into your Error enum.

[tag: verify_review_comment]

.cargo/config.toml (1)

1-2: LGTM! Proper WASM configuration for getrandom.

The configuration correctly sets the getrandom backend to "wasm_js" for the WASM target, which is the standard approach for browser-compatible WASM builds.

crates/cli/src/meta/types/authoring/v2.rs (4)

1-1: LGTM! Added necessary import for new destructuring pattern.

The FixedBytes import is correctly added to support the destructuring pattern used later in the file.


94-94: LGTM! Simplified ABI decode API usage.

The removal of the boolean parameter aligns with the alloy 1.0.9 API simplification. The new API appears cleaner and less error-prone.


130-130: LGTM! Updated client creation method.

The method name change from new_from_urls to new_from_http_urls provides better clarity about the expected URL types.


160-169:

Details

✅ Verification successful

LGTM! Improved type safety with structured destructuring.

The change from tuple field access (._0) to structured destructuring (FixedBytes(metahash)) provides better type safety and readability.


🏁 Script executed:

#!/bin/bash
# Description: Verify all similar patterns have been updated consistently
# Expected: No remaining ._0 access patterns for client.read() calls

echo "=== Searching for potential outdated tuple access patterns ==="
rg "\.read\(" --type rust -A 5 -B 2

echo -e "\n=== Searching for any remaining ._0 access patterns ==="
rg "\._0" --type rust -A 2 -B 2

echo -e "\n=== Searching for FixedBytes usage patterns ==="
rg "FixedBytes" --type rust -A 2 -B 2

Length of output: 2257


No remaining tuple accesses for client.read()
Verified that all ._0 usages have been removed in crates/cli/src/meta/types/authoring/v2.rs (using FixedBytes(metahash)) and no other outdated tuple access patterns were found. LGTM!

crates/cli/src/meta/types/authoring/v1.rs (4)

62-62: LGTM: ABI decoding interface simplified.

The removal of the boolean parameter from abi_decode calls simplifies the interface, which aligns with the alloy library updates mentioned in the PR.


72-74: Excellent refactor: validation logic simplified.

The refactoring to call abi_decode followed by explicit validation is cleaner and more maintainable than the previous approach.


100-112: Excellent improvement: more idiomatic Rust with better error handling.

The iterator-based approach using map and collect is more idiomatic Rust and provides better error propagation compared to the manual loop approach. The error handling with collect::<Result<_, _>>() properly short-circuits on the first error.


117-119: Good simplification: validation logic consolidated.

The simplified approach of calling abi_decode first then validating is cleaner and follows the DRY principle by reusing the existing decode logic.

crates/cli/src/meta/mod.rs (6)

14-14: LGTM: Updated to use new alloy client type.

The import change from ReadableClientHttp to ReadableClient aligns with the alloy library update objectives.


416-416: LGTM: Function signature updated for new client type.

The parameter type change from &ReadableClientHttp to &ReadableClient is consistent with the import changes.


436-436: Good simplification: direct boolean return.

The removal of .map(|r| r.0) suggests the updated alloy library now returns the boolean directly instead of wrapping it in a tuple, which simplifies the code.


924-930: LGTM: Updated test imports for new mocking approach.

The import changes from httpmock to alloy's native mocking utilities (Asserter, ErrorPayload) align with modernizing the test infrastructure.


1296-1309: Excellent refactor: cleaner test setup with native alloy mocking.

The replacement of HTTP server mocking with alloy's Asserter and ReadableClient::new_mocked provides a more direct and maintainable testing approach. The mock responses are now set up declaratively rather than through HTTP request/response matching.


1314-1335: LGTM: Test logic preserved with improved mocking.

The test cases maintain the same coverage (true response, false response, and revert scenarios) while using the cleaner alloy mocking approach. The logic and assertions remain consistent with the original tests.

Comment thread Cargo.toml
alloy = { version = "0.1.4", features = ["rand", "json", "json-abi"] }
alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "adda117b1f43e1a4dfa012299e71f2b0e73f46f4" }
alloy = { version = "1.0.9", features = ["rand", "json", "json-abi"] }
alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "f7b5bfd0687f16c77dbfdd4905b2434793fa7885" }
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Jun 7, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify git revision compatibility for related dependencies.

The git revisions for alloy-ethers-typecast and rain-erc have been updated. Ensure these specific commits are compatible with the alloy 1.0.9 upgrade.

Also applies to: 20-20


🏁 Script executed:

#!/bin/bash
# Description: Verify the compatibility of the updated git dependencies
# Expected: Commits should exist and be compatible with alloy 1.0.9

echo "=== Checking alloy-ethers-typecast commit ==="
git ls-remote https://github.com/rainlanguage/alloy-ethers-typecast f7b5bfd0687f16c77dbfdd4905b2434793fa7885

echo -e "\n=== Checking rain-erc commit ==="
git ls-remote https://github.com/rainlanguage/rain.erc 7b0f382f5e0788b0173c2391e09f4411f1c38300

echo -e "\n=== Searching for alloy-ethers-typecast usage ==="
rg "alloy_ethers_typecast" --type rust -A 2 -B 2

Length of output: 1642


Fix invalid Git revisions in Cargo.toml

The specified commits for both dependencies weren’t found on GitHub. Please update them to valid SHAs and confirm compatibility with Alloy 1.0.9.

• Cargo.toml, line 16: alloy-ethers-typecast rev f7b5bfd0687f16c77dbfdd4905b2434793fa7885 not found
• Cargo.toml, line 20: rain-erc rev 7b0f382f5e0788b0173c2391e09f4411f1c38300 not found

Suggested update:

-alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "f7b5bfd0687f16c77dbfdd4905b2434793fa7885" }
+alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "<valid-sha>" }

-rain-erc              = { git = "https://github.com/rainlanguage/rain-erc",             rev = "7b0f382f5e0788b0173c2391e09f4411f1c38300" }
+rain-erc              = { git = "https://github.com/rainlanguage/rain-erc",             rev = "<valid-sha>" }
🤖 Prompt for AI Agents
In Cargo.toml at lines 16 and 20, the git revision SHAs for the dependencies
alloy-ethers-typecast and rain-erc are invalid and not found on GitHub. Update
these lines with valid commit SHAs from their respective repositories that are
compatible with alloy 1.0.9. Verify the new SHAs exist by running git ls-remote
commands and ensure the dependencies work correctly with the updated commits.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They are valid and latest lol

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

@0xgleb My apologies! Let me verify those commits again to understand what went wrong with my initial check.


🏁 Script executed:

#!/bin/bash
# Re-verify the git commits more thoroughly
echo "=== Checking alloy-ethers-typecast commit with different approach ==="
curl -s "https://api.github.com/repos/rainlanguage/alloy-ethers-typecast/commits/f7b5bfd0687f16c77dbfdd4905b2434793fa7885" | jq '.sha // "Not found"'

echo -e "\n=== Checking rain-erc commit with different approach ==="
curl -s "https://api.github.com/repos/rainlanguage/rain.erc/commits/7b0f382f5e0788b0173c2391e09f4411f1c38300" | jq '.sha // "Not found"'

echo -e "\n=== Trying git ls-remote again with full SHA ==="
git ls-remote https://github.com/rainlanguage/alloy-ethers-typecast | grep f7b5bfd0687f16c77dbfdd4905b2434793fa7885 || echo "Not found in ls-remote"
git ls-remote https://github.com/rainlanguage/rain.erc | grep 7b0f382f5e0788b0173c2391e09f4411f1c38300 || echo "Not found in ls-remote"

echo -e "\n=== Checking if repos exist and are accessible ==="
curl -s "https://api.github.com/repos/rainlanguage/alloy-ethers-typecast" | jq '.name // "Repo not found"'
curl -s "https://api.github.com/repos/rainlanguage/rain.erc" | jq '.name // "Repo not found"'

Length of output: 1545


@0xgleb You're absolutely right, and I apologize for the incorrect assessment!

The verification now confirms that both commits are indeed valid and are actually the HEAD commits on the main branches:

  • f7b5bfd0687f16c77dbfdd4905b2434793fa7885 is the latest commit for alloy-ethers-typecast
  • 7b0f382f5e0788b0173c2391e09f4411f1c38300 is the latest commit for rain.erc

My initial verification script must have had an issue or I misinterpreted the results. Thank you for the correction!


✏️ Learnings added
Learnt from: 0xgleb
PR: rainlanguage/rain.metadata#72
File: Cargo.toml:16-16
Timestamp: 2025-06-07T09:54:46.513Z
Learning: When verifying git commit SHAs, use multiple verification methods (GitHub API, git ls-remote) and be careful not to jump to conclusions if one method doesn't immediately show results. Commits that are HEAD of main branches are by definition "latest" and valid.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@0xgleb 0xgleb requested review from findolor and hardyjosh June 7, 2025 09:54
@0xgleb 0xgleb merged commit 908c336 into main Jun 7, 2025
10 checks passed
@0xgleb 0xgleb deleted the upd/alloy branch June 7, 2025 10:14
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.

Upgrade alloy, alloy-ethers-typecast, and rain.erc versions in rain.metadata

3 participants