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

Missing definition in generated plutus.json file #1086

Open
1 task done
Dodilanne opened this issue Jan 24, 2025 · 1 comment · May be fixed by #1089
Open
1 task done

Missing definition in generated plutus.json file #1086

Dodilanne opened this issue Jan 24, 2025 · 1 comment · May be fixed by #1089
Assignees
Labels
blueprint CIP-0057 bug Something isn't working

Comments

@Dodilanne
Copy link

What Git revision are you using?

aiken v1.1.10+b25afa2

What operating system are you using, and which version?

  • macOS

Describe what the problem is?

When creating a datum type containing an alias for a Pair and an associative list using the same type alias, only the schema definition for the associative list gets included in the generated blueprint when executing aiken build.

Example

When building this simple validator:

use cardano/transaction.{OutputReference, Transaction}

pub type MyPair = Pair<Int, Int>

pub type MyDatum {
  pair: MyPair,
  pairs: List<MyPair>,
}

validator placeholder {
  spend(_datum: Option<MyDatum>, _redeemer: Void, _utxo: OutputReference, _self: Transaction) {
    True
  }
}

...the resulting schema for the datum fields is as follows:

[
  {
    "title": "pair",
    "$ref": "#/definitions/MyPair"
  },
  {
    "title": "pairs",
    "$ref": "#/definitions/List$MyPair"
  }
]

...but there is no definition for the MyPair type, only for the List$MyPair.

Is this expected? I could infer the MyPair type from the List$MyPair schema but it feels like a weird edge case.

What should be the expected behavior?

I would expect all $ref paths to point to a schema definition.

plutus.json

@rvcas
Copy link
Member

rvcas commented Jan 26, 2025

@Dodilanne thanks for reporting, I'll take a look

@KtorZ KtorZ self-assigned this Jan 27, 2025
@KtorZ KtorZ moved this from 🪣 Backlog to 🫡 In Progress in Project Tracking Jan 27, 2025
@KtorZ KtorZ added bug Something isn't working blueprint CIP-0057 labels Jan 27, 2025
KtorZ added a commit that referenced this issue Jan 30, 2025
  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.
KtorZ added a commit that referenced this issue Jan 30, 2025
  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.
@KtorZ KtorZ linked a pull request Jan 30, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blueprint CIP-0057 bug Something isn't working
Projects
Status: 🫡 In Progress
Development

Successfully merging a pull request may close this issue.

3 participants