Skip to content

[draft] Fixes used by st0x.rest.api preview deployment#2561

Draft
alastairong1 wants to merge 4 commits intorainlanguage:mainfrom
alastairong1:alastair/st0x-rest-api-deploy-fixes
Draft

[draft] Fixes used by st0x.rest.api preview deployment#2561
alastairong1 wants to merge 4 commits intorainlanguage:mainfrom
alastairong1:alastair/st0x-rest-api-deploy-fixes

Conversation

@alastairong1
Copy link
Copy Markdown

Draft for review by @alastairong1 — not for upstream merge yet. Captures fixes applied locally to make the st0x.rest.api preview deployment behave correctly. Splitting into per-topic PRs once each is validated.

Summary

Four independent changes, one commit each. Each is reviewable on its own and can be split into a standalone PR if upstream prefers:

1. `bindings: switch IERC20 interface to ERC20 contract bindings` (`55731bd`)

The `sol!` macro for ERC20 now uses the actual contract artifact (`ERC20.sol/ERC20.json`) with `rpc` derives enabled, instead of the generic IERC20 interface. Mechanical follow-on rename across all `approveCall { amount: ... }` call sites and decoded-call assertions: `amount` → `value` to match the ERC20 ABI. `IERC20Instance` → `ERC20Instance`, `IERC20::symbolCall` → `ERC20::symbolCall`, `IERC20::decimalsCall` → `ERC20::decimalsCall`.

2. `bindings: avoid request amplification in mk_read_provider` (`e0161ee`)

`FallbackLayer::with_active_transport_count(rpcs.len())` dispatches every request to ALL configured transports in parallel — the opposite of what operators expect when supplying multiple RPCs for load sharing. With N RPCs, every read becomes N reads, downstream rate limits fire N× sooner.

Set `active_transport_count = 1` so the FallbackLayer health-routes a single transport per request and falls back to others on error/429. No behavior change for single-RPC setups; multi-RPC setups stop amplifying.

3. `local_db: raise SQLite busy_timeout from 500ms to 10s` (`34bd830`)

500ms is below the writer-contention window seen under real ingest concurrency: parallel readers held off by a single long write hit `SQLITE_BUSY` immediately. 10s is conservative for WAL-mode reads.

4. `quote: thread per-order signed_contexts through batch quoting` (`76ca3b2`)

Adds an optional `signed_contexts: Option<&[Vec]>` parameter to `get_order_quotes` and `get_order_quotes_batch`. When supplied, the per-order context is attached to the generated `QuoteV2` request as `signedContext`. When `None`, behavior is unchanged.

Why: callers gating order-fill on a signed context (e.g. an off-chain authorization passed via `SignedContextInjector`) need to quote with the same signed context they intend to take with — otherwise the gate check on the calculate-io side fails at simulation, producing misleading "no liquidity" results for orders that would actually fill.

Backward compatible: every existing call site passes `None` and gets prior behavior.

Status

The sol! macro for ERC20 now uses the actual contract artifact
(`ERC20.sol/ERC20.json`) with `rpc` derives enabled, instead of the
generic IERC20 interface. This unblocks call/send paths that need the
RPC-aware instance type and matches what alloy now expects for the
`approveCall` schema (field is `value`, not `amount`).

Mechanical follow-on changes:
- All `approveCall { amount: ... }` call sites and decoded-call assertions
  rename `amount` -> `value` to match the ERC20 ABI.
- `IERC20Instance` -> `ERC20Instance`, `IERC20::symbolCall` ->
  `ERC20::symbolCall`, `IERC20::decimalsCall` -> `ERC20::decimalsCall`
  in the common ERC20 helper, fuzz impls, and vaults tests.

No behavior change beyond the binding switch.
`FallbackLayer::with_active_transport_count(rpcs.len())` dispatches every
request to ALL configured transports in parallel — the opposite of what
operators expect when supplying multiple RPCs for load sharing or burst
absorption. With N RPCs, every read becomes N reads, and downstream rate
limits fire N times sooner.

Set `active_transport_count = 1` so the FallbackLayer health-routes a
single transport per request and falls back to others on error/429,
preserving load-sharing semantics. Also short-circuit the empty-rpcs
case before constructing the layer to make the error path obvious.

No behavior change for single-RPC setups; multi-RPC setups stop
amplifying requests.
500ms is below the writer-contention window that shows up under real
ingest concurrency: parallel readers being held off by a single long
write hit `SQLITE_BUSY` returns to the caller. 10s is conservative for
WAL-mode reads and aligned with the upstream rusqlite default
recommendation for high-concurrency workloads.

No correctness change — just a longer wait window before surfacing
SQLITE_BUSY to the application.
Adds an optional `signed_contexts: Option<&[Vec<SignedContextV1>]>`
parameter to `get_order_quotes` and `get_order_quotes_batch`. When
supplied, the per-order context (indexed by order position) is attached
to each generated `QuoteV2` request as `signedContext`. When `None` (or
out of range), behavior is unchanged: empty signedContext, matching the
prior default.

Why: callers gating order-fill on a signed context (e.g. an off-chain
authorization passed via SignedContextInjector) need to quote with the
same signed context they intend to take with — otherwise the gate
check on the calculate-io side fails at simulation, producing
misleading "no liquidity" results for orders that would actually fill.

Backward compatible: every existing call site passes `None` and gets
the previous behavior. Only one new parameter, no field renames.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b857d121-dbfe-4e5b-ab29-1d63f03c680a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❤️ Share

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant