Skip to content

Update batch quote logic to use error registry#2268

Merged
findolor merged 7 commits intomainfrom
openchain-issue
Oct 27, 2025
Merged

Update batch quote logic to use error registry#2268
findolor merged 7 commits intomainfrom
openchain-issue

Conversation

@findolor
Copy link
Copy Markdown
Collaborator

@findolor findolor commented Oct 24, 2025

Motivation

See issues:

Solution

  • Create new function that uses the new registry logic in rain-error repository
  • Wrap the batch quote function for backwards compatibility
  • Update tests to use fake registry

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

  • New Features

    • Registry-based error decoding for more accurate multicall error messages.
  • Improvements

    • Enhanced error handling and fallbacks for multicall operations while remaining backward-compatible.
  • Chores

    • Updated error-decoding and URL dependencies across the workspace.
    • Added a dev dependency to support async tooling in quote-related tests.
    • Updated a submodule pointer.

@findolor findolor requested review from 0xgleb and hardyjosh October 24, 2025 11:18
@findolor findolor self-assigned this Oct 24, 2025
@findolor findolor linked an issue Oct 24, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 24, 2025

Walkthrough

Added optional ErrorRegistry support to quote error decoding: batch_quote gained a registry: Option<&dyn ErrorRegistry> parameter and decoding calls now accept the registry; tests updated to exercise a fake registry. Also updated rain-error-decoding git rev, bumped url, added a dev-dependency, and advanced a submodule pointer.

Changes

