Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add eip-7702 helpers #950

Merged
merged 23 commits into from
Jun 24, 2024
Merged

feat: add eip-7702 helpers #950

merged 23 commits into from
Jun 24, 2024

Conversation

onbjerg
Copy link
Member

@onbjerg onbjerg commented Jun 20, 2024

Motivation

EIP-7702 is up for inclusion in Prague.

Solution

Adds helpers and some types specified in EIP-7702.

The transaction type itself will be added in another PR as it is not relevant right now (for example, the RPC spec has not been updated yet).

This also adds a k256 feature to alloy_eips since authority recovery requires signature recovery which is only possible with k256 enabled in alloy_primitives

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@onbjerg onbjerg added the enhancement New feature or request label Jun 20, 2024
@onbjerg onbjerg force-pushed the onbjerg/eip-7702 branch from 26a7009 to bca4239 Compare June 20, 2024 13:58
@onbjerg onbjerg changed the title feat: add eip-7702 tx type feat: add eip-7702 helpers Jun 20, 2024
@onbjerg onbjerg marked this pull request as ready for review June 20, 2024 14:02
crates/eips/src/eip7702/auth_list.rs Outdated Show resolved Hide resolved
crates/eips/src/eip7702/auth_list.rs Show resolved Hide resolved
crates/eips/src/eip7702/auth_list.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

one comment on validation

crates/eips/src/eip7702/auth_list.rs Outdated Show resolved Hide resolved
crates/eips/src/eip7702/auth_list.rs Outdated Show resolved Hide resolved
crates/eips/src/eip7702/auth_list.rs Show resolved Hide resolved
crates/eips/src/eip7702/auth_list.rs Outdated Show resolved Hide resolved
@onbjerg onbjerg requested a review from mattsse June 20, 2024 18:16
@onbjerg onbjerg requested a review from Rjected June 20, 2024 18:17
crates/eips/src/eip7702/auth_list.rs Show resolved Hide resolved
crates/eips/src/eip7702/auth_list.rs Outdated Show resolved Hide resolved
crates/eips/src/eip7702/auth_list.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

can we has some sanity tests? :)

crates/eips/src/eip7702/auth_list.rs Show resolved Hide resolved
@onbjerg onbjerg requested a review from mattsse June 21, 2024 08:32

/// A signed EIP-7702 authorization.
#[derive(Debug, Clone, RlpEncodable, RlpDecodable)]
pub struct SignedAuthorization<S> {
Copy link
Contributor

@rakita rakita Jun 21, 2024

Choose a reason for hiding this comment

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

Can we add RecoveredAuthorization? Where we will cache the recovered account as Option<Address (Option as it can fail).

Recovery can be expensive and can be done before revm gets called. We are okay to do that as it is covered by gas.

The idea that I have is to have an enum in Revm as input:

AuthorisationList {
   Recovered(Vec<RecoveredAuthorization>),
   Signed(Vec<SignedAuthorization>),
}

Copy link
Member Author

Choose a reason for hiding this comment

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

added

@@ -70,6 +70,7 @@ serde = [
kzg = ["kzg-sidecar", "sha2", "dep:derive_more", "dep:c-kzg", "dep:once_cell"]
kzg-sidecar = ["sha2"]
sha2 = ["dep:sha2"]
k256 = ["alloy-primitives/k256"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to have seck256k1 lib/feature flag as it is faster. But looking at it as a low priority.

@onbjerg onbjerg requested a review from rakita June 24, 2024 11:01
Copy link
Contributor

@rakita rakita left a comment

Choose a reason for hiding this comment

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

lgtm

@mattsse mattsse merged commit 2d26b05 into main Jun 24, 2024
22 checks passed
@mattsse mattsse deleted the onbjerg/eip-7702 branch June 24, 2024 11:52
ben186 pushed a commit to ben186/alloy that referenced this pull request Jul 27, 2024
* feat: add eip-7702 auth list types

* chore: fmt

* chore: no_std

* feat: add k256 feature to alloy-eips

* chore: const fns

* chore: lint

* chore: rm vec type alias

* feat: split into signed/unsigned types

* fix: use `signature_prehash`

* chore: fmt

* chore: const fn

* docs: fix doc link

* chore: fmt

-.-

* chore: make pub

* chore: cleanup

* fix: error on list longer than 1 for nonce

* chore: const fn -.-

* feat: default derive

* chore: manual decode impl for `OptionalNonce`

* docs: small driveby link nits

* test: add small rt ser/de tests

* feat: add `RecoveredAuthorization`

* fix: partial move
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants