anoma / juvix

A language for intent-centric and declarative decentralised applications
https://docs.juvix.org
GNU General Public License v3.0
457 stars 53 forks source link

The test "invoke an exported function using Anoma _validate_tx signature" fails #1475

Closed lukaszcz closed 1 year ago

lukaszcz commented 2 years ago

The test fails on my machine and no hint is provided as to how to make it go through. If this is not real bug, then what should I do to make the test suite go through?

I get:

       Invoke an exported function using Anoma _validate_tx signature:      (node:91330) UnhandledPromiseRejectionWarning: TypeError: wasm function signature contains illegal type
    at /tmp/extra-dir-20783963321672/input.js:6:45
(node:91330) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:91330) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
1c1
< ""
---
> "1n\n"

End diff
paulcadman commented 2 years ago

I can't reproduce this issue. What version of node are you running on your machine? I'm running v18.7.0 and CI is running v16.17.0 on Mac and linux agents.

If you compile the test file manually what is the signature of the _validate_tx function? so we can try to figure out what the illegal type is (the _validate_tx function should only involve the I64 Wasm type):

$ cd tests/positive/MiniC/AlwaysValidVP
$ juvix compile -r standalone Input.juvix
$ wasmer inspect Input.wasm
Type: wasm
Size: 1.4 KB
Imports:
  Functions:
  Memories:
  Tables:
  Globals:
Exports:
  Functions:
    "encodeBool": [I32] -> [I64]
    "_validate_tx": [I64, I64, I64, I64, I64, I64, I64, I64] -> [I64]
  Memories:
    "memory": not shared (2 pages..)
  Tables:
  Globals:
lukaszcz commented 2 years ago

I'll check this next week. It only fails on my Ubuntu laptop, works fine on the Mac.

lukaszcz commented 2 years ago

When I try juvix compile -r standalone Input.juvix I get:

/home/heliax/Documents/juvix/tests/positive/MiniC/AlwaysValidVP/.juvix-build/Input.c:55:16: warning: unknown attribute 'export_name' ignored [-Wunknown-attributes]
__attribute__((export_name("encodeBool")))
               ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/heliax/Documents/juvix/tests/positive/MiniC/AlwaysValidVP/.juvix-build/Input.c:57:16: warning: unknown attribute 'export_name' ignored [-Wunknown-attributes]
__attribute__((export_name("_validate_tx")))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
/usr/bin/ld: /lib/x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
paulcadman commented 2 years ago

I'm sorry for the delay in replying to this!

Now that the native target is the default you need to pass the -t wasm flag to the compiler for the Wasm files, the native target assumes that a main function is defined in the root module.

juvix compile -t wasm -r standalone Input.juvix
lukaszcz commented 2 years ago

Inspecting gives:

Type: wasm
Size: 2.1 KB
Imports:
  Functions:
  Memories:
  Tables:
  Globals:
Exports:
  Functions:
    "encodeBool": [I32] -> [I64]
    "_validate_tx": [I64, I64, I64, I64, I64, I64, I64, I64] -> [I64]
  Memories:
    "memory": not shared (2 pages..)
  Tables:
  Globals:

which seems exactly the same as your inspecting output. Still, the test fails.