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(consensus-tx): enable fast is_create #1683

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

hai-rise
Copy link
Contributor

@hai-rise hai-rise commented Nov 25, 2024

Motivation

alloy-consensus::Transaction implementors didn't have a cheap way to check if the transaction was a Create. They had to go through kind which copies the 21-byte TxKind. This may scale poorly for code that processes (hundreds of) thousands of transactions per second: paradigmxyz/reth#12838.

Solution

Add is_create to the trait that allows fast non-allocating implementation. I considered making kind returns &TxKind but transactions like EIP-4844, 7702, etc. only store an Address and it would be bad if we forced them to promote it to TxKind.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

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.

makes sense

@mattsse mattsse merged commit 3eb494d into alloy-rs:main Nov 25, 2024
26 checks passed
@hai-rise hai-rise deleted the tx-is-create branch November 25, 2024 12:14
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.

2 participants