tweag / cooked-validators

MIT License
39 stars 11 forks source link

Enable printing from scripts #326

Closed carlhammann closed 1 year ago

carlhammann commented 1 year ago

This adds a module with some functions to be used in validators or minting policies to print information that is contained on the TxInfo to BuiltinString. The intended use is debugging. You have to jump through quite a few hoops to accomplish this, and I'm indebted to @facundominguez for finding out the main tricks.

However, even with the (mild) optimisations I took, the capabilities introduced here are not at all usable in production code. It seems to be inherently inefficient to work with BuiltinString, and even for very simple examples, printing the whole TxInfo will cause scripts to run over budget. It remains to be investigated which protocol parameters (?) and choices made during transaction generation we can tweak to temporarily allow bigger execution budgets.

facundominguez commented 1 year ago

It remains to be investigated which protocol parameters (?) and choices made during transaction generation we can tweak to temporarily allow bigger execution budget.

This is a concern when offering the code as a standalone library, since in cooked there is allowBigTransactions, right?

carlhammann commented 1 year ago

Does the speed up achieved with BSSyntax justify its weight?

Compared to the naive implementation, the point at which we run over budget comes later. I'll definitely try the showsPrec route you suggested, though. That idiom is better known and probably at least as performant.

carlhammann commented 1 year ago

It remains to be investigated which protocol parameters (?) and choices made during transaction generation we can tweak to temporarily allow bigger execution budget.

This is a concern when offering the code as a standalone library, since in cooked there is allowBigTransactions, right?

From what I understand, allowBigTransactions is a thing of the past, and plutus-apps now has increaseTransactionLimits. So far on cooked v2, we've just never come into the situation where a transaction runs over budget. Our API currently doesn't expose this facility, and we have to decide how to go about it.