Open christian-rogobete opened 1 year ago
I'm not familiar with the AssemblyScript SDK and in any event I think this is an issue to take up with that SDK, not the soroban environment crate.
Apologies, I misunderstood -- this bug is a request to change the env to provide missing hooks that the AS SDK needs, I guess?
Hello @graydon,
Thank you for looking into this.
I'm not sure if we need the missing hooks, because I am unable to find out why the validation fails. Info about the runtime is described here. I am using stub
:
... stub runtime does not provide a garbage collector at all and never frees (simple bump allocation, extremely small)....
And the hooks, described in the docs as interface are not needed, as least not in this case.
I created a very simple contract to reduce as much overhead as possible:
export function testStr(): val.RawVal {
return 21 as val.RawVal;
}
This gives me a wasm as follows: nostr-stub.wat. Which is perfectly working.
But if I add the string op:
export function testStr(): val.RawVal {
let a = "a" + "b"
return 21 as val.RawVal;
}
It gives me str-stub.wat. Which looks fine for me, but fails with VM Validation error.
As you can see no hooks are used. Therefore I am not sure if we need the hooks. Unfortunately I can not find out why the validation fails.
I also tried with the option --exportRuntime
. In this case it wants to use the env hooks. See: export.wat. But the wasm is huge ... and I would like to avoid that.
Wasm files attached: as-wasm.zip
in AS code leads to following error when executed in the
soroban-cli
:The easiest way to reproduce, is to use the files that I attached to this issue.
They are compiled from the example that I prepared here: https://github.com/Soneso/as-soroban-examples/tree/main/some_issues
Code of the function
add_str
from the example:I have compiled the example and attached following files in this issue:
noadd.wasm
andnoadd.wat
(line is commented in the AS code above before compilation)addstr.wasm
andaddstr.wat
(line is uncommented in the AS code above before compilation)One can call their
add_str
function as follows:and
issue_addstr_files.zip
see also: https://github.com/stellar/sorobanathon/discussions/25