Skip to content

core/types: cleanup tx signer logic #31434

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

Merged
merged 9 commits into from
Mar 19, 2025
Merged

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Mar 19, 2025

This removes the signer type-train in favor of defining a single object that can handle all tx types. Supported types are enabled via a map. Notably, the new signer also supports disabling legacy transactions.

fjl added 2 commits March 19, 2025 09:59
This removes the signer type train in favor of defining a single object that
can handle all tx types. Supported types are enabled via a map. Notably, the
Pnew signer also supports disabling legacy transactions.
@fjl fjl changed the title Core types cleanup signing core/types: cleanup tx signing logic Mar 19, 2025
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

LGTM, nice!

@fjl fjl requested a review from lightclient as a code owner March 19, 2025 10:25
@fjl fjl changed the title core/types: cleanup tx signing logic core/types: cleanup tx signer logic Mar 19, 2025
@fjl
Copy link
Contributor Author

fjl commented Mar 19, 2025

PTAL

Copy link
Contributor

@jwasinger jwasinger left a comment

Choose a reason for hiding this comment

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

This is nice as it removes a bunch of duplicated code for all post eip-155 signers. It also makes sense for signature recovery legacy type transactions to fall through directly to the legacy signer instead of being evaluated by each previous signer in reverse fork order. And ofc, now that computing the hash is coupled with the transaction and not the signer, that prevents the need to do similar chained evaluation to find matching hashing logic for a tx from a previous fork.

Hard for me to give a firm thumbs-up on anything in this area as this is very sensitive core stuff, but from what I've seen lgtm.

@fjl
Copy link
Contributor Author

fjl commented Mar 19, 2025

So one note here, this could probably be even faster by using a bitmap but I decided not to go there. We can do it if it's wanted, but I have a hunch it will be easier for downstream projects/forks to work with this type and add their own entries when it's a map.

return nil, nil, nil, ErrTxTypeNotSupported
}
if tt == LegacyTxType {
return s.legacy.SignatureValues(tx, sig)
}
// Check that chain ID of tx matches the signer. We also accept ID zero here,
Copy link
Member

Choose a reason for hiding this comment

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

This is kinda outdated now, right? We are not accepting 0 anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are!

Copy link
Member

Choose a reason for hiding this comment

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

Ah now I get the logic

@fjl fjl added this to the 1.15.6 milestone Mar 19, 2025
@fjl fjl merged commit 80b8d7a into ethereum:master Mar 19, 2025
4 checks passed
sivaratrisrinivas pushed a commit to sivaratrisrinivas/go-ethereum that referenced this pull request Apr 21, 2025
This removes the signer type-train in favor of defining a single object
that can handle all tx types. Supported types are enabled via a map.
Notably, the new signer also supports disabling legacy transactions.
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.

3 participants