Skip to content

Variable-sized Coin serialization - #2373

Open
sisou wants to merge 6 commits into
albatrossfrom
soeren/variable-size-coin
Open

Variable-sized Coin serialization#2373
sisou wants to merge 6 commits into
albatrossfrom
soeren/variable-size-coin

Conversation

@sisou

@sisou sisou commented Apr 17, 2024

Copy link
Copy Markdown
Member

What's in this pull request?

This PR makes Coin serialize to a varint in transactions and accounts, both over the wire and their internal representations (history store).

Reasoning

No transaction will likely ever make use of the full u64 range for its value, and especially not for fee. So most zero bytes for Coins in most transactions are wasted. This is especially true for signaling transactions, which have 16 zero-bytes to represent 0 value and (mostly) 0 fee. This PR reduces them to two zero bytes.

Drawbacks

  • A transaction could increase in size when adding or increasing the fee, requiring to increase the fee again if targeting a specific fee-per-byte.

Exceptions

There are two exceptions for backwards-compatibility with PoW transactions:

  1. Coins in vesting contract creation data are still serialized with fixint::be
  2. For determining a transaction's hash, tx.serialize_content() serializes value and fee as before with fixint::be

Pull request checklist

  • All tests pass. The project builds and runs.
  • I have resolved any merge conflicts.
  • I have resolved all clippy and rustfmt warnings.

@sisou sisou self-assigned this Apr 17, 2024

@hrxi hrxi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like a good improvement to me.

@sisou sisou added the testnet-restart Change breaks the protocol and requires a testnet restart label Aug 1, 2024
@sisou
sisou force-pushed the soeren/variable-size-coin branch from fc78f99 to aa4382b Compare August 23, 2024 10:15
@sisou
sisou marked this pull request as ready for review August 23, 2024 10:16
@sisou
sisou force-pushed the soeren/variable-size-coin branch from 8d391d9 to c12d921 Compare November 5, 2024 08:05
@hrxi

hrxi commented Feb 12, 2025

Copy link
Copy Markdown
Contributor

I think we decided not to do that because it's a breaking change. Is that correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testnet-restart Change breaks the protocol and requires a testnet restart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants