Skip to content

cow-venue: use alloy primitives instead of byte-array aliases - #588

Merged
mfw78 merged 1 commit into
dev/m1from
cow/546-alloy-primitives
Jul 24, 2026
Merged

cow-venue: use alloy primitives instead of byte-array aliases#588
mfw78 merged 1 commit into
dev/m1from
cow/546-alloy-primitives

Conversation

@mfw78

@mfw78 mfw78 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What

Replaces cow-venue's pub type Address = [u8; 20] / pub type U256 = [u8; 32] aliases with alloy_primitives::Address/U256 throughout the order body (SellToken/BuyToken, the OrderBody fields, the builder constructor) and every dependent, dropping the to_be_bytes/from_be_bytes/into_array hops in assembly.rs and the adapter that existed only to cross the old alias boundary. The value-flow header and quotation projections now go through a new AssetAmount::erc20(Address, U256) constructor on videre-sdk, which owns the minimal big-endian uint encoding next to the wire type it serves, so the adapter no longer hand-rolls to_be_bytes_trimmed_vec and its call sites read in plain alloy types (value_flow becomes a real module re-exporting the bindings, so its public path is unchanged). Borsh support for the alloy types comes from alloy-primitives' own borsh feature (the FixedBytes/Address impls live in-crate and its feature passes through to ruint/borsh for U256), the same pattern composable-cow already uses. The U256 borsh wire form moves from 32-byte big-endian to ruint's little-endian, so the published codec vectors and header goldens are regenerated; the conformance suite gains regeneration-parity tests and an ignored regenerate_published_fixtures writer matching the videre-test house pattern. The issue's two hygiene points are settled as well: alloy-primitives is regated from the assembly slice into the body slice (kept optional only because it gates the empty --no-default-features build), and the no_std cfg_attr plus the extern crate alloc plumbing are dropped since every target compiles the crate with full std over wasm32-wasip2.

Why

The aliases shadowed alloy primitive names with raw byte arrays, forcing byte-hop projections at every chain edge and keeping the body types unnaturally weakly typed. Nothing is released, so the wire may move freely with no body-version bump.

Closes #546

Testing

nix develop --command just ci passed (fmt, clippy -D warnings, doc, the module wasm builds, cargo test --workspace --all-features). nix develop --command just check-venue-agnostic and nix develop --command just check-cow-orderbook-only both passed. The regenerated fixtures round-trip through the shipped codec and the adapter's own mainnet derivation.

AI Assistance

Implemented with Claude Code.

The order body's Address/U256 type aliases over raw byte arrays shadowed the alloy names; the body fields, SellToken/BuyToken, and the builder constructor now carry alloy_primitives::Address/U256 directly, and the assembly projections drop the to_be_bytes/from_be_bytes hops that existed only to cross the old alias boundary.

Borsh impls for the alloy types come from alloy-primitives' own borsh feature (FixedBytes/Address in-crate, U256 through its ruint passthrough), so the U256 wire form moves from 32-byte big-endian to ruint's little-endian; the published codec vectors and header goldens are regenerated, and the conformance suite gains regeneration-parity tests plus an ignored regenerate_published_fixtures writer.

The value-flow header and quotation projections now go through a new AssetAmount::erc20(Address, U256) constructor on videre-sdk, which owns the minimal big-endian uint encoding next to the wire type it serves; the adapter no longer hand-rolls to_be_bytes_trimmed_vec, so its call sites read in plain alloy types. value_flow becomes a real module re-exporting the bindings so the public path is unchanged.

The alias removal also settles the two hygiene points the issue names: alloy-primitives is regated from the assembly slice to the body slice (optional only so the empty --no-default-features build stays dependency-free), and the no_std attribute is dropped since every target compiles the crate with full std over wasm32-wasip2.

Closes #546
@mfw78
mfw78 force-pushed the cow/546-alloy-primitives branch from 6b87dfb to 4bddebb Compare July 24, 2026 22:54
@mfw78
mfw78 merged commit 2aa8380 into dev/m1 Jul 24, 2026
7 checks passed
@mfw78
mfw78 deleted the cow/546-alloy-primitives branch July 24, 2026 23:00
mfw78 added a commit that referenced this pull request Jul 27, 2026
The order body's Address/U256 type aliases over raw byte arrays shadowed the alloy names; the body fields, SellToken/BuyToken, and the builder constructor now carry alloy_primitives::Address/U256 directly, and the assembly projections drop the to_be_bytes/from_be_bytes hops that existed only to cross the old alias boundary.

Borsh impls for the alloy types come from alloy-primitives' own borsh feature (FixedBytes/Address in-crate, U256 through its ruint passthrough), so the U256 wire form moves from 32-byte big-endian to ruint's little-endian; the published codec vectors and header goldens are regenerated, and the conformance suite gains regeneration-parity tests plus an ignored regenerate_published_fixtures writer.

The value-flow header and quotation projections now go through a new AssetAmount::erc20(Address, U256) constructor on videre-sdk, which owns the minimal big-endian uint encoding next to the wire type it serves; the adapter no longer hand-rolls to_be_bytes_trimmed_vec, so its call sites read in plain alloy types. value_flow becomes a real module re-exporting the bindings so the public path is unchanged.

The alias removal also settles the two hygiene points the issue names: alloy-primitives is regated from the assembly slice to the body slice (optional only so the empty --no-default-features build stays dependency-free), and the no_std attribute is dropped since every target compiles the crate with full std over wasm32-wasip2.

Closes #546
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