Skip to content

Alloy Account type conversion#3599

Merged
squadgazzz merged 19 commits intomainfrom
alloy-account-convert
Sep 3, 2025
Merged

Alloy Account type conversion#3599
squadgazzz merged 19 commits intomainfrom
alloy-account-convert

Conversation

@squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Aug 29, 2025

Description

Adds a conversion from ethcontract::Account to the corresponding alloy types. A wrapper is introduced because local accounts don’t share a common type with KMS or PrivateKey in alloy. The usage also differs when building/signing transactions: for a local account it’s enough to just set the from field (an address), while with KMS and PrivateKey there isn’t a direct way to use a signer that’s different from the provider’s configured one(more details alloy-rs/alloy#2829).

ethcontract::Account::Locked remains unused in this repo and it seems like there is no direct way to convert it into alloy::signers::local::LocalSigner, so this branch is unimplemented.

This PR also depends on cowprotocol/ethcontract-rs#981, which explains incompatibilities.

After ethcontract was updated in cowprotocol/ethcontract-rs#981, driver tests started failing with stack overflow. As @jmg-duarte's research showed, that the issue lies in how updated third-party libraries optimizations work, which is not related to any infinite recursion. The problem doesn't exist when building with the --release flag, so instead, the stack size was increased.

How to test

In the upcoming PRs.

@squadgazzz squadgazzz changed the title Alloy account conversion Alloy Account type conversion Aug 29, 2025
@squadgazzz squadgazzz marked this pull request as ready for review August 29, 2025 06:27
Copilot AI review requested due to automatic review settings August 29, 2025 06:27
@squadgazzz squadgazzz requested a review from a team as a code owner August 29, 2025 06:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces conversion functionality from ethcontract::Account to corresponding alloy types to enable interoperability between the two libraries. The implementation addresses differences in account handling between local accounts (which only need an address) and KMS/PrivateKey accounts (which require actual signers).

  • Adds AlloyAccount enum wrapper to handle different account types uniformly
  • Implements async conversion trait TryIntoAlloyAsync for ethcontract::Account
  • Updates dependencies to include necessary alloy signer features and switches ethcontract to development branch

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/ethrpc/src/alloy/conversions.rs Adds AlloyAccount enum and conversion implementation from ethcontract Account types
crates/ethrpc/Cargo.toml Enables required alloy signer features for local and AWS KMS signing
Cargo.toml Updates ethcontract dependencies to development branch with AWS library updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@squadgazzz squadgazzz force-pushed the alloy-account-convert branch 2 times, most recently from 18c92f5 to c4443b2 Compare August 29, 2025 16:33
@squadgazzz squadgazzz force-pushed the alloy-account-convert branch from 92dc286 to 2111790 Compare August 29, 2025 16:50
@squadgazzz squadgazzz mentioned this pull request Aug 29, 2025
Base automatically changed from alloy-rebased to main September 1, 2025 06:40
@squadgazzz squadgazzz mentioned this pull request Sep 1, 2025
5 tasks
# Conflicts:
#	crates/ethrpc/Cargo.toml
#	crates/ethrpc/src/alloy/conversions.rs
@squadgazzz squadgazzz marked this pull request as draft September 2, 2025 06:33
@squadgazzz squadgazzz marked this pull request as ready for review September 2, 2025 14:02
squadgazzz added a commit that referenced this pull request Sep 2, 2025
# Description
When experimenting with
#3599 I was able to avoid
some dependency conflicts after running `cargo generate-lockfile`. This
PR updates the lockfile to keep it up-to-date and it should be easier
later to work with dependency updates.
Copy link
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

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

LGTM. just nits.

derivative = "2.2.0"
derive_more = { version = "1.0.0", features = ["full"] }
ethcontract = { version = "0.25.8", default-features = false, features = ["aws-kms"] }
ethcontract = { git = "https://github.com/cowprotocol/ethcontract-rs", rev = "c9ec7c090ea649f1cd2a999caae71aa571251b48", default-features = false, features = ["aws-kms"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the commits here still needed? Do you expect many more changes needed in ethcontract-rs to aid the alloy migration?

Copy link
Contributor

Choose a reason for hiding this comment

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

0.25.9 wasnt released yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't release anything anymore due to an issue with the expired deployment key which I suppose belongs to the gnosis team.

Copy link
Contributor

Choose a reason for hiding this comment

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

If doing new releases turns out to be a problem let's stick with pinning commits. After all we want to migrate away from that library anyway. 👌

@squadgazzz squadgazzz enabled auto-merge (squash) September 3, 2025 10:52
@squadgazzz squadgazzz merged commit 2352e89 into main Sep 3, 2025
16 checks passed
@squadgazzz squadgazzz deleted the alloy-account-convert branch September 3, 2025 11:03
@github-actions github-actions bot locked and limited conversation to collaborators Sep 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants