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

WIP: Annotated decoder #4934

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

WIP: Annotated decoder #4934

wants to merge 1 commit into from

Conversation

coot
Copy link
Contributor

@coot coot commented Aug 21, 2024

This is an experiment to provide runAnnotatedPeer, which is like 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 txinsideMsgReplyTxs`.

The Codec type in typed-protocols was generalised for this purpose. The core functionality is implemented in
runAnnotatedDecoderWithChannel 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).

TODO:

  • runAnnotatedPeerWithLimits
  • runAnnotatedPipelinedPeerWithLimits

It's actually the last one that we will need in tx-submission.

  • Add
data WithBytes a {
  encoded :: ByteString,
  decoded :: a

and generalise codecTxSubmission2 so that it can be used to used with annotator and without it - it might require two separate function, but I think it can be generated from one more general function (so we don't need to maintain two codecs).

TODO: design & implement quickcheck properties

Description

reasonably detailed description of the pull request

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
This is an experiment to provide `runAnnotatedPeer`, which is like
`runPeer' but allows us to run a decoder which has access to bytes used
when decoding a message.   This allows one to record offsets and decode
record ByteString from which a piece of data was decoded, e.g. for each
`tx` inside `MsgReplyTxs`.

The `Codec` type in `typed-protocols` was generalised for this purpose.
The core functionality is implemented in
`runAnnotatedDecoderWithChannel` 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`).

TODO:

* `runAnnotatedPipelinedPeer`
* `runAnnotatedPeerWithLimits`
* `runAnnotatedPipelinedPeerWithLimits`

It's actually the last one that we will need in `tx-submission`.

TODO:

Find a nice way so we won't need to maintain two codecs for `tx-submission`,
e.g. `Codec` and `AnnotatedCodec`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tx-submission Issues related to tx-submission protocol typed-protocols Issues related to typed-protocols
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants