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

Logical channels + streaming encoders #66

Open
wants to merge 119 commits into
base: main
Choose a base branch
from
Open

Logical channels + streaming encoders #66

wants to merge 119 commits into from

Conversation

sgwilym
Copy link
Contributor

@sgwilym sgwilym commented Dec 13, 2024

This PR contains several new implementations and refactorings in pursuit of the following:

  • Efficient streaming encoders and decoders.
  • LCMUX, a new protocol for resource control and multiplexing based on logical channels.
  • The integration of the above into our nascent implementation of the WGPS.

There are also several new crates with applications outside of Willow.

New crates

Several new crates appeared! These will gradually be moved to their own repositories as we complete their documentation and prepare them for public release.

ufotofu_codec

A new family of traits for (streaming) encoding and decoding of values to and from bytestrings using ufotofu.

Absolute encoding traits

Traits for encoding and decoding values in isolation.

  • Encodable and Decodable convert between the domain of encodable values and the domain of finite bytestrings.
  • DecodableCanonic allows working with canonic subsets of an encoding relation, i.e., encodings where there is a one-to-one correspondence between values and codes.
  • EncodableKnownSize describes how to compute the size of encoding without actually performing the encoding
  • EncodableSync and DecodableSync allow synchronous encoding/decoding.

Relative Encoding traits

Corresponding traits for encoding and decoding values relative to some value we have prior knowledge of:

  • RelativeEncodable and RelativeDecodable
  • RelativeDecodableCanonic
  • RelativeEncodableKnownSize
  • RelativeEncodableSync and RelativeDecodableSync

There are also some nice new fuzz testing macros which can be used to property test implementations of these traits, e.g. fuzz_absolute_all! and fuzz_relative_all!.

ufotofu_codec_endian

Endian-aware fixed-width integer codecs for ufotofu_codec, e.g. U8BE, U64LE, etc.

compact_u64

Compact encoding for unsigned 64-bit integers. This builds upon our prior concept of compact widths used in many Willow encodings.

lcmux

An implementation of LCMUX, a new protocol for resource control and multiplexing based on logical channels. The specification of LCMUX can be found here: https://macromania-25vs0z0b0phr.deno.dev/specs/resource-control/index.html#sec_lcmux

wb_async_utils

A crate of handy async utilities.

  • Mutex, An awaitable, single-threaded mutex
  • OnceCell, an optional value that can be set to Some at most once, and which allows to .await that time.
  • Rw, an awaitable, single-threaded read-write lock.
  • TakeCell, an async cell akin to Option whose value can only be accessed by an async take method that non-blocks while the cell is empty.
  • MPMC, a multi-producer multi-consumer channel with an UFOTOFU-based interface.
  • `SPSC, a single-producer single-consumer channel with an UFOTOFU-based interface.

Improvements

  • Path
    • Path encoding and decoding refactored to use ufotofu_codec and compact_u64
    • PathBuilder, a new API for efficiently constructing paths
  • Relative encodings updated for new encoding crates
    • Nearly all of them updated!
  • Fuzz testing
    • All fuzz tests for absolute and relative encodings have been updated to use the new property-testing macros from ufotofu_codec.
  • WGPS
    • LCMUX now integrated into sync_with_peer.

Deprecations

  • willow-encoding’s functionality now is broken up into several smaller, better crates, and can be considered deprecated.

AljoschaMeyer and others added 30 commits December 10, 2024 10:43
…h-decoding

Implement some silly optimisations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants