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

Add CBOR encoded Datum #1110

Closed
wants to merge 3 commits into from
Closed

Conversation

sorki
Copy link
Contributor

@sorki sorki commented May 4, 2022

Introduces txDatumBytes field
with CBOR serialized Datum.

Introduces `txDatumBytes` field
with CBOR serialized Datum.
@sorki sorki requested a review from erikd as a code owner May 4, 2022 10:47
@kderme
Copy link
Contributor

kderme commented May 4, 2022

2 notes on this:

  • There will probably be many changes soon on these fields with Next hard fork support #1081
  • Many of these serialisations can be avoided, since if a datum is already in db, it doesn't need to be inserted again. So we should first do a query based on the unique hash and do the serialisation only if needed. This is something we can do for many existing fields (mostly datum and scripts) and doesn't apply only to this pr.

@sorki
Copy link
Contributor Author

sorki commented May 5, 2022

There will probably be many changes soon on these fields with Next hard fork support #1081

Noticed! I think that's fine, this will be especially useful with inline datums.

Many of these serialisations can be avoided, since if a datum is already in db, it doesn't need to be inserted again. So we should first do a query based on the unique hash and do the serialisation only if needed. This is something we can do for many existing fields (mostly datum and scripts) and doesn't apply only to this pr.

I've added two commits to address this for scripts and datums.

@sorki
Copy link
Contributor Author

sorki commented May 5, 2022

Many of these serialisations can be avoided, since if a datum is already in db, it doesn't need to be inserted again. So we should first do a query based on the unique hash and do the serialisation only if needed. This is something we can do for many existing fields (mostly datum and scripts) and doesn't apply only to this pr.

Note that it isn't possible to do this in generic way since Persistent generated types have strict fields.

λ: :i Datum
type Datum :: *
data Datum
  = Datum {datumHash :: !ByteString,
           datumTxId :: <snip>
           datumValue :: !(Maybe Text),
           datumBytes :: !ByteString}

It's tempting to also rename Datum value to json so it is similar to e.g. Script or TxMetadata. Not sure if it's worth the breakage. What do you think?

@erikd
Copy link
Contributor

erikd commented Jun 7, 2022

Closed in favor of #1136 .

@erikd erikd closed this Jun 7, 2022
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.

3 participants