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

Introduce new witness api #763

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Introduce new witness api #763

wants to merge 7 commits into from

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Feb 25, 2025

Changelog

- description: |
    New witness api
# uncomment types applicable to the change:
  type:
  - feature        # introduces a new feature
  - compatible     # the API has changed but is non-breaking
  - refactoring    # QoL changes

Context

Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@Jimbo4350 Jimbo4350 force-pushed the jordan/new-scripts-api branch from 41613bf to ee59574 Compare February 25, 2025 19:35
@Jimbo4350 Jimbo4350 force-pushed the jordan/new-scripts-api branch 2 times, most recently from 53e997c to 8b9e4cd Compare February 27, 2025 19:22
@Jimbo4350 Jimbo4350 force-pushed the jordan/new-scripts-api branch 3 times, most recently from 5e14d8f to e00ddf0 Compare February 27, 2025 20:16

constructRedeeemerPointerMap
:: AlonzoEraOnwards era
-> [AnyIndexedPlutusScriptWitness ((ShelleyLedgerEra era))]

Check notice

Code scanning / HLint

Redundant bracket Note

cardano-api/src/Cardano/Api/Internal/Experimental/Plutus/IndexedPlutusScriptWitness.hs:169:38-59: Suggestion: Redundant bracket
  
Found:
  ((ShelleyLedgerEra era))
  
Perhaps:
  (ShelleyLedgerEra era)
This allows us to use the new plutus script api with the legacy api and
our new api without modifying other existing types
@Jimbo4350 Jimbo4350 force-pushed the jordan/new-scripts-api branch from e00ddf0 to ad6e828 Compare February 28, 2025 15:54
:: TxScriptWitnessRequirements (ShelleyLedgerEra era) <-
caseShelleyToMaryOrAlonzoEraOnwards
(const $ error "Impossible to construct TxScriptWitnessRequirements in pre-Alonzo era")
(\eon -> collectTxBodyScriptWitnessRequirements eon bc)

Check notice

Code scanning / HLint

Avoid lambda using `infix` Note

cardano-api/src/Cardano/Api/Internal/Tx/Body.hs:2107:9-63: Suggestion: Avoid lambda using infix
  
Found:
  (\ eon -> collectTxBodyScriptWitnessRequirements eon bc)
  
Perhaps:
  (collectTxBodyScriptWitnessRequirements bc)
@Jimbo4350 Jimbo4350 force-pushed the jordan/new-scripts-api branch 2 times, most recently from 7954288 to 2882c59 Compare February 28, 2025 19:08
This is intended to replace the type `Witness witctx era` but if you
look closely they are similar.

The main difference is we do away with `witctx` type parameter because this only really pertains
to plutus script witnesses. The witness context is now relfected in the purpose type
parameter of the `PlutusScriptWitness` type of the `AnyPlutusScriptWitness`
constructor.
…pt lang` which

wrapped a `ShortByteString` which essentially means if our script it
malformed we will be informed of this upon deserialization in the ledger i.e at
transaction submission or when using transaction build.

`PlutusScriptInEra lan era` wraps cardano-ledger's `PlutusRunnable
lang`. This allows us to fail early as the deserialization to `PlutusRunnable`
will error for malformed scripts.

NB: Before the introduction of the new api we did implement a
`PlutusScriptInEra era lang` in the old api but this simply wrapped
`PlutusScript lang` and utilized the serialization instances of
`PlutusRunnable lang`.
@Jimbo4350 Jimbo4350 force-pushed the jordan/new-scripts-api branch 2 times, most recently from feeb2f9 to c1d7f9b Compare February 28, 2025 20:16
`PlutusScriptWitness lang era` is almost identical to the old api's
notion of plutus script witnesses except:
- It's treated as a separate type to simple script witnesses vs as a constructor of a sum type
- A type family is used to represent the presense of a script datum
  depending on the plutus script language and purpose

The `PlutusScriptDatumF` type family has been introduced to capture what
script type can have a datum and if that datum can be optional.
@Jimbo4350 Jimbo4350 force-pushed the jordan/new-scripts-api branch from c1d7f9b to 3520bd4 Compare February 28, 2025 20:18
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.

1 participant