This was the quarter of encoding. The rust-bitcoin
project identified that the last piece of the puzzle to release v1.0.0 of the low-level units
and primitives
crates was a revamp of the encoding. This was pretty relevant to the bip324
networking code I have been hacking on, so I hopped in to help get this across the line.
The existing rust-bitcoin
encoding library has a strong dependency on the standard library’s Read
and Write
traits. This is unfortunate for a library which aims to be no-std compliant. And from my experience, is also a bummer for async runtimes. But the real sticking point is that we don’t want this tie to be forever locked in with the v1.0.0 releases. Ideally, rust-bitcoin
’s encoding is sans-io and lets the higher layers decided what I/O is best for their use case.
Kix proposed a while back to use his push_decode
library. I think it is a great piece of software. However, it is a little over-engineered if we focus on what is needed for just the bitcoin domain. Also, Kix has been MIA for a bit now, so tough to get his take on the current scenario. But in any case, push_decode is a great starting point.
Over the past few months, the concensus_encoding
crate has come together and is about to get its v1.0.0 release which unblocks units
and primitives
. Stoked! I documented a lot of learnings in the Sans I/O series and have a few of the code highlights. Was also able to provide a lot more review for the code pouring in.
- [LOG] Sans I/O Series // Starts with push_decode and digs into some of the tough design trade-offs.
- [LOG] Transaction Encoding // Bitcoin transactions have some encoding quirks due to backwards compatibility.
- [CODE] Units Encoders // Kick the tires by adding
units
encoders. - [CODE] I/O for Encoders // Add I/O drivers for encoders.
- [CODE] Basic Decoding // Set the stage for the decoders half of the crate.
- [CODE] Decoding Error Patterns // Attempted a trait bound and phantom data pattern for decoding errors. This didn’t end up being the pattern we settled on, but was a great learning experience.
- [CODE] Clean Up Encoder Lifetimes // Nice code clean up, deep in lifetimes.
- [CODE] Units Decoders // Basic decoders for the
units
crate. - [CODE] Decoder I/O drivers // Decoder I/O drivers.
- [CODE] Inline Composers // Incorporate lessons from SIMD hacking,
inline
these simple functions. - [CODE] Clean Up Encoders // Add some unit tests and fix a
SliceEncoder
bug. - [CODE] Composition Unit Tests // More unit tests for the composition encoders/decoders which are more complex.
- [CODE] Rename min_bytes_needed // Bring some clarity to the decoders interface.
- [CODE] Remove State // Remove an unnecessary variant in the
Decoder2
state, simplify the code.