Padding problem: execution cost exceeded budget limit

When working on contracts that are doing a lot of hashes (checking Merkle Tree Proofs), quite often I had to add “padding” to the program itself to avoid having an error that says that execution cost exceeded budget. I also recently added a check to Simplicity that would return an error before an “underpaid” transaction would reach a node:

I relied on the rust-simplicity’s functionality to get and check program’s budget:

The follow-up problem is how to automatically “grow” the tx size, so the tx fee would cover the execution cost. It is not possible to have a separate UTXO that would pay for the execution cost of another, because the budget is calculated per currently executed UTXO basis:

Before the annex padding is introduced, would be nice to have some other automatic mechanism. Though I am not sure whether it is better to leave as is, and have a guide that would help, or try to solve the problem in a different way.

Fundamentally, I cannot see a solution that is flexible and generic without it being implemented on the level of rust-simplicity.

Would love to hear your opinion on this.

2 Likes

Also related Yet another padding option: Tapleaves

And feat: add padding keyword to increase program size by stringhandler · Pull Request #226 · BlockstreamResearch/SimplicityHL · GitHub

1 Like

With any program that has at least two spending branches or more, padding becomes non-trivial, IMO

For example, for the HTLC, one branch could need one padding, another one does not need it at all