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

Add the serialized transaction size to UnminedTx #2778

Closed
Tracked by #2744 ...
teor2345 opened this issue Sep 21, 2021 · 1 comment · Fixed by #2824
Closed
Tracked by #2744 ...

Add the serialized transaction size to UnminedTx #2778

teor2345 opened this issue Sep 21, 2021 · 1 comment · Fixed by #2824
Assignees

Comments

@teor2345
Copy link
Contributor

teor2345 commented Sep 21, 2021

Motivation

ZIP-401 weights transactions by their serialized size.

Consensus Rules

The mempool of a node holds a set of transactions.
Each transaction has a cost, which is an integer defined as:
max(serialized transaction size in bytes, 4000)

https://zips.z.cash/zip-0401#specification

Design

This existing code calculates the size of a Message:

/// Obtain the size of the body of a given message. This will match the
/// number of bytes written to the writer provided to `write_body` for the
/// same message.
///
/// TODO: Replace with a size estimate, to avoid multiple serializations
/// for large data structures like lists, blocks, and transactions.
/// See #1774.
fn body_length(&self, msg: &Message) -> usize {

Maybe we want to turn it into a default method on the ZcashSerialize trait?

@teor2345 teor2345 changed the title Add the serialized transaction size to Add the serialized transaction size to UnminedTx Sep 21, 2021
@teor2345 teor2345 mentioned this issue Sep 21, 2021
59 tasks
@teor2345
Copy link
Contributor Author

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 a pull request may close this issue.

3 participants