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 function collectPlutusScriptHashes to collect script hashes needed to validate a given transaction #735

Merged
merged 4 commits into from
Feb 4, 2025

Conversation

palas
Copy link
Contributor

@palas palas commented Jan 24, 2025

Changelog

- description: |
    Add function `collectPlutusScriptHashes` to collect script hashes needed to validate a given transaction
  type:
  - feature

Context

This is required functionality by this cardano-cli PR: IntersectMBO/cardano-cli#1031

How to trust this PR

Ensure the API is in the correct place and has the right structure, that it does the right thing, that the documentation is adequate. Also check in conjunction with the related PRs:

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

cardano-api/internal/Cardano/Api/Plutus.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Plutus.hs Outdated Show resolved Hide resolved
-- and return them in a map with their corresponding 'ScriptWitnessIndex' as key.
collectScriptHashes
:: AlonzoEraOnwards era
-> TxBody era
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is more related to TxBody rather than to this module, so it should go to Cardano.Api.Tx.Body I think.

(Cardano.Api.Tx.Body should get chopped down into smaller modules, but that's a separate discussion...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried but it generated a cyclic dependency. It would probably be solvable by creating some Type modules and moving stuff around, but it was not trivial at all

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok lets leave it for now. 👍🏻

Copy link
Contributor

Choose a reason for hiding this comment

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

I would parameterize this on a the api's Tx era. TxBody era will be removed in the future because it is a poor abstraction. It (unsuccessfully) tries to find a middle ground between a full transaction and a tx body as defined in the ledger.

cardano-api/internal/Cardano/Api/Plutus.hs Outdated Show resolved Hide resolved
@palas palas force-pushed the plutus-script-cost-calculation-cmd branch from 31cd3fe to 99577e1 Compare January 27, 2025 11:47
@palas palas requested review from carbolymer and smelc January 27, 2025 11:53
@palas palas force-pushed the plutus-script-cost-calculation-cmd branch from 99577e1 to 3767bb3 Compare January 28, 2025 12:32
@palas
Copy link
Contributor Author

palas commented Jan 31, 2025

@palas palas force-pushed the plutus-script-cost-calculation-cmd branch from 3767bb3 to 2d9f907 Compare January 31, 2025 15:20
@palas palas enabled auto-merge January 31, 2025 15:20
@palas palas added this pull request to the merge queue Jan 31, 2025
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

Before this is merged and exposed I want to have a crack at where this is called in cardano-cli.

@palas palas removed this pull request from the merge queue due to a manual request Jan 31, 2025
@palas palas requested a review from Jimbo4350 January 31, 2025 15:56
@palas palas changed the title Add function collectScriptHashes to collect script hashes needed to validate a given transaction Add function collectPlutusScriptHashes to collect script hashes needed to validate a given transaction Jan 31, 2025
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

LGTM but one comment needs to be addressed.

-- and return them in a map with their corresponding 'ScriptWitnessIndex' as key.
collectScriptHashes
:: AlonzoEraOnwards era
-> TxBody 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 would parameterize this on a the api's Tx era. TxBody era will be removed in the future because it is a poor abstraction. It (unsuccessfully) tries to find a middle ground between a full transaction and a tx body as defined in the ledger.

@palas palas force-pushed the plutus-script-cost-calculation-cmd branch from fe1d56e to 6e17447 Compare February 4, 2025 15:51
@palas
Copy link
Contributor Author

palas commented Feb 4, 2025

I would parameterize this on a the api's Tx era. TxBody era will be removed in the future because it is a poor abstraction. It (unsuccessfully) tries to find a middle ground between a full transaction and a tx body as defined in the ledger.

Addressed here: 6e17447

@palas palas added this pull request to the merge queue Feb 4, 2025
Merged via the queue into master with commit 87afbdd Feb 4, 2025
29 checks passed
@palas palas deleted the plutus-script-cost-calculation-cmd branch February 4, 2025 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command to calculate the correct Plutus Script Costs online
4 participants