Description
Sometimes scripts are written to include useless computation to "salt" the script. For example, the following script includes the integer salt
in the body s.t. different salts
will induce the script to have different script hashes, but the script has the same functionality.
myScript :: Int -> ScriptContext -> Redeemer -> ()
myScript salt scriptContext redeemer = (\_ -> ... ) salt
Clearly, this poses a problem for certain optimizations -- namely, if we optimize after the salt
is applied, then evaluating the expression (\_ -> ...) salt
leads to just the body ...
, and we've clearly removed the salt
from the script. Thus, scripts with different salts now all have the same script hash.
This can have disastrous consequences if other parts of the protocol crucially rely on these scripts having distinct hashes.
So, the design considerations for covenant are as follows:
- we can ignore this in optimization passes and say "don't run covenant AFTER the script has been parameterized"; or
- we can introduce "volatile" constants which aren't optimized, and still let covenant run AFTER the script has been parameterized
See this slack thread for more details https://mlabs-corp.slack.com/archives/C02QQHLFB6Y/p1738182211804239.
Activity