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

Centralize txn size calculation #4064

Conversation

ThomasBrady
Copy link
Contributor

…from txn and overlay systems

Description

Resolves #4023

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copy link
Contributor

@SirTyson SirTyson left a comment

Choose a reason for hiding this comment

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

Thanks for this cleanup! I think there are a few more places in the code where we should be using the new getTransactionEnvelopeSize instead of the old calculation. I see some places in src/herder/test/HerderTests.cpp, src/transactions/test/InvokeHostFunctionTests.cpp, and src/transactions/test/SorobanTxTestUtils.cpp. Any place where we have xdr::xdr_size(txEnvelope) should probably use the new function for consistency.

if (isSoroban())
{
auto txSize = static_cast<int64_t>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this move inside the if? Seems cleaner to get the size just once like before.

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 don't use the size in the final else case (non-soroban, non-useByteLimitInClassic), so I moved the computation into the cases where we are using it. But I agree its cleaner to only have the computation in one place.

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like txSize is still calculated twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

src/transactions/TransactionFrame.cpp Outdated Show resolved Hide resolved
src/transactions/TransactionUtils.cpp Outdated Show resolved Hide resolved
@ThomasBrady ThomasBrady force-pushed the 4023-centralize-transaction-size-computation branch from 23c49dd to b44f884 Compare December 21, 2023 00:54
@marta-lokhova
Copy link
Contributor

r+ b44f884

@latobarita latobarita merged commit e07ad68 into stellar:master Dec 21, 2023
15 checks passed
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.

centralize tx size computation across tx subsytem and overlay
5 participants