-
Notifications
You must be signed in to change notification settings - Fork 88
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
Spike: cost of on-chain CBOR encoding #154
Conversation
@@ -0,0 +1 @@ | |||
# Plutus CBOR |
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.
Writing 1 or 2 lines here trivial and helps people a lot. So please do :)
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.
:'(
@@ -0,0 +1,125 @@ | |||
cabal-version: 2.2 | |||
name: plutus-cbor | |||
version: 0.1.0 |
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.
Now this gets interesting. So far all the packages were very much Hydra specific in our mono repo and we would tag and release them all with the same version. But this (and the MPT package) are arguably more standalone.
How would we handle this?
Interpret a tag 0.2.0
as everything hydra-
prefixed being on that version with additional tags for plutus-cbor-0.1.0
, plutus-cbor-0.2.0
... on the repo?
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.
Ah! I actually wondered why the MPT was versioned 0.2.0 and it didn't occur to me that this was following the Hydra versioning 🤔 ... Not sure how we want to do with that.
encodeInteger, | ||
|
||
-- * Data-structures | ||
) where |
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.
Empty section? I'd suggest not maintaining both, export-level and intra-module haddocks.
|
||
encodingToBuiltinByteString :: Encoding -> BuiltinByteString | ||
encodingToBuiltinByteString = id | ||
{-# INLINEABLE encodingToBuiltinByteString #-} |
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.
What's the point of this function?
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.
Well, the fact that the module uses a BuiltinByteString
as an intermediary representation of encoding is sort of an implementation detail, so, when considering the library from a user perspective, this should not transpire through the interface IMO.
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.
A newtype with non-exported or marked Unsafe
data constructor would hint at that more rigorously IMO
distanceExUnits (ExUnits m0 s0) (ExUnits m1 s1) = | ||
ExUnits | ||
(if m0 > m1 then m0 - m1 else m1 - m0) | ||
(if s0 > s1 then s0 - s1 else s1 - s0) |
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.
🎉
encodeIntegerValidator :: Scripts.TypedValidator (EncodeValidator Integer) | ||
encodeIntegerValidator = | ||
Scripts.mkTypedValidator @(EncodeValidator Integer) | ||
$$(Plutus.compile [||\() xs _ctx -> let _bytes = encodeInteger <$> xs in True||]) |
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.
This didn't work for me..#155 (comment)
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.
Aaaand, it doesn't for me either actually 😂
📍 Create new 'plutus-cbor' package.
📍 Write simple implementation of an on-chain CBOR encoder for integer.
📍 Compare on-chain CBOR encoder with off-chain oracle ('cborg' library).
📍 fixup create lib.
📍 Define new property for measuring and controlling the execution cost of an encoder.
📍 Write plumbing code for the validators and the calculation of execution units.
Property failing: