Skip to content

refactor(agglayer): refactor EthAddress and EthAddressFormat#2622

Open
partylikeits1983 wants to merge 2 commits intoagglayerfrom
ajl-eth-address-refactor
Open

refactor(agglayer): refactor EthAddress and EthAddressFormat#2622
partylikeits1983 wants to merge 2 commits intoagglayerfrom
ajl-eth-address-refactor

Conversation

@partylikeits1983
Copy link
Contributor

@partylikeits1983 partylikeits1983 commented Mar 17, 2026

Closes #2357

Description

The previous EthAddressFormat type served dual purposes: representing both real Ethereum addresses (e.g., origin token contract addresses, bridge-out destinations) and Miden AccountId values encoded in the 20-byte Ethereum address format (bridge-in destinations). This PR separates these concerns into two distinct types:

  • EthAddressFormat (previously EthAddress) — A plain 20-byte Ethereum address. Used for origin token addresses, bridge-out destination addresses, and any context requiring a real EVM address. Provides new(), from_hex(), as_bytes(), into_bytes(), to_hex(), and to_elements().

  • EthAccountIdFormat (previously EthAddressFormat) — A newtype around EthAddressFormat for the bridge-in (CLAIM) flow, where a Miden AccountId is encoded as [0, 0, 0, prefix, suffix]. Adds from_account_id() and to_account_id() conversion methods. Converts to/from EthAddressFormat via From impls.

Breaking Changes

  • EthAddressFormat no longer has from_account_id() or to_account_id() methods. Use EthAccountIdFormat for AccountId ↔ Ethereum address conversions.
  • The From<AccountId> for EthAddressFormat impl has been removed. Use EthAccountIdFormat::from(account_id) instead.

File Structure

The old address.rs has been split into:

  • eth_address_format.rsEthAddressFormat + AddressConversionError
  • eth_account_id_format.rsEthAccountIdFormat (imports from eth_address_format)

@partylikeits1983 partylikeits1983 added rust Issues that affect or pull requests that update Rust code agglayer PRs or issues related to AggLayer bridging integration pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority labels Mar 17, 2026
@partylikeits1983 partylikeits1983 self-assigned this Mar 17, 2026
@partylikeits1983 partylikeits1983 changed the title refactor(agglayer): separate EthAddressFormat and EthAccountIdFormat refactor(agglayer): refactor EthAddress and EthAddressFormat Mar 17, 2026
@partylikeits1983 partylikeits1983 marked this pull request as ready for review March 17, 2026 15:31
@partylikeits1983 partylikeits1983 changed the title refactor(agglayer): refactor EthAddress and EthAddressFormat refactor(agglayer): refactor EthAddress and EthAddressFormat Mar 17, 2026
/// and the Ethereum address format when constructing CLAIM notes or calling the AggLayer Bridge
/// `bridgeAsset()` function.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EthAccountIdFormat(EthAddressFormat);
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: why not do this as just EthAccountIdFormat(AccountId) - i.e., internal representation would be just AccountId, but we could convert to/from Ethereum address.

Copy link
Collaborator

@mmagician mmagician left a comment

Choose a reason for hiding this comment

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

I find the proposed naming distinction confusing: I often refer to Ethereum address as "account id" (maybe this is just me, it's probably not technically precise language), "account hex" or similar.

If we proceed with this refactoring then I'd much rather have the distinction very clear, maybe something like EthEmbeddedAccountId, or just EmbeddedAccountId (in eth_types module, so the import is clear eth_types::EmbeddedAccountId).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agglayer PRs or issues related to AggLayer bridging integration pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority rust Issues that affect or pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants