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

network: correct data modeling for headers messages #1425

Merged
merged 1 commit into from
Dec 2, 2020
Merged

Conversation

hdevalence
Copy link
Contributor

@hdevalence hdevalence commented Dec 2, 2020

We modeled a Bitcoin headers message as being a list of block headers.
However, the actual data structure is slightly different: it's a list of (block
header, transaction count) pairs. This caused zcashd to reject our headers
messages.

To fix this, introduce a new CountedHeader struct with a block::Header and
transaction count usize, then thread it through the inbound service and the
state.

I tested this locally by running Zebra with these changes and inspecting a
trace-level log of the span of a peer connection that requested a nontrivial
headers packet from us, and verified that it did not reject our message.

Closes #1424.
Closes #1409.
Closes #1398.

@zfnd-bot zfnd-bot bot added this to In progress in 🦓 Dec 2, 2020
@hdevalence
Copy link
Contributor Author

Fixes the problem revealed by #1423.

zebra-chain/src/block.rs Outdated Show resolved Hide resolved
@@ -19,6 +19,7 @@ RUN cargo test --all --release; cargo build --release
# Runner image
FROM debian:buster-slim AS zebrad-release

COPY --from=builder /zebra/otelcol-custom /
Copy link
Contributor Author

Choose a reason for hiding this comment

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

was this meant for this PR?

teor2345
teor2345 previously approved these changes Dec 2, 2020
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Also looks good, guess we should merge these all soon?

teor2345
teor2345 previously approved these changes Dec 2, 2020
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Looks good, apart from a minor rustfmt tweak.

We modeled a Bitcoin `headers` message as being a list of block headers.
However, the actual data structure is slightly different: it's a list of (block
header, transaction count) pairs.  This caused zcashd to reject our headers
messages.

To fix this, introduce a new `CountedHeader` struct with a `block::Header` and
transaction count `usize`, then thread it through the inbound service and the
state.

I tested this locally by running Zebra with these changes and inspecting a
trace-level log of the span of a peer connection that requested a nontrivial
headers packet from us, and verified that it did not reject our message.
@hdevalence
Copy link
Contributor Author

Rebased to pick up cargo fmt fixes in #1427

@mpguerra mpguerra added this to the First Alpha Release milestone Dec 2, 2020
@hdevalence hdevalence merged commit b449fe9 into main Dec 2, 2020
🦓 automation moved this from In progress to Done Dec 2, 2020
@hdevalence hdevalence deleted the headers-fix branch December 2, 2020 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
🦓
  
Done
4 participants