Skip to content

virtual raindex#2167

Closed
hardyjosh wants to merge 20 commits intomainfrom
2025-09-26-virtual-raindex
Closed

virtual raindex#2167
hardyjosh wants to merge 20 commits intomainfrom
2025-09-26-virtual-raindex

Conversation

@hardyjosh
Copy link
Copy Markdown
Contributor

@hardyjosh hardyjosh commented Sep 26, 2025

Motivation

  • We need a deterministic, in-memory replica of the Rain Orderbook so builders can quote, take, and replay orders without tethering to an RPC endpoint.
  • Existing tooling could not simulate undeployed orders, batch event replays, or WASM targets with full interpreter semantics, which blocked backtesting, CI, and integration scenarios.
  • Delivering the initial Virtual Raindex implementation (code, tests, docs, and plan) unlocks downstream work across simulators, UI, and automation that depend on a stable local engine.

Solution

  • Introduced the virtual-raindex crate featuring the VirtualRaindex engine, mutation-driven state model, REVM-based interpreter host, bytecode cache, and typed quote/take APIs.
  • Added comprehensive integration tests validating quoting, taking, vault/store mutations, and snapshot flows against known scenarios.
  • Documented the architecture with crate-level Rust docs, module comments, implementation notes, and a README that explains features, layout, and usage for consumers.

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

    • Virtual in-memory orderbook engine with quoting, take/execution flows, post-task handling, and deterministic snapshots.
    • Pluggable bytecode cache and REVM-backed interpreter host for running order logic.
  • Documentation

    • New crate README with overview, usage examples, and testing guidance.
  • Tests

    • Extensive unit and integration tests, including a LocalEVM harness and proptest regressions.
  • Chores

    • New workspace crate manifest and dependency wiring.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 26, 2025

Walkthrough

Adds a new workspace crate virtual-raindex implementing an in-memory Rain orderbook engine with bytecode caching, a REVM-backed interpreter host, quote and take flows, state & store management, post-task execution, extensive unit and integration tests, and a shared order_hash utility moved to common.

Changes

Cohort / File(s) Summary
Crate infra & docs
crates/virtual-raindex/Cargo.toml, crates/virtual-raindex/README.md, crates/virtual-raindex/proptest-regressions/integration_tests.txt, Cargo.toml (workspace root)
Adds new crate manifest and README; registers workspace deps (revm, assert_matches, others), dev-dependencies, and proptest regression seeds.
Public API re-exports
crates/virtual-raindex/src/lib.rs
Declares crate modules and re-exports core types (engine, cache, host, error, state, store) for external use.
Bytecode cache
crates/virtual-raindex/src/cache.rs
Adds CodeCache trait and thread-safe StaticCodeCache with ensure/lookup helpers and unit tests.
Interpreter host (REVM)
crates/virtual-raindex/src/host/mod.rs, crates/virtual-raindex/src/host/revm.rs
Introduces InterpreterHost abstraction, EvalOutcome, and RevmInterpreterHost that loads bytecode into an InMemoryDB, runs evals, and returns stack/writes with error mapping.
Error model
crates/virtual-raindex/src/error.rs
Adds RaindexError enum, BytecodeKind, Result<T> alias, conversions and Display/Error implementations.
State model & mutations
crates/virtual-raindex/src/state.rs, crates/virtual-raindex/src/engine/mutations.rs
Implements in-memory RaindexState, Snapshot, RaindexMutation variants, vault/store/token handling, mutation application including recursive batches and mutation preflight (prepare_mutations, ensure_vault_entries).
Store utilities
crates/virtual-raindex/src/store.rs
Adds store namespace derivation, fqn generation, state overlay building, writes-to-pairs conversion, apply_store_writes and apply_overrides helpers plus tests.
Engine core & orchestration
crates/virtual-raindex/src/engine/mod.rs
Adds generic VirtualRaindex<C,H> with lifecycle APIs (new, snapshot, interpreter/code_cache access, add_order, quote, take_orders, take_orders_and_apply_state, apply_mutations), OrderRef, helper u8_to_b256 and module wiring.
Context construction
crates/virtual-raindex/src/engine/context.rs
Builds interpreter context grids (calling context, calculations, vault IO, signed contexts) and exposes IOContext helper.
Eval call builder
crates/virtual-raindex/src/engine/eval.rs
Adds EvalEntrypoint and build_eval_call to construct EvalV4 payloads with correct sourceIndex.
Calculate Io flow
crates/virtual-raindex/src/engine/calc.rs
Implements calculate_order_io and OrderCalculation to run CalculateIo entrypoint, validate/clamp outputs, collect stack and store writes.
Quote flow
crates/virtual-raindex/src/engine/quote.rs
Adds StoreOverride, QuoteRequest, Quote, and quote flow that applies overrides, validates indices/tokens, and calls calculate_order_io.
Take flow
crates/virtual-raindex/src/engine/take.rs
Implements full take-order processor (TakeOrder types, validations, calculate, vault updates, store writes, HandleIo mapping) and top-level take_orders/take_orders_and_apply_state.
Add-order & post-tasks
crates/virtual-raindex/src/engine/add_order.rs
Adds add_order, post-task execution, and bytecode preflight for tasks with store-write application.
Engine tests & integration
crates/virtual-raindex/src/engine/tests.rs, crates/virtual-raindex/src/integration_tests.rs
Introduces comprehensive unit tests with mocks (NullCache/NullInterpreter/RecordingHost) and an extensive LocalEVM integration harness with proptest-driven scenarios.
Calc/eval helpers tests
crates/virtual-raindex/src/engine/calc.rs, crates/virtual-raindex/src/engine/eval.rs
Unit tests for calculate-order and eval call construction, including error paths and clamping.
Common util: order_hash
crates/common/src/utils/order_hash.rs, crates/common/src/utils/mod.rs
New order_hash module and function computing keccak256 of ABI-encoded OrderV4; tests assert a stable default hash.
Downstream updates
crates/js_api/src/bindings/mod.rs, crates/quote/src/cli/mod.rs, crates/quote/src/quote.rs
Replace inline keccak usage with shared order_hash utility in tests and code paths.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant VirtualRaindex
    participant CodeCache
    participant InterpreterHost
    participant REVM

    Caller->>VirtualRaindex: quote(request)
    VirtualRaindex->>VirtualRaindex: resolve_order(reference)
    VirtualRaindex->>VirtualRaindex: build_quote_context(...)
    VirtualRaindex->>CodeCache: ensure_artifacts(order)
    CodeCache-->>VirtualRaindex: Ok / MissingBytecode
    VirtualRaindex->>InterpreterHost: eval4(interpreter, eval_call, store_snapshot, env)
    InterpreterHost->>CodeCache: interpreter(addr) / store(addr)
    CodeCache-->>InterpreterHost: bytecode
    InterpreterHost->>REVM: execute(eval)
    REVM-->>InterpreterHost: stack, writes
    InterpreterHost-->>VirtualRaindex: EvalOutcome
    VirtualRaindex-->>Caller: Quote { io_ratio, output_max, stack, writes }
Loading
sequenceDiagram
    participant Caller
    participant VirtualRaindex
    participant TakeProcessor
    participant State
    participant CodeCache
    participant InterpreterHost

    Caller->>VirtualRaindex: take_orders_and_apply_state(config)
    VirtualRaindex->>TakeProcessor: start processing orders
    loop per order
        TakeProcessor->>VirtualRaindex: resolve_order(ref)
        TakeProcessor->>VirtualRaindex: validate_io_indices & tokens
        TakeProcessor->>InterpreterHost: calculate_order_io(...)
        InterpreterHost->>CodeCache: ensure artifacts
        InterpreterHost-->>TakeProcessor: EvalOutcome
        TakeProcessor->>State: apply_vault_updates(deltas)
        TakeProcessor->>State: apply_store_writes(writes)
        TakeProcessor->>TakeProcessor: record mutations
    end
    TakeProcessor-->>VirtualRaindex: TakeOrdersOutcome (results, mutations, warnings)
    VirtualRaindex->>State: apply_mutations(outcome.mutations)
    VirtualRaindex-->>Caller: TakeOrdersOutcome
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45–60 minutes

Areas to focus review on:

  • StaticCodeCache concurrency and RwLock usage.
  • REVM host: bytecode lazy-loading, InMemoryDB population, env/state overlay correctness, and error mapping.
  • Mutation orchestration: recursive Batch handling, atomicity of add_order/post-tasks, and vault delta accumulation.
  • calculate_order_io / quote / take flows: index validations, token-decimal lookups, clamping logic, and correct translation of interpreter writes to store mutations.
  • Integration tests: harness setup, proptest scenarios, and deterministic seeds.

Suggested labels

rust, test

Suggested reviewers

  • 0xgleb

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.89% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'virtual raindex' is overly vague and generic, lacking specificity about the changeset. It does not convey meaningful information about the primary changes introduced. Use a more descriptive title that captures the main intent, such as 'Add VirtualRaindex engine for in-memory orderbook simulation' or 'Introduce VirtualRaindex crate with state, quote, and take functionality'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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 2025-09-26-virtual-raindex

📜 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 40508fb and 5ea0dec.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • Cargo.toml (2 hunks)
  • crates/quote/src/quote.rs (2 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/**/*.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
**/*.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
🧠 Learnings (29)
📓 Common learnings
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the format: "TOTAL=number ADDITIONS=number DELETIONS=number". This report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the exact format: "TOTAL=number\nADDITIONS=number\nDELETIONS=number". This report should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/**/*.rs : Rust code lives in the workspace under crates/* (e.g., cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests)
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.
📚 Learning: 2025-07-16T10:40:05.717Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-10-13T12:57:05.900Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2198
File: crates/common/src/raindex_client/local_db/query/fetch_store_addresses/mod.rs:7-8
Timestamp: 2025-10-13T12:57:05.900Z
Learning: In the rain.orderbook repository, using unqualified serde helper names (e.g., `#[serde(with = "serde_address")]`) that rely on glob imports is acceptable and does not need to be changed to fully qualified paths.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-04-29T06:19:15.446Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1706
File: crates/quote/src/js_api/mod.rs:57-61
Timestamp: 2025-04-29T06:19:15.446Z
Learning: In the rain.orderbook codebase, the `get_id` function is designed to use `U256::from_str()` rather than `U256::from_hex()` for parsing order hashes, despite the potential for hex string inputs.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-07-04T09:02:57.301Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/fuzz/mod.rs:64-64
Timestamp: 2025-07-04T09:02:57.301Z
Learning: In rainlanguage/rain.orderbook, user findolor prefers to limit type consistency changes to only the parts directly related to the current work scope. For example, when updating chain_id fields from u64 to u32 in fuzz-related code, unrelated files like tauri-app wallet commands can remain as u64 if they serve different purposes and aren't part of the current changes.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-07-18T10:31:05.498Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2008
File: crates/common/src/raindex_client/add_orders.rs:85-86
Timestamp: 2025-07-18T10:31:05.498Z
Learning: In the rainlanguage/rain.orderbook codebase, cfg-guarded imports like `#[cfg(not(target_family = "wasm"))] use super::*;` in test modules are sometimes needed to fix compiler warnings, even when similar imports exist in nested sub-modules. These should not be removed as they serve a specific purpose in the compilation process.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-07-21T16:37:20.599Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/utils/mod.rs:1-1
Timestamp: 2025-07-21T16:37:20.599Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers explicit module imports over re-exporting symbols at higher levels. Specifically for the float constants in crates/subgraph/src/utils/float.rs, they prefer using `utils::float::*` rather than re-exporting with `pub use float::*` in the utils module, as the explicit import makes it clearer what is being imported and why it's needed.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-07-21T16:34:31.193Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/types/impls.rs:7-15
Timestamp: 2025-07-21T16:34:31.193Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers breaking changes that remove unsafe default behaviors to be intentional and acceptable. Specifically, the get_decimals() method in crates/subgraph/src/types/impls.rs was intentionally changed to return MissingDecimals error instead of defaulting to 18 decimals, as defaulting to 18 is considered unsafe and should never have been done.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-05-19T10:39:19.157Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/lib/types/transaction.ts:71-77
Timestamp: 2025-05-19T10:39:19.157Z
Learning: In the Rain Orderbook project, `orderHash` is typed as `string` (not `Hex`) in the `InternalTransactionArgs` interface because it comes from the WASM function `getRemoveOrderCalldata` which returns a string value. Meanwhile, `txHash` is typed as `Hex` since it represents an actual blockchain transaction hash that requires the stricter type.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-09-24T10:59:25.666Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/js_api/src/gui/state_management.rs:196-203
Timestamp: 2025-09-24T10:59:25.666Z
Learning: In crates/js_api/src/gui/state_management.rs, the RainMetaDocumentV1Item::hash(false) method returns a slice, so wrapping the result with FixedBytes() is necessary to convert it to the expected FixedBytes type for DotrainGuiStateV1.dotrain_hash field.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-08-15T15:57:45.830Z
Learnt from: Siddharth2207
Repo: rainlanguage/rain.orderbook PR: 2089
File: test/concrete/ob/OrderBook.withdraw.t.rounding.sol:7-7
Timestamp: 2025-08-15T15:57:45.830Z
Learning: In the rainlanguage/rain.orderbook codebase, user Siddharth2207 considers Math import from OpenZeppelin contracts as required in test files like test/concrete/ob/OrderBook.withdraw.t.rounding.sol, even when direct usage is not immediately visible in the code.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-06-17T16:21:24.384Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-06-18T18:24:32.049Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:180-199
Timestamp: 2025-06-18T18:24:32.049Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to avoid refactoring duplicate search logic between get_orderbook_by_address and get_orderbook_by_network_key when there are only 2 functions, indicating they would consider it if more similar functions are added in the future.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-09-02T08:04:34.729Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: crates/js_api/src/gui/select_tokens.rs:421-424
Timestamp: 2025-09-02T08:04:34.729Z
Learning: User findolor in the rainlanguage/rain.orderbook codebase prefers not to change test code when tests are already passing, even if there appear to be type mismatches or potential issues. Working tests should be left alone unless there are actual errors.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-06-24T08:46:03.368Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1947
File: crates/common/src/raindex_client/orders.rs:98-125
Timestamp: 2025-06-24T08:46:03.368Z
Learning: In the vault merging logic in crates/common/src/raindex_client/orders.rs, optimization isn't necessary because the maximum list items are usually around 5 items. For such small datasets, the simple three-loop approach is preferred over HashMap-based optimization due to clarity and minimal performance impact.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 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/quote.rs
📚 Learning: 2025-05-13T20:06:22.602Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1713
File: crates/settings/src/remote/chains/mod.rs:43-226
Timestamp: 2025-05-13T20:06:22.602Z
Learning: When writing tests for collections of complex objects in Rust, prefer item-by-item comparison over direct vector comparison to get more specific error messages that pinpoint exactly which item and field has a mismatch.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-05-09T05:28:22.089Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/js_api/src/subgraph/order.rs:109-114
Timestamp: 2025-05-09T05:28:22.089Z
Learning: In the rain.orderbook project, SubgraphError contains or converts from OrderbookSubgraphClientError, so using OrderbookSubgraphClientError in error creation followed by a conversion to SubgraphError (via ? operator) is acceptable.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-08-26T14:52:37.000Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2099
File: crates/common/src/hyper_rpc.rs:3-7
Timestamp: 2025-08-26T14:52:37.000Z
Learning: In the rain.orderbook codebase, creating new reqwest::Client instances per request in HyperRpcClient is not considered an issue by the maintainers, despite potential performance benefits of client reuse.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-05-19T12:25:02.658Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/cynic_client.rs:27-29
Timestamp: 2025-05-19T12:25:02.658Z
Learning: In the Rain Orderbook codebase, when passing a URL from `self.get_base_url()` to `reqwest::Client::post()`, the `.clone()` is necessary because `get_base_url()` returns a reference (`&Url`), but an owned `Url` is needed for the reqwest client in the async context to avoid lifetime issues.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-06-17T16:32:04.554Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/js_api/src/gui/order_operations.rs:124-134
Timestamp: 2025-06-17T16:32:04.554Z
Learning: In the rain.orderbook codebase, RPC lists are typically small (2 items maximum), so performance optimizations around cloning and converting small Vec<Url> collections are generally unnecessary.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-06-08T18:43:51.842Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1891
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/page.test.ts:66-80
Timestamp: 2025-06-08T18:43:51.842Z
Learning: In the rain.orderbook webapp test files, when mocking objects like the transaction manager, it's acceptable to use simple empty objects with ts-expect-error comments rather than providing complete mock implementations with all properties and methods.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-09-25T12:19:33.736Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2099
File: crates/common/src/raindex_client/sqlite_web/fetch.rs:1203-1209
Timestamp: 2025-09-25T12:19:33.736Z
Learning: httpmock json_body_partial expects Into<String> (JSON string), while json_body expects Into<serde_json::Value> (JSON object). Using .to_string() with json_body_partial is the correct usage.

Applied to files:

  • crates/quote/src/quote.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/**/*.rs : Rust code lives in the workspace under crates/* (e.g., cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests)

Applied to files:

  • Cargo.toml
📚 Learning: 2025-05-16T17:24:34.724Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:27-28
Timestamp: 2025-05-16T17:24:34.724Z
Learning: In Rust projects, dependencies listed in the [dependencies] section of Cargo.toml are available for both application code and tests. There's no need to duplicate them in [dev-dependencies] unless you want a different version or configuration specifically for tests.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-05-16T17:24:34.724Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:27-28
Timestamp: 2025-05-16T17:24:34.724Z
Learning: In Rust projects, dependencies listed in the [dependencies] section of Cargo.toml are available for both application code and tests. The tokio crate with the "full" feature set includes the "test" feature needed for `#[tokio::test]` to work properly.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-05-15T22:27:49.771Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1777
File: tauri-app/src-tauri/Cargo.toml:64-64
Timestamp: 2025-05-15T22:27:49.771Z
Learning: User 0xgleb prefers to maintain the dot notation format for some Cargo.toml dependencies (e.g., `rain-interpreter-eval.path = "path"`) rather than converting all to inline table format, as both formats are valid in Rust.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-05-14T04:49:14.621Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1710
File: crates/quote/Cargo.toml:30-30
Timestamp: 2025-05-14T04:49:14.621Z
Learning: In the rain.orderbook repository, wasm-bindgen-utils is intentionally used as an unconditional dependency because non-wasm targets (like tests) sometimes need to use it.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-06-06T16:38:04.182Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1913
File: Cargo.toml:55-55
Timestamp: 2025-06-06T16:38:04.182Z
Learning: In rain.orderbook repository, during PR chains involving dependency updates, wasm-bindgen-utils may temporarily point to git commits that don't contain the full required functionality, with the understanding that subsequent PRs in the chain will update it to the correct commit.

Applied to files:

  • Cargo.toml
🧬 Code graph analysis (1)
crates/quote/src/quote.rs (1)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (7-9)
⏰ 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: Deploy-Docs-Preview
  • GitHub Check: Deploy-Preview-Push
  • GitHub Check: test
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
  • GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: build-tauri (ubuntu-22.04, true)
🔇 Additional comments (2)
Cargo.toml (1)

66-66: assert_matches is correctly pinned to the latest version.

assert_matches 1.5.0 (Feb 5, 2021) is already at the latest available release on crates.io. No version updates needed.

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

323-323: LGTM! Test code now uses shared order_hash helper.

The import and test updates improve consistency by using the canonical helper instead of inline hashing logic.

Also applies to: 335-335


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

@hardyjosh
Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 27, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 213cc49 and 95fb7f4.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (21)
  • crates/test_fixtures/src/lib.rs (2 hunks)
  • crates/virtual-raindex/Cargo.toml (1 hunks)
  • crates/virtual-raindex/README.md (1 hunks)
  • crates/virtual-raindex/src/cache.rs (1 hunks)
  • crates/virtual-raindex/src/engine/context.rs (1 hunks)
  • crates/virtual-raindex/src/engine/mod.rs (1 hunks)
  • crates/virtual-raindex/src/engine/mutations.rs (1 hunks)
  • crates/virtual-raindex/src/engine/post_tasks.rs (1 hunks)
  • crates/virtual-raindex/src/engine/quote.rs (1 hunks)
  • crates/virtual-raindex/src/engine/take.rs (1 hunks)
  • crates/virtual-raindex/src/engine/tests.rs (1 hunks)
  • crates/virtual-raindex/src/error.rs (1 hunks)
  • crates/virtual-raindex/src/host/mod.rs (1 hunks)
  • crates/virtual-raindex/src/host/revm.rs (1 hunks)
  • crates/virtual-raindex/src/integration_tests.rs (1 hunks)
  • crates/virtual-raindex/src/lib.rs (1 hunks)
  • crates/virtual-raindex/src/state.rs (1 hunks)
  • crates/virtual-raindex/src/types/mod.rs (1 hunks)
  • crates/virtual-raindex/src/types/order_ref.rs (1 hunks)
  • crates/virtual-raindex/src/types/quote.rs (1 hunks)
  • crates/virtual-raindex/src/types/take.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-07-31T19:34:11.716Z
Learnt from: brusherru
PR: rainlanguage/rain.orderbook#2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.

Applied to files:

  • crates/virtual-raindex/README.md
  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-08-02T02:34:32.237Z
Learnt from: brusherru
PR: rainlanguage/rain.orderbook#2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.

Applied to files:

  • crates/virtual-raindex/README.md
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/integration_tests.rs
📚 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/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-09-06T07:12:25.751Z
Learnt from: CR
PR: rainlanguage/rain.orderbook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-06T07:12:25.751Z
Learning: Applies to crates/**/{src,tests,benches,examples}/**/*.rs : Rust crates: ensure `cargo test --workspace` passes

Applied to files:

  • crates/virtual-raindex/Cargo.toml
📚 Learning: 2025-07-16T10:40:05.717Z
Learnt from: findolor
PR: rainlanguage/rain.orderbook#2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
🪛 markdownlint-cli2 (0.18.1)
crates/virtual-raindex/README.md

3-3: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)

⏰ 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: build-tauri (ubuntu-22.04, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
  • 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-sol-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: Deploy-Preview-Push
  • GitHub Check: Deploy-Docs-Preview

@@ -0,0 +1,93 @@
# virtual-raindex

Virtual Raindex is a pure-Rust implementation of the Rain Orderbook. It keeps
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.

⚠️ Potential issue | 🟡 Minor

Remove trailing whitespace flagged by markdownlint.

Line 3 ends with a stray space, tripping markdownlint rule MD009. Please trim the trailing whitespace so the markdown checks stay green.

- Virtual Raindex is a pure-Rust implementation of the Rain Orderbook. It keeps 
+ Virtual Raindex is a pure-Rust implementation of the Rain Orderbook. It keeps

Based on static analysis hints.

📝 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
Virtual Raindex is a pure-Rust implementation of the Rain Orderbook. It keeps
Virtual Raindex is a pure-Rust implementation of the Rain Orderbook. It keeps
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

3-3: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)

🤖 Prompt for AI Agents
In crates/virtual-raindex/README.md at line 3, the line "Virtual Raindex is a
pure-Rust implementation of the Rain Orderbook. It keeps " has a trailing space
that triggers markdownlint MD009; remove the stray space at the end of the line
so it ends with the sentence period and no trailing whitespace, then save the
file to clear the linter warning.

Comment thread crates/virtual-raindex/src/engine/take.rs
Comment thread crates/virtual-raindex/src/engine/take.rs
Comment thread crates/virtual-raindex/src/engine/tests.rs
Comment thread crates/virtual-raindex/src/engine/tests.rs
Comment thread crates/virtual-raindex/src/engine/tests.rs Outdated
Comment thread crates/virtual-raindex/src/engine/tests.rs Outdated
Comment thread crates/virtual-raindex/src/engine/tests.rs
Comment thread crates/virtual-raindex/src/host/revm.rs
Comment thread crates/virtual-raindex/src/types/take.rs Outdated
@hardyjosh hardyjosh marked this pull request as ready for review September 30, 2025 21:26
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 95fb7f4 and 4d72b8c.

📒 Files selected for processing (3)
  • crates/virtual-raindex/Cargo.toml (1 hunks)
  • crates/virtual-raindex/src/engine/tests.rs (1 hunks)
  • crates/virtual-raindex/src/integration_tests.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
crates/**/{src,tests,benches,examples}/**/*.rs

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

crates/**/{src,tests,benches,examples}/**/*.rs: Rust crates: lint with cargo clippy --workspace --all-targets --all-features -D warnings
Rust crates: ensure cargo test --workspace passes
Rust crates: build with cargo build during development/readiness checks

Files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
🧬 Code graph analysis (2)
crates/virtual-raindex/src/integration_tests.rs (4)
crates/test_fixtures/src/lib.rs (3)
  • deposit (291-324)
  • new (81-141)
  • new_with_tokens (146-162)
crates/virtual-raindex/src/host/revm.rs (1)
  • new (59-64)
crates/virtual-raindex/src/state.rs (5)
  • new (30-36)
  • new (48-50)
  • order_hash (201-203)
  • snapshot (129-137)
  • derive_fqn (206-208)
crates/virtual-raindex/src/cache.rs (4)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
crates/virtual-raindex/src/engine/tests.rs (4)
crates/virtual-raindex/src/state.rs (1)
  • derive_fqn (206-208)
crates/virtual-raindex/src/engine/mod.rs (5)
  • interpreter (58-60)
  • new (43-50)
  • snapshot (53-55)
  • address_to_u256 (134-136)
  • quote (104-106)
crates/virtual-raindex/src/types/quote.rs (1)
  • new (29-43)
crates/virtual-raindex/src/engine/quote.rs (1)
  • quote (19-145)
⏰ 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). (1)
  • GitHub Check: build-tauri (ubuntu-22.04, true)
🔇 Additional comments (5)
crates/virtual-raindex/Cargo.toml (3)

1-6: Package metadata looks good.

The workspace metadata delegation follows standard Rust patterns and aligns with the monorepo structure.


19-23: Dev-dependencies configuration is appropriate.

The cfg(not(target_family = "wasm")) gate correctly excludes test-only dependencies from WASM builds, aligning with the PR's goal to support WASM targets. The tokio features and path-based test fixtures follow standard patterns.


17-17: No changes needed for parking_lot version
The version "0.12" in Cargo.toml already covers patch releases up to 0.12.4 (latest) and no security advisories exist.

crates/virtual-raindex/src/engine/tests.rs (1)

1-1327: LGTM! Comprehensive test coverage for VirtualRaindex engine.

The test module provides excellent coverage including:

  • Mock implementations (NullCache, NullInterpreter, RecordingHost) that enable isolated unit testing
  • Comprehensive mutation testing (env, orders, vaults, store)
  • Quote and take flow validation with error handling
  • REVM integration tests verifying contract compatibility
  • End-to-end tests with LocalEvm confirming on-chain behavior parity

The test suite exercises both success paths and error conditions, validates state transitions, and includes integration tests that verify the virtual engine matches on-chain contract behavior.

crates/virtual-raindex/src/integration_tests.rs (1)

1-904: LGTM! Excellent integration test suite with comprehensive on-chain/virtual parity verification.

The integration test module demonstrates strong engineering:

  • Harness design: Coordinates LocalEvm, on-chain orderbook, and virtual raindex with bidirectional state tracking
  • Action-based testing: Uses proptest to fuzz test action sequences (Deposit, Take, Quote, AdvanceTime) with meaningful constraints
  • Synchronization: Maintains and verifies parity between on-chain and virtual state for vault balances, store values, and env variables
  • RainLang integration: Dynamically generates and compiles order templates and post-tasks, exercising the full compilation and execution pipeline
  • Store key discovery: Intelligently discovers hashed store keys from virtual snapshots after Take operations
  • Comprehensive assertions: Verifies balances, quotes, and store values match between on-chain and virtual implementations after every action

The proptest configuration (6 cases, 32 shrink iterations) provides good fuzz coverage while remaining practical for CI execution.

Comment thread crates/virtual-raindex/Cargo.toml Outdated
rain-math-float = { workspace = true }
rain_orderbook_bindings = { workspace = true }
rain_interpreter_bindings = { workspace = true }
revm = { version = "25.0.0", default-features = false }
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Sep 30, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Verify revm version for latest release and security advisories.

Since my knowledge cutoff predates the current date, confirm that revm 25.0.0 is a valid, secure, and appropriate version for production use.


🏁 Script executed:

#!/bin/bash
# Description: Check latest revm version and security advisories

# Check latest version on crates.io
curl -s https://crates.io/api/v1/crates/revm | jq -r '.crate.max_stable_version'

# Check for security advisories
gh api graphql -f query='
{
  securityVulnerabilities(first: 10, ecosystem: RUST, package: "revm") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

Length of output: 56


Upgrade revm to latest stable (29.0.1) and verify compatibility. The revm crate is currently pinned to 25.0.0, but the latest stable release is 29.0.1 with no reported security advisories; please update the dependency in Cargo.toml and ensure disabling default features still works with the new API.

🤖 Prompt for AI Agents
In crates/virtual-raindex/Cargo.toml around line 13, the revm dependency is
pinned to 25.0.0; update it to 29.0.1 and verify compatibility by changing the
version specifier to 29.0.1 while keeping default-features = false, then run
cargo update && cargo build && cargo test to surface any API breakages; if
builds fail, consult revm 26–29 changelogs to adapt imports/types/constructor
calls (adjust any renamed functions, moved modules, or changed trait methods)
and confirm feature flags still provide the needed functionality or enable
specific features required by the new API.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

actually 30.1.2 is the latest revm

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.

@0xgleb, thank you for the correction! You're absolutely right that revm 30.1.2 is the latest stable version.

Please update the dependency in Cargo.toml from version 25.0.0 to 30.1.2:

revm = { version = "30.1.2", default-features = false }

Since this is a significant version jump (25.0.0 → 30.1.2), please verify compatibility by running:

cargo update && cargo build && cargo test

If you encounter any API breakages, consult the revm changelogs for versions 26–30 to identify:

  • Renamed functions or types
  • Moved modules
  • Changed trait methods
  • New or modified feature flags

Ensure that default-features = false still provides the functionality needed, or enable specific features if required by the new API.

@hardyjosh hardyjosh mentioned this pull request Oct 2, 2025
4 tasks
@hardyjosh hardyjosh self-assigned this Oct 2, 2025
Comment thread crates/test_fixtures/src/lib.rs Outdated
Comment on lines +339 to +345
let try_new_limit = || {
Anvil::new()
.arg("--code-size-limit")
.arg(code_size_limit.clone())
.try_spawn()
};
let try_legacy_disable = || Anvil::new().arg("--disable-code-size-limit").try_spawn();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is there any reason why we need to keep two ways of disabling size limit? shouldn't we have just a single version of anvil pinned by Cargo.lock to worry about?

vec![vec![order_hash, order.owner.into_word()]]
}

#[allow(clippy::too_many_arguments)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd create a new IO struct or something like that and put IOV2, decimals, and balance there. Then there would be just one arg for input and one arg for output and then the call site might be a bit cleaner and we won't need to disable clippy

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.

took your suggestion, done

Comment on lines +90 to +98
let mut signers = Vec::with_capacity(signed_context.len());
for sc in signed_context {
signers.push(sc.signer.into_word());
}
context.push(signers);

for sc in signed_context {
context.push(sc.context.clone());
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nitpick: consider

Suggested change
let mut signers = Vec::with_capacity(signed_context.len());
for sc in signed_context {
signers.push(sc.signer.into_word());
}
context.push(signers);
for sc in signed_context {
context.push(sc.context.clone());
}
let signers: Vec<_> = signed_context
.iter()
.map(|sc| sc.signer.into_word())
.collect();
context.push(signers);
context.extend(signed_context.into_iter().map(|sc| sc.context));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it's pretty easy to mess up logic manipulating a matrix of untyped 32 byte values. consider adding unit tests so that this doesn't accidentally get messed up in the future

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.

added tests

Comment thread crates/virtual-raindex/src/engine/tests.rs
Comment thread crates/virtual-raindex/src/state.rs Outdated
}

/// Applies a batch of mutations, recursing through nested batches as needed.
pub fn apply_mutations(&mut self, mutations: &[RaindexMutation]) -> Result<()> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same suggestion about qualifying Result

Comment thread crates/virtual-raindex/src/state.rs Outdated
}

/// Applies a single vault balance delta to the state.
fn apply_vault_delta(&mut self, delta: &VaultDelta) -> Result<()> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

and here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

consider unit testing apply_mutations, apply_vault_delta, and maybe derive_fqn

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.

added

Comment thread crates/virtual-raindex/src/state.rs Outdated
}

/// Computes the canonical hash for an [`OrderV4`].
pub fn order_hash(order: &OrderV4) -> B256 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we not have a helper for this somewhere?

Comment thread crates/virtual-raindex/Cargo.toml Outdated
rain-math-float = { workspace = true }
rain_orderbook_bindings = { workspace = true }
rain_interpreter_bindings = { workspace = true }
revm = { version = "25.0.0", default-features = false }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

actually 30.1.2 is the latest revm

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

♻️ Duplicate comments (4)
crates/virtual-raindex/src/cache.rs (1)

