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

Memoize transaction size and hash at the same time #4812

Merged
merged 2 commits into from
Dec 16, 2022

Conversation

fab-10
Copy link
Contributor

@fab-10 fab-10 commented Dec 13, 2022

Signed-off-by: Fabio Di Fabio fabio.difabio@consensys.net

PR description

Since to calculate the transaction hash and size, the transaction needs to be encoded to bytes, we can cache both values at the same time, in order to avoid extra expensive encoding tasks.

Fixed Issue(s)

relates to #4724

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if
    updates are required.

Changelog

@fab-10 fab-10 mentioned this pull request Dec 13, 2022
2 tasks
@fab-10 fab-10 marked this pull request as ready for review December 13, 2022 18:35
Comment on lines 58 to +61
if (TransactionType.FRONTIER.equals(transactionType)) {
encodeFrontier(transaction, rlpOutput);
rlpOutput.writeRaw(opaqueBytes);
} else {
rlpOutput.writeBytes(encodeOpaqueBytes(transaction));
rlpOutput.writeBytes(opaqueBytes);
Copy link
Contributor

Choose a reason for hiding this comment

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

I scrutinized this to be sure we are not creating a regression for non-frontier transactions. LGTM

Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

🚢

@garyschulte
Copy link
Contributor

looks like there is a build failure for NewPooledTransactionHashesMessageProcessorTest since cacluateSize() is gone now.

@fab-10
Copy link
Contributor Author

fab-10 commented Dec 13, 2022

looks like there is a build failure for NewPooledTransactionHashesMessageProcessorTest since cacluateSize() is gone now.

Fixed

Copy link
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 merged commit 8b46caf into hyperledger:main Dec 16, 2022
@fab-10 fab-10 deleted the memoize-tx-size branch December 16, 2022 15:35
jflo pushed a commit to jflo/besu that referenced this pull request Dec 22, 2022
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
macfarla pushed a commit to macfarla/besu that referenced this pull request Jan 10, 2023
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
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