Open KristianBalaj opened 1 year ago
aiken uplc encode --to named-debruijn artifacts/foo.spend.uplc > foo.namedDeBruijn
Please attach the result of this command (as a file or under a spoiler).
(delay (\i_i0 -> i_i1 100))) []
What evaluator do you use? This doesn't seem like the syntax that we use in those errors, although I might be wrong about that.
Anyway, the error message says that a function is applied to the Scott-encoded FooScriptParams
(and it's encoded correctly) while expecting some constant. What function? I can't tell without seeing the whole program.
... but actually, thinking about it, wasn't Aiken encoding all data types using Data
instead of replicating our old (we now have SOPs) Scott-encoding? If so, then that's your error: the function implemented in Aiken wants you to provide a Data
-encoded value of FooScriptParams
and you provide it a Scott-encoded one.
I'm going to remove the bug
label for now and I'll return it later if it turns out that the bug is indeed on the Plutus side.
aiken uplc encode --to named-debruijn artifacts/foo.spend.uplc > foo.namedDeBruijn
Please attach the result of this command (as a file or under a spoiler).
Here's the Aiken's named debruijn of the always pass code listed above via hexdump:
Here's the same but from the stdout in terminal:
And here's the binary file (the upload expires in 6 days) - https://filebin.net/uv538dwurqn2pp0j
What evaluator do you use? This doesn't seem like the syntax that we use in those errors, although I might be wrong about that.
I'm using the following tool to run the validator https://github.com/mlabs-haskell/plutus-simple-model I'm not sure what evaluator does it use, but my guess would be the Cardano ledger one.
If so, then that's your error: the function implemented in Aiken wants you to provide a Data-encoded value of FooScriptParams and you provide it a Scott-encoded one.
That sounds like the possible problem. Is there a way how to modify the parameter application to be data-encoded instead of the scott encoded one?
compiledFoo :: CompiledCode UntypedValidator
compiledFoo = compiledFooUnapplied `PlutusTx.applyCode` PlutusTx.liftCode FooScriptParams {a = 100}
Is there a way how to modify the parameter application to be data-encoded instead of the scott encoded one?
No, we do not support Data
-encoded data in any way, it's Aiken's thing. I know @michaelpj has strong opinions about it. Basically, it's just super extra inefficient to encode data using Data
.
If you really need such a thing, your best bet is probably to compile to SOPs using our most recent release and then convert SOPs to Data
, shouldn't be too hard. But I don't know how Aiken encodes data, so perhaps it makes sense for you to request such functionality from Aiken people.
I'll take a look at the provided file shortly, thanks for sharing.
So this is the decoded program:
The lambda that you apply is the one binding i_8
. i_8
is expected to be a Data
object with an Integer
in its single constructor, i.e. this all confirms my hypothesis.
I do not see what the Plutus team can do here, I don't think we're going to support converting SOPs to Data in any observable future (we might decide to do that if we end up implementing a fancy ScriptContext
encoding or something). @michaelpj please verify this when you're back.
Hence I'm closing the issue, do feel free to reopen if you disagree.
Thank you very much for your insights again 🙌 I really appreciate it.
Happy to help!
No, we do not support Data-encoded data in any way, it's Aiken's thing. I know @michaelpj has strong opinions about it. Basically, it's just super extra inefficient to encode data using Data.
I mean, it's stupid and very slow, but I think we could support this as a datatype compilation mode now. Although I would mostly use it to show how bad it is :joy:
I mean, it's stupid and very slow, but I think we could support this as a datatype compilation mode now. Although I would mostly use it to show how bad it is joy
OK, if there's a serious consideration for us to do it, then I'm reopening this issue.
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:
Then using the following transformation to named deBruijn:
aiken build --uplc
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:Actual Result
Now when executing the
compiledFoo
from the steps to reproduce, I get the following error:Where the
(delay (\i_i0 -> i_i1 100))) []
seems to be the encodedFooScriptParams
. 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