88-219: Cache implementation and tests look solid.

Thread-safe maps, clear errors, and coverage for missing/present artifacts. Nice.

crates/virtual-raindex/src/engine/quote.rs (1)

237-289: Overrides helper and tests are clean; earlier feedback addressed.

Using From conversions simplifies merging; unit tests cover insert/overwrite.

crates/virtual-raindex/src/integration_tests.rs (1)

55-57: Hex formatting helper: prior nit acknowledged.

You can keep format_store_key for 0x-prefixed, width-padded output required by scripts; alternatively, use alloy::hex if you standardize the format.

Also applies to: 833-840

crates/virtual-raindex/src/host/revm.rs (1)

91-93: Avoid cloning calldata on the hot path

You can move the Vec from abi_encode directly into RevmBytes::from to skip an extra alloc/copy.

-        let output = evm
-            .transact_system_call_finalize(revm_address, RevmBytes::from(calldata.clone()))
+        let output = evm
+            .transact_system_call_finalize(revm_address, RevmBytes::from(calldata))
             .map_err(|err| RaindexError::RevmExecution(err.to_string()))?;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d72b8c and b6472e6.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (21)
  • Cargo.toml (2 hunks)
  • crates/common/src/utils/mod.rs (1 hunks)
  • crates/common/src/utils/order_hash.rs (1 hunks)
  • crates/js_api/src/bindings/mod.rs (2 hunks)
  • crates/quote/src/cli/mod.rs (2 hunks)
  • crates/quote/src/quote.rs (2 hunks)
  • crates/virtual-raindex/Cargo.toml (1 hunks)
  • crates/virtual-raindex/proptest-regressions/integration_tests.txt (1 hunks)
  • crates/virtual-raindex/src/cache.rs (1 hunks)
  • crates/virtual-raindex/src/engine/context.rs (1 hunks)
  • crates/virtual-raindex/src/engine/mod.rs (1 hunks)
  • crates/virtual-raindex/src/engine/mutations.rs (1 hunks)
  • crates/virtual-raindex/src/engine/post_tasks.rs (1 hunks)
  • crates/virtual-raindex/src/engine/quote.rs (1 hunks)
  • crates/virtual-raindex/src/engine/take.rs (1 hunks)
  • crates/virtual-raindex/src/engine/tests.rs (1 hunks)
  • crates/virtual-raindex/src/error.rs (1 hunks)
  • crates/virtual-raindex/src/host/revm.rs (1 hunks)
  • crates/virtual-raindex/src/integration_tests.rs (1 hunks)
  • crates/virtual-raindex/src/lib.rs (1 hunks)
  • crates/virtual-raindex/src/state.rs (1 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/virtual-raindex/src/state.rs
  • crates/common/src/utils/mod.rs
  • crates/common/src/utils/order_hash.rs
  • crates/js_api/src/bindings/mod.rs
  • crates/virtual-raindex/src/engine/mutations.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/quote/src/quote.rs
  • crates/virtual-raindex/src/error.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/quote/src/cli/mod.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/cache.rs
  • crates/virtual-raindex/src/host/revm.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/engine/mod.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/virtual-raindex/src/state.rs
  • crates/common/src/utils/mod.rs
  • crates/common/src/utils/order_hash.rs
  • crates/js_api/src/bindings/mod.rs
  • crates/virtual-raindex/src/engine/mutations.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/quote/src/quote.rs
  • crates/virtual-raindex/src/error.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/quote/src/cli/mod.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/cache.rs
  • crates/virtual-raindex/src/host/revm.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/engine/mod.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/virtual-raindex/src/state.rs
  • crates/common/src/utils/mod.rs
  • crates/common/src/utils/order_hash.rs
  • crates/js_api/src/bindings/mod.rs
  • crates/virtual-raindex/src/engine/mutations.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/quote/src/quote.rs
  • crates/virtual-raindex/src/error.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/quote/src/cli/mod.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/cache.rs
  • crates/virtual-raindex/src/host/revm.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/engine/mod.rs
🧠 Learnings (2)
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
PR: rainlanguage/rain.orderbook#0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/integration_tests/** : Place Rust integration tests under crates/integration_tests

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-09-30T21:18:01.636Z
Learnt from: hardyjosh
PR: rainlanguage/rain.orderbook#2167
File: crates/virtual-raindex/src/engine/take.rs:131-138
Timestamp: 2025-09-30T21:18:01.636Z
Learning: In the virtual-raindex take order flow (crates/virtual-raindex/src/engine/take.rs), balance diffs are written from the order's perspective where the taker is the counterparty: the order's input column receives taker_output (what the taker provides to the order) and the order's output column receives taker_input (what the taker requests from the order).

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
🧬 Code graph analysis (17)
crates/virtual-raindex/src/state.rs (3)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/mod.rs (3)
  • new (56-63)
  • snapshot (66-68)
  • apply_mutations (86-101)
crates/virtual-raindex/src/error.rs (1)
  • from (52-54)
crates/common/src/utils/mod.rs (1)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/js_api/src/bindings/mod.rs (1)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/mutations.rs (2)
crates/virtual-raindex/src/engine/mod.rs (1)
  • new (56-63)
crates/virtual-raindex/src/state.rs (2)
  • new (29-35)
  • new (47-49)
crates/virtual-raindex/src/engine/tests.rs (5)
crates/virtual-raindex/src/engine/mod.rs (9)
  • address_to_u256 (147-149)
  • interpreter (71-73)
  • interpreter (175-177)
  • store (179-181)
  • ensure_artifacts (183-185)
  • eval4 (192-200)
  • new (56-63)
  • snapshot (66-68)
  • quote (117-119)
crates/virtual-raindex/src/state.rs (4)
  • derive_fqn (200-202)
  • new (29-35)
  • new (47-49)
  • snapshot (128-136)
crates/virtual-raindex/src/cache.rs (6)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/host/revm.rs (3)
  • eval4 (29-35)
  • eval4 (72-120)
  • new (59-64)
crates/virtual-raindex/src/engine/quote.rs (4)
  • new (55-69)
  • from (31-33)
  • from (37-39)
  • quote (94-235)
crates/virtual-raindex/src/engine/post_tasks.rs (3)
crates/virtual-raindex/src/engine/context.rs (4)
  • namespace_for_order (109-114)
  • interpreter (134-136)
  • store (138-140)
  • eval4 (151-159)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (59-64)
  • eval4 (29-35)
  • eval4 (72-120)
crates/virtual-raindex/src/state.rs (3)
  • new (29-35)
  • new (47-49)
  • derive_fqn (200-202)
crates/quote/src/quote.rs (1)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/error.rs (2)
crates/js_api/src/bindings/mod.rs (2)
  • from (141-143)
  • from (147-152)
crates/quote/src/cli/mod.rs (2)
  • from (69-74)
  • from (83-85)
crates/virtual-raindex/src/engine/quote.rs (3)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/mod.rs (3)
  • address_to_u256 (147-149)
  • new (56-63)
  • quote (117-119)
crates/virtual-raindex/src/state.rs (3)
  • new (29-35)
  • new (47-49)
  • derive_fqn (200-202)
crates/quote/src/cli/mod.rs (1)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/lib.rs (1)
crates/virtual-raindex/src/state.rs (1)
  • derive_fqn (200-202)
crates/virtual-raindex/src/cache.rs (3)
crates/virtual-raindex/src/engine/context.rs (3)
  • interpreter (134-136)
  • store (138-140)
  • ensure_artifacts (142-144)
crates/virtual-raindex/src/host/revm.rs (1)
  • new (59-64)
crates/virtual-raindex/src/integration_tests.rs (1)
  • new (198-223)
crates/virtual-raindex/src/host/revm.rs (3)
crates/virtual-raindex/src/cache.rs (4)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
crates/virtual-raindex/src/integration_tests.rs (1)
  • new (198-223)
crates/virtual-raindex/src/state.rs (2)
  • new (29-35)
  • new (47-49)
crates/virtual-raindex/src/integration_tests.rs (5)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/state.rs (4)
  • new (29-35)
  • new (47-49)
  • snapshot (128-136)
  • derive_fqn (200-202)
crates/virtual-raindex/src/engine/mod.rs (6)
  • address_to_u256 (147-149)
  • new (56-63)
  • interpreter (71-73)
  • interpreter (175-177)
  • store (179-181)
  • snapshot (66-68)
crates/test_fixtures/src/lib.rs (3)
  • deposit (294-327)
  • new (81-144)
  • new_with_tokens (149-165)
crates/virtual-raindex/src/cache.rs (4)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
crates/virtual-raindex/src/engine/take.rs (4)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/context.rs (2)
  • namespace_for_order (109-114)
  • store (138-140)
crates/virtual-raindex/src/engine/mod.rs (3)
  • new (56-63)
  • resolve_order (133-143)
  • store (179-181)
crates/virtual-raindex/src/state.rs (2)
  • new (29-35)
  • new (47-49)
crates/virtual-raindex/src/engine/context.rs (5)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/mod.rs (8)
  • address_to_u256 (147-149)
  • u8_to_b256 (152-154)
  • new (56-63)
  • interpreter (71-73)
  • interpreter (175-177)
  • store (179-181)
  • ensure_artifacts (183-185)
  • eval4 (192-200)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (59-64)
  • eval4 (29-35)
  • eval4 (72-120)
crates/virtual-raindex/src/state.rs (3)
  • new (29-35)
  • new (47-49)
  • derive_fqn (200-202)
crates/virtual-raindex/src/cache.rs (6)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/engine/mod.rs (5)
crates/virtual-raindex/src/engine/quote.rs (4)
  • quote (94-235)
  • new (55-69)
  • from (31-33)
  • from (37-39)
crates/virtual-raindex/src/engine/take.rs (4)
  • new (146-178)
  • take_orders (91-103)
  • take_orders_and_apply_state (106-119)
  • resolve_order (201-215)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (59-64)
  • eval4 (29-35)
  • eval4 (72-120)
crates/virtual-raindex/src/state.rs (4)
  • new (29-35)
  • new (47-49)
  • snapshot (128-136)
  • apply_mutations (139-187)
crates/virtual-raindex/src/cache.rs (6)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
🔇 Additional comments (20)
Cargo.toml (1)

66-66: Verify assert_matches version is latest.

Confirm that assert_matches 1.5.0 is the current stable release (or the appropriate version for this project's MSRV).

crates/virtual-raindex/Cargo.toml (2)

14-14: Revm version inherited from workspace.

Line 14 references revm = { workspace = true }, which inherits from the root workspace dependency currently pinned to 25.0.0. Once the root Cargo.toml is updated to 30.1.2, ensure the virtual-raindex crate still compiles and all tests pass with the new version (accounting for any REVM API changes).


1-25: Overall manifest structure is sound.

The package metadata, dependency wiring, workspace inheritance, and platform-specific dev-dependencies are all correctly structured. The cfg(not(target_family = "wasm")) gate is appropriate for excluding non-portable test fixtures.

crates/virtual-raindex/proptest-regressions/integration_tests.txt (1)

1-8: LGTM! Proptest regression seeds are properly documented.

This file correctly captures proptest failure cases for regression testing. The documentation clearly explains the purpose and the recommendation to check into source control is appropriate.

crates/virtual-raindex/src/engine/context.rs (2)

20-24: Good refactor addressing previous feedback.

The IOContext struct effectively groups related IO parameters (token, vault, decimals, balance), making the API cleaner and addressing the previous concern about too many arguments.


186-278: Comprehensive test coverage.

The tests effectively validate:

  • Column population in the quote context grid
  • Signed context row appending
  • Proper integration of IOContext and metadata

This addresses the previous reviewer's request for unit tests.

crates/virtual-raindex/src/engine/post_tasks.rs (1)

215-352: Excellent test coverage addressing previous feedback.

The test suite comprehensively validates:

  • Bytecode validation (success and both error cases)
  • Task execution (empty tasks, empty bytecode, store writes)
  • Error propagation

This directly addresses the previous reviewer's request for unit tests.

crates/virtual-raindex/src/error.rs (1)

1-126: Well-designed error types with comprehensive coverage.

The error module provides:

  • Clear, informative error variants covering all failure modes
  • Proper trait implementations (From<FloatError>, Display, Error)
  • Context-rich error messages including addresses, indices, and values

The design facilitates good error handling and debugging across the crate.

crates/virtual-raindex/src/state.rs (3)

13-124: Clean state representation with well-designed mutation model.

The state types and mutations provide:

  • Clear separation of concerns (Env, VaultKey, StoreKey)
  • Comprehensive mutation coverage (env, orders, vaults, store, decimals)
  • Atomic batch operations via RaindexMutation::Batch
  • Snapshot capability for inspection and testing

139-187: Correct implementation of mutation application.

The recursive handling of mutations properly:

  • Updates all state segments (env, orders, vaults, store, decimals)
  • Supports nested batches for atomic operations
  • Propagates errors appropriately

235-381: Comprehensive test coverage addressing previous feedback.

The test suite validates:

  • All mutation variants and their interactions
  • Vault delta creation and accumulation with Float arithmetic
  • Namespace derivation correctness
  • Edge cases like removing orders and nested batches

This directly addresses the previous reviewer's request for unit tests.

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

315-318: LGTM

Canonical order hash usage is correct; test vectors remain stable.

crates/js_api/src/bindings/mod.rs (2)

11-11: Verify import path

If the common crate doesn’t re-export order_hash at the root, change this to use rain_orderbook_common::utils::order_hash; or add pub use utils::order_hash; to rain_orderbook_common’s lib.rs.


37-44: LGTM

get_order_hash now delegates to the canonical helper; interface unchanged.

crates/quote/src/cli/mod.rs (1)

157-158: Tests now use shared order_hash

Good move to rely on the canonical helper; keeps test fixtures aligned with prod hashing.

Also applies to: 333-336

crates/virtual-raindex/src/lib.rs (1)

12-23: Public API surface looks good.

Clear re-exports and cfg(test) gating are tidy. No issues.

crates/virtual-raindex/src/engine/quote.rs (1)

111-178: Input validation and balance lookups are correct.

Indices, self-trade prevention, decimals, and required balances are enforced. Good guardrails.

crates/virtual-raindex/src/engine/mod.rs (2)

232-300: Unit tests added for resolve_order/address_to_u256/u8_to_b256 — nice coverage

These address prior feedback to add unit tests for resolve_order and address_to_u256, and also cover u8_to_b256.


85-101: Code is correct—helper methods are properly in scope

The methods are defined in crates/virtual-raindex/src/engine/mutations.rs with pub(super) visibility and the mutations module is properly declared in engine/mod.rs (line 16: pub(super) mod mutations;). This makes both prepare_mutations and ensure_order_context accessible to the impl block in mod.rs. The code will compile without issues.

crates/virtual-raindex/src/engine/take.rs (1)

362-382: Use working_state.env for handle-io to match the store snapshot

run_handle_io uses self.raindex.state.env while reading store_snapshot from the evolving working_state. If env can be mutated during the session, this drifts. Prefer working_state.env for consistency.

-            self.raindex.state.env,
+            self.working_state.env,

Comment thread Cargo.toml
rain_interpreter_dispair = { path = "lib/rain.interpreter/crates/dispair" }
rain_interpreter_parser = { path = "lib/rain.interpreter/crates/parser" }
rain-interpreter-eval = { path = "lib/rain.interpreter/crates/eval" }
revm = { version = "25.0.0", default-features = false }
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Update revm from 25.0.0 to 30.1.2 (critical version lag).

The prior review already flagged this: revm 25.0.0 is five major versions behind the latest stable (30.1.2). This introduces security risks, API compatibility issues, and potential performance regressions. The new virtual-raindex crate depends on this via workspace = true, so the outdated version directly impacts it.

Update the dependency:

-revm = { version = "25.0.0", default-features = false }
+revm = { version = "30.1.2", default-features = false }

Then verify the build and test suite to confirm compatibility, and update virtual-raindex code if needed for any API changes introduced between versions 25–30 (as noted in the learnings, expect breaking changes on major revm version bumps).


I'll verify the claims in the review comment by checking the latest dependency versions and examining the codebase structure.<!-- [scratchpad_update]
[task review_verification_1/3 dependency_checks]
Web search results received. Key findings:

  • revm latest appears to be around 29.0.0 (from docs.rs), but search results are unclear about 30.1.2
  • Result 6 shows docs.rs for revm 22.0.1
  • Result 9 shows docs.rs for revm 29.0.0
  • Need more specific search for actual latest revm version
  • assert_matches: Results show version history on crates.io but don't clearly indicate latest version number
  • Need shell inspection of Cargo.toml to see actual current state

[pending]

  • Confirm if 30.1.2 actually exists/is current for revm
  • Check actual Cargo.toml content
  • Verify workspace dependencies for virtual-raindex
    [scratchpad_end] -->

Let me search more specifically for the latest revm version and examine the Cargo.toml:<!-- [scratchpad_update]
[task review_verification_1/3 dependency_checks]
Critical finding from web search on revm versions:

  • GitHub CHANGELOG (result 21) shows revm: 27.0.3 -> 27.1.0 on July 23, 2025
  • Results show docs.rs for revm 29.0.0 and 22.0.1
  • Result 28 shows lib.rs dated "August 24, 2025"
  • Changelog shows v27.1.0 as latest mentioned release (July 23, 2025)
  • NO EVIDENCE of version 30.1.2 existing

[major_issue]

  • Review comment claims latest is 30.1.2, but evidence shows ~27.1.0 is more recent
  • This undermines the core argument that 25.0.0 is "five versions behind"
  • Need to verify actual Cargo.toml to see dependencies and workspace setup

[actions_next]

  • Examine actual Cargo.toml file for line 50 and surrounding context
  • Search for virtual-raindex references
  • Verify if there are actual breaking changes between 25.0.0 and current versions
    [scratchpad_end] -->

Now let me examine the actual Cargo.toml file to verify the current state:


Now let me look at the root Cargo.toml structure:




Then let me search for virtual-raindex:





<!-- [scratchpad_update]
[task generating_shell_scripts]
Attempting to verify:
1. Actual Cargo.toml content
2. Workspace structure
3. virtual-raindex existence
4. Actual dependency versions used
[scratchpad_end] -->

---

🏁 Script executed:

```shell
#!/bin/bash
# Find and examine Cargo.toml, especially around line 50 and dependencies
find . -name "Cargo.toml" -type f | head -5 | while read file; do
  echo "=== FILE: $file ==="
  wc -l "$file"
done

Length of output: 374


🏁 Script executed:

#!/bin/bash
# Examine root Cargo.toml lines around the revm dependency
if [ -f "Cargo.toml" ]; then
  echo "=== Root Cargo.toml (lines 45-70) ==="
  sed -n '45,70p' Cargo.toml
  echo ""
  echo "=== Checking for revm and assert_matches ==="
  grep -n "revm\|assert_matches" Cargo.toml
fi

Length of output: 1481


🏁 Script executed:

#!/bin/bash
# Search for virtual-raindex and workspace references
echo "=== Searching for virtual-raindex ==="
rg "virtual-raindex" --type toml 2>/dev/null | head -20

echo ""
echo "=== Checking workspace members ==="
grep -A 20 "workspace" Cargo.toml 2>/dev/null | head -30

Length of output: 1058


Let me check the virtual-raindex Cargo.toml and verify the actual latest revm version:

Now let me search for the actual latest revm version and security information:


🏁 Script executed:

#!/bin/bash
# Examine virtual-raindex Cargo.toml
echo "=== crates/virtual-raindex/Cargo.toml ==="
cat crates/virtual-raindex/Cargo.toml

Length of output: 921


🌐 Web query:

revm latest version crates.io 2025

💡 Result:

The latest revm release on crates.io is 30.2.0 (released Oct 17, 2025). [1][2]

Sources:
[1] revm docs (CHANGELOG showing 30.2.0 — 2025-10-17).
[2] revm crate listing (summary of recent versions).


🌐 Web query:

revm security vulnerabilities CVE advisories

💡 Result:

I found no public CVE entries that specifically name the revm crate (no revm-specific CVE) as of Oct 21, 2025. Sources and related items:

  • revm project pages / security contact (no CVE listed). [1][4]
  • Related EVM/Rust CVE: CVE‑2024‑21629 (affects rust-ethereum/evm implementation). [2]
  • Rust standard-library advisories that may affect Rust-based projects (example: CVE‑2024‑24576). [3]

If you want, I can:

  • run a deeper sweep (NVD, GitHub Security Advisories, RustSec) and return any new CVEs or advisories mentioning revm specifically, or
  • monitor GitHub Advisories / RustSec for future revm notices and send updates. Which do you prefer?

Sources:
[1] revm GitHub project (security/contact).
[2] NVD — CVE-2024-21629.
[3] Rust Blog — CVE-2024-24576 (Rust Security Response WG).
[4] revm crate docs (docs.rs).


🌐 Web query:

assert_matches latest version crate

💡 Result:

The latest released version of the assert_matches crate is 1.5.0 (published Feb 5, 2021). Add to Cargo.toml under [dev-dependencies]:
assert_matches = "1.5" .
Sources: [1] crate page (versions) — crates.io/docs mirror; [2] docs.rs listing.


Update revm from 25.0.0 to 30.2.0 (significant version lag).

The revm dependency is five major versions behind the latest stable release (30.2.0, released Oct 17, 2025). virtual-raindex depends on revm via workspace = true, so this outdated version directly impacts the new crate. While no public security vulnerabilities are recorded for revm, the major version gap increases risk of API incompatibilities and misses performance optimizations available in recent releases.

Update the dependency:

-revm = { version = "25.0.0", default-features = false }
+revm = { version = "30.2.0", default-features = false }

Then verify the build and test suite to confirm compatibility. Expect potential API changes between versions 25–30 that may require adjustments to virtual-raindex code.

Note: assert_matches 1.5.0 is already at the latest available version.

📝 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
revm = { version = "25.0.0", default-features = false }
revm = { version = "30.2.0", default-features = false }

Comment thread crates/common/src/utils/mod.rs Outdated
Comment on lines +2 to +3
mod order_hash;
pub use order_hash::order_hash;
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

Confirm intended public path for order_hash

This re-exports order_hash under utils::. In crates/js_api it’s imported as rain_orderbook_common::order_hash. Ensure the crate root also re-exports it (e.g., pub use utils::order_hash; in lib.rs), or switch all imports to rain_orderbook_common::utils::order_hash for consistency.

🤖 Prompt for AI Agents
In crates/common/src/utils/mod.rs around lines 2-3, you currently re-export
order_hash as utils::order_hash which is being imported elsewhere as
rain_orderbook_common::order_hash; to fix this either add a crate-root re-export
in the common crate (e.g., in crates/common/src/lib.rs add a public re-export of
utils::order_hash so consumers can use rain_orderbook_common::order_hash) or
update all consumer imports to the explicit path
rain_orderbook_common::utils::order_hash for consistency; choose one approach
and implement it across the repo so the public path is unambiguous.

Comment thread crates/common/src/utils/order_hash.rs
Comment thread crates/quote/src/quote.rs Outdated
Comment on lines 303 to 304
use rain_orderbook_common::utils::order_hash;
use rain_orderbook_subgraph_client::OrderbookSubgraphClientError;
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

Use of shared order_hash is good

Switching tests to the canonical helper improves consistency. Consider updating QuoteTarget::get_order_hash to call the same helper to avoid divergence if hashing logic ever changes.

🤖 Prompt for AI Agents
In crates/quote/src/quote.rs around lines 303-304, QuoteTarget::get_order_hash
currently implements its own hashing logic; update it to call the shared helper
rain_orderbook_common::utils::order_hash instead. Import order_hash if not
already imported, replace the internal hash computation with a call to
order_hash(&order) (or the appropriate order type), and ensure any return type
and error handling match the helper’s signature so the method forwards or maps
errors consistently.

Comment thread crates/virtual-raindex/src/engine/mutations.rs Outdated
Comment on lines +72 to +73
scripted: Mutex<Vec<host::EvalOutcome>>,
}
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

Avoid O(n) remove from front in test host

scripted.remove(0) is O(n). Use VecDeque for cheap front pops (even in tests it’s trivial to improve):

-use std::{
-    collections::HashMap,
-    sync::{Arc, Mutex},
-};
+use std::{
+    collections::{HashMap, VecDeque},
+    sync::{Arc, Mutex},
+};

-    scripted: Mutex<Vec<host::EvalOutcome>>,
+    scripted: Mutex<VecDeque<host::EvalOutcome>>,

-    fn push_outcome(&self, outcome: host::EvalOutcome) {
-        self.scripted.lock().unwrap().push(outcome);
-    }
+    fn push_outcome(&self, outcome: host::EvalOutcome) {
+        self.scripted.lock().unwrap().push_back(outcome);
+    }

-        let mut scripted = self.scripted.lock().unwrap();
-        if !scripted.is_empty() {
-            Ok(scripted.remove(0))
+        let mut scripted = self.scripted.lock().unwrap();
+        if let Some(next) = scripted.pop_front() {
+            Ok(next)
         } else {
             Ok(self.outcome.clone())
         }

Also applies to: 93-95, 109-113

🤖 Prompt for AI Agents
In crates/virtual-raindex/src/engine/tests.rs around lines 72-73 (and likewise
at 93-95 and 109-113), the test uses a Vec and calls scripted.remove(0) which is
O(n); change the field type from Mutex<Vec<host::EvalOutcome>> to
Mutex<VecDeque<host::EvalOutcome>> (add use std::collections::VecDeque) and
replace all remove(0) calls with scripted.pop_front() (or
scripted.lock().pop_front()) so front pops are O(1); adjust any pattern matching
or type annotations accordingly and update imports and test code to compile.

Comment on lines +573 to +574
assert_matches::assert_matches!(err, RaindexError::MinimumInputNotMet { .. });
}
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.

🛠️ Refactor suggestion | 🟠 Major

Use std::assert_matches (or import the macro) to avoid dependency ambiguity

Calls use assert_matches::assert_matches! which assumes an external crate. Prefer the standard macro:

  • Option A (import once at top of the test module):
+use std::assert_matches::assert_matches;

Then replace occurrences of

-assert_matches::assert_matches!(...)
+assert_matches!(...)
  • Option B (fully qualify each call):
-assert_matches::assert_matches!(...)
+std::assert_matches::assert_matches!(...)

This avoids adding a new dev-dependency and satisfies clippy with -D warnings.

Also applies to: 626-629, 1061-1061, 1089-1089, 1099-1099, 1118-1118, 1180-1180

🤖 Prompt for AI Agents
In crates/virtual-raindex/src/engine/tests.rs around lines 573-574 (and also at
626-629, 1061, 1089, 1099, 1118, 1180), tests call the external crate macro
`assert_matches::assert_matches!`; change these to use the standard library
macro instead by either adding a single import at the top of the test module
(use std::assert_matches::assert_matches;) or by replacing each call with the
fully-qualified std form `std::assert_matches!`; update all listed occurrences
to remove the external crate qualifier so Clippy and the build don’t require an
extra dev-dependency.

Comment on lines +904 to +907
let local_evm = LocalEvm::new().await;
let rain_src =
b"/* 0. calculate-io */\n_ _: now() block-number();\n\n/* 1. handle-io */\n:;".to_vec();

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.

⚠️ Potential issue | 🟡 Minor

Comment vs code mismatch: now() vs block-number() order

The Rainlang snippet is now() block-number(), but the comment says block-number then now. Align them to avoid confusion. Suggested fix (keeps assertions the same by emitting block first):

- b"/* 0. calculate-io */\n_ _: now() block-number();\n\n/* 1. handle-io */\n:;".to_vec();
+ b"/* 0. calculate-io */\n_ _: block-number() now();\n\n/* 1. handle-io */\n:;".to_vec();

Or adjust the comment to match the current snippet.

Also applies to: 1007-1012

🤖 Prompt for AI Agents
In crates/virtual-raindex/src/engine/tests.rs around lines 904-907 (and also
update the similar instance at 1007-1012), the inline comment describing the
Rainlang snippet has the wrong order for now() and block-number(); update the
comment text to state "now() then block-number()" (or otherwise mirror the
actual snippet order) so the comment matches the code and avoids confusion.

Comment on lines +1 to +24
use crate::{
cache::StaticCodeCache,
host::RevmInterpreterHost,
state::{self, StoreKey, VaultKey},
Float, OrderRef, QuoteRequest, RaindexMutation, TakeOrder, TakeOrdersConfig,
TokenDecimalEntry, VaultDelta, VirtualRaindex,
};
use alloy::primitives::{Address, Bytes, B256, U256};
use alloy::providers::{ext::AnvilApi, Provider};
use alloy::rpc::types::BlockNumberOrTag;
use proptest::prelude::*;
use rain_interpreter_test_fixtures::{Interpreter, Store};
use rain_orderbook_bindings::IOrderBookV5::{EvaluableV4, OrderV4, TaskV2, IOV2};
use rain_orderbook_common::utils::order_hash;
use rain_orderbook_test_fixtures::LocalEvm;
use rain_orderbook_test_fixtures::Orderbook::{
self, EvaluableV4 as OnchainEvaluable, OrderConfigV4 as OnchainOrderConfig,
QuoteV2 as OnchainQuoteV2, TakeOrderConfigV4 as OnchainTakeOrderConfig,
TakeOrdersConfigV4 as OnchainTakeOrdersConfig, TaskV2 as OnchainTaskV2,
IOV2 as OnchainIOV2,
};
use std::sync::Arc;
use tokio::runtime::Runtime;

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

Relocate as workspace integration tests.

Move this module under crates/integration_tests to decouple from crate build and speed iteration.

Based on learnings

Comment on lines +59 to +61
fn address_to_u256(address: Address) -> U256 {
U256::from_be_slice(address.into_word().as_slice())
}
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

Deduplicate address_to_u256 utility.

This duplicates engine::address_to_u256. Expose a shared helper (e.g., pub(crate) in engine or a small utils module) and reuse here.

🤖 Prompt for AI Agents
In crates/virtual-raindex/src/integration_tests.rs around lines 59-61 the local
fn address_to_u256 duplicates engine::address_to_u256; remove the duplicate and
reuse the shared helper instead: expose engine::address_to_u256 with pub(crate)
(or add a small shared utils module in the engine crate) if it is not already
public, update the import in integration_tests.rs to use the engine helper,
delete the local function, and run cargo test to ensure no breakages.

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

♻️ Duplicate comments (1)
crates/virtual-raindex/src/engine/post_tasks.rs (1)

107-113: Validate interpreter write pairs before applying them

If the interpreter ever returns an odd number of words in writes, the current if let [key, value] drops the trailing element and we silently lose a store update. That’s effectively corrupt state when a task misbehaves. Please fail fast instead of ignoring the extra word.

+        if outcome.writes.len() % 2 != 0 {
+            return Err(RaindexError::RevmExecution(format!(
+                "interpreter returned odd number of writes: {}",
+                outcome.writes.len()
+            )));
+        }
+
-        for chunk in outcome.writes.chunks(2) {
-            if let [key, value] = chunk {
-                state
-                    .store
-                    .insert(StoreKey::new(task.evaluable.store, qualified, *key), *value);
-            }
-        }
+        for pair in outcome.writes.chunks_exact(2) {
+            let key = pair[0];
+            let value = pair[1];
+            state
+                .store
+                .insert(StoreKey::new(task.evaluable.store, qualified, key), value);
+        }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6472e6 and 1b8a237.

📒 Files selected for processing (13)
  • crates/virtual-raindex/src/engine/calc.rs (1 hunks)
  • crates/virtual-raindex/src/engine/context.rs (1 hunks)
  • crates/virtual-raindex/src/engine/eval.rs (1 hunks)
  • crates/virtual-raindex/src/engine/mod.rs (1 hunks)
  • crates/virtual-raindex/src/engine/post_tasks.rs (1 hunks)
  • crates/virtual-raindex/src/engine/quote.rs (1 hunks)
  • crates/virtual-raindex/src/engine/take.rs (1 hunks)
  • crates/virtual-raindex/src/engine/tests.rs (1 hunks)
  • crates/virtual-raindex/src/host/revm.rs (1 hunks)
  • crates/virtual-raindex/src/integration_tests.rs (1 hunks)
  • crates/virtual-raindex/src/lib.rs (1 hunks)
  • crates/virtual-raindex/src/state.rs (1 hunks)
  • crates/virtual-raindex/src/store.rs (1 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/virtual-raindex/src/engine/eval.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/host/revm.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/store.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.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/virtual-raindex/src/engine/eval.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/host/revm.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/store.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.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/virtual-raindex/src/engine/eval.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/host/revm.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/store.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
🧠 Learnings (62)
📓 Common learnings
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the format: "TOTAL=number ADDITIONS=number DELETIONS=number". This report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the exact format: "TOTAL=number\nADDITIONS=number\nDELETIONS=number". This report should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/**/*.rs : Rust code lives in the workspace under crates/* (e.g., cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests)
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 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/virtual-raindex/src/engine/eval.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/integration_tests/** : Place Rust integration tests under crates/integration_tests

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-08-02T02:34:32.237Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/store.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-07-31T19:34:11.716Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-07-21T16:33:12.129Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/erc20.rs:336-350
Timestamp: 2025-07-21T16:33:12.129Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers both LocalEvm-based tests and mocked tests to be "unit tests" - they don't distinguish between them as "unit" vs "integration" tests based on their implementation approach.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-05-17T15:32:28.733Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1790
File: tauri-app/src-tauri/src/commands/vault.rs:67-67
Timestamp: 2025-05-17T15:32:28.733Z
Learning: For the PR focused on testing Tauri commands::order module, the generic type parameter R: Runtime was selectively added where needed for the PR scope, applying the changes primarily to order.rs and related files while leaving other modules like vault.rs for potential future refactoring.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-09-02T08:04:44.814Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/ui-components/src/__tests__/VaultIdInformation.test.ts:9-13
Timestamp: 2025-09-02T08:04:44.814Z
Learning: In packages/ui-components/src/__tests__/VaultIdInformation.test.ts and similar test files in the rain.orderbook project, the passthrough vi.mock('rainlanguage/orderbook', async (importOriginal) => { return { ...(await importOriginal()) }; }); block is required for tests to run properly, even when not overriding any exports. This is needed due to the specific Vitest configuration or test environment setup in the project.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-18T10:31:05.498Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2008
File: crates/common/src/raindex_client/add_orders.rs:85-86
Timestamp: 2025-07-18T10:31:05.498Z
Learning: In the rainlanguage/rain.orderbook codebase, cfg-guarded imports like `#[cfg(not(target_family = "wasm"))] use super::*;` in test modules are sometimes needed to fix compiler warnings, even when similar imports exist in nested sub-modules. These should not be removed as they serve a specific purpose in the compilation process.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-06-17T16:21:24.384Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: For Rust tests, prefer insta snapshots and proptest where helpful

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/host/revm.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-11T06:40:49.511Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1983
File: crates/js_api/src/gui/mod.rs:964-1199
Timestamp: 2025-07-11T06:40:49.511Z
Learning: In crates/js_api/src/gui/mod.rs tests, findolor prefers to keep large hardcoded YAML strings (like the validation test YAML) inline in the test file rather than extracting them to separate external files for maintainability purposes.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-04-30T09:28:36.960Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:111-118
Timestamp: 2025-04-30T09:28:36.960Z
Learning: In the rain.orderbook repository, the WASM tests are already properly configured with conditional compilation using `#[cfg(target_family = "wasm")]` and `#[cfg(not(target_family = "wasm"))]`, and don't require additional `wasm_bindgen_test_configure!(run_in_browser)` directives.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-10-06T06:07:57.208Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2111
File: crates/common/src/raindex_client/mod.rs:13-13
Timestamp: 2025-10-06T06:07:57.208Z
Learning: In Rust, when a module is declared in the same file with `pub mod module_name;`, importing from that module using `use module_name::Item;` is valid and does not require the `self::` prefix. The order of `use` statements and `mod` declarations does not affect module resolution.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-05-16T17:24:34.724Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:27-28
Timestamp: 2025-05-16T17:24:34.724Z
Learning: In Rust projects, dependencies listed in the [dependencies] section of Cargo.toml are available for both application code and tests. There's no need to duplicate them in [dev-dependencies] unless you want a different version or configuration specifically for tests.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-05-16T17:24:34.724Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:27-28
Timestamp: 2025-05-16T17:24:34.724Z
Learning: In Rust projects, dependencies listed in the [dependencies] section of Cargo.toml are available for both application code and tests. The tokio crate with the "full" feature set includes the "test" feature needed for `#[tokio::test]` to work properly.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-05-20T15:34:06.751Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1846
File: crates/quote/src/quote.rs:309-317
Timestamp: 2025-05-20T15:34:06.751Z
Learning: In Rust, when importing from the alloy crate, `use alloy::hex;` imports the hex macro, not a module, so it can't be consolidated with imports like `use alloy::hex::ToHex;` using the grouped import syntax.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-04-29T06:19:15.446Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1706
File: crates/quote/src/js_api/mod.rs:57-61
Timestamp: 2025-04-29T06:19:15.446Z
Learning: In the rain.orderbook codebase, the `get_id` function is designed to use `U256::from_str()` rather than `U256::from_hex()` for parsing order hashes, despite the potential for hex string inputs.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-05-27T06:16:35.738Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:69-127
Timestamp: 2025-05-27T06:16:35.738Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, directly accessing internal RwLock state in tests using `notice.0.read().unwrap()` is acceptable and does not require encapsulation through public getter methods.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/**/*.rs : Rust code lives in the workspace under crates/* (e.g., cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests)

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-10-06T08:05:02.438Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-06T08:05:02.438Z
Learning: Applies to crates/*/tests/**/*.rs : Rust crates must have passing tests (cargo test --workspace or --package <crate>)

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Rust: build with nix develop -c cargo build --workspace; test with nix develop -c cargo test

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-06-18T18:24:32.049Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:180-199
Timestamp: 2025-06-18T18:24:32.049Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to avoid refactoring duplicate search logic between get_orderbook_by_address and get_orderbook_by_network_key when there are only 2 functions, indicating they would consider it if more similar functions are added in the future.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-07-21T16:32:19.576Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/add_order.rs:297-300
Timestamp: 2025-07-21T16:32:19.576Z
Learning: User 0xgleb prefers explicit destructuring patterns like `let (_, Address(FixedBytes(address))) = ...` over intermediate variables when extracting nested data structures, as they believe it makes clearer what is being unwrapped from complex types.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-09-30T21:18:01.636Z
Learnt from: hardyjosh
Repo: rainlanguage/rain.orderbook PR: 2167
File: crates/virtual-raindex/src/engine/take.rs:131-138
Timestamp: 2025-09-30T21:18:01.636Z
Learning: In the virtual-raindex take order flow (crates/virtual-raindex/src/engine/take.rs), balance diffs are written from the order's perspective where the taker is the counterparty: the order's input column receives taker_output (what the taker provides to the order) and the order's output column receives taker_input (what the taker requests from the order).

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-06-24T08:45:10.971Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1947
File: crates/common/src/raindex_client/orders.rs:462-1643
Timestamp: 2025-06-24T08:45:10.971Z
Learning: User findolor prefers to keep tests simple and avoid refactoring for maintainability when the code is stable and viewed as "one time thing" that won't require frequent changes.

Applied to files:

  • crates/virtual-raindex/src/engine/post_tasks.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to **/*.sol : For Solidity, add fuzz/property tests where relevant

Applied to files:

  • crates/virtual-raindex/src/engine/post_tasks.rs
📚 Learning: 2025-06-24T08:46:03.368Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1947
File: crates/common/src/raindex_client/orders.rs:98-125
Timestamp: 2025-06-24T08:46:03.368Z
Learning: In the vault merging logic in crates/common/src/raindex_client/orders.rs, optimization isn't necessary because the maximum list items are usually around 5 items. For such small datasets, the simple three-loop approach is preferred over HashMap-based optimization due to clarity and minimal performance impact.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-07-16T10:40:05.717Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-10-02T19:17:20.332Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/common/src/raindex_client/orders.rs:738-741
Timestamp: 2025-10-02T19:17:20.332Z
Learning: In crates/common/src/raindex_client/orders.rs, fetch_dotrain_source() is intentionally called in try_from_sg_order for every order conversion because the dotrain source information is needed immediately. A future optimization with local DB logic is planned to eliminate the network round-trip concern.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-05-19T07:14:24.219Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1838
File: crates/cli/src/output.rs:29-41
Timestamp: 2025-05-19T07:14:24.219Z
Learning: For the rainlanguage/rain.orderbook repository, findolor prefers minimal documentation for straightforward functions like `output` in crates/cli/src/output.rs where the implementation is self-explanatory.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-06-07T05:19:46.330Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1872
File: packages/webapp/src/__tests__/handleVaultDeposit.test.ts:20-53
Timestamp: 2025-06-07T05:19:46.330Z
Learning: In the rain.orderbook codebase, simple wrapper/adapter functions that just delegate to other functions (like handleVaultDeposit) don't need extensive edge case testing for missing parameters or error handling - the current test coverage focusing on core functionality is sufficient.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-07-21T16:34:04.947Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/raindex_client/orders.rs:720-720
Timestamp: 2025-07-21T16:34:04.947Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers using `.unwrap()` in test code rather than `.expect()` with descriptive messages, considering the direct unwrap approach acceptable for test contexts where failures should be fast and clear.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-05-27T06:16:12.195Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:87-114
Timestamp: 2025-05-27T06:16:12.195Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, testing one WriteTransactionStatus variant (like PendingPrepare) is sufficient for the update_status_and_emit method since all variants follow the same code path through the From<WriteTransactionStatus<T>> implementation.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-10-06T08:05:02.438Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-06T08:05:02.438Z
Learning: Applies to packages/orderbook/**/*.{test,spec}.{ts,tsx} : Orderbook tests must pass (npm run test -w rainlanguage/orderbook)

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-03-26T15:00:17.997Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1516
File: packages/webapp/src/routes/deploy/[strategyName]/layout.test.ts:0-0
Timestamp: 2025-03-26T15:00:17.997Z
Learning: For Rain Orderbook projects, there's a preference not to include tests for SvelteKit methods (like parent function rejections) in test files, as these are considered framework responsibilities rather than application code that needs testing.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-07-21T16:34:31.193Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/types/impls.rs:7-15
Timestamp: 2025-07-21T16:34:31.193Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers breaking changes that remove unsafe default behaviors to be intentional and acceptable. Specifically, the get_decimals() method in crates/subgraph/src/types/impls.rs was intentionally changed to return MissingDecimals error instead of defaulting to 18 decimals, as defaulting to 18 is considered unsafe and should never have been done.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-05-13T20:06:22.602Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1713
File: crates/settings/src/remote/chains/mod.rs:43-226
Timestamp: 2025-05-13T20:06:22.602Z
Learning: When writing tests for collections of complex objects in Rust, prefer item-by-item comparison over direct vector comparison to get more specific error messages that pinpoint exactly which item and field has a mismatch.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-08-01T09:07:20.383Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: packages/orderbook/README.md:186-189
Timestamp: 2025-08-01T09:07:20.383Z
Learning: In the rainlanguage/rain.orderbook project, Rust methods on structs like RaindexVaultsList are exported as JavaScript getters in WASM bindings using #[wasm_bindgen(getter)]. This means while the Rust code uses method calls like items(), the JavaScript/WASM API exposes them as property access like .items. The README.md correctly documents the JavaScript API surface, not the Rust implementation details.

Applied to files:

  • crates/virtual-raindex/src/lib.rs
📚 Learning: 2025-07-21T16:37:20.599Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/utils/mod.rs:1-1
Timestamp: 2025-07-21T16:37:20.599Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers explicit module imports over re-exporting symbols at higher levels. Specifically for the float constants in crates/subgraph/src/utils/float.rs, they prefer using `utils::float::*` rather than re-exporting with `pub use float::*` in the utils module, as the explicit import makes it clearer what is being imported and why it's needed.

Applied to files:

  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-10-13T12:57:05.900Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2198
File: crates/common/src/raindex_client/local_db/query/fetch_store_addresses/mod.rs:7-8
Timestamp: 2025-10-13T12:57:05.900Z
Learning: In the rain.orderbook repository, using unqualified serde helper names (e.g., `#[serde(with = "serde_address")]`) that rely on glob imports is acceptable and does not need to be changed to fully qualified paths.

Applied to files:

  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/store.rs
📚 Learning: 2025-08-01T07:44:53.910Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:319-336
Timestamp: 2025-08-01T07:44:53.910Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore (crates/js_api/src/filters/raindex_filter_store.rs), the team chose a simplified monolithic approach with hard-coded keys and default auto-save behavior over configurable stores. The update_vaults method intentionally auto-saves to both localStorage and URL after each update as the default behavior, following a design evolution from a previous configurable approach.

Applied to files:

  • crates/virtual-raindex/src/lib.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-05-16T17:26:09.529Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:29-33
Timestamp: 2025-05-16T17:26:09.529Z
Learning: When testing error cases that might produce different types of errors depending on external conditions (such as hardware presence), using `unwrap_err()` without further assertions can be preferred over `assert!(result.is_err())` with specific error messages to avoid misleading readers about expected error details.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-08-02T03:55:25.215Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: packages/orderbook/test/js_api/filters.test.ts:19-36
Timestamp: 2025-08-02T03:55:25.215Z
Learning: In the rainlanguage/rain.orderbook project's WASM tests, the pattern of chaining `.value!` calls on WASM result types (like from VaultsFilterBuilder methods) is the established and preferred approach for handling WASM results, and should not be refactored into intermediate variables as it would add unnecessary verbosity without improving the code.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-04-08T12:56:03.272Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1512
File: packages/ui-components/src/__tests__/OrderDetail.test.ts:125-143
Timestamp: 2025-04-08T12:56:03.272Z
Learning: The OrderDetail component in the Rain orderbook UI doesn't currently have error handling tests, but issue #1605 has been created to address this in the future.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-09-02T08:04:34.729Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: crates/js_api/src/gui/select_tokens.rs:421-424
Timestamp: 2025-09-02T08:04:34.729Z
Learning: User findolor in the rainlanguage/rain.orderbook codebase prefers not to change test code when tests are already passing, even if there appear to be type mismatches or potential issues. Working tests should be left alone unless there are actual errors.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-04T10:25:10.315Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: packages/ui-components/src/__tests__/TransactionManager.test.ts:160-161
Timestamp: 2025-07-04T10:25:10.315Z
Learning: In the rain.orderbook project, maintainer findolor prefers to keep non-null assertions (!) in test files rather than replacing them with optional chaining (?.) as they are not needed for tests where the structure is controlled and known to exist.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-06-16T10:49:47.770Z
Learnt from: thedavidmeister
Repo: rainlanguage/rain.orderbook PR: 1926
File: test/concrete/ob/OrderBook.clear.zeroAmount.t.sol:24-32
Timestamp: 2025-06-16T10:49:47.770Z
Learning: LibTestAddOrder.conformConfig() in test/util/lib/LibTestAddOrder.sol automatically constrains OrderConfigV3 to prevent common test failures by ensuring validInputs[0].token != validOutputs[0].token, setting them to address(0) and address(1) respectively if they're equal. This prevents TokenSelfTrade errors in fuzz tests.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-04T10:27:22.544Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/orders.rs:609-609
Timestamp: 2025-07-04T10:27:22.544Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor prefers not to implement overflow protection for trades count casting (usize to u16) at this time, considering it unnecessary for the current scope since the practical risk of orders having 65,535+ trades is extremely low.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-06-17T17:38:21.943Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/cli/src/transaction.rs:105-105
Timestamp: 2025-06-17T17:38:21.943Z
Learning: In Rust, Vec<String> can be compared with Vec<&str> using assert_eq! because Vec<T> implements PartialEq<Vec<U>> when T: PartialEq<U>, and String implements PartialEq<&str>. This means comparisons like assert_eq!(vec_of_strings, vec!["string_literal"]) work correctly without needing to convert string literals to String.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-23T13:03:40.669Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/vault_balance_changes_query.rs:133-135
Timestamp: 2025-07-23T13:03:40.669Z
Learning: User 0xgleb prefers not to make changes to test code when tests are already passing, even if the code format could be standardized differently. Working test code should be left alone unless there's a functional issue.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-19T15:55:42.079Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1846
File: crates/quote/src/quote.rs:1039-1049
Timestamp: 2025-05-19T15:55:42.079Z
Learning: For quote module tests, exact error message matching is preferred over substring matching when testing error cases.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-15T22:27:49.771Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1777
File: tauri-app/src-tauri/Cargo.toml:64-64
Timestamp: 2025-05-15T22:27:49.771Z
Learning: User 0xgleb prefers to maintain the dot notation format for some Cargo.toml dependencies (e.g., `rain-interpreter-eval.path = "path"`) rather than converting all to inline table format, as both formats are valid in Rust.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-10-06T08:05:02.438Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-06T08:05:02.438Z
Learning: Applies to crates/*/{src,tests,benches,examples}/**/*.rs : Rust code must pass clippy with all warnings denied (cargo clippy --workspace --all-targets --all-features -D warnings)

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-21T22:47:21.927Z
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:47:21.927Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very beginning of any comment, before any learning used section or other content.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-21T22:35:26.448Z
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:35:26.448Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very last part of any comment, after any learning used section or other content.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-21T21:24:53.708Z
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-09-02T08:05:07.646Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/webapp/src/lib/components/DepositModal.svelte:25-28
Timestamp: 2025-09-02T08:05:07.646Z
Learning: In packages/webapp/src/lib/components/DepositModal.svelte, findolor considers the double-cast pattern `as unknown as AccountBalance` safe for initializing userBalance with Float.parse('0').value and formattedBalance: '0'.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-07-04T09:02:57.301Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/fuzz/mod.rs:64-64
Timestamp: 2025-07-04T09:02:57.301Z
Learning: In rainlanguage/rain.orderbook, user findolor prefers to limit type consistency changes to only the parts directly related to the current work scope. For example, when updating chain_id fields from u64 to u32 in fuzz-related code, unrelated files like tauri-app wallet commands can remain as u64 if they serve different purposes and aren't part of the current changes.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-06-18T12:56:44.290Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/mod.rs:102-118
Timestamp: 2025-06-18T12:56:44.290Z
Learning: In the rainlanguage/rain.orderbook codebase, it's acceptable to scaffold unused enum variants in initial implementation PRs when they will be implemented in future PRs, as confirmed by findolor.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-07-16T05:52:05.576Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:59-59
Timestamp: 2025-07-16T05:52:05.576Z
Learning: User findolor prefers to handle documentation updates for getter methods in batch via dedicated PRs rather than addressing them individually during feature development, as mentioned for the formatted amount string fields in crates/common/src/raindex_client/vaults.rs.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-07-16T14:33:45.887Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2001
File: crates/common/src/raindex_client/vaults.rs:0-0
Timestamp: 2025-07-16T14:33:45.887Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor considers using Address::random() in tests to be acceptable when the mock server doesn't validate the address parameter and returns a fixed response, making the test deterministic regardless of the address value used.

Applied to files:

  • crates/virtual-raindex/src/engine/mod.rs
🧬 Code graph analysis (13)
crates/virtual-raindex/src/engine/eval.rs (1)
crates/virtual-raindex/src/engine/mod.rs (2)
  • sample_order (209-227)
  • store (176-178)
crates/virtual-raindex/src/integration_tests.rs (5)
crates/virtual-raindex/src/store.rs (3)
  • derive_fqn (35-37)
  • address_to_u256 (30-32)
  • new (24-26)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/test_fixtures/src/lib.rs (2)
  • new (81-144)
  • new_with_tokens (149-165)
crates/virtual-raindex/src/engine/mod.rs (6)
  • quote (119-121)
  • new (58-65)
  • interpreter (73-75)
  • interpreter (172-174)
  • store (176-178)
  • snapshot (68-70)
crates/virtual-raindex/src/cache.rs (4)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
crates/virtual-raindex/src/engine/post_tasks.rs (5)
crates/virtual-raindex/src/engine/mutations.rs (1)
  • ensure_vault_entries (43-50)
crates/virtual-raindex/src/cache.rs (4)
  • store (17-17)
  • store (64-66)
  • interpreter (15-15)
  • interpreter (59-61)
crates/virtual-raindex/src/store.rs (4)
  • namespace_for_order (40-45)
  • new (24-26)
  • address_to_u256 (30-32)
  • derive_fqn (35-37)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (60-65)
  • eval4 (30-36)
  • eval4 (73-121)
crates/virtual-raindex/src/state.rs (2)
  • new (26-32)
  • new (44-46)
crates/virtual-raindex/src/host/revm.rs (2)
crates/virtual-raindex/src/cache.rs (4)
  • store (17-17)
  • store (64-66)
  • interpreter (15-15)
  • interpreter (59-61)
crates/virtual-raindex/src/store.rs (1)
  • build_state_overlay (81-92)
crates/virtual-raindex/src/engine/take.rs (7)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/calc.rs (1)
  • calculate_order_io (40-114)
crates/virtual-raindex/src/engine/eval.rs (1)
  • build_eval_call (24-39)
crates/virtual-raindex/src/engine/mod.rs (9)
  • store (176-178)
  • take_orders (106-108)
  • new (58-65)
  • take_orders_and_apply_state (111-116)
  • resolve_order (135-145)
  • interpreter (73-75)
  • interpreter (172-174)
  • ensure_artifacts (180-182)
  • eval4 (189-197)
crates/virtual-raindex/src/store.rs (3)
  • apply_store_writes (59-68)
  • writes_to_pairs (48-56)
  • new (24-26)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (60-65)
  • eval4 (30-36)
  • eval4 (73-121)
crates/virtual-raindex/src/state.rs (2)
  • new (26-32)
  • new (44-46)
crates/virtual-raindex/src/lib.rs (2)
crates/virtual-raindex/src/cache.rs (2)
  • store (17-17)
  • store (64-66)
crates/virtual-raindex/src/store.rs (1)
  • derive_fqn (35-37)
crates/virtual-raindex/src/engine/context.rs (4)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/mod.rs (7)
  • u8_to_b256 (149-151)
  • new (58-65)
  • interpreter (73-75)
  • interpreter (172-174)
  • store (176-178)
  • ensure_artifacts (180-182)
  • eval4 (189-197)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (60-65)
  • eval4 (30-36)
  • eval4 (73-121)
crates/virtual-raindex/src/cache.rs (6)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/store.rs (3)
crates/virtual-raindex/src/engine/quote.rs (3)
  • new (52-66)
  • from (28-30)
  • from (34-36)
crates/virtual-raindex/src/integration_tests.rs (2)
  • new (199-224)
  • address_to_u256 (60-62)
crates/virtual-raindex/src/state.rs (3)
  • new (26-32)
  • new (44-46)
  • snapshot (125-133)
crates/virtual-raindex/src/engine/tests.rs (5)
crates/virtual-raindex/src/cache.rs (6)
  • store (17-17)
  • store (64-66)
  • interpreter (15-15)
  • interpreter (59-61)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/store.rs (3)
  • address_to_u256 (30-32)
  • derive_fqn (35-37)
  • new (24-26)
crates/virtual-raindex/src/host/revm.rs (3)
  • eval4 (30-36)
  • eval4 (73-121)
  • new (60-65)
crates/virtual-raindex/src/engine/quote.rs (4)
  • new (52-66)
  • from (28-30)
  • from (34-36)
  • quote (91-160)
crates/virtual-raindex/src/state.rs (3)
  • new (26-32)
  • new (44-46)
  • snapshot (125-133)
crates/virtual-raindex/src/engine/calc.rs (3)
crates/virtual-raindex/src/store.rs (3)
  • namespace_for_order (40-45)
  • new (24-26)
  • writes_to_pairs (48-56)
crates/virtual-raindex/src/engine/eval.rs (1)
  • build_eval_call (24-39)
crates/virtual-raindex/src/state.rs (2)
  • new (26-32)
  • new (44-46)
crates/virtual-raindex/src/engine/quote.rs (3)
crates/virtual-raindex/src/engine/mod.rs (3)
  • store (176-178)
  • new (58-65)
  • quote (119-121)
crates/virtual-raindex/src/engine/calc.rs (1)
  • calculate_order_io (40-114)
crates/virtual-raindex/src/store.rs (2)
  • new (24-26)
  • apply_overrides (71-78)
crates/virtual-raindex/src/engine/mod.rs (6)
crates/virtual-raindex/src/engine/quote.rs (4)
  • quote (91-160)
  • new (52-66)
  • from (28-30)
  • from (34-36)
crates/virtual-raindex/src/engine/post_tasks.rs (4)
  • new (143-148)
  • add_order (18-42)
  • eval4 (156-165)
  • eval4 (172-180)
crates/virtual-raindex/src/engine/take.rs (8)
  • new (137-169)
  • interpreter (501-503)
  • take_orders (82-94)
  • take_orders_and_apply_state (97-110)
  • resolve_order (192-206)
  • store (505-507)
  • ensure_artifacts (509-511)
  • eval4 (518-526)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (60-65)
  • eval4 (30-36)
  • eval4 (73-121)
crates/virtual-raindex/src/state.rs (4)
  • new (26-32)
  • new (44-46)
  • snapshot (125-133)
  • apply_mutations (136-184)
crates/virtual-raindex/src/cache.rs (6)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/state.rs (3)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/mod.rs (3)
  • new (58-65)
  • snapshot (68-70)
  • apply_mutations (88-103)
crates/virtual-raindex/src/error.rs (1)
  • from (52-54)
⏰ 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). (4)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: Deploy-Preview-Push
  • GitHub Check: Deploy-Docs-Preview

Comment thread crates/virtual-raindex/src/engine/mod.rs
Comment thread crates/virtual-raindex/src/engine/take.rs
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

♻️ Duplicate comments (2)
crates/virtual-raindex/src/engine/post_tasks.rs (1)

107-113: Surface malformed interpreter writes instead of dropping them

If outcome.writes has an odd length we silently skip the last element, so a bad interpreter payload results in losing a store update rather than failing fast. That corrupts order state and is hard to debug. Please reject odd-length outputs and only iterate once you know you have complete key/value pairs.

-        for chunk in outcome.writes.chunks(2) {
-            if let [key, value] = chunk {
-                state
-                    .store
-                    .insert(StoreKey::new(task.evaluable.store, qualified, *key), *value);
-            }
-        }
+        if outcome.writes.len() % 2 != 0 {
+            return Err(RaindexError::RevmExecution(format!(
+                "interpreter returned odd number of writes: {}",
+                outcome.writes.len()
+            )));
+        }
+
+        for chunk in outcome.writes.chunks_exact(2) {
+            let key = chunk[0];
+            let value = chunk[1];
+            state
+                .store
+                .insert(StoreKey::new(task.evaluable.store, qualified, key), value);
+        }
crates/virtual-raindex/src/engine/mod.rs (1)

87-103: Critical: Nested SetOrders in Batch mutations bypass order context setup.

The current implementation only inspects top-level mutations for SetOrders. If a caller nests RaindexMutation::SetOrders inside a RaindexMutation::Batch (which is supported by RaindexState::apply_mutations), the ensure_order_context call is skipped. This will cause downstream TokenDecimalMissing or vault errors during quote/take operations.

Apply this diff to recursively walk the mutation tree:

     pub fn apply_mutations(&mut self, mutations: &[RaindexMutation]) -> Result<()> {
         self.prepare_mutations(mutations)?;

         let mut draft = self.state.clone();
-        for mutation in mutations {
-            if let RaindexMutation::SetOrders { orders } = mutation {
-                for order in orders {
-                    self.ensure_order_context(&mut draft, order)?;
-                }
-            }
-        }
+        self.seed_order_context(&mut draft, mutations)?;

         draft.apply_mutations(mutations)?;
         self.state = draft;
         Ok(())
     }
+
+    fn seed_order_context(
+        &self,
+        draft: &mut state::RaindexState,
+        mutations: &[RaindexMutation],
+    ) -> Result<()> {
+        for mutation in mutations {
+            match mutation {
+                RaindexMutation::SetOrders { orders } => {
+                    for order in orders {
+                        self.ensure_order_context(draft, order)?;
+                    }
+                }
+                RaindexMutation::Batch(nested) => self.seed_order_context(draft, nested)?,
+                _ => {}
+            }
+        }
+        Ok(())
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b8a237 and 1212464.

📒 Files selected for processing (14)
  • crates/virtual-raindex/src/cache.rs (1 hunks)
  • crates/virtual-raindex/src/engine/calc.rs (1 hunks)
  • crates/virtual-raindex/src/engine/context.rs (1 hunks)
  • crates/virtual-raindex/src/engine/eval.rs (1 hunks)
  • crates/virtual-raindex/src/engine/mod.rs (1 hunks)
  • crates/virtual-raindex/src/engine/mutations.rs (1 hunks)
  • crates/virtual-raindex/src/engine/post_tasks.rs (1 hunks)
  • crates/virtual-raindex/src/engine/quote.rs (1 hunks)
  • crates/virtual-raindex/src/engine/take.rs (1 hunks)
  • crates/virtual-raindex/src/engine/tests.rs (1 hunks)
  • crates/virtual-raindex/src/host/revm.rs (1 hunks)
  • crates/virtual-raindex/src/integration_tests.rs (1 hunks)
  • crates/virtual-raindex/src/state.rs (1 hunks)
  • crates/virtual-raindex/src/store.rs (1 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/virtual-raindex/src/engine/eval.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/cache.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mutations.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/store.rs
  • crates/virtual-raindex/src/state.rs
  • crates/virtual-raindex/src/host/revm.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/virtual-raindex/src/engine/eval.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/cache.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mutations.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/store.rs
  • crates/virtual-raindex/src/state.rs
  • crates/virtual-raindex/src/host/revm.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/virtual-raindex/src/engine/eval.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/cache.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mutations.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/store.rs
  • crates/virtual-raindex/src/state.rs
  • crates/virtual-raindex/src/host/revm.rs
🧠 Learnings (70)
📓 Common learnings
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the format: "TOTAL=number ADDITIONS=number DELETIONS=number". This report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the exact format: "TOTAL=number\nADDITIONS=number\nDELETIONS=number". This report should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/**/*.rs : Rust code lives in the workspace under crates/* (e.g., cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests)
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:319-336
Timestamp: 2025-08-01T07:44:53.910Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore (crates/js_api/src/filters/raindex_filter_store.rs), the team chose a simplified monolithic approach with hard-coded keys and default auto-save behavior over configurable stores. The update_vaults method intentionally auto-saves to both localStorage and URL after each update as the default behavior, following a design evolution from a previous configurable approach.
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 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/virtual-raindex/src/engine/eval.rs
  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/context.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-08-02T02:34:32.237Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/store.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/integration_tests/** : Place Rust integration tests under crates/integration_tests

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-31T19:34:11.716Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-07-21T16:33:12.129Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/erc20.rs:336-350
Timestamp: 2025-07-21T16:33:12.129Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers both LocalEvm-based tests and mocked tests to be "unit tests" - they don't distinguish between them as "unit" vs "integration" tests based on their implementation approach.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-09-02T08:04:44.814Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/ui-components/src/__tests__/VaultIdInformation.test.ts:9-13
Timestamp: 2025-09-02T08:04:44.814Z
Learning: In packages/ui-components/src/__tests__/VaultIdInformation.test.ts and similar test files in the rain.orderbook project, the passthrough vi.mock('rainlanguage/orderbook', async (importOriginal) => { return { ...(await importOriginal()) }; }); block is required for tests to run properly, even when not overriding any exports. This is needed due to the specific Vitest configuration or test environment setup in the project.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-17T15:32:28.733Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1790
File: tauri-app/src-tauri/src/commands/vault.rs:67-67
Timestamp: 2025-05-17T15:32:28.733Z
Learning: For the PR focused on testing Tauri commands::order module, the generic type parameter R: Runtime was selectively added where needed for the PR scope, applying the changes primarily to order.rs and related files while leaving other modules like vault.rs for potential future refactoring.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-06-17T16:21:24.384Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-07-18T10:31:05.498Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2008
File: crates/common/src/raindex_client/add_orders.rs:85-86
Timestamp: 2025-07-18T10:31:05.498Z
Learning: In the rainlanguage/rain.orderbook codebase, cfg-guarded imports like `#[cfg(not(target_family = "wasm"))] use super::*;` in test modules are sometimes needed to fix compiler warnings, even when similar imports exist in nested sub-modules. These should not be removed as they serve a specific purpose in the compilation process.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mutations.rs
📚 Learning: 2025-07-16T10:40:05.717Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-07-11T06:40:49.511Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1983
File: crates/js_api/src/gui/mod.rs:964-1199
Timestamp: 2025-07-11T06:40:49.511Z
Learning: In crates/js_api/src/gui/mod.rs tests, findolor prefers to keep large hardcoded YAML strings (like the validation test YAML) inline in the test file rather than extracting them to separate external files for maintainability purposes.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-04-30T09:28:36.960Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:111-118
Timestamp: 2025-04-30T09:28:36.960Z
Learning: In the rain.orderbook repository, the WASM tests are already properly configured with conditional compilation using `#[cfg(target_family = "wasm")]` and `#[cfg(not(target_family = "wasm"))]`, and don't require additional `wasm_bindgen_test_configure!(run_in_browser)` directives.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-10-06T06:07:57.208Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2111
File: crates/common/src/raindex_client/mod.rs:13-13
Timestamp: 2025-10-06T06:07:57.208Z
Learning: In Rust, when a module is declared in the same file with `pub mod module_name;`, importing from that module using `use module_name::Item;` is valid and does not require the `self::` prefix. The order of `use` statements and `mod` declarations does not affect module resolution.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-05-16T17:24:34.724Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:27-28
Timestamp: 2025-05-16T17:24:34.724Z
Learning: In Rust projects, dependencies listed in the [dependencies] section of Cargo.toml are available for both application code and tests. The tokio crate with the "full" feature set includes the "test" feature needed for `#[tokio::test]` to work properly.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-05-16T17:24:34.724Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:27-28
Timestamp: 2025-05-16T17:24:34.724Z
Learning: In Rust projects, dependencies listed in the [dependencies] section of Cargo.toml are available for both application code and tests. There's no need to duplicate them in [dev-dependencies] unless you want a different version or configuration specifically for tests.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-05-20T15:34:06.751Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1846
File: crates/quote/src/quote.rs:309-317
Timestamp: 2025-05-20T15:34:06.751Z
Learning: In Rust, when importing from the alloy crate, `use alloy::hex;` imports the hex macro, not a module, so it can't be consolidated with imports like `use alloy::hex::ToHex;` using the grouped import syntax.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-04-29T06:19:15.446Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1706
File: crates/quote/src/js_api/mod.rs:57-61
Timestamp: 2025-04-29T06:19:15.446Z
Learning: In the rain.orderbook codebase, the `get_id` function is designed to use `U256::from_str()` rather than `U256::from_hex()` for parsing order hashes, despite the potential for hex string inputs.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-05-27T06:16:35.738Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:69-127
Timestamp: 2025-05-27T06:16:35.738Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, directly accessing internal RwLock state in tests using `notice.0.read().unwrap()` is acceptable and does not require encapsulation through public getter methods.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to crates/**/*.rs : Rust code lives in the workspace under crates/* (e.g., cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests)

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-10-06T08:05:02.438Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-06T08:05:02.438Z
Learning: Applies to crates/*/tests/**/*.rs : Rust crates must have passing tests (cargo test --workspace or --package <crate>)

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Rust: build with nix develop -c cargo build --workspace; test with nix develop -c cargo test

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-06-18T18:24:32.049Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:180-199
Timestamp: 2025-06-18T18:24:32.049Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to avoid refactoring duplicate search logic between get_orderbook_by_address and get_orderbook_by_network_key when there are only 2 functions, indicating they would consider it if more similar functions are added in the future.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-07-21T16:32:19.576Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/add_order.rs:297-300
Timestamp: 2025-07-21T16:32:19.576Z
Learning: User 0xgleb prefers explicit destructuring patterns like `let (_, Address(FixedBytes(address))) = ...` over intermediate variables when extracting nested data structures, as they believe it makes clearer what is being unwrapped from complex types.

Applied to files:

  • crates/virtual-raindex/src/integration_tests.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: For Rust tests, prefer insta snapshots and proptest where helpful

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/host/revm.rs
📚 Learning: 2025-05-16T17:26:09.529Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:29-33
Timestamp: 2025-05-16T17:26:09.529Z
Learning: When testing error cases that might produce different types of errors depending on external conditions (such as hardware presence), using `unwrap_err()` without further assertions can be preferred over `assert!(result.is_err())` with specific error messages to avoid misleading readers about expected error details.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-05-13T20:06:22.602Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1713
File: crates/settings/src/remote/chains/mod.rs:43-226
Timestamp: 2025-05-13T20:06:22.602Z
Learning: When writing tests for collections of complex objects in Rust, prefer item-by-item comparison over direct vector comparison to get more specific error messages that pinpoint exactly which item and field has a mismatch.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/mutations.rs
📚 Learning: 2025-07-21T16:34:04.947Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/raindex_client/orders.rs:720-720
Timestamp: 2025-07-21T16:34:04.947Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers using `.unwrap()` in test code rather than `.expect()` with descriptive messages, considering the direct unwrap approach acceptable for test contexts where failures should be fast and clear.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-08-02T03:55:25.215Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: packages/orderbook/test/js_api/filters.test.ts:19-36
Timestamp: 2025-08-02T03:55:25.215Z
Learning: In the rainlanguage/rain.orderbook project's WASM tests, the pattern of chaining `.value!` calls on WASM result types (like from VaultsFilterBuilder methods) is the established and preferred approach for handling WASM results, and should not be refactored into intermediate variables as it would add unnecessary verbosity without improving the code.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-04-08T12:56:03.272Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1512
File: packages/ui-components/src/__tests__/OrderDetail.test.ts:125-143
Timestamp: 2025-04-08T12:56:03.272Z
Learning: The OrderDetail component in the Rain orderbook UI doesn't currently have error handling tests, but issue #1605 has been created to address this in the future.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-09-02T08:04:34.729Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: crates/js_api/src/gui/select_tokens.rs:421-424
Timestamp: 2025-09-02T08:04:34.729Z
Learning: User findolor in the rainlanguage/rain.orderbook codebase prefers not to change test code when tests are already passing, even if there appear to be type mismatches or potential issues. Working tests should be left alone unless there are actual errors.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-04T10:25:10.315Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: packages/ui-components/src/__tests__/TransactionManager.test.ts:160-161
Timestamp: 2025-07-04T10:25:10.315Z
Learning: In the rain.orderbook project, maintainer findolor prefers to keep non-null assertions (!) in test files rather than replacing them with optional chaining (?.) as they are not needed for tests where the structure is controlled and known to exist.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-21T16:34:31.193Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/types/impls.rs:7-15
Timestamp: 2025-07-21T16:34:31.193Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers breaking changes that remove unsafe default behaviors to be intentional and acceptable. Specifically, the get_decimals() method in crates/subgraph/src/types/impls.rs was intentionally changed to return MissingDecimals error instead of defaulting to 18 decimals, as defaulting to 18 is considered unsafe and should never have been done.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-06-16T10:49:47.770Z
Learnt from: thedavidmeister
Repo: rainlanguage/rain.orderbook PR: 1926
File: test/concrete/ob/OrderBook.clear.zeroAmount.t.sol:24-32
Timestamp: 2025-06-16T10:49:47.770Z
Learning: LibTestAddOrder.conformConfig() in test/util/lib/LibTestAddOrder.sol automatically constrains OrderConfigV3 to prevent common test failures by ensuring validInputs[0].token != validOutputs[0].token, setting them to address(0) and address(1) respectively if they're equal. This prevents TokenSelfTrade errors in fuzz tests.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-04T10:27:22.544Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/orders.rs:609-609
Timestamp: 2025-07-04T10:27:22.544Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor prefers not to implement overflow protection for trades count casting (usize to u16) at this time, considering it unnecessary for the current scope since the practical risk of orders having 65,535+ trades is extremely low.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-06-17T17:38:21.943Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/cli/src/transaction.rs:105-105
Timestamp: 2025-06-17T17:38:21.943Z
Learning: In Rust, Vec<String> can be compared with Vec<&str> using assert_eq! because Vec<T> implements PartialEq<Vec<U>> when T: PartialEq<U>, and String implements PartialEq<&str>. This means comparisons like assert_eq!(vec_of_strings, vec!["string_literal"]) work correctly without needing to convert string literals to String.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-07-23T13:03:40.669Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/vault_balance_changes_query.rs:133-135
Timestamp: 2025-07-23T13:03:40.669Z
Learning: User 0xgleb prefers not to make changes to test code when tests are already passing, even if the code format could be standardized differently. Working test code should be left alone unless there's a functional issue.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-19T15:55:42.079Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1846
File: crates/quote/src/quote.rs:1039-1049
Timestamp: 2025-05-19T15:55:42.079Z
Learning: For quote module tests, exact error message matching is preferred over substring matching when testing error cases.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-15T22:27:49.771Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1777
File: tauri-app/src-tauri/Cargo.toml:64-64
Timestamp: 2025-05-15T22:27:49.771Z
Learning: User 0xgleb prefers to maintain the dot notation format for some Cargo.toml dependencies (e.g., `rain-interpreter-eval.path = "path"`) rather than converting all to inline table format, as both formats are valid in Rust.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-10-06T08:05:02.438Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-06T08:05:02.438Z
Learning: Applies to crates/*/{src,tests,benches,examples}/**/*.rs : Rust code must pass clippy with all warnings denied (cargo clippy --workspace --all-targets --all-features -D warnings)

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-21T22:47:21.927Z
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:47:21.927Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very beginning of any comment, before any learning used section or other content.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-21T22:35:26.448Z
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:35:26.448Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very last part of any comment, after any learning used section or other content.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-05-21T21:24:53.708Z
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Applied to files:

  • crates/virtual-raindex/src/engine/tests.rs
📚 Learning: 2025-09-30T21:18:01.636Z
Learnt from: hardyjosh
Repo: rainlanguage/rain.orderbook PR: 2167
File: crates/virtual-raindex/src/engine/take.rs:131-138
Timestamp: 2025-09-30T21:18:01.636Z
Learning: In the virtual-raindex take order flow (crates/virtual-raindex/src/engine/take.rs), balance diffs are written from the order's perspective where the taker is the counterparty: the order's input column receives taker_output (what the taker provides to the order) and the order's output column receives taker_input (what the taker requests from the order).

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/calc.rs
  • crates/virtual-raindex/src/engine/mutations.rs
  • crates/virtual-raindex/src/engine/mod.rs
📚 Learning: 2025-06-24T08:46:03.368Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1947
File: crates/common/src/raindex_client/orders.rs:98-125
Timestamp: 2025-06-24T08:46:03.368Z
Learning: In the vault merging logic in crates/common/src/raindex_client/orders.rs, optimization isn't necessary because the maximum list items are usually around 5 items. For such small datasets, the simple three-loop approach is preferred over HashMap-based optimization due to clarity and minimal performance impact.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/mutations.rs
  • crates/virtual-raindex/src/engine/mod.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-10-02T19:17:20.332Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/common/src/raindex_client/orders.rs:738-741
Timestamp: 2025-10-02T19:17:20.332Z
Learning: In crates/common/src/raindex_client/orders.rs, fetch_dotrain_source() is intentionally called in try_from_sg_order for every order conversion because the dotrain source information is needed immediately. A future optimization with local DB logic is planned to eliminate the network round-trip concern.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/mutations.rs
📚 Learning: 2025-05-19T07:14:24.219Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1838
File: crates/cli/src/output.rs:29-41
Timestamp: 2025-05-19T07:14:24.219Z
Learning: For the rainlanguage/rain.orderbook repository, findolor prefers minimal documentation for straightforward functions like `output` in crates/cli/src/output.rs where the implementation is self-explanatory.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-06-07T05:19:46.330Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1872
File: packages/webapp/src/__tests__/handleVaultDeposit.test.ts:20-53
Timestamp: 2025-06-07T05:19:46.330Z
Learning: In the rain.orderbook codebase, simple wrapper/adapter functions that just delegate to other functions (like handleVaultDeposit) don't need extensive edge case testing for missing parameters or error handling - the current test coverage focusing on core functionality is sufficient.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-05-27T06:16:12.195Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:87-114
Timestamp: 2025-05-27T06:16:12.195Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, testing one WriteTransactionStatus variant (like PendingPrepare) is sufficient for the update_status_and_emit method since all variants follow the same code path through the From<WriteTransactionStatus<T>> implementation.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-10-06T08:05:02.438Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-06T08:05:02.438Z
Learning: Applies to packages/orderbook/**/*.{test,spec}.{ts,tsx} : Orderbook tests must pass (npm run test -w rainlanguage/orderbook)

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-03-26T15:00:17.997Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1516
File: packages/webapp/src/routes/deploy/[strategyName]/layout.test.ts:0-0
Timestamp: 2025-03-26T15:00:17.997Z
Learning: For Rain Orderbook projects, there's a preference not to include tests for SvelteKit methods (like parent function rejections) in test files, as these are considered framework responsibilities rather than application code that needs testing.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-09-24T10:54:42.060Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/cli/src/commands/order/calldata.rs:47-48
Timestamp: 2025-09-24T10:54:42.060Z
Learning: In crates/cli/src/commands/order/calldata.rs, the config_deployment variable is used both as a parameter to AddOrderArgs::new_from_deployment() and later to extract RPC information, requiring the clone() to maintain access after ownership transfer.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-06-24T13:36:28.797Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1950
File: crates/common/src/raindex_client/orders.rs:301-301
Timestamp: 2025-06-24T13:36:28.797Z
Learning: In the RaindexClient codebase, when Arc::new(RwLock::new(self.clone())) is used (e.g., in get_orders and get_order_by_hash methods), this creates new Arc/RwLock wrappers around a cloned RaindexClient, but the underlying client data is functionally the same. This pattern is used to provide the correct Arc<RwLock<RaindexClient>> type expected by RaindexOrder::try_from_sg_order() method.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
  • crates/virtual-raindex/src/engine/mutations.rs
📚 Learning: 2025-07-04T10:24:29.750Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/add_orders.rs:132-132
Timestamp: 2025-07-04T10:24:29.750Z
Learning: In the rain.orderbook codebase, findolor prefers to use `unwrap_or("")` for optional frontmatter in dotrain parsing, allowing empty strings to be handled by downstream validation in `NewConfig::try_from_yaml()` rather than adding explicit early validation checks at the extraction point.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-04-30T10:32:53.866Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:101-105
Timestamp: 2025-04-30T10:32:53.866Z
Learning: In the rain.orderbook project, the `get_remove_order_calldata` function takes `SgOrder` by value rather than by reference, as per maintainer preference.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-06-17T16:54:43.176Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/common/src/deposit.rs:63-64
Timestamp: 2025-06-17T16:54:43.176Z
Learning: In the rain.orderbook codebase, the maintainer findolor prefers to keep the current implementation that clones the rpcs vector when calling ReadableClient::new_from_urls rather than optimizing it to avoid the clone or adding early validation for empty rpcs. Performance micro-optimizations like avoiding vector clones in this context are not a priority.

Applied to files:

  • crates/virtual-raindex/src/engine/take.rs
📚 Learning: 2025-03-31T18:53:12.208Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1477
File: crates/settings/src/yaml/dotrain.rs:20-20
Timestamp: 2025-03-31T18:53:12.208Z
Learning: In the DotrainYaml struct, the cache field is kept public (`pub cache: Cache`) without additional getter methods, which is consistent with the existing design pattern in the codebase where other fields like `documents` are also public.

Applied to files:

  • crates/virtual-raindex/src/cache.rs
📚 Learning: 2025-04-07T09:52:30.960Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1483
File: crates/settings/src/yaml/dotrain.rs:20-20
Timestamp: 2025-04-07T09:52:30.960Z
Learning: In the DotrainYaml struct, the newly added `cache` field is kept public without documentation, which the maintainer confirmed is acceptable for now.

Applied to files:

  • crates/virtual-raindex/src/cache.rs
📚 Learning: 2025-06-24T08:45:10.971Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1947
File: crates/common/src/raindex_client/orders.rs:462-1643
Timestamp: 2025-06-24T08:45:10.971Z
Learning: User findolor prefers to keep tests simple and avoid refactoring for maintainability when the code is stable and viewed as "one time thing" that won't require frequent changes.

Applied to files:

  • crates/virtual-raindex/src/cache.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
📚 Learning: 2025-10-06T08:05:50.452Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-06T08:05:50.452Z
Learning: Applies to **/*.sol : For Solidity, add fuzz/property tests where relevant

Applied to files:

  • crates/virtual-raindex/src/cache.rs
  • crates/virtual-raindex/src/engine/post_tasks.rs
📚 Learning: 2025-08-01T07:44:53.910Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:319-336
Timestamp: 2025-08-01T07:44:53.910Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore (crates/js_api/src/filters/raindex_filter_store.rs), the team chose a simplified monolithic approach with hard-coded keys and default auto-save behavior over configurable stores. The update_vaults method intentionally auto-saves to both localStorage and URL after each update as the default behavior, following a design evolution from a previous configurable approach.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
  • crates/virtual-raindex/src/state.rs
📚 Learning: 2025-09-02T08:05:07.646Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/webapp/src/lib/components/DepositModal.svelte:25-28
Timestamp: 2025-09-02T08:05:07.646Z
Learning: In packages/webapp/src/lib/components/DepositModal.svelte, findolor considers the double-cast pattern `as unknown as AccountBalance` safe for initializing userBalance with Float.parse('0').value and formattedBalance: '0'.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-07-04T09:02:57.301Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/fuzz/mod.rs:64-64
Timestamp: 2025-07-04T09:02:57.301Z
Learning: In rainlanguage/rain.orderbook, user findolor prefers to limit type consistency changes to only the parts directly related to the current work scope. For example, when updating chain_id fields from u64 to u32 in fuzz-related code, unrelated files like tauri-app wallet commands can remain as u64 if they serve different purposes and aren't part of the current changes.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-06-18T12:56:44.290Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/mod.rs:102-118
Timestamp: 2025-06-18T12:56:44.290Z
Learning: In the rainlanguage/rain.orderbook codebase, it's acceptable to scaffold unused enum variants in initial implementation PRs when they will be implemented in future PRs, as confirmed by findolor.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-07-16T05:52:05.576Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:59-59
Timestamp: 2025-07-16T05:52:05.576Z
Learning: User findolor prefers to handle documentation updates for getter methods in batch via dedicated PRs rather than addressing them individually during feature development, as mentioned for the formatted amount string fields in crates/common/src/raindex_client/vaults.rs.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-07-21T16:37:20.599Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/utils/mod.rs:1-1
Timestamp: 2025-07-21T16:37:20.599Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers explicit module imports over re-exporting symbols at higher levels. Specifically for the float constants in crates/subgraph/src/utils/float.rs, they prefer using `utils::float::*` rather than re-exporting with `pub use float::*` in the utils module, as the explicit import makes it clearer what is being imported and why it's needed.

Applied to files:

  • crates/virtual-raindex/src/engine/quote.rs
📚 Learning: 2025-07-15T08:01:38.534Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:282-292
Timestamp: 2025-07-15T08:01:38.534Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor prefers to avoid concurrency optimizations like using `futures::future::try_join_all` for parallel processing of balance changes, considering such optimizations "not that critical at the moment" when the performance impact is minimal.

Applied to files:

  • crates/virtual-raindex/src/engine/mutations.rs
📚 Learning: 2025-07-11T08:45:43.961Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1925
File: crates/settings/src/remote_tokens.rs:44-62
Timestamp: 2025-07-11T08:45:43.961Z
Learning: findolor prefers to avoid performance micro-optimizations like changing `.values()` to `.into_values()` in HashMap iterations in the rainlanguage/rain.orderbook codebase, even when they would eliminate unnecessary cloning.

Applied to files:

  • crates/virtual-raindex/src/engine/mutations.rs
📚 Learning: 2025-06-17T16:46:19.035Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/cli/src/commands/order/calldata.rs:47-57
Timestamp: 2025-06-17T16:46:19.035Z
Learning: In the CLI command `crates/cli/src/commands/order/calldata.rs`, the user prefers to let lower-level errors from `try_into_call()` bubble up when the RPCs list is empty, rather than adding early validation checks with custom error messages.

Applied to files:

  • crates/virtual-raindex/src/engine/mutations.rs
📚 Learning: 2025-07-16T14:33:45.887Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2001
File: crates/common/src/raindex_client/vaults.rs:0-0
Timestamp: 2025-07-16T14:33:45.887Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor considers using Address::random() in tests to be acceptable when the mock server doesn't validate the address parameter and returns a fixed response, making the test deterministic regardless of the address value used.

Applied to files:

  • crates/virtual-raindex/src/engine/mod.rs
🧬 Code graph analysis (13)
crates/virtual-raindex/src/integration_tests.rs (4)
crates/virtual-raindex/src/store.rs (3)
  • derive_fqn (38-40)
  • address_to_u256 (33-35)
  • new (24-29)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/test_fixtures/src/lib.rs (2)
  • new (81-144)
  • new_with_tokens (149-165)
crates/virtual-raindex/src/cache.rs (4)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
crates/virtual-raindex/src/engine/tests.rs (5)
crates/virtual-raindex/src/cache.rs (6)
  • store (17-17)
  • store (64-66)
  • interpreter (15-15)
  • interpreter (59-61)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/store.rs (2)
  • address_to_u256 (33-35)
  • derive_fqn (38-40)
crates/virtual-raindex/src/host/revm.rs (2)
  • eval4 (30-36)
  • eval4 (73-121)
crates/virtual-raindex/src/state.rs (1)
  • snapshot (125-133)
crates/virtual-raindex/src/engine/quote.rs (3)
  • from (22-24)
  • from (28-30)
  • quote (85-151)
crates/virtual-raindex/src/engine/take.rs (6)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/calc.rs (1)
  • calculate_order_io (40-108)
crates/virtual-raindex/src/engine/eval.rs (1)
  • build_eval_call (24-39)
crates/virtual-raindex/src/cache.rs (6)
  • store (17-17)
  • store (64-66)
  • interpreter (15-15)
  • interpreter (59-61)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/store.rs (3)
  • apply_store_writes (62-71)
  • writes_to_pairs (51-59)
  • new (24-29)
crates/virtual-raindex/src/state.rs (2)
  • new (26-32)
  • new (44-46)
crates/virtual-raindex/src/engine/calc.rs (3)
crates/virtual-raindex/src/store.rs (3)
  • namespace_for_order (43-48)
  • new (24-29)
  • writes_to_pairs (51-59)
crates/virtual-raindex/src/engine/eval.rs (1)
  • build_eval_call (24-39)
crates/virtual-raindex/src/state.rs (2)
  • new (26-32)
  • new (44-46)
crates/virtual-raindex/src/engine/context.rs (4)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/mod.rs (7)
  • u8_to_b256 (149-151)
  • new (58-65)
  • interpreter (73-75)
  • interpreter (172-174)
  • store (176-178)
  • ensure_artifacts (180-182)
  • eval4 (189-197)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (60-65)
  • eval4 (30-36)
  • eval4 (73-121)
crates/virtual-raindex/src/cache.rs (6)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/cache.rs (4)
crates/virtual-raindex/src/engine/context.rs (3)
  • interpreter (125-127)
  • store (129-131)
  • ensure_artifacts (133-135)
crates/virtual-raindex/src/engine/mod.rs (5)
  • interpreter (73-75)
  • interpreter (172-174)
  • store (176-178)
  • ensure_artifacts (180-182)
  • new (58-65)
crates/virtual-raindex/src/host/revm.rs (1)
  • new (60-65)
crates/virtual-raindex/src/integration_tests.rs (1)
  • new (196-221)
crates/virtual-raindex/src/engine/post_tasks.rs (6)
crates/virtual-raindex/src/engine/mutations.rs (1)
  • ensure_vault_entries (41-48)
crates/virtual-raindex/src/engine/mod.rs (6)
  • store (176-178)
  • code_cache (78-80)
  • interpreter (73-75)
  • interpreter (172-174)
  • new (58-65)
  • eval4 (189-197)
crates/virtual-raindex/src/cache.rs (4)
  • store (17-17)
  • store (64-66)
  • interpreter (15-15)
  • interpreter (59-61)
crates/virtual-raindex/src/store.rs (4)
  • namespace_for_order (43-48)
  • new (24-29)
  • address_to_u256 (33-35)
  • derive_fqn (38-40)
crates/virtual-raindex/src/state.rs (2)
  • new (26-32)
  • new (44-46)
crates/virtual-raindex/src/host/revm.rs (3)
  • new (60-65)
  • eval4 (30-36)
  • eval4 (73-121)
crates/virtual-raindex/src/engine/quote.rs (4)
crates/virtual-raindex/src/engine/mod.rs (3)
  • store (176-178)
  • new (58-65)
  • quote (119-121)
crates/virtual-raindex/src/engine/calc.rs (1)
  • calculate_order_io (40-108)
crates/virtual-raindex/src/state.rs (2)
  • new (26-32)
  • new (44-46)
crates/virtual-raindex/src/store.rs (2)
  • new (24-29)
  • apply_overrides (74-81)
crates/virtual-raindex/src/engine/mutations.rs (2)
crates/virtual-raindex/src/engine/mod.rs (1)
  • new (58-65)
crates/virtual-raindex/src/state.rs (2)
  • new (26-32)
  • new (44-46)
crates/virtual-raindex/src/engine/mod.rs (5)
crates/virtual-raindex/src/engine/quote.rs (2)
  • quote (85-151)
  • new (46-60)
crates/virtual-raindex/src/engine/post_tasks.rs (2)
  • new (143-148)
  • add_order (18-42)
crates/virtual-raindex/src/engine/take.rs (7)
  • new (137-169)
  • interpreter (495-497)
  • take_orders (82-94)
  • take_orders_and_apply_state (97-110)
  • resolve_order (192-206)
  • store (499-501)
  • ensure_artifacts (503-505)
crates/virtual-raindex/src/state.rs (4)
  • new (26-32)
  • new (44-46)
  • snapshot (125-133)
  • apply_mutations (136-184)
crates/virtual-raindex/src/cache.rs (6)
  • interpreter (15-15)
  • interpreter (59-61)
  • store (17-17)
  • store (64-66)
  • ensure_artifacts (20-20)
  • ensure_artifacts (69-85)
crates/virtual-raindex/src/store.rs (3)
crates/virtual-raindex/src/state.rs (3)
  • new (26-32)
  • new (44-46)
  • snapshot (125-133)
crates/virtual-raindex/src/engine/quote.rs (3)
  • new (46-60)
  • from (22-24)
  • from (28-30)
crates/virtual-raindex/src/integration_tests.rs (2)
  • new (196-221)
  • address_to_u256 (59-61)
crates/virtual-raindex/src/state.rs (3)
crates/common/src/utils/order_hash.rs (1)
  • order_hash (6-8)
crates/virtual-raindex/src/engine/mod.rs (4)
  • new (58-65)
  • store (176-178)
  • snapshot (68-70)
  • apply_mutations (88-103)
crates/virtual-raindex/src/engine/take.rs (2)
  • new (137-169)
  • store (499-501)
crates/virtual-raindex/src/host/revm.rs (2)
crates/virtual-raindex/src/cache.rs (4)
  • store (17-17)
  • store (64-66)
  • interpreter (15-15)
  • interpreter (59-61)
crates/virtual-raindex/src/store.rs (1)
  • build_state_overlay (84-95)
⏰ 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). (4)
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: Deploy-Docs-Preview
  • GitHub Check: Deploy-Preview-Push

Comment on lines +140 to +142
if outcome.stack.len() < 2 {
return Err(RaindexError::Unimplemented("calculate-io outputs"));
}
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Nov 7, 2025

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Improve error message specificity.

The generic Unimplemented("calculate-io outputs") error doesn't indicate what went wrong. When stack length < 2, include the actual stack length in the error message to help diagnose malformed interpreter bytecode.

Apply this diff:

     if outcome.stack.len() < 2 {
-        return Err(RaindexError::Unimplemented("calculate-io outputs"));
+        return Err(RaindexError::Unimplemented(
+            &format!("calculate-io requires 2 stack outputs (io_ratio, output_max), got {}", outcome.stack.len())
+        ));
     }

Consider also adding a comment above line 126 documenting the expected stack contract:

// calculate-io entrypoint must produce exactly 2 stack values:
// stack[0] = io_ratio (input/output exchange rate)
// stack[1] = output_max (maximum available output)
🤖 Prompt for AI Agents
In crates/virtual-raindex/src/engine/calc.rs around lines 140-142, the error
returned when outcome.stack.len() < 2 is too generic; change the Err to include
the actual stack length (e.g., RaindexError::Unimplemented(format!("calculate-io
outputs: expected 2 values, got {}", outcome.stack.len()))) so the message
reports the observed length, and add a comment above line 126 documenting the
expected stack contract: that calculate-io must produce exactly 2 stack values
(stack[0] = io_ratio, stack[1] = output_max).

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.

added a new error type

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.

@hardyjosh, great! Adding a dedicated error type is actually a better solution than formatting the message within the generic Unimplemented variant. A specific error type will provide better type safety and make it easier to handle this particular failure case programmatically. 👍


🧠 Learnings used
Learnt from: hardyjosh
Repo: rainlanguage/rain.orderbook PR: 2167
File: crates/virtual-raindex/src/engine/take.rs:131-138
Timestamp: 2025-09-30T21:18:01.636Z
Learning: In the virtual-raindex take order flow (crates/virtual-raindex/src/engine/take.rs), balance diffs are written from the order's perspective where the taker is the counterparty: the order's input column receives taker_output (what the taker provides to the order) and the order's output column receives taker_input (what the taker requests from the order).

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/cli/src/commands/order/calldata.rs:47-57
Timestamp: 2025-06-17T16:46:19.035Z
Learning: In the CLI command `crates/cli/src/commands/order/calldata.rs`, the user prefers to let lower-level errors from `try_into_call()` bubble up when the RPCs list is empty, rather than adding early validation checks with custom error messages.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1983
File: crates/settings/src/gui.rs:965-973
Timestamp: 2025-07-11T08:37:24.423Z
Learning: In the rainlanguage/rain.orderbook project, user findolor prefers to keep user-facing error messages generic and user-friendly rather than technically specific. For example, using "a valid number" instead of "a valid u8 (0-255)" in GUI validation error messages to maintain simplicity for end users.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.

Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/types/impls.rs:7-15
Timestamp: 2025-07-21T16:34:31.193Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers breaking changes that remove unsafe default behaviors to be intentional and acceptable. Specifically, the get_decimals() method in crates/subgraph/src/types/impls.rs was intentionally changed to return MissingDecimals error instead of defaulting to 18 decimals, as defaulting to 18 is considered unsafe and should never have been done.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T23:09:27.578Z
Learning: For PR #1884 in rainlanguage/rain.orderbook repository, I must always reassess the PR size after each new commit, calculating the total changes up to the very latest commit and ensuring accuracy of the report. The calculation must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and report in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number".

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the format: "TOTAL=number ADDITIONS=number DELETIONS=number". This report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/quote/src/quote.rs (1)

61-70: Reuse the canonical order_hash helper

We just introduced a shared helper, so this method should delegate to it instead of hand-rolling the keccak. That keeps the hash logic consistent across crates and avoids two places to update if serialization ever changes. As per coding guidelines

+use rain_orderbook_common::utils::order_hash::order_hash;
@@
     /// Get the order hash of self
     pub fn get_order_hash(&self) -> B256 {
-        keccak256(self.quote_config.order.abi_encode())
+        order_hash(&self.quote_config.order)
     }
♻️ Duplicate comments (2)
crates/virtual-raindex/README.md (1)

3-3: Fix trailing whitespace on line 3.

Line 3 has a trailing space after "keeps" that violates markdownlint rule MD009. This was flagged in the previous review and needs to be corrected.

- Virtual Raindex is a pure-Rust implementation of the Rain Orderbook. It keeps 
+ Virtual Raindex is a pure-Rust implementation of the Rain Orderbook. It keeps
crates/virtual-raindex/src/engine/tests.rs (1)

602-609: Prefer the std assert_matches! macro

The standard library ships std::assert_matches::assert_matches!, so we can drop the external path and just import it once for the whole module. That avoids an extra dependency and aligns with upstream guidance.

+use std::assert_matches::assert_matches;
@@
-    assert_matches::assert_matches!(err, RaindexError::MinimumInputNotMet { .. });
+    assert_matches!(err, RaindexError::MinimumInputNotMet { .. });

Please apply the same change to the other assert_matches::assert_matches! calls in this file. As per coding guidelines

scenarios without depending on a live blockchain node, making it ideal for
simulation, backtesting, and deterministic replay workloads.

## Features
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

Adjust markdown heading format to match codebase convention.

The codebase uses two spaces after ## in markdown headings (e.g., ## Features rather than ## Features). Update all four headings to align with this established style.

- ## Features
+ ##  Features

- ## Crate Layout
+ ##  Crate Layout

- ## Getting Started
+ ##  Getting Started

- ## Running Tests
+ ##  Running Tests

Based on learnings from PR 1944.

Also applies to: 25-25, 39-39, 83-83

🤖 Prompt for AI Agents
In crates/virtual-raindex/README.md around lines 10, 25, 39 and 83, the markdown
headings use a single space after the "##" instead of the repository's
convention of two spaces; update each heading line (lines 10, 25, 39, 83) to
insert a second space after "##" (e.g., change "## Features" to "##  Features")
so all four headings follow the established style.

Comment on lines +107 to +112
for chunk in outcome.writes.chunks(2) {
if let [key, value] = chunk {
state
.store
.insert(StoreKey::new(task.evaluable.store, qualified, *key), *value);
}
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.

⚠️ Potential issue | 🟠 Major

Validate interpreter writes before applying them.

chunks(2) + if let [key, value] = chunk silently discards a trailing entry when outcome.writes has odd length (e.g., malformed interpreter output). That drops store updates without surfacing an error, leaving the virtual state inconsistent with the interpreter’s intent. Please validate the length first (or reuse store::writes_to_pairs), and fail fast instead of mutating partial data.

Apply this diff to centralize the validation:

-        for chunk in outcome.writes.chunks(2) {
-            if let [key, value] = chunk {
-                state
-                    .store
-                    .insert(StoreKey::new(task.evaluable.store, qualified, *key), *value);
-            }
-        }
+        for (key, value) in crate::store::writes_to_pairs(&outcome.writes)? {
+            state
+                .store
+                .insert(StoreKey::new(task.evaluable.store, qualified, key), value);
+        }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In crates/virtual-raindex/src/engine/add_order.rs around lines 107 to 112, the
loop over outcome.writes using chunks(2) + if let silently drops a trailing key
or value when writes has odd length; change this to first validate that
outcome.writes.len() is even (or call store::writes_to_pairs which performs
validation) and return an error immediately if it's not, then convert writes
into key/value pairs before mutating state so no partial store updates occur;
ensure the function propagates the error and only applies inserts after
successful validation and pair conversion.

@hardyjosh hardyjosh closed this Apr 14, 2026
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