-
Notifications
You must be signed in to change notification settings - Fork 677
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
Implement consensus de/serialization in Clarity #3132
Conversation
Codecov Report
@@ Coverage Diff @@
## next #3132 +/- ##
==========================================
- Coverage 83.64% 83.63% -0.02%
==========================================
Files 267 268 +1
Lines 209188 209655 +467
==========================================
+ Hits 174981 175338 +357
- Misses 34207 34317 +110
Continue to review full report at Codecov.
|
impl TypeSignature { | ||
/// Return the maximum length of the consensus serialization of a | ||
/// Clarity value of this type. The returned length *may* not fit | ||
/// in in a Clarity buffer! For example, the maximum serialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo -- "in in a"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in d8f7628
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. Just had a few superficial / edification comments, with a request for a (trivial) additional bit of test coverage. Thanks for whipping this up!
@MarvinJanssen do you want to do a pass on this before merging? Let us know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing, I was working on a to-consensus-buff
for the REPL but this code is a lot more elegant. Can easily it be ported to the REPL (and thus Clarinet) before 2.1 launches?
Migrating the REPL to use this canonical clarity lib is high on my todo list. Once that is done, we would enable a 2.1 option for testing before 2.1 is launched. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, looks like all my comments were addressed 👍
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
This PR adds
to-consensus-buff
andfrom-consensus-buff
methods to theClarity2
native methods.Applicable issues
Additional info (benefits, drawbacks, caveats)
These methods are both fallible -- this may be surprising in the case of
to-consensus-buff
, but the reason is that some legal Clarity values serialize into buffers that are larger than the maximum Clarity value size; this is because of the type prefix and length encoding.The typing of
to-consensus-buff
produces a buffer size which is the maximum possible buffer size for its input. In the case of uints, ints, and bools this is always correct. For other types, however, it will be an overestimate in many cases (e.g., forprincipal
, it assumes the principal is a contract with the longest possible Clarity name).