Cohort / File(s) Summary
Workspace & Tauri manifests
Cargo.toml, tauri-app/src-tauri/Cargo.toml
Updated dependency rain-error-decoding git rev (to 3d2ed70f...) and bumped url from 2.5.02.5.7.
Quote crate dev-deps
crates/quote/Cargo.toml
Added dev-dependency async-trait = "0.1".
Quote RPC & decoding
crates/quote/src/rpc.rs, crates/quote/src/quote.rs, crates/quote/src/quote_debug.rs
batch_quote gained registry: Option<&dyn ErrorRegistry>; error-decoding calls now pass an optional registry; call sites updated to pass None where appropriate; tests added/updated to use a FakeRegistry.
Common decoding call sites
crates/common/src/erc20.rs, crates/common/src/fuzz/impls.rs
Updated AbiDecodedErrorType::selector_registry_abi_decode invocations to include an extra None registry argument.
Submodule pointer
lib/rain.interpreter
Submodule updated from commit ff1d064d8fef...98f76e26bf47....

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant batch_quote_wrapper as "batch_quote (wrapper)"
    participant batch_quote_impl as "batch_quote_with_registry"
    participant OpenChainRegistry as "OpenChainRegistry (default)"
    participant ErrorDecoder as "AbiDecodedErrorType/ErrorDecoder"

    Caller->>batch_quote_wrapper: batch_quote(..., multicall, registry_opt)
    alt registry_opt is None
        batch_quote_wrapper->>OpenChainRegistry: create default registry
        OpenChainRegistry-->>batch_quote_wrapper: &registry
    else registry_opt provided
        batch_quote_wrapper-->>batch_quote_impl: pass provided &registry
    end
    batch_quote_wrapper->>batch_quote_impl: batch_quote_with_registry(..., &registry)
    batch_quote_impl->>ErrorDecoder: decode(revert_bytes, &registry)
    ErrorDecoder-->>batch_quote_impl: decoded error/result
    batch_quote_impl-->>batch_quote_wrapper: Vec<QuoteResult>
    batch_quote_wrapper-->>Caller: Result<Vec<QuoteResult>>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to crates/quote/src/rpc.rs changes (new parameter propagation and tests).
  • Verify all AbiDecodedErrorType::selector_registry_abi_decode callsites updated consistently (crates/common/*, crates/quote/*).

Possibly related PRs

Suggested labels

rust, test

Suggested reviewers

  • hardyjosh
  • 0xgleb

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Update batch quote logic to use error registry" is directly and specifically related to the core changes in the pull request. The raw summary shows that the primary functional change is the modification of the batch_quote function to accept a registry: Option<&dyn ErrorRegistry> parameter and propagate it through error-decoding paths across multiple files. The title accurately captures this main objective without being vague, misleading, or overly broad. A teammate scanning the history would immediately understand that this PR introduces error registry support to the batch quote operation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch openchain-issue

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 284ab2e and 4702cac.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • tauri-app/src-tauri/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • Cargo.toml (2 hunks)
  • crates/common/src/erc20.rs (2 hunks)
  • crates/common/src/fuzz/impls.rs (2 hunks)
  • crates/quote/src/quote_debug.rs (1 hunks)
  • crates/quote/src/rpc.rs (9 hunks)
  • lib/rain.interpreter (1 hunks)
  • tauri-app/src-tauri/Cargo.toml (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
crates/*/{src,tests,benches,examples}/**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Rust code must pass clippy with all warnings denied (cargo clippy --workspace --all-targets --all-features -D warnings)

Files:

  • crates/quote/src/quote_debug.rs
  • crates/quote/src/rpc.rs
  • crates/common/src/erc20.rs
  • crates/common/src/fuzz/impls.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Rust code lives in the workspace under crates/* (e.g., cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests)

Files:

  • crates/quote/src/quote_debug.rs
  • crates/quote/src/rpc.rs
  • crates/common/src/erc20.rs
  • crates/common/src/fuzz/impls.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Format Rust with nix develop -c cargo fmt --all
Lint Rust with nix develop -c rainix-rs-static (preconfigured flags)
Use snake_case for Rust crates/modules and PascalCase for types

Files:

  • crates/quote/src/quote_debug.rs
  • crates/quote/src/rpc.rs
  • crates/common/src/erc20.rs
  • crates/common/src/fuzz/impls.rs
tauri-app/**

📄 CodeRabbit inference engine (AGENTS.md)

Desktop app code is in tauri-app (Rust + Svelte); src-tauri is not part of the Cargo workspace

Files:

  • tauri-app/src-tauri/Cargo.toml
🧠 Learnings (1)
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
PR: rainlanguage/rain.orderbook#1859
File: crates/quote/src/quote_debug.rs:472-492
Timestamp: 2025-05-20T10:20:08.206Z
Learning: In the Rain Orderbook codebase, the `#[tokio::test(flavor = "multi_thread")]` annotation is specifically needed for tests that use `LocalEvm`, not just for consistency across all async tests.

Applied to files:

  • crates/quote/src/rpc.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
  • GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
  • GitHub Check: build-tauri (ubuntu-22.04, true)
  • GitHub Check: test
  • GitHub Check: Deploy-Docs-Preview
  • GitHub Check: Deploy-Preview-Push
🔇 Additional comments (13)
Cargo.toml (2)

59-59: rain-error-decoding update aligns with PR objectives.

The git revision update to 3d2ed70fb2f7c6156706846e10f163d1e493a8d3 directly supports the PR goal of integrating error registry support for quote error decoding. Ensure this commit is accessible and verified with the maintainers.


34-34: No issues found — url 2.5.7 is safe.

The url 2.5.7 release is a patch version with no documented breaking changes and no new security advisories targeting it; any IDNA security issues (RUSTSEC-2024-0421 / CVE-2024-12224) were already addressed in earlier url updates.

lib/rain.interpreter (1)

1-1: Cannot verify the submodule commit—manual confirmation needed.

The sandbox environment cannot access git repository metadata or inspect the submodule commit. The file does not exist as a regular filesystem file (it is a gitlink entry managed by git). Verification requires:

  • Confirming commit 98f76e26bf47e9062ba56c900acb700f912a470e is valid and exists in the rain.interpreter submodule repository
  • Confirming the commit contains the expected registry-based error decoding changes referenced in the PR
  • Confirming no breaking changes are introduced to dependent modules (quote modules)
tauri-app/src-tauri/Cargo.toml (2)

65-65: LGTM!

The git revision update for rain-error-decoding brings in the necessary ErrorRegistry support for this PR.


47-47: No action required—url crate version 2.5.7 is valid and secure.

Version 2.5.7 is a published release available on crates.io, and the security advisory check returned no known vulnerabilities. The patch-level version bump from 2.5.0 to 2.5.7 is a standard update with no breaking changes expected.

crates/quote/src/quote_debug.rs (1)

76-77: LGTM!

The addition of the None parameter correctly adapts to the new selector_registry_abi_decode signature while maintaining backward-compatible behavior.

crates/common/src/fuzz/impls.rs (1)

532-533: LGTM!

The addition of the None parameter correctly adapts to the new API signature, maintaining consistency with other error decoding call sites in the codebase.

crates/common/src/erc20.rs (2)

102-103: LGTM!

The error decoding update correctly passes None for the registry parameter, maintaining default behavior for ERC20 multicall failures.


168-169: LGTM!

The error decoding update correctly passes None for the registry parameter, maintaining default behavior for contract revert handling.

crates/quote/src/rpc.rs (4)

10-10: LGTM!

The ErrorRegistry import is necessary for the new registry parameter support.


46-71: LGTM!

The multicall failure handling correctly passes the registry to the error decoder and appropriately propagates the decoded error to all quote targets.


84-93: LGTM!

Individual call failures are correctly decoded with the registry parameter, allowing custom error registries to provide enhanced error information.


273-288: FakeRegistry implementation is correct and well-designed.

The async-trait dependency is available in the crate (version 0.1). The FakeRegistry implementation correctly implements the ErrorRegistry trait, returning a known error for the test selector (0x734bc71c) and an empty vec for unknown selectors, enabling proper test coverage of both error paths.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b7dae5 and 284ab2e.

📒 Files selected for processing (2)
  • crates/quote/src/quote.rs (4 hunks)
  • crates/quote/src/rpc.rs (9 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/*/{src,tests,benches,examples}/**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Rust code must pass clippy with all warnings denied (cargo clippy --workspace --all-targets --all-features -D warnings)

Files:

  • crates/quote/src/quote.rs
  • crates/quote/src/rpc.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Rust code lives in the workspace under crates/* (e.g., cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests)

Files:

  • crates/quote/src/quote.rs
  • crates/quote/src/rpc.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Format Rust with nix develop -c cargo fmt --all
Lint Rust with nix develop -c rainix-rs-static (preconfigured flags)
Use snake_case for Rust crates/modules and PascalCase for types

Files:

  • crates/quote/src/quote.rs
  • crates/quote/src/rpc.rs
🧠 Learnings (1)
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
PR: rainlanguage/rain.orderbook#1859
File: crates/quote/src/quote_debug.rs:472-492
Timestamp: 2025-05-20T10:20:08.206Z
Learning: In the Rain Orderbook codebase, the `#[tokio::test(flavor = "multi_thread")]` annotation is specifically needed for tests that use `LocalEvm`, not just for consistency across all async tests.

Applied to files:

  • crates/quote/src/rpc.rs
🧬 Code graph analysis (1)
crates/quote/src/quote.rs (1)
crates/quote/src/rpc.rs (2)
  • batch_quote (16-96)
  • rpcs (24-27)
🔇 Additional comments (8)
crates/quote/src/quote.rs (4)

80-91: LGTM: back-compat call updated

Passing None for the new registry parameter keeps existing behavior and compiles against the new signature. No issues spotted.


124-124: LGTM: batch invocation updated

The added None aligns with the new rpc::batch_quote signature.


190-198: LGTM: subgraph path updated

Registry parameter wired as None; behavior preserved.


278-287: LGTM: batch spec path updated

Call-site correctly forwards None for registry; flow using VecDeque remains unchanged.

crates/quote/src/rpc.rs (4)

10-10: New decoding imports are appropriate

Bringing in AbiDecodedErrorType, ErrorRegistry, OpenChainRegistry matches the new registry-aware decoding path.


53-56: Registry-aware decoding correctly applied

Both multicall error paths now use decode_with_registry(registry). This is consistent and maintains per-call vs. aggregate failure handling.

Also applies to: 85-87


271-286: Tests exercise custom registry path

FakeRegistry via async-trait is minimal and effective; assertions cover Known vs Unknown decoding. Nice.

Also applies to: 294-296, 102-102, 109-109


22-23: All internal call sites correctly updated, but public API break requires external user verification

The function batch_quote is publicly exported (pub mod rpc in lib.rs) and its signature was changed by adding an Option<&dyn ErrorRegistry> parameter. All internal call sites within the workspace have been updated to pass None for this parameter. However, if this crate is used as a library by external projects, those users' code will break when upgrading. Consider providing a deprecated wrapper function retaining the old signature, or verify through your package's dependency tracking/usage telemetry that no external users depend on the old signature.

Comment thread crates/quote/src/rpc.rs Outdated
Comment on lines +46 to +48
let oc_default = OpenChainRegistry::default();
let registry: &dyn ErrorRegistry = registry.unwrap_or(&oc_default);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Slight improvement: avoid constructing default when not needed

Current unwrap_or always builds OpenChainRegistry even when a registry is provided. Minor cost, but you can avoid it with an if-let.

-    let oc_default = OpenChainRegistry::default();
-    let registry: &dyn ErrorRegistry = registry.unwrap_or(&oc_default);
+    let oc_default;
+    let registry: &dyn ErrorRegistry = if let Some(reg) = registry {
+        reg
+    } else {
+        oc_default = OpenChainRegistry::default();
+        &oc_default
+    };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let oc_default = OpenChainRegistry::default();
let registry: &dyn ErrorRegistry = registry.unwrap_or(&oc_default);
let oc_default;
let registry: &dyn ErrorRegistry = if let Some(reg) = registry {
reg
} else {
oc_default = OpenChainRegistry::default();
&oc_default
};
🤖 Prompt for AI Agents
In crates/quote/src/rpc.rs around lines 46 to 48, the current code always
constructs OpenChainRegistry::default() even when a registry is provided; change
the logic to only create the default when registry is None by replacing
unwrap_or with an if-let (or match) that checks registry: if Some(r) use r, else
construct OpenChainRegistry::default() and use a reference to it, ensuring the
default is only built when needed.

@findolor findolor merged commit fbd8f68 into main Oct 27, 2025
19 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 27, 2025

Tip

For best results, initiate chat on the files or code changes.

SIZE=M


🧠 Learnings used
Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T21:24:42.275Z
Learning: For PR #1884, after each commit review, I should provide a new comment with a PR size report in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding irrelevant files such as lock files (package-lock.json, cargo.lock, etc.).

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.

Update batch quote logic to use fake openchain registry

3 participants