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

Update cli build command to calculate Plutus script cost #3589

Merged
merged 1 commit into from Feb 17, 2022

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Feb 9, 2022

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"
    }
]
  

@Jimbo4350 Jimbo4350 changed the title Implement cli command to calculate Plutus script cost Update cli build command to calculate Plutus script cost Feb 14, 2022
@Jimbo4350 Jimbo4350 force-pushed the jordan/plutus-script-cost-estimator branch 5 times, most recently from 11138da to 4865975 Compare February 15, 2022 14:31
@Jimbo4350 Jimbo4350 marked this pull request as ready for review February 15, 2022 14:31
@Jimbo4350 Jimbo4350 force-pushed the jordan/plutus-script-cost-estimator branch from 4865975 to 29fda4f Compare February 15, 2022 14:52
@Jimbo4350 Jimbo4350 force-pushed the jordan/plutus-script-cost-estimator branch from 29fda4f to 0a369ce Compare February 17, 2022 13:11
output the plutus script cost in execution units and Lovelace
@Jimbo4350 Jimbo4350 force-pushed the jordan/plutus-script-cost-estimator branch from 0a369ce to 6c8359c Compare February 17, 2022 13:12
@Jimbo4350
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request 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
Copy link
Contributor

iohk-bors bot commented Feb 17, 2022

This PR was included in a batch that was canceled, it will be automatically retried

@Jimbo4350
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 17, 2022

Already running a review

iohk-bors bot added a commit that referenced this pull request 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
Copy link
Contributor

iohk-bors bot commented Feb 17, 2022

This PR was included in a batch that successfully built, but then failed to merge into master (it was a non-fast-forward update). It will be automatically retried.

@Jimbo4350
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 17, 2022

Already running a review

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 17, 2022

Build succeeded:

@iohk-bors iohk-bors bot merged commit 600f5d2 into master Feb 17, 2022
@iohk-bors iohk-bors bot deleted the jordan/plutus-script-cost-estimator branch February 17, 2022 17:57
@rchak007
Copy link

Hi for some reason i am getting "Invalid option `--calculate-plutus-script-cost'"
Any idea ? i tried --alonzo-era too

chakravarti@chakravarti-Latitude-7280:~/CrowdFundingCardanoPlutus/shell-scripts$ cardano-cli transaction build --babbage-era --cardano-mode --testnet-magic 2 \

--tx-in 4d56f6d736f15652fd0d3c6246acc481ffd36392f119ef4201ec780e2f1ba904#0
--tx-in 47665eb1170c9c062239ddb29412a4f2a9808f92649207cb81d5e8c4362d9952#0
--tx-in-script-file /home/chakravarti/CrowdFundingCardanoPlutus/plutus-scripts/CrowdFunding.plutus
--tx-in-datum-file /home/chakravarti/CrowdFundingCardanoPlutus/plutus-scripts/crowdFunding-datumOut.json
--tx-in-redeemer-file /home/chakravarti/CrowdFundingCardanoPlutus/plutus-scripts/crowdFundingContribute-redeem.json
--required-signer /home/chakravarti/CrowdFundingCardanoPlutus/.priv/Wallets/Collateral/Collateral.skey --tx-in-collateral=4d56f6d736f15652fd0d3c6246acc481ffd36392f119ef4201ec780e2f1ba904#0
--tx-out addr_test1wzx9l6k7kdrhy6m45y4gkyrh25ktx3mzthd27y3gchs4dqqjs3hvd+152000000+"1 404c7e7ab0e42a8b1a247c2eba252698cad8a19c50c0cf5cfb1c2283.4d7943726f776446756e64"
--tx-out-inline-datum-file /home/chakravarti/CrowdFundingCardanoPlutus/plutus-scripts/crowdFunding-datumOut.json
--change-address=addr_test1vqxjn5hh9ws37vup0q7a54gpzw0njlvpaqeyfl8p8ea8zxs6e3vwy
--protocol-params-file /home/chakravarti/CrowdFundingCardanoPlutus/tx/pparams.json
--out-file /home/chakravarti/CrowdFundingCardanoPlutus/tx/tx.draft
--calculate-plutus-script-cost /home/chakravarti/CrowdFundingCardanoPlutus/plutus-scripts/create-crowd-fund.scriptcost
Invalid option `--calculate-plutus-script-cost'

Usage: cardano-cli
( Era based commands
| Byron specific commands
| Miscellaneous commands
)

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.

Plutus script cost calculation cli command
3 participants