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

PLT-271: Use of pure cardano-api transaction in emulator #503

Merged
merged 17 commits into from
Jun 13, 2022

Conversation

sjoerdvisscher
Copy link
Contributor

@sjoerdvisscher sjoerdvisscher commented Jun 8, 2022

Actual new code is mostly just the changes in plutus-ledger/src/Ledger/Tx.hs.
The big change is that the emulated blockchain now also contains CardanoTx, so either transaction type or both.

Pre-submit checklist:

  • Branch
    • Tests are provided (if possible)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
    • Formatting, PNG optimization, etc. are updated
  • PR
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@sjoerdvisscher sjoerdvisscher force-pushed the PLT-271-cardano-api-tx-only-in-emulator branch from eddec40 to 7700412 Compare June 9, 2022 17:31
@sjoerdvisscher sjoerdvisscher marked this pull request as ready for review June 10, 2022 14:28
@sjoerdvisscher sjoerdvisscher requested review from koslambrou and a user June 10, 2022 15:39
setValidity :: Bool -> C.Tx era -> C.Tx era
setValidity validity (C.Tx (C.ShelleyTxBody C.ShelleyBasedEraAlonzo txBody scripts dat aux _) era) =
C.Tx (C.ShelleyTxBody C.ShelleyBasedEraAlonzo txBody scripts dat aux (toTxScriptValidity validity)) era
setValidity _ tx = tx -- only applies in Alonzo era
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the comment. You mean this "applies to eras pre-Alonzo"?

(fromOnChainCardanoTx False)
ctx

fromOnChainCardanoTx :: Bool -> SomeCardanoApiTx -> ChainIndexTx
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on why we need to manually set the script validity when converting from CardanoTx to ChainIndexTx?

pure (e, events)

validateL :: Params -> Slot -> Validation.UTxO Index.EmulatorEra -> SomeCardanoApiTx -> Maybe Index.ValidationErrorInPhase
validateL params slot idx (CardanoApiEmulatorEraTx tx) = Validation.hasValidationErrors params (fromIntegral slot) idx tx
-- TODO: generate ScriptValidationEvents
Copy link
Contributor

@koslambrou koslambrou Jun 12, 2022

Choose a reason for hiding this comment

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

What do that refer to exactly? Do we have a story for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I will make one.

@koslambrou
Copy link
Contributor

LGTM :)

@sjoerdvisscher sjoerdvisscher merged commit 43b73ac into main Jun 13, 2022
@sjoerdvisscher sjoerdvisscher deleted the PLT-271-cardano-api-tx-only-in-emulator branch June 13, 2022 14:50
koslambrou pushed a commit that referenced this pull request Jun 22, 2022
* Deeper support for Cardano API Tx's in the emulator

* Implement getCardanoTxData

* Update Utxo index for cardano api txs

* Restore normal behavior

* Add a testcase

* Remove NFData instance, it seems to be unused

* Fix build

* Remove acidental change

* Generate PureScript

* Revert Rollup changes and throw error instead

* Fix temp change

* plutus-chain-index: Use fromCardanoTx in fromOnChainTx

* plutus-chain-index: with Both, use emulator tx in fromOnChainTx

* Fix build

* PR and Hoogle feedback
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.

2 participants