Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

program execution: Rust 1.45 introduces incompatible math runtime behavior changes #10626

Closed
ryoqun opened this issue Jun 16, 2020 · 5 comments
Closed
Assignees
Milestone

Comments

@ryoqun
Copy link
Contributor

ryoqun commented Jun 16, 2020

Problem

Rust 1.45 will introduce incompatible math runtime behavior changes: https://github.com/rust-lang/rust/blob/master/RELEASES.md#compatibility-notes

In one sentence, (N/0.0) as {integer} is changed from 0 to {integer}::MAX.

In our codecase, this manifested 3 times already, caught via nightly test runs in #10585 and #10445. I think this is high occurance, worth to be aware of from this observation.

At worst, this might cause a cluster consensus loss due to different handling regarding rewards, fees, fork selection, and other token calculation with some edge cases, assuming a cluster comprised of differently-built binaries.

@jackcmay Also, smart contracts could be affected? (Well, dumb question, bpf supports floating number math??) (Quick googling tells me this is not the case...)

Proposed Solution

  • Don't go straightly to update 1.45. Let's see how the rust community handles the transition
  • Once more, go through any suspicious fdivs in our codebase? (But this couldn't cover our depending crates)
  • Build with 1.44 and 1.45 and mix them within a cluster? (= testnet)
@mvines mvines added this to the v1.3.0 milestone Jul 21, 2020
@mvines mvines modified the milestones: v1.3.0, v1.3.4 Aug 15, 2020
@joncinque joncinque modified the milestones: v1.3.4, v1.3.6 Aug 28, 2020
@oJshua oJshua modified the milestones: v1.3.8, v1.3.9 Sep 3, 2020
@mvines mvines modified the milestones: v1.3.9, v1.3.10 Sep 9, 2020
@ryoqun ryoqun modified the milestones: v1.3.10, v1.3.11 Sep 15, 2020
@mvines
Copy link
Contributor

mvines commented Sep 15, 2020

testnet has been running Rust 1.45.x since July, so I think we're ok here.

@mvines mvines closed this as completed Sep 15, 2020
@ryoqun ryoqun modified the milestones: v1.3.11, v1.3.10 Sep 15, 2020
@jackcmay
Copy link
Contributor

@ryoqun The BPF instruction set does not support floating-point math but LLVM provides compiler intrinsics that do so currently you can perform floating-point math in our programs (though we should probably explicitly disallow that. So as it stands if anyone is using floating-point math the incompatibility mentioned in this issue could affect program execution as we update our Rust-BPF versions

@jackcmay jackcmay reopened this Sep 15, 2020
@ryoqun ryoqun modified the milestones: v1.3.10, v1.3.12 Sep 15, 2020
@ryoqun
Copy link
Contributor Author

ryoqun commented Sep 15, 2020

Oh, let's update the milestone as well, then. :)

@mvines mvines changed the title Rust 1.45 introduces incompatible math runtime behavior changes program execution: Rust 1.45 introduces incompatible math runtime behavior changes Sep 16, 2020
@jackcmay
Copy link
Contributor

@ryoqun Looks like this is probably not an issue for BPF programs from a backward compatibility perspective. Programs built against the old toolchain are already immutable in their executable accounts. Any programs built against the new toolchain will be in new accounts.

@mvines mvines modified the milestones: v1.3.12, v1.3.13 Sep 20, 2020
@mvines mvines modified the milestones: v1.3.14, v1.3.16, v1.4.0 Oct 3, 2020
@mvines
Copy link
Contributor

mvines commented Oct 10, 2020

Anything we need to do here?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants