Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Floats ending in .0 converted to integers #155

Closed
bgins opened this issue Mar 4, 2024 · 0 comments · Fixed by ipvm-wg/homestar#595
Closed

[bug]: Floats ending in .0 converted to integers #155

bgins opened this issue Mar 4, 2024 · 0 comments · Fixed by ipvm-wg/homestar#595
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@bgins
Copy link

bgins commented Mar 4, 2024

Describe the bug

When converting a templated workflow to a Homestar workflow, values like 5.0 are converted integers like 5. In JavaScript, they are the same, but they are distinct when considered as WIT types.

To Reproduce

The Writing Functions blog post code generates some components that use float32 types. For example, the Rust sourced component has add and divide functions that implement a WIT with float32 types: https://github.com/everywhere-computer/writing-functions-blogpost-2024/blob/main/wit/math.wit.

Running the add workflow is probably the simplest test, but adapt the args to include a value like 5.0: https://github.com/everywhere-computer/writing-functions-blogpost-2024/blob/main/workflows/add.json.

This should fail with an error in the Homestar logs like:

ts=2024-03-04T21:25:08.909906Z level=error target=homestar_runtime::worker message="error in running task" subject=worker.run.task.err category=worker.run err="not able to run fn add for cid: bafyrmih3u5lcjxdxwcdd6e6srp4asihxvpepef7jmingens24dc3bi2qaa, in workflow bafyrmifpmy3dwkfasexrc4hq6tkfbh2plxh3dnmcjbfg6qtoi7z47sq4iy\n\nCaused by:\n    cannot execute wasm module: no compatible WIT type for Ipld structure: Integer(5)"

Expected behavior

Floats ending in .0 should be treated literally with the .0 preserved in the Homestar workflow.

Additional context

We did a quick experiment to see if we could avoid this issue with CBOR, but so far that has not been successful: https://github.com/bgins/cbor-float-test

@bgins bgins added bug Something isn't working help wanted Extra attention is needed labels Mar 4, 2024
zeeshanlakhani pushed a commit to ipvm-wg/homestar that referenced this issue Mar 5, 2024
# Description

Finish Ipld <=> Wit interpreter across all available Val/Types. 

fix: handle ints as floats in the interpreter (when given a float Wit
type).

Includes
  - skip notifications when there are no receivers
  - add logging in wasm/guest-fn test to web server integration test
- update Homestar-function(s) to use cargo-component 0.9 and update for
breaking changes
  - readme updates around cargo-component
  - const recursion/grow-only defaults for stacker
- remove most pattern-matching guards and move to nested matches in the
interpreter
  - newly generated test wasms (= cid updates)
  - move to location/module-path in logs (from updated tracing-logfmt)

## Closes

- Closes fission-codes/stack#155.
- Closes #61 and "finishes" our WIT <=> IPLD interpreter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants