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

Fix blueprint pairs schema generation #1089

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Jan 30, 2025

This ensures that we only prune unnecessary schema definitions from the blueprint when they truly are unnecessary. The first commit fixes #1086, but as we discussed internally, there's another problem we should find a resolution for (which I wish to include in this PR): currently, we generate schema for pairs as #pairs; which translates to a UPLC Term (not serializable as Data).

So my first reaction was to simply forbid the presence of pairs in the contract ABI, but @MicroProofs pointed that part of the validator wrapper code includes conversion from lists of 2 elements to pairs (if types require it). Which means that pairs are technically allowed in the contract ABI, but serialized as Data::List of two elements.

Hence, the generated schema should reflect that; but only when pairs are present in datums / redeemers. When present as parameters, they are expected to be UPLC terms.

  This is to avoid pruning a definition which may end up needed later
  on. The issue can be seen when definition to a Pair is used *before*
  another Map definitions that uses this same Pair.

  Before this commit, the Map definition would simply remove the
  definition generated for the Pair, since it would be pointless (and it
  is a lot easier to generate those pointless definition than trying to
  remember we are currently generating definition for a Map).

  So now, we defer the removal of the orphan definition to after all
  defnitions have been generated by basically looking at a dependency
  graph. I _could have_ used pet-graph on this to solve it similar to
  how we do package dependencies; but given that we only really need to
  that for pairs, the problem is relatively simple to solve (though
  cumbersome since we need to traverse all defintions).

  Fixes #1086.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Missing definition in generated plutus.json file
1 participant