Skip to content

feat(consensus-any): move AnyTxType, UnknownTxEnvelope, UnknownTypedTransaction from alloy-network#3878

Open
TechFusionData wants to merge 1 commit intoalloy-rs:mainfrom
TechFusionData:fix/move-any-types-to-own-crates-1598
Open

feat(consensus-any): move AnyTxType, UnknownTxEnvelope, UnknownTypedTransaction from alloy-network#3878
TechFusionData wants to merge 1 commit intoalloy-rs:mainfrom
TechFusionData:fix/move-any-types-to-own-crates-1598

Conversation

@TechFusionData
Copy link
Copy Markdown

Partially resolves #1598.

Summary

Moves the three unknown transaction types from alloy-network into alloy-consensus-any, so that downstream crates which only need to inspect or pattern-match unknown transaction envelopes no longer need to pull in the full alloy-network dependency tree.

Types moved to alloy-consensus-any:

  • AnyTxType
  • UnknownTypedTransaction
  • UnknownTxEnvelope

alloy-network re-exports all three types unchanged, so this is backwards-compatible for existing users.

Why not move AnyTypedTransaction / AnyTxEnvelope?

The Network trait requires:

type TransactionRequest: From<Self::TxEnvelope> + From<Self::UnsignedTx> + ...

For AnyNetwork, TransactionRequest = WithOtherFields<TransactionRequest>. Moving AnyTxEnvelope/AnyTypedTransaction to alloy-consensus-any would require the From impls to live in alloy-consensus-any as well, but alloy-rpc-types-eth already depends on alloy-consensus-any, creating a circular dependency. This is left as a follow-up — one approach would be to move TransactionRequest to a lighter crate.

Changes

  • crates/consensus-any/src/unknown.rs — new file with the moved types; uses alloy_eips::eip2930::AccessList instead of alloy_rpc_types_eth::AccessList (same type, lighter dep path)
  • crates/consensus-any/Cargo.toml — enables serde + alloy-serde when std feature is active (required by OtherFields and OnceLock)
  • crates/network/src/any/unknowns.rs — becomes a thin re-export wrapper
  • crates/network/src/any/either.rs — unchanged behaviour, updated to import unknown types from alloy_consensus_any

Testing

cargo check -p alloy-consensus-any -p alloy-network -p alloy-rpc-types-eth -p alloy-rpc-types-any — zero errors, zero warnings.

…ransaction from alloy-network

Partially resolves alloy-rs#1598.

Move the three 'unknown' transaction types from alloy-network into
alloy-consensus-any, reducing the dependency surface for crates that
only need to work with unknown transaction envelopes:

- AnyTxType
- UnknownTypedTransaction
- UnknownTxEnvelope (+ internal DeserMemo helper)

Key changes:
- New crates/consensus-any/src/unknown.rs with the moved types
- alloy-consensus-any Cargo.toml: enable serde + alloy-serde when std
  feature is active (required by OtherFields and OnceLock)
- alloy-network re-exports the moved types from alloy-consensus-any
  for backwards compatibility
- AnyTypedTransaction and AnyTxEnvelope remain in alloy-network; moving
  them requires resolving the From<Self::UnsignedTx/TxEnvelope> bounds
  on the Network::TransactionRequest associated type, which would create
  a circular dependency between alloy-consensus-any and alloy-rpc-types-eth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Feature] Move AnyNetwork types into their own crate(s)

2 participants