-
Notifications
You must be signed in to change notification settings - Fork 156
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
Start optimising the memory footprint of the UTxO. #1663
Conversation
Since we rely on the (de)serialiseAddress then we should inherit the round trip property, but it's worth adding a QC test anyway. |
ca8b5ba
to
cb967d5
Compare
This changes the memory representation of TxIn and TxOut, to reduce overhead. In particular, we use unpacked Word64 for coin values and txout indices, and use the serialisation of addresses as ShortByteString. This does not yet change the representation of TxId. The changes are nearly opaque, in that we provide view patterns that takes the place of the old constructors. We do need to add a Crypto constraint wherever we use a TxOut, however, since the view pattern relies on serialisation/deserialisation.
Previously, we had relied on Generic, which was using the CompactUTxO construnctor directly (so the bytestring which was supposed to be a serialised address was just a random bystestring).
d4e9afc
to
6aeb5a8
Compare
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.
LGTM!
shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/TxData.hs
Outdated
Show resolved
Hide resolved
pattern TxIn :: | ||
Crypto crypto => | ||
TxId crypto -> | ||
Natural -> -- TODO We might want to change this to Word64 generally |
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.
I agree with this TODO.
Co-authored-by: Duncan Coutts <[email protected]>
This changes the memory representation of TxIn and TxOut, to reduce overhead.
In particular, we use unpacked Word64 for coin values and txout indices, and use
the serialisation of addresses as ShortByteString.
This does not yet change the representation of TxId.
The changes are nearly opaque, in that we provide view patterns that takes the
place of the old constructors. We do need to add a Crypto constraint wherever we
use a TxOut, however, since the view pattern relies on
serialisation/deserialisation.
This is a draft PR for now, as I'd like to add some properties around the TxOut (I've introduced a
panic
when deserialisation fails in the view pattern, which should never occur, since the constructor itself is not exported, and so the only way to construct a TxOut is using serialisation).