plutus icon indicating copy to clipboard operation
plutus copied to clipboard

[Builtins] Make costing of 'equalsData' more accurate

Open effectfully opened this issue 6 months ago • 1 comments

This makes the user not pay for so the nodes that equalsData ends up not processing (when False is returned early, because two nodes don't match and there's no point in traversing the Data objects further).

The idea is simple: instead of computing the cost of equalsData d1 d2 as (pseudocode)

minCost (memoryUsage d1) (memoryUsage d2)

we compute it as

let common = minData d1 d2
in minCost (memoryUsage common) (memoryUsage common)

effectfully avatar Jun 11 '25 02:06 effectfully

PR Preview Action v1.6.1 :---: |

:rocket: View preview at
https://IntersectMBO.github.io/plutus/pr-preview/pr-7138/

|
Built to branch gh-pages at 2025-06-11 03:26 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

github-actions[bot] avatar Jun 11 '25 02:06 github-actions[bot]

As demonstrated here, costing update here doesn't really benefit script evaluations in the node.

In short, this is because most validators when they use equalsData either use it on two data of same structure, like checking equality of TxOutRef. When they use equalsData on data of unknown structure, it's frequently comparing Redeemer or Datum which validators often expect equalsData to be true. So cases where new costing of equalsData actually being beneficial is very rare.

SeungheonOh avatar Jul 04 '25 03:07 SeungheonOh