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

Improve performance of computation of sizeTxF for ShelleyTx and AlonzoTx. #4901

Open
lehins opened this issue Feb 20, 2025 · 1 comment
Open
Labels
💳 technical-debt Issues related to technical debt we introduced performance serialization Anything that affects serialization of ledger types

Comments

@lehins
Copy link
Collaborator

lehins commented Feb 20, 2025

There should be no reason why ShelleyTx retains the whole of original bytes, because it can't do so in a block anyways. The only reason why it uses MemoBytes is for size calculation needed for sizedTxF. Remove usage of MemoBytes for ShelleyTx, thus avoiding keeping around bytes for . However in order for us to memoize the size needed for computing the fee we should add a field to AlonzoTx and ShelleyTx. This will require creation of AlonzoTxRaw and removal of MemoBytes for ShelleyTx

@lehins lehins added 💳 technical-debt Issues related to technical debt we introduced serialization Anything that affects serialization of ledger types labels Feb 20, 2025
@lehins lehins changed the title ShelleyTx does not need to use MemoBytes Add txSize field to ShelleyTx and AlonzoTx. Feb 20, 2025
@lehins
Copy link
Collaborator Author

lehins commented Feb 28, 2025

Giving it a bit more thought, I think current way of computing the size of transaction for the purpose of fee calculation is unnecessarily very expensive. Current approach combines parts of transaction together as a bytestring and then the size of the bytestring is computed.
We can instead just get the sizes of components and add the constant overhead of the combined version. This approach would allow us to avoid this unnecessary construction of a bytestring just to get the size.

This means that we don't really need to add an extra field anymore, because that approach described above is very cheap and the result doesn't need to be memoized

@lehins lehins changed the title Add txSize field to ShelleyTx and AlonzoTx. Improve performance of computation of sizeTxF for ShelleyTx and AlonzoTx. Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💳 technical-debt Issues related to technical debt we introduced performance serialization Anything that affects serialization of ledger types
Projects
None yet
Development

No branches or pull requests

1 participant