Skip to content

chore(deps): ethers→alloy migration phase 4 (U256/H160 boundary)#374

Merged
glitch003 merged 4 commits into
mainfrom
glitch003/ethers-to-alloy-next-phase
May 21, 2026
Merged

chore(deps): ethers→alloy migration phase 4 (U256/H160 boundary)#374
glitch003 merged 4 commits into
mainfrom
glitch003/ethers-to-alloy-next-phase

Conversation

@clawdbot-glitch003
Copy link
Copy Markdown
Collaborator

Summary

Phase 4 of the ethers→alloy migration. Migrates the H160/U256 boundary files and the accounts / account_management public APIs to alloy primitives. Codex review surfaced no findings.

Scope-shift from the original plan: the signer_pool / signable_contract middleware stack stays on ethers because the abigen-generated AccountConfig<M> requires M: ethers::Middleware. That swap is now grouped with Phase 5 where the contract bindings are regenerated via sol! and the dependency inverts (alloy contracts take alloy providers). The plan doc is updated to reflect this.

What moved to alloy

  • utils/mod.rs, utils/parse_with_hash.rs — keccak256, U256, Address
  • core/v1/helpers/api_status.rsFrom<ethers FromStrRadixErr> → alloy's ruint::ParseError; dropped unused From<ProviderError> and From<ConversionError> (no callers)
  • core/v1/models/curve_type.rs — removed unused TryFrom<ethers::U256> / From<CurveType> for ethers::U256 (alloy's blanket TryFrom on U256 conflicted with the hand-rolled From; no external callers)
  • accounts/blockchain_cache.rs — cache-key fns take alloy types; address rendering switched from ethers' lowercase Debug to {:#x} so keys stay deterministic (alloy Debug uses EIP-55 checksum)
  • actions/client/op_code_helpers/private_keys.rsLocalWalletPrivateKeySigner
  • accounts/mod.rs — public API on alloy; bridges to ethers at every contract call site via the new utils::alloy_ethers helpers
  • core/account_management.rs — alloy pubsig and internals; wallet construction via PrivateKeySigner. Removes the Phase 3 H160::from_slice(signer.as_slice()) bridge

What stayed on ethers (deferred to Phase 5)

  • accounts/signer_pool.rs, accounts/signable_contract.rs — middleware stack stays ethers because contracts require ethers::Middleware
  • accounts::Metadata (abigen-generated) — metadata_to_item keeps an ethers::types::U256::zero() comparison until sol! regenerates the struct
  • accounts/decode_revert.rsethers::contract::ContractError API

New bridge module

src/utils/alloy_ethers.rs — four inline conversion helpers (alloy_u256_to_ethers / ethers_u256_to_alloy / alloy_address_to_ethers / ethers_address_to_alloy) plus a round-trip test. Entire module is removed in Phase 5.

Test plan

  • cargo check -p lit-api-server clean (lib + tests)
  • cargo clippy --tests -p lit-api-server clean
  • 217/217 lib tests pass (215 prior + 2 new bridge round-trip tests; curve_type lost 2 tests with the removed U256 impls)
  • codex review --commit HEAD returned no findings
  • CI green
  • Manual smoke test of one endpoint that exercises a contract write path (e.g. POST /v1/accounts → triggers accounts::new_account and register_wallet_derivation through the new bridge layer)

🤖 Generated with Claude Code

Migrates the H160/U256 boundary files plus the accounts and
account_management public APIs to alloy primitives. The signer pool
and signable_contract internals stay on ethers because the abigen-
generated AccountConfig<M> requires M: ethers::Middleware; that swap
is now grouped with Phase 5 where the contract bindings are regenerated
via sol! and the dependency inverts (alloy contracts take alloy
providers).

What moved to alloy:
- utils/mod.rs, utils/parse_with_hash.rs: keccak256, U256, Address
- core/v1/helpers/api_status.rs: replaced From<ethers FromStrRadixErr>
  with alloy's ruint::ParseError; dropped unused From<ProviderError>
  and From<ConversionError>
- core/v1/models/curve_type.rs: removed unused TryFrom<ethers::U256>
  and From<CurveType> for ethers::U256 (no external callers; alloy's
  blanket TryFrom on U256 conflicted with the hand-rolled From)
- accounts/blockchain_cache.rs: cache-key fns take alloy types;
  switched address rendering from ethers' lowercase Debug to {:#x}
  so keys remain deterministic (alloy's Debug uses EIP-55 checksum)
- actions/client/op_code_helpers/private_keys.rs: LocalWallet →
  PrivateKeySigner
- accounts/mod.rs: public API on alloy; internally bridges to ethers
  at every contract call site via the new utils::alloy_ethers module
- core/account_management.rs: pubsig and internals on alloy; wallet
  construction via PrivateKeySigner; the Phase 3 H160::from_slice(
  signer.as_slice()) bridge is gone

What stayed on ethers (deferred to Phase 5):
- accounts/signer_pool.rs, accounts/signable_contract.rs: middleware
  stack stays ethers because contracts require ethers::Middleware
- accounts::Metadata (abigen-generated): metadata_to_item keeps an
  ethers::types::U256::zero() comparison until sol! regenerates it
- accounts/decode_revert.rs: ethers::contract::ContractError API

The new utils/alloy_ethers.rs ships four inline bridge helpers
(alloy_u256_to_ethers / ethers_u256_to_alloy / alloy_address_to_ethers
/ ethers_address_to_alloy) plus a round-trip test. The whole module
is removed in Phase 5.

217 lib tests pass; clippy clean.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@clawdbot-glitch003 clawdbot-glitch003 requested a review from a team May 21, 2026 17:49
Copy link
Copy Markdown
Contributor

@GTC6244 GTC6244 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this PR is referencing another PR that will remove all the bridge functions .

@glitch003 glitch003 merged commit b975a6e into main May 21, 2026
12 checks passed
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.

3 participants