stellar / rs-soroban-env

Rust environment for Soroban contracts.
Apache License 2.0
60 stars 40 forks source link

Updating rust-version going forward #1311

Closed leighmcculloch closed 8 months ago

leighmcculloch commented 8 months ago

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:

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

The existing plan isn't perfect:

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:

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 commented 8 months ago

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.

graydon commented 8 months ago

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

leighmcculloch commented 8 months ago

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 https://github.com/stellar/rs-stellar-xdr/pull/341:

leighmcculloch commented 8 months ago

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.