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

Verify Math Floating Point consistency #6448

Open
mhofman opened this issue Oct 13, 2022 · 4 comments
Open

Verify Math Floating Point consistency #6448

mhofman opened this issue Oct 13, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@mhofman
Copy link
Member

mhofman commented Oct 13, 2022

In endojs/endo#1319 we note that Math's floating point operations may provide slightly different results depending on the engine / OS / architecture. While we may be immune from the first given we're currently relying on the XS engine, the second and third point may differ between validators. Also the XS engine will need updates and while we have a story about managing updates with potential execution differences, we should actually ensure no Math based divergences sneaks into patch updates.

One item may be to add a test similar to fingerprinting with the expected values hardcoded to detect any such divergences.

@mhofman mhofman added the enhancement New feature or request label Oct 13, 2022
@warner
Copy link
Member

warner commented Oct 13, 2022

We might add a unit test to agoric-sdk that enforces what we think is the majority behavior, and declare that validators must run on a platform that passes the unit test suite. Or we might add a quick check at runtime which crashes early if the non-majority behavior is detected.

Of course, if the difference is visible between an amd64 linux host and an aarch64 M1 Mac laptop, then I'm gonna ask for a better mitigation scheme, because I like being able to run our tests on my own machine :)

@mhofman
Copy link
Member Author

mhofman commented Jan 10, 2024

From memory, I believe we looked into this and that XS relies on the OS stdlib and the CPU for some of these operations, which means the result could diverge between platforms. While we only officially support Linux on x64 for operating validators, even in that mode there could be divergences. We should get xsnap to adopt a library like fdlibm to prevent this potential source of divergence.

@mhofman
Copy link
Member Author

mhofman commented Jan 10, 2024

I have verified that some results of the fingerprint test above differ between an x64 machine and an arm64 machine.

@mhofman
Copy link
Member Author

mhofman commented Jan 29, 2024

Moddable has an experiment using fdlibm for more Math operations, solely through headers defines in the host app (xsnap-worker in our case)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants