Let's imagine I have AlwaysSucceeds Plutus validator script, which is:
mkValidator :: Params -> Datum -> Redeemer -> ScriptContext -> Bool
mkValidator _ _ _ _ = True
I locked many different utxos at the script address in the testnet. Let's image 15 in total. Now I want to spend all of those utxos at once from the script using cardano-cli. Building transaction as usual, and providing those utxos as --tx-in:
--tx-in "abcdef#1" \
--tx-in-script-file alwaysSucceeds.plutus \
--tx-in-datum-value 420 \
--tx-in-redeemer-file redeemer.json \
--tx-in "abcdef#2" \
--tx-in-script-file alwaysSucceeds.plutus \
--tx-in-datum-value 420 \
--tx-in-redeemer-file redeemer.json \
...
...
--tx-in "abcdef#15" \
--tx-in-script-file alwaysSucceeds.plutus \
--tx-in-datum-value 420 \
--tx-in-redeemer-file redeemer.json \
I am pretty sure, that script is included only once in the transaction (is it?). Then submitting transaction to the testnet, I get the following error:
Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ExUnitsTooBigUTxO (ExUnits {exUnitsMem = 12500000, exUnitsSteps = 10000000000}) (ExUnits {exUnitsMem = 31256460, exUnitsSteps = 14103266205}))))])
This basically means that I exceeded memory limit by 3 times and CPU by 1.5.
When lowering utxo count to 14,13... it scales down pretty much linearly:
15 utxos: {exUnitsMem = 31256460, exUnitsSteps = 14103266205}
14: {exUnitsMem = 28008316, exUnitsSteps = 12629952076}
13: {exUnitsMem = 24926512, exUnitsSteps = 11232794573}
12: {exUnitsMem = 22011048, exUnitsSteps = 9911793696}
11: {exUnitsMem = 19261924, exUnitsSteps = 8666949445}
10: {exUnitsMem = 16679140, exUnitsSteps = 7498261820}
9: {exUnitsMem = 14262696, exUnitsSteps = 6405730821}
8: Transaction successfully submitted.
The validator script itself has no logic, it should not inflate memory and CPU usage (even though unfortunately it will be executed same amount of times as there are utxos).
My questions:
- Does this really mean that somewhat around 10 inputs are the maximum possible to spend from the script?
- Is there any way to overcome this, and allow way more inputs from the script to be spent at once?
- Are exUnitsMem and exUnitsSteps the same on the mainnet?
- Maybe there is a way to increase those parameters to be able to submit the transaction?
- Is script really included only once then submitting/Am I building transaction correctly?
- As I am validating multiple utxos at once, is it possible to run validator only once and not for each utxo?
- If this is really the limit, how we are supposed to build something useful? When and by how much are those units are planned to increase?
- Is there any plans, regarding running validator only once for all utxo set, instead of executing it for each utxo?
EDIT:
after updating node version to 1.32.1, error is thrown on the build step also, then utxo count is increased even further. Result is pretty much the same, only the error message is different:
Command failed: transaction build Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with:
The Plutus script evaluation failed: An error has occurred: User error:
The budget was overspent. Final negative state: ({ cpu: 5931879314
| mem: -1199
})