IntersectMBO / IntersectMBO/plutus
Apply params to validator loaded from file fails
- Dominant language
- Haskell
- Stars
- 1.6k
- Forks
- 508
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 22
Description
### Summary
I'm trying to apply parameters to Aiken written validator that is loaded from file in Plutus.
When the validator is non-parametrized, it works fine, but the problem is when applying parameters to a validator.
The problem seems to be that the encoding of parameter application doesn't seem to match but I'm not sure what is the format Plutus is using to apply parameters and whether it could be customised.
### Steps to reproduce the behavior
The Aiken's validator is a simple always pass validator that accesses the script parameters.
The following is the Aiken code for reference:
```
type FooScriptParams {
a: Int,
}
validator(params: FooScriptParams) {
fn spend(datum: Void, redeemer: Void, ctx: ScriptContext) -> Bool {
let FooScriptParams { a } = params
a == a
}
}
```
Then using the following transformation to named deBruijn:
1. `aiken build --uplc`
2. `aiken uplc encode --to named-debruijn artifacts/foo.spend.uplc > foo.namedDeBruijn`
I'm using the following revision of Aiken https://github.com/aiken-lang/aiken/commit/699467a876f54232833e034a0b21deea4f3a69af
The following is the loading of the validator encoded in named deBruijn from `foo.namedDeBruijn` into Plutus:
```haskell
data FooScriptParams = FooScriptParams
{ a :: Integer
}
PlutusTx.makeLift ''FooScriptParams
PlutusTx.makeIsDataIndexed ''FooScriptParams [('FooScriptParams, 0)]
compiledFooUnapplied :: CompiledCode (FooScriptParams -> UntypedValidator)
compiledFooUnapplied = $$(PlutusTx.loadFromFile "some_path/foo.namedDeBruijn")
compiledFoo :: CompiledCode UntypedValidator
compiledFoo = compiledFooUnapplied `PlutusTx.applyCode` PlutusTx.liftCode FooScriptParams {a = 100}
```
### Actual Result
Now when executing the `compiledFoo` from the steps to reproduce, I get the following error:
```
Could not unlift a builtin:
Not a constant
Caused by: (delay (\i_i0 -> i_i1 100))) []
```
Where the `(delay (\i_i0 -> i_i1 100))) []` seems to be the encoded `FooScriptParams`.
So I'm expecting the problem is in the application of parameters.
### Expected Result
Expected is that the parameters get properly applied to the validator and the validator validates.
### Describe the approach you would take to fix this
_No response_
### System info
Plutus revision: https://github.com/input-output-hk/plutus/commit/f003b096dbc5abca9dbb74fbff847914dd39fa6b
Contributor guide
Assessment
This issue has not been assessed yet.