Skip to content
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

Merged
merged 8 commits into from Jul 15, 2020

Conversation

kantp
Copy link
Contributor

@kantp kantp commented Jul 14, 2020

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).

@dcoutts
Copy link
Contributor

dcoutts commented Jul 14, 2020

Since we rely on the (de)serialiseAddress then we should inherit the round trip property, but it's worth adding a QC test anyway.

@kantp kantp force-pushed the philipp/memory-opt branch 2 times, most recently from ca8b5ba to cb967d5 Compare July 14, 2020 19:22
@kantp kantp marked this pull request as ready for review July 15, 2020 20:03
Philipp Kant added 7 commits July 15, 2020 17:51
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).
Copy link
Contributor

@JaredCorduan JaredCorduan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

pattern TxIn ::
Crypto crypto =>
TxId crypto ->
Natural -> -- TODO We might want to change this to Word64 generally
Copy link
Contributor

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 <duncan@well-typed.com>
@JaredCorduan JaredCorduan merged commit 9dc2eab into master Jul 15, 2020
@iohk-bors iohk-bors bot deleted the philipp/memory-opt branch July 15, 2020 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants