Skip to content

chore(deps): patch cowprotocol to bleu/cow-rs main (post-alpha.3)#10

Draft
brunota20 wants to merge 4 commits into
nullislabs:mainfrom
bleu:feat/cowprotocol-bleu-main
Draft

chore(deps): patch cowprotocol to bleu/cow-rs main (post-alpha.3)#10
brunota20 wants to merge 4 commits into
nullislabs:mainfrom
bleu:feat/cowprotocol-bleu-main

Conversation

@brunota20
Copy link
Copy Markdown

Draft, stacked on top of #8 + #9 — the diff includes those PRs' commits until they land.

`cowprotocol` v1.0.0-alpha.3 (the crates.io release the engine depends on after #8) was cut from `cowdao-grants/cow-rs` PR #5 at commit `1742ffa`. `bleu/cow-rs` main has 18 commits since, and several are directly relevant to the cow-api backend in #8:

Commit Why it matters here
`fix(composable): correct Proof width and add signature assemblers` Affects the TWAP poll path the host will eventually drive through `cow_twap_*` host calls — the wrong-width `Proof` array would silently truncate a multi-leaf merkle proof at the contract boundary.
`refactor(trading): fail fast on a zero from-address` Closes the MEDIUM "wrong-target submission" review finding mfw78 left on PR #5 — `OrderCreation::from_signed_order_data` now rejects `from = 0x0` host-side, so the cow-api submit path catches a wrong-owner bug before the orderbook does.
`feat(order_book): enforce QuoteRequest invariants, collapse boilerplate` Hardens `QuoteRequest` so guests handing the engine a degenerate quote request get a typed error instead of an opaque 4xx from the orderbook.
`feat(domain,order): add EIP-712 typed-data and message-hash helpers` Useful for the future TWAP / EthFlow encoding work; lets the engine surface signing payloads without re-implementing the EIP-712 dance.
`feat(order-book): migrate trades to /api/v2 with pagination` The trades endpoint shape changed; pinning to alpha.3 means the cow-api passthrough still hits /api/v1 for `/trades` which the orderbook will deprecate.
`fix(cowprotocol): gate DEFAULT_HTTP_TIMEOUT import to non-wasm` Companion fix to the wasm32 reqwest gate the cow-sdk-wasm shim relies on — keeps the dep tree clean for any future component-side cowprotocol use.
`refactor(composable): extract deployed() helper, split TWAP submodule` The `composable` submodule layout moved; this PR confirms the host's existing imports survive the split (`cargo build` clean), so we lock in the new path before a follow-up host PR adds the TWAP poll helpers.

How

Workspace-level `[patch.crates-io]` pinned to a specific bleu/cow-rs commit for determinism:

```toml
[patch.crates-io]
cowprotocol = { git = "https://github.com/bleu/cow-rs\", rev = "c012404ffefc411bff543d2290e19ba7fbef2516" }
```

When José publishes the next alpha (likely `1.0.0-alpha.4`) the patch line goes away in one commit.

Verified

Trade-off note

Patching to a git rev shifts dep resolution from a stable crates.io artifact to a moving branch tip (we pin a rev, so the tip stays put until we bump it). Anyone consuming this PR needs the bleu/cow-rs commit accessible, which it is — public repo, public branch. Reverting to alpha.3 is a one-line undo if the patch ever causes friction.

brunota20 added 4 commits June 1, 2026 14:19
Adds the dependencies the 0.2 host backends need:

- cowprotocol (1.0.0-alpha) for the cow-api submission path
  (OrderBookApi, OrderCreation, OrderUid, Chain).
- alloy-provider / -rpc-client / -transport-ws / -primitives (1.5)
  for the chain JSON-RPC dispatch. The reqwest feature on
  alloy-provider engages connect_http; the pubsub/ws features back
  eth_subscribe-class methods.
- redb (2) for local-store. Same crate cowprotocol's own watch-tower
  picked, so the dep tree does not bifurcate when both are used in
  the same workspace.
- reqwest (0.12, rustls-tls) — direct, so the import survives any
  future cowprotocol feature rearrangement.
- tracing + tracing-subscriber (env-filter + fmt) — replaces the 0.1
  eprintln! debug log so the engine can drop into a structured log
  pipeline without re-instrumenting every host call.
- thiserror (2) — typed error enums in each backend.
- tempfile + wiremock as dev-deps for the host backend tests.

Adds engine.example.toml documenting the [engine] state_dir + per-
chain RPC URLs the chain backend reads at boot; data/ is now
ignored so a local run does not leave the redb file in tree.
Replaces the 0.2 Unsupported stubs with working backends. Each
capability lives in its own host submodule so the trait impls in
main.rs stay thin (dispatch + project the backend's typed error
onto HostError).

cow_api::submit_order
  - Parses the guest's bytes as JSON cowprotocol::OrderCreation.
  - Dispatches via cowprotocol::OrderBookApi::post_order.
  - Returns the assigned OrderUid as a 0x-prefixed hex string.

cow_api::request
  - REST passthrough. The base URL is whichever URL the pool's
    OrderBookApi client carries — so OrderBookApi::new_with_base_url
    overrides (staging, wiremock) flow through transparently.
  - Method/path validated host-side; orderbook 4xx/5xx bodies are
    surfaced verbatim so the guest can decode {errorType,description}.

chain::request
  - Raw JSON-RPC dispatch over an alloy DynProvider opened from
    engine.toml at boot. WebSocket URLs engage pubsub (eth_subscribe);
    HTTP URLs use the HTTP transport. Params are passed as
    serde_json::RawValue so alloy does not re-encode.
  - request-batch falls back to per-call dispatch (same shape as the
    earlier stub but now backed by real RPC).

local_store
  - redb file under engine_config.engine.state_dir.
  - Single shared table. Per-module namespacing is enforced
    host-side via [len:u8][module_name][raw_key] prefix on every
    key. list_keys strips the prefix before returning to the guest.

logging
  - Routes through tracing::event! tagged with module=<namespace>.
  - Engine boot installs an EnvFilter-based subscriber; RUST_LOG
    overrides the engine.toml log_level.

identity / remote-store / messaging / http stay at Unsupported per
the 0.2 roadmap (keystore / Swarm / Waku land in 0.3).

Tests (14, all green):
  - cow_orderbook: pool default chains, unknown-chain typing, REST
    GET passthrough, relative-path resolution, unknown-method
    rejection, submit_order round-trip — last three under wiremock
    so the full HTTP path is exercised without hitting api.cow.fi.
  - provider_pool: empty pool surfaces UnknownChain.
  - local_store: roundtrip, namespace isolation, delete, list_keys
    prefix-stripping, empty-namespace rejection.

End-to-end against modules/example: example.wasm loads under the
new wiring, logs init + on_event through the tracing pipeline.
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