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

core/types: updates for EIP-7702 API functions #30933

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Dec 18, 2024

Here I am proposing two small changes to the exported API for EIP-7702:

(1) Authorization has a very generic name, but it is in fact only used for one niche use case: authorizing code in a SetCodeTx. So I propose calling it SetCodeAuthorization instead. The signing function is renamed to SignSetCode instead of SignAuth.

(2) The signing function for authorizations should take key as the first parameter, and the authorization second. The key will almost always be in a variable, while the authorization can be given as a literal. Compare these two invocations:

a, err := types.SignSetCode(types.SetCodeAuthorization{
    ChainID: getChainID(),
    Nonce: getNonce(),
}, key)

with

a, err := types.SignSetCode(key, types.SetCodeAuthorization{
    ChainID: getChainID(),
    Nonce: getNonce(),
})

I feel like the second one is easier to read.

fjl added 2 commits December 18, 2024 10:08
The signing key should be passed first, because it is usually in a variable,
while the authorization will often be a literal.

Compare

    a, err := types.SignAuthorization(types.SetCodeAuthorization{
        ChainID: getChainID(),
        Nonce: getNonce(),
    }, key)

with

    a, err := types.SignAuthorization(key, types.SetCodeAuthorization{
        ChainID: getChainID(),
        Nonce: getNonce(),
    })
Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

SGTM

@rjl493456442
Copy link
Member

Btw, just to mention that we still need to support SetCodeTx in txpool

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

SGTM

@fjl fjl merged commit 9d4b29f into ethereum:master Dec 18, 2024
3 checks passed
@fjl fjl added this to the 1.14.13 milestone Dec 18, 2024
fjl added a commit to fjl/go-ethereum that referenced this pull request Dec 18, 2024
As a follow-up to ethereum#30933, I propose to also use the SetCode prefix in our internal APIs
for the authorization list.
fjl added a commit that referenced this pull request Dec 19, 2024
As a follow-up to #30933, I propose to also use the SetCode prefix in
our internal APIs for the authorization list.
GrapeBaBa pushed a commit to optimism-java/shisui that referenced this pull request Dec 23, 2024
Here I am proposing two small changes to the exported API for EIP-7702:

(1) `Authorization` has a very generic name, but it is in fact only used
for one niche use case: authorizing code in a `SetCodeTx`. So I propose
calling it `SetCodeAuthorization` instead. The signing function is
renamed to `SignSetCode` instead of `SignAuth`.
   
(2) The signing function for authorizations should take key as the first
parameter, and the authorization second. The key will almost always be
in a variable, while the authorization can be given as a literal.
GrapeBaBa pushed a commit to optimism-java/shisui that referenced this pull request Dec 23, 2024
…30935)

As a follow-up to ethereum#30933, I propose to also use the SetCode prefix in
our internal APIs for the authorization list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants