-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add rust-version field to solana-program to prevent the accidental use of unsupported platform-tools versions #32232
Conversation
6cb677c
to
ff01150
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omg thank you
Cargo.toml
Outdated
@@ -120,6 +120,7 @@ repository = "https://github.com/solana-labs/solana" | |||
homepage = "https://solanalabs.com/" | |||
license = "Apache-2.0" | |||
edition = "2021" | |||
rust-version = "1.69.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, here's the info about this field: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
Actually sorry, please hold. I realized this is perhaps not quite right. It's unfortunately not always the case that the Rust stable version we're using for building the validator is the same as Rust version that |
platform-tools are upgraded fairly often. However, it takes several weeks to do an upgrade, so it’s impractical to upgrade platform-tools to every stable release. Usually I skip 2-3 releases between upgrades. Monorepo update to use a new version of rust is much simpler and a lot quicker on the other hand. Also on-chain programs usually don’t need the latest rust features so much as may be desirable for the native code. |
Why does it take so long to do an upgrade? Are there typically a large number of merge conflicts? |
The tools consist of 5 components: llvm, compiler-builtins, rust compiler, rust standard libraries, and cargo. Compilers and cargo are relatively easy to upgrade. Rust standard libraries upgrade takes most of the time and labor. The process of reapplying our patches is not fully mechanical. Often rust libraries internal implementations change substantially and it takes time to understand how this affects our patches. When a new release introduces some incompatibility and it causes frictions with dependency crates that solana SDK uses it makes senses to upgrade platform-tools urgently to that release of rust, but to keep in sync with the version of rust that the native solana code uses, seems unnecessary labor. |
Ok bringing this out of draft! There's been some changes to my previous approach. Now I'm only attempting to solve the problem of programs being accidentally built with an older platform-tools here, due to the fact that we are currently unable to guarantee rust version consistency between the SBF and the native archs.
|
I think in the past there was at least one brief occasion when platform-tools were upgraded to newer rust version before solana monorepo started using that rust version for the native code. It's probably not going to happen often, if ever again. |
here's the new output when one tries to build
|
ci/test-stable.sh
Outdated
platform_tools_rust_version=$(sdk/sbf/dependencies/platform-tools/rust/bin/rustc --version) | ||
platform_tools_rust_version=$(echo "$platform_tools_rust_version" | cut -d\ -f2) # Remove "rustc " prefix from a string like "rustc 1.68.0-dev" | ||
platform_tools_rust_version=$(echo "$platform_tools_rust_version" | cut -d- -f1) # Remove "-dev" suffix from a string like "1.68.0-dev" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ftr: I broke this up into multiple lines because bash comments and line continuations have conflicting syntax 😭
eg:
foo=$(this \ # THIS COMMENT WON'T WORK
and # AND ALSO THIS COMMENT WON'T WORK \
that \
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#32254 is looking nice, I'll probably rebase this sucker on that PR once it lands and that'll clean up all this ugly bash!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, now using the new fancy output from cargo build-sbf --version
. Thanks @dmakarov!
@brooksprumo or @yihau - this is ready for review now 🥺
Codecov Report
@@ Coverage Diff @@
## master #32232 +/- ##
=========================================
- Coverage 82.0% 82.0% -0.1%
=========================================
Files 772 772
Lines 209322 209322
=========================================
- Hits 171729 171704 -25
- Misses 37593 37618 +25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you <3. I love this native solution for inconsistent version!
I'm thinking do we want to put this one to test-sanity
step. but current version works for me 😈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…ntal use of unsupported platform-tools versions (backport of #32232) (#32262) Add rust-version field to solana-program to prevent the accidental use of unsupported platform-tools versions (#32232) Require the rust-version of solana-program crate to match platform-tools (cherry picked from commit f202ccb) Co-authored-by: mvines <mvines@gmail.com>
…e of unsupported platform-tools versions (solana-labs#32232) Require the rust-version of solana-program crate to match platform-tools
…e of unsupported platform-tools versions (solana-labs#32232) Require the rust-version of solana-program crate to match platform-tools
People are accidentally using unsupported versions of rust when building solana programs.
A recent notable occurrence of this is #32133, where people are trying to build solana-program 1.16.1 without installing the 1.16-version of the platform-tools. The resulting error is not obvious and hard to debug. With this patch instead they'll get an immediate error from
cargo
indicating they're using an unsupported rustc versionFixes #32133