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

Plutus script cost calculation cli command #3590

Closed
Jimbo4350 opened this issue Feb 9, 2022 · 0 comments · Fixed by #3589
Closed

Plutus script cost calculation cli command #3590

Jimbo4350 opened this issue Feb 9, 2022 · 0 comments · Fixed by #3589
Assignees
Labels
enhancement New feature or request

Comments

@Jimbo4350
Copy link
Contributor

It would be useful to have a cli command that takes a txbody, tx or Plutus script(s) and outputs the cost to execute the script in terms of Ada and execution units.

@Jimbo4350 Jimbo4350 added the enhancement New feature or request label Feb 9, 2022
@Jimbo4350 Jimbo4350 self-assigned this Feb 9, 2022
iohk-bors bot added a commit that referenced this issue Feb 17, 2022
3587: Bump ledger and network dependencies r=denisshevchenko a=nc6

The changes here come from a few areas:

- Refactoring of the ledger code to move the protocol concerns into their own package.
- Some additional errors for Plutus scripts (not yet enabled).
- Additional ledger events.
- Remove ToJSON instances which have now migrated to the ledger codebase.
- Change `TxIx` to be a `Word16`, which is its new bound in Shelley+ eras.

This also incorporates `@bolt12's` changes from #3561. 

3589: Update  cli build command to calculate Plutus script cost r=Jimbo4350 a=Jimbo4350

Resolves: #3590

 We introduce the  following change:
```
cardano-cli transaction build 
...
(--out-file FILE | --calculate-plutus-script-cost FILE)
```
If you are only interested in the script cost, specify the `--calculate-plutus-script-cost` option.

Example: 

```
$CARDANO_CLI transaction build \
  --alonzo-era \
  --cardano-mode \
  --testnet-magic "$TESTNET_MAGIC" \
  --change-address "$utxoaddr" \
  --tx-in "$plutusutxotxin" \
  --tx-in-collateral "$txinCollateral" \
  --tx-out "$dummyaddress+10000000" \
  --tx-in-script-file "$plutusscriptinuse" \
  --tx-in-datum-file "$datumfilepath"  \
  --protocol-params-file "$WORK/pparams.json" \
  --tx-in-redeemer-file "$redeemerfilepath" \
  --calculate-plutus-script-cost "$WORK/create-datum-output.scriptcost"
  
  > cat $WORK/create-datum-output.scriptcost
  [
    {
        "executionUnits": {
            "memory": 1700,
            "steps": 476468
        },
        "lovelaceCost": 133,
        "scriptHash": "67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"
    }
]
  
  ```

Co-authored-by: Nicholas Clarke <nick@topos.org.uk>
Co-authored-by: Armando Santos <armandoifsantos@gmail.com>
Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
iohk-bors bot added a commit that referenced this issue Feb 17, 2022
3589: Update  cli build command to calculate Plutus script cost r=Jimbo4350 a=Jimbo4350

Resolves: #3590

 We introduce the  following change:
```
cardano-cli transaction build 
...
(--out-file FILE | --calculate-plutus-script-cost FILE)
```
If you are only interested in the script cost, specify the `--calculate-plutus-script-cost` option.

Example: 

```
$CARDANO_CLI transaction build \
  --alonzo-era \
  --cardano-mode \
  --testnet-magic "$TESTNET_MAGIC" \
  --change-address "$utxoaddr" \
  --tx-in "$plutusutxotxin" \
  --tx-in-collateral "$txinCollateral" \
  --tx-out "$dummyaddress+10000000" \
  --tx-in-script-file "$plutusscriptinuse" \
  --tx-in-datum-file "$datumfilepath"  \
  --protocol-params-file "$WORK/pparams.json" \
  --tx-in-redeemer-file "$redeemerfilepath" \
  --calculate-plutus-script-cost "$WORK/create-datum-output.scriptcost"
  
  > cat $WORK/create-datum-output.scriptcost
  [
    {
        "executionUnits": {
            "memory": 1700,
            "steps": 476468
        },
        "lovelaceCost": 133,
        "scriptHash": "67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"
    }
]
  
  ```

3593: Update MissingScript error in evaluateTransactionExecutionUnits r=Jimbo4350 a=Jimbo4350



Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
@iohk-bors iohk-bors bot closed this as completed in 600f5d2 Feb 17, 2022
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 a pull request may close this issue.

1 participant