Conversation
|
I've just learned about |
|
Neat! I am in favor of using cc #1251 where push-based decoding was first discussed. |
|
I'm not sure how much we can feature-gate it if we want to delegate the impls. (Maintaining two different implementations is annoying; though thankfully they shouldn't change much.) If we're going to do that I would limit it to one release or so. Also I don't think we can reasonably feature gate it on Rust version - Note that 1.55 is already >2 years old (September 2021) and 1.63 is in Debian stable. But if we're going to bump it I'd jump to 1.56 which is still 2 years old and supports edition 2021 (we don't have to use it right away but it's nice to have). |
|
Sounds good to me. cc @tcharding is there an existing issue that we should glom onto to discuss MSRV bumps, or should @Kixunil just make a PR to bump to 1.56 and we'll try to get a bunch of ACKs. cc #1722. |
|
Lets PR and push forward! I tried bringing up Rust 1.57 a few months ago but I was too early because it was not yet 2 years old, #1983 I'd like to see 1.56, edition 2021 would make my life a bunch easier. |
|
I'm keen for this PR. I don't have any comments or suggestions other than that I'm afraid. |
That's fine. I was mainly checking that my approach isn't viewed as horribly complicated or something like that. |
|
Updated to use |
|
Rebased and a bit improved but not really ready. Working on encoding now. |
804193f to
c41e5b9
Compare
This implements `bitcoin_consensus_encoding::Decode` for `Transaction` and the types used inside it to demonstrate how `push_decode` can be used to abstract over the byte source (sync/async, std/no-std). The change is designed to be incremental so the exisitng code continues to use old traits, we're just adding new capabilities that may later replace the current encoding approach.
Similarly to push-based decoding there's pull-based encoding. This change adds pull-based encoding support for the types that were already implementing push-bassed encoding plus `Script` which can be encoded but not decoded.
|
Just rebase, will address the review later. |
Pull Request Test Coverage Report for Build 10075949365Details
💛 - Coveralls |
|
Also I'd love to rebase this on top of #3100 (not that I love rebasing this monstrosity...) |
|
Concept ACK. Just spent whole morning trying to understand. But after a few hours it started to click. Pretty cool! TLDR: It's all basically Rust version of Haskell's data Decoder a = Fail !B.ByteString String
| Partial (Maybe B.ByteString -> Decoder a)
| Done !B.ByteString a
| BytesRead !Int64 (Int64 -> Decoder a)
newtype Get a = C { runCont :: forall r.
B.ByteString ->
Success a r ->
Decoder r }
type Success a r = B.ByteString -> a -> Decoder r
instance Monad Get where … |
I knew I wanted to expand the documentation a lot but damn, I didn't expect it to take people hours without it. :( Good to know. |
There are many details to understand, part of them in push_decode which I was not familiar with; for example: in transaction decoder, what do I don't think it's problem of documentation, rather it's the size and (inherent) complexity. |
|
Yeah, the thing is, I hope it won't be required to understand all of it to get benefits. Basically understand the basic idea, have examples how to use it and some examples how to implement decoders/encoders. Side note: I had some other ideas that would make the crate even bigger but would result in simpler usage. Some of those ideas are quite crazy though :D. |
This is Kix's work shamelessly stolen from without his draft PR rust-bitcoin#2184 Implement a decoder for decoding compact size integer. Will be used to decode the length prefix when implementing vec decoders. Co-authored-by: Martin Habovstiak <martin.habovstiak@gmail.com>
This is Kix's work shamelessly stolen from his draft PR rust-bitcoin#2184 Implement a decoder for decoding compact size integer. Will be used to decode the length prefix when implementing vec decoders. Co-authored-by: Martin Habovstiak <martin.habovstiak@gmail.com>
This is Kix's work shamelessly stolen from his draft PR rust-bitcoin#2184 Implement a decoder for decoding compact size integer. Will be used to decode the length prefix when implementing vec decoders. Co-authored-by: Martin Habovstiak <martin.habovstiak@gmail.com>
This is Kix's work shamelessly stolen from his draft PR rust-bitcoin#2184 Implement a decoder for decoding compact size integer. Will be used to decode the length prefix when implementing vec decoders. Co-authored-by: Martin Habovstiak <martin.habovstiak@gmail.com>
This is Kix's work shamelessly stolen from his draft PR rust-bitcoin#2184 Implement a decoder for decoding compact size integer. Will be used to decode the length prefix when implementing vec decoders. Co-authored-by: Martin Habovstiak <martin.habovstiak@gmail.com>
This is Kix's work shamelessly stolen from his draft PR rust-bitcoin#2184 Implement a decoder for decoding compact size integer. Will be used to decode the length prefix when implementing vec decoders. Co-authored-by: Martin Habovstiak <martin.habovstiak@gmail.com>
This is a demo of push-based decoding - sloppy programming ahead! Insufficient error handling, no DoS protection, missing checks during decoding, missing documentation, some things (no-std) not tested, different MSRV...This is now ready.
I'm mainly gathering general feedback: is this something we want to do? Do you think the added complexity is worth it? Do you have other ideas to improve it (other than intentionally ignored parts).
Note that this is currently just decoding, encoding to come later unless this proposal is rejected.
Also regarding MSRV, I could make it lower but it'd help if I didn't have to. It should be 1.51 but I didn't actually check - I tested with 1.63. What do you think about bumping it?
Closes #1741
Closes #1251