BlockstreamResearch / rust-simplicity

Creative Commons Zero v1.0 Universal
58 stars 12 forks source link

Cost: Compute padding #179

Closed uncomputable closed 9 months ago

uncomputable commented 10 months ago

Extend the Cost struct to compute the necessary padding based on a given witness stack. Test the new methods. Keep the changes to the public API minimal.

uncomputable commented 9 months ago

Rebased, squashed and ready for review

apoelstra commented 9 months ago

f28ec2f353b158ed7d49d9c5b99bdedd12a97f2d looks great! All my comments are fairly minor.

uncomputable commented 9 months ago

Rebased and addressed some of the nits. Thanks for the helpful comments.

uncomputable commented 9 months ago

Rebased and addressed the remaining comments.

apoelstra commented 9 months ago

In a followup PR we should maybe replace Vec<Vec<u8>> with Witness which is more efficiently implemented (in particular it doesn't make you serialize to a sink to get its length).

But I think that would require changes in rust-elements first which maybe we don't want to bother with (in general, we are just keeping rust-elements on life support until rust-bitcoin 1.0 when we will need to more-or-less rewrite it to match the rust-bitcoin API).