cow-venue: use alloy primitives instead of byte-array aliases - #588
Merged
Conversation
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
force-pushed
the
cow/546-alloy-primitives
branch
from
July 24, 2026 22:54
6b87dfb to
4bddebb
Compare
This was referenced Jul 24, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces cow-venue's
pub type Address = [u8; 20]/pub type U256 = [u8; 32]aliases withalloy_primitives::Address/U256throughout the order body (SellToken/BuyToken, theOrderBodyfields, the builder constructor) and every dependent, dropping theto_be_bytes/from_be_bytes/into_arrayhops inassembly.rsand the adapter that existed only to cross the old alias boundary. The value-flow header and quotation projections now go through a newAssetAmount::erc20(Address, U256)constructor on videre-sdk, which owns the minimal big-endianuintencoding next to the wire type it serves, so the adapter no longer hand-rollsto_be_bytes_trimmed_vecand its call sites read in plain alloy types (value_flowbecomes a real module re-exporting the bindings, so its public path is unchanged). Borsh support for the alloy types comes from alloy-primitives' ownborshfeature (theFixedBytes/Addressimpls live in-crate and its feature passes through toruint/borshforU256), the same pattern composable-cow already uses. TheU256borsh 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 ignoredregenerate_published_fixtureswriter matching the videre-test house pattern. The issue's two hygiene points are settled as well: alloy-primitives is regated from theassemblyslice into thebodyslice (kept optional only because it gates the empty--no-default-featuresbuild), and theno_stdcfg_attr plus theextern crate allocplumbing 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 cipassed (fmt, clippy -D warnings, doc, the module wasm builds,cargo test --workspace --all-features).nix develop --command just check-venue-agnosticandnix develop --command just check-cow-orderbook-onlyboth passed. The regenerated fixtures round-trip through the shipped codec and the adapter's own mainnet derivation.AI Assistance
Implemented with Claude Code.