Skip to content

bug: arc-consensus-types arbitrary feature does not build standalone #233

Description

@mehmetkr-31

Summary

The arbitrary feature of arc-consensus-types does not build when the crate is compiled on its own.

Reproduction

On main:

$ cargo check -p arc-consensus-types --features arbitrary
error[E0433]: failed to resolve: could not find `Arbitrary` in `arbitrary`
  --> crates/types/src/address.rs:39:53
   |
39 | #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
   |                                                     ^^^^^^^^^ could not find `Arbitrary` in `arbitrary`

Adding only the derive feature moves the failure one step further:

error[E0277]: the trait bound `alloy_primitives::Address: Arbitrary<'_>` is not satisfied

Cause

The feature gates derive(arbitrary::Arbitrary) on Address but declares neither of the two things that derive needs:

  1. arbitrary/derive — the derive macro lives behind that feature of the arbitrary crate.
  2. alloy-primitives/arbitrary — the wrapped alloy_primitives::Address has no Arbitrary impl without it, so the generated impl does not satisfy its bound.

Why CI does not catch it

arc-consensus-db and arc-node-consensus both depend on alloy-rpc-types-engine with features = ["arbitrary"]. In a workspace build, feature unification turns on exactly what this crate omitted, so cargo clippy --all-targets --all-features at the workspace level passes and the gap stays invisible. It only appears when the crate is built alone — which is how a consumer would build it, and crates/types inherits publish from the workspace rather than opting out.

Suggested fix

Declare both, following the pattern arc-evm and arc-node already use, where the arbitrary feature forwards to its alloy dependencies explicitly:

[features]
arbitrary = ["dep:arbitrary", "alloy-primitives/arbitrary"]

[dependencies]
arbitrary = { workspace = true, optional = true, features = ["derive"] }

I have this working locally with no Cargo.lock change and no workspace regression, and opened #231 with it — happy to close that if you would rather take a different approach, such as enabling derive on the workspace-level arbitrary dependency instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions