Skip to content

Annotated decoder for TxSubmission mini-protocol #4934

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

Merged
merged 7 commits into from
Aug 6, 2025
Merged

Conversation

coot
Copy link
Contributor

@coot coot commented Aug 21, 2024

Description

This PR depends on input-output-hk/typed-protocols#74.

It provides:

  • API to run a peer against AnnotatedDecoder;
  • tx-submission AnnotatedDecoder;
  • QuickCheck properties for the codec.

Commits

/This PR can be reviewed commit-by-commit./

  • ouroboros-network-protocols: updated typed-protcools dependency
  • ouroboros-network-protocols: decodeTxSubmission2 refactoring
  • ouroboros-network-framework: drivers for annotated decoders
  • tx-submission2: implemented AnnotatedCodec
  • ouroboros-network-protocols:tests - increased heap size

Checklist

Quality

  • Commit sequence makes sense and have useful messages, see ref.
  • New tests are added and existing tests are updated.
  • Self-reviewed the PR.

Maintenance

  • Linked an issue or added the PR to the current sprint of ouroboros-network project.
  • Added labels.
  • Updated changelog files.
  • The documentation has been properly updated, see ref.

@coot coot added typed-protocols Issues related to typed-protocols tx-submission Issues related to tx-submission protocol labels Aug 21, 2024
@crocodile-dentist crocodile-dentist force-pushed the coot/annotated-decoder branch 7 times, most recently from f7cc59a to 4b47e98 Compare September 5, 2024 09:53
@coot coot force-pushed the coot/annotated-decoder branch from 4b47e98 to fede497 Compare September 5, 2024 12:26
@coot coot force-pushed the coot/annotated-decoder branch 3 times, most recently from 8555251 to 04db194 Compare July 28, 2025 08:43
@coot coot changed the title WIP: Annotated decoder Annotated decoder for TxSubmission mini-protocol Jul 28, 2025
@coot coot added the mithril Things related to Mithril. label Jul 28, 2025
@coot coot marked this pull request as ready for review July 28, 2025 08:52
@coot coot requested review from a team as code owners July 28, 2025 08:52
@coot coot force-pushed the coot/annotated-decoder branch from 04db194 to 4be8297 Compare July 28, 2025 17:34
@coot coot moved this from In Progress to In Review in Ouroboros Network Jul 28, 2025
@coot coot requested a review from Copilot July 28, 2025 17:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for annotated decoders in the TxSubmission mini-protocol, which allows for accessing the raw CBOR bytes alongside the decoded message data. It introduces new APIs for running peers with annotated codecs and implements the AnnotatedCodec for TxSubmission2.

Key changes:

  • Updated typed-protocols dependency from v1.0 to v1.1 across the codebase
  • Added driver support for annotated decoders in the network framework
  • Implemented anncodecTxSubmission2 with CBOR byte preservation
  • Added comprehensive QuickCheck properties for the new codec

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cabal.project Adds source repository for typed-protocols dependency
Various .cabal files Updates typed-protocols dependency to ^>=1.1
TxSubmission2/Codec.hs Implements annotated codec with WithBytes wrapper and decoder refactoring
Driver/Simple.hs Adds annotated peer runner functions and driver support
Driver/Limits.hs Extends limit enforcement to annotated codecs
Various test files Updates test signatures to return Property instead of Bool
nix/ouroboros-network.nix Increases heap size for test execution

@coot coot force-pushed the coot/annotated-decoder branch from bd727d1 to 328f239 Compare July 28, 2025 17:50
Copy link
Contributor

@crocodile-dentist crocodile-dentist left a comment

Choose a reason for hiding this comment

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

One remark on efficiency

@coot coot force-pushed the coot/annotated-decoder branch from 8e63f27 to 2838168 Compare August 5, 2025 14:43
@coot coot added this pull request to the merge queue Aug 5, 2025
@coot coot removed this pull request from the merge queue due to a manual request Aug 5, 2025
@coot
Copy link
Contributor Author

coot commented Aug 5, 2025

I'll merge it once I'll release typed-protocols-1.1 to Hackage.

@coot coot force-pushed the coot/annotated-decoder branch from 2838168 to 9cbd6d6 Compare August 5, 2025 15:35
coot added 7 commits August 5, 2025 18:47
This commit provides `runAnnotatedPeer` and alikes.  It is similar to
`runPeer' but allows us to run a decoder which has access to bytes used
when decoding a message.   This allows one to record ByteString from
which a piece of data was decoded, e.g. for each `tx` inside
`MsgReplyTxs`.

This patch adds the following APIs:
* `runAnnotatedPeer`
* `runPipelinedAnnotatedPeer`
* `runAnnotatedPeerWithLimits`
* `runPipelinedAnnotatedPeerWithLimits`
The following two are left to be implemented when we'll actually need
them:
* `runAnnotatedPeerWithLimitsRnd`
* `runPipelinedAnnotatedPeerWithLimitsRnd`

The `Codec` type in `typed-protocols` was generalised for this purpose.
The core functionality is implemented in
`runAnnotatedDecoderWithChannel` (and `runAnnotatedDecoderWithLimit`)
which runs `AnnotatedCodec` against a `Channel` which does incremental
decoding & recording bytes used so far.  We also expose
`runAnnotatedPeer` which runs a `Peer` against `Channel` using an
`AnnotatedCodec` (using `annotatedDriverSimple`).
Reorder cases so they are more logical, i.e. first handling trailing
bytes from previous message, then bytes received from network followed
by `DecodeDone` and `DecodeFail`.
@coot coot force-pushed the coot/annotated-decoder branch from 9cbd6d6 to 60b36b1 Compare August 5, 2025 16:48
@coot coot added this pull request to the merge queue Aug 6, 2025
Merged via the queue into main with commit 90b2c4b Aug 6, 2025
12 checks passed
@coot coot deleted the coot/annotated-decoder branch August 6, 2025 07:50
@github-project-automation github-project-automation bot moved this from In Review to Done in Ouroboros Network Aug 6, 2025
@coot coot mentioned this pull request Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mithril Things related to Mithril. tx-submission Issues related to tx-submission protocol typed-protocols Issues related to typed-protocols
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants