Skip to content

Design Consideration. #44

Open
Open
@jaredponn

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    milestone-3c2uplc code generatorquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions