tweag / cooked-validators

MIT License
39 stars 11 forks source link

Improving the use of reference scripts #447

Closed mmontin closed 2 months ago

mmontin commented 3 months ago

At the moment, using reference scripts is done when specifying redeemers and attaching a TxOutRef. Maybe this passing of utxo could be avoided.

Already, when we consume a utxo belonging to a script, we don't provide the script itself and cooked finds it directly into a certain inner part of the mockchain state. Maybe we could have another map there, or a list, to store utxos that have been attached to reference scripts (or simply look at them through the existing index and dont add any other structure ...).

Then, whenever a script witness is necessary in a skeleton, we could look in those utxos and, if we find a reference script there with the right hash, we would feed it directly as reference script.

There could still be the option to pass it explicitly, and we could use the new logging mechanism to ensure that this is not 100% silent and the user gets a notification when a reference script is attached directly.

This issue comes from the fact that it's very annoying to carry around reference script utxos in traces.