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

Create CompactSize64 for non-message-length fields #3008

Merged
merged 9 commits into from
Nov 4, 2021
Merged

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Nov 3, 2021

Motivation

To implement addrv2 in #2681, we need a CompactSize type that can be larger than MAX_PROTOCOL_MESSAGE_LEN.

This is the first part of that change, which blocks ticket #2681.

Specifications

https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers

Designs

We're switching from serialization methods to serialized types.
This makes sure we don't confuse compactSize fields with different limits.

Solution

  • Add a CompactSize64 type for non-message-length fields
  • Add a CompactSizeMessage type for message length fields
  • Implement serialization, deserialization, and conversion for these types
  • Update the doctests to use these types
  • Use CompactSizeMessage instead of read_compactsize and write_compactsize in zebra_chain::serialization

First part of #2173.

Review

@jvff can review the rest of this PR.

This PR is blocking #2681, so I'd like to get it merged this week.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

Sorry, something went wrong.

@teor2345 teor2345 added C-bug Category: This is a bug A-consensus Area: Consensus rule updates A-rust Area: Updates to Rust code P-Medium A-network Area: Network protocol updates or fixes labels Nov 3, 2021
@teor2345 teor2345 requested review from jvff and oxarbitrage November 3, 2021 06:23
@teor2345 teor2345 self-assigned this Nov 3, 2021
@teor2345 teor2345 force-pushed the compact-size-unlimited branch from 3d1cf88 to f398d4f Compare November 3, 2021 06:25
Copy link
Contributor

@jvff jvff left a comment

Choose a reason for hiding this comment

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

Looking good! I added a few nit-picks, but they are all optional.

But don't remove read_compactsize and write_compactsize yet.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
MylesBorins Myles Borins
```sh
fastmod compactSize CompactSize zebra* book
fastmod compactsize CompactSize zebra* book
```
@teor2345 teor2345 force-pushed the compact-size-unlimited branch from f398d4f to 1fb3d2d Compare November 4, 2021 01:05
@teor2345 teor2345 removed the request for review from oxarbitrage November 4, 2021 03:03
@teor2345 teor2345 marked this pull request as ready for review November 4, 2021 03:22
@jvff jvff enabled auto-merge (squash) November 4, 2021 15:28
@jvff jvff merged commit 01e63da into main Nov 4, 2021
@jvff jvff deleted the compact-size-unlimited branch November 4, 2021 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Consensus rule updates A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants