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

Updating rust-version going forward #1311

Assignees

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Jan 2, 2024

I think we need to discuss the plan for the minimum supported rust version of crates, and our testing plan around rust versions, now that Protocol 20 is released.

Context

Rust binaries are built with whatever version of Rust is installed in most cases. Rust products are typically pinned to a "channel" of Rust, such as "stable" rather than a specific version. But a rust version can be pinned for building by specifying it in rust-toolchain.toml or by simply installing only that version of Rust.

Rust libraries are built with whatever version of Rust is installed, and libraries can specify a minimum supported rust version (MSRV). If a library requires v1.75 and v1.74 is installed, an error occurs blocking builds. There is no concept of a maximum supported rust version.

Rust releases rarely involve backporting to past stable releases. Bugs get fixed in the next stable release.

What we're doing now

The status quo is that we track the latest released rust version immediately upon its release. By tracked, I mean we use the latest version in our CI, and we require at least the version we tested with at release. We require the latest version by specifying it in the rust-version field of all of the crates' Cargo.toml files which is snapshotted when the crate is published to crates.io.

The existing plan has some advantages:

  • Everyone developing on the crates is building with the same version of rust across the entire stack.
  • Everyone is building locally with the same version we use in CI.
  • Everyone can use the latest in tooling which is constantly being improved (e.g. rust-analyzer).
  • If important bugs/security-bugs/features are released in a new version of Rust, it's easy to benefit from them with a small diff.
  • New users are likely to pick the latest version of Rust, not the version of Rust we tested libs when at release, and so by upgrading immediately we are also testing our stuff asap with what others are using.

The existing plan wasn't heavily discussed, but it was motivated by the benefits above.

The existing plan isn't perfect:

  • There's no guarantee that the version of rust people use with the Rust SDK will be the same version we tested with. We released all the crates having tested them with Rust v1.74, but folks are likely already using the Rust SDK and Env with Rust v1.75. But per the benefit above, because we update immediately we start running our tests on new versions quickly and if we detected a test breakage we could address that in a patch release.
  • If we released a minor/patch of stellar-core, we might need to update the Rust version it uses if a lib was updated already, which is updating a dependency in a minor/patch release. Arguably one of the most tested dependencies in our dep graph though.
  • If we released a minor/patch of Rust SDK and had updated the Rust version, folks might need to update their Rust version. Some organizations won't tolerate updating toolchains as quickly.

Alternative for moving forward

Set MSRV of crates to v1.74, run CI with v1.74, and pin stellar-core to v1.74 to minimize change.

Core Ubuntu releases would be using a build of Env that is as consistent as can be with past builds. Source and Homebrew tap builds of Core may not use v1.74. We won't be doing any testing of core with newer versions of Rust with existing Core CI.

Contract and app developers who have started developing won't need to update their rust-version when they update minor/patch versions of the Rust SDK, Env, Stellar XDR lib, etc. We'd probably need to test the lib releases with both v1.74 and the latest release to catch breakages but those additional CI runs would be parallel.

If a meaningful bug or security-bug is released, we may want to re-release with newer versions of Rust, and bump the MSRV if it's particularly meaningful to core functionality of the libs.

Changes required:

  • Remove the update rust-version job from each repo
  • Change CI in all Rust repos to build and test with both the MSRV and latest stable
  • Change any product binaries to utilize rust-toolchain.toml to pin to a version they decide to use (prob v1.74 for stellar-core)

Thoughts

I think we should start doing the alternative. I think down the road there will be folks that are disrupted by us doing MSRV updates in minor/patch releases, particularly larger organizations that have rules around what toolchains they use. It also hands control over what version to release with to products (e.g. stellar-core) and libraries get used in a range of versions anyway. Devs can also still use newer versions of Rust and tooling locally on the Rust libs.

Whichever way we go I'd like to document what we're doing once we make a decision.

cc @graydon @MonsieurNicolas @anupsdf

@leighmcculloch
Copy link
Member Author

leighmcculloch commented Jan 4, 2024

I've implemented the suggested alternative flow for the stellar-xdr lib:

I was motivated to implement it because that repo uses clippy in CI and with the new rust just released clippy is failing. So it was an easy two problems one solution to pin CI to run clippy on the msrv for now.

This ☝🏻 can serve as a example and reference to what we'd need to do elsewhere if we decided to change what we're doing.

@leighmcculloch leighmcculloch self-assigned this Jan 4, 2024
@graydon
Copy link
Contributor

graydon commented Jan 8, 2024

I concur with your suggestion here. Fwiw stellar-core already pins to channel = "1.74" in rust-toolchain.toml.

@leighmcculloch
Copy link
Member Author

leighmcculloch commented Jan 8, 2024

With @MonsieurNicolas's comment in slack and @graydon's comment, I'm going to move forward with this approach then.

Applications will need to make their own decision, they can release with any version of Rust they want that's greater than the env/sdk's MSRV:

Libraries will need updating using the same pattern that is in use in stellar/rs-stellar-xdr#341:

@leighmcculloch
Copy link
Member Author

I suggest for anything that isn't stellar-core, we should probably leave the rust-toolchain.toml files set to stable and allow them to be released with latest stable. They don't carry the same divergence risk (except maybe preflight to some degree) but all our Rust project are retested before release in any case.

github-merge-queue bot pushed a commit that referenced this issue Jan 10, 2024
### What
Build and test the MSRV and latest.

### Why
For #1311
github-merge-queue bot pushed a commit to stellar/rs-soroban-sdk that referenced this issue Jan 10, 2024
### What
Build and test the MSRV and latest

### Why
For stellar/rs-soroban-env#1311
leighmcculloch added a commit to stellar/soroban-example-dapp that referenced this issue Jan 11, 2024
Build and test the MSRV and latest
leighmcculloch added a commit to stellar/soroban-example-dapp that referenced this issue Jan 11, 2024
spotlight301 pushed a commit to spotlight301/Dapp-Soro that referenced this issue Sep 30, 2024
Build and test the MSRV and latest
spotlight301 pushed a commit to spotlight301/Dapp-Soro that referenced this issue Sep 30, 2024
joaovmp pushed a commit to joaovmp/Soroban_dapp that referenced this issue Oct 23, 2024
Build and test the MSRV and latest
joaovmp pushed a commit to joaovmp/Soroban_dapp that referenced this issue Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment