chore(deps): ethers→alloy migration phase 4 (U256/H160 boundary)#374
Merged
Conversation
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>
GTC6244
approved these changes
May 21, 2026
Contributor
GTC6244
left a comment
There was a problem hiding this comment.
Assuming this PR is referencing another PR that will remove all the bridge functions .
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.
Summary
Phase 4 of the ethers→alloy migration. Migrates the H160/U256 boundary files and the
accounts/account_managementpublic APIs to alloy primitives. Codex review surfaced no findings.Scope-shift from the original plan: the
signer_pool/signable_contractmiddleware stack stays on ethers because the abigen-generatedAccountConfig<M>requiresM: ethers::Middleware. That swap is now grouped with Phase 5 where the contract bindings are regenerated viasol!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, Addresscore/v1/helpers/api_status.rs—From<ethers FromStrRadixErr>→ alloy'sruint::ParseError; dropped unusedFrom<ProviderError>andFrom<ConversionError>(no callers)core/v1/models/curve_type.rs— removed unusedTryFrom<ethers::U256>/From<CurveType> for ethers::U256(alloy's blanketTryFromonU256conflicted with the hand-rolledFrom; no external callers)accounts/blockchain_cache.rs— cache-key fns take alloy types; address rendering switched from ethers' lowercaseDebugto{:#x}so keys stay deterministic (alloyDebuguses EIP-55 checksum)actions/client/op_code_helpers/private_keys.rs—LocalWallet→PrivateKeySigneraccounts/mod.rs— public API on alloy; bridges to ethers at every contract call site via the newutils::alloy_ethershelperscore/account_management.rs— alloy pubsig and internals; wallet construction viaPrivateKeySigner. Removes the Phase 3H160::from_slice(signer.as_slice())bridgeWhat stayed on ethers (deferred to Phase 5)
accounts/signer_pool.rs,accounts/signable_contract.rs— middleware stack stays ethers because contracts requireethers::Middlewareaccounts::Metadata(abigen-generated) —metadata_to_itemkeeps anethers::types::U256::zero()comparison untilsol!regenerates the structaccounts/decode_revert.rs—ethers::contract::ContractErrorAPINew 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-serverclean (lib + tests)cargo clippy --tests -p lit-api-servercleancurve_typelost 2 tests with the removed U256 impls)codex review --commit HEADreturned no findingsPOST /v1/accounts→ triggersaccounts::new_accountandregister_wallet_derivationthrough the new bridge layer)🤖 Generated with Claude Code