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-7685 enc/decode traits #704

Merged
merged 4 commits into from
May 7, 2024
Merged

feat: add eip-7685 enc/decode traits #704

merged 4 commits into from
May 7, 2024

Conversation

onbjerg
Copy link
Member

@onbjerg onbjerg commented May 7, 2024

Motivation

EIP-7685 adds an EL → CL request list. The list items are requests, which are encoded as type ++ request_data, where request_data is an opaque byte buffer. The meaning of the bytes is up to each request, which are defined in separate EIPs.

Solution

Add traits for encoding and decoding requests. This follows the same overall design as our traits for EIP-2718, with the difference being that EIP-2718 also has special handling for legacy transactions.

The expected usage is to define something a la TxEnvelope, e.g. RequestsEnvelope, which is an enum that internally holds each legal request type. The requests themselves are decoded and encoded according to their own EIPs, e.g. with RLP.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@onbjerg onbjerg added the enhancement New feature or request label May 7, 2024
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 add a combined trait for this as well?

pub trait Eip2718Envelope: Decodable2718 + Encodable2718 {}
impl<T> Eip2718Envelope for T where T: Decodable2718 + Encodable2718 {}

@onbjerg onbjerg requested a review from mattsse May 7, 2024 11:25
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.

imo it makes sense to roll a dedicated trait for this.

@onbjerg onbjerg requested a review from prestwich May 7, 2024 15:59
@onbjerg onbjerg merged commit e60d64c into main May 7, 2024
24 checks passed
@onbjerg onbjerg deleted the onbjerg/eip-7685 branch May 7, 2024 18:48
ben186 pushed a commit to ben186/alloy that referenced this pull request Jul 27, 2024
* feat: add eip-7685 enc/decode traits

* chore: fmt

* feat: combined trait

* chore: mark non_exhaustive
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.

3 participants