Skip to content

The build command calculates insufficient Plutus script cost for two certificates #1023

@mkoura

Description

@mkoura

Description

In a situation where two certificates with Plutus script are used in single tx, the build command computes lower cost than is needed, and tx submit fails. I can observe this behavior in a test that registers Plutus stake address and delegate it to a pool in single tx.

I can build the tx using build-raw and submit it successfully.

The build command:

cardano-cli conway transaction build \
--certificate-file "test_delegate_deregister[script_file-build-plutus_v2]_ci0_wvc_addr0_stake_reg.cert" \
--certificate-script-file cardano_node_tests/tests/data/plutus/v2/stake-script.plutus \
--certificate-redeemer-file cardano_node_tests/tests/data/plutus/42.redeemer \
--certificate-file "test_delegate_deregister[script_file-build-plutus_v2]_ci0_wvc_addr0_stake_deleg.cert" \
--certificate-script-file cardano_node_tests/tests/data/plutus/v2/stake-script.plutus \
--certificate-redeemer-file cardano_node_tests/tests/data/plutus/42.redeemer \
--tx-in-collateral "33336bf4d21a09196256345cd738e301626b53db4cbdb79bb566b3185afd0185#0" \
--tx-in "33336bf4d21a09196256345cd738e301626b53db4cbdb79bb566b3185afd0185#3" \
--change-address addr_test1yp9ex2dj99plru9w8ukmplsenlxzvz0hgdy5l2c2upss5auu36w607q78j5sfp0n96l0exqn0j9vyc9qw2sqcj40zskskzmsj7 \
--witness-override 1 \
--out-file "test_delegate_deregister[script_file-build-plutus_v2]_ci0_wvc_reg_deleg_tx.body" \
--testnet-magic 42

Tx submit fails with (shortened error):

The plutus evaluation error is: CekError An error has occurred:\nThe machine terminated part way through evaluation due to overspending the budget.\nThe budget when the machine terminated was:\n({cpu: -570964\n| mem: 28})\nNegative numbers indicate the overspent budget; note that this only indicates the budget that was needed for the next step, not to run the program to completion.

The scripts cost reported by transaction build:

[{'executionUnits': {'memory': 613680, 'steps': 196655766},
  'lovelaceCost': 49589,
  'scriptHash': '9c8e9da7f81e3ca90485f32ebefc98137c8ac260a072a00c4aaf142d'},
 {'executionUnits': {'memory': 616152, 'steps': 197801730},
  'lovelaceCost': 49814,
  'scriptHash': '9c8e9da7f81e3ca90485f32ebefc98137c8ac260a072a00c4aaf142d'}]

The reported cost is the same for cardano-cli version where I can observe the issue, and for the last release where the issue was not present.

I can reproduce it with cardano-cli that has #986 merged.

Steps to Reproduce

  1. build the tx using transaction build
  2. submit the tx
  3. see the error

Additional Context

Files used to build the tx and full error message: issue_delegation_plutus.tar.gz

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions