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

Update to rust 1.44.0 #10585

Merged
merged 16 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bench-tps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn main() {
// Sort keypairs so that do_bench_tps() uses the same subset of accounts for each run.
// This prevents the amount of storage needed for bench-tps accounts from creeping up
// across multiple runs.
keypairs.sort_by(|x, y| x.pubkey().to_string().cmp(&y.pubkey().to_string()));
keypairs.sort_by_key(|x| x.pubkey().to_string());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sakridge, @jstarry: I wonder why this is sorted in terms of base58...? Well, why .to_string() is needed? Plain binary byte-for-byte ordering isn't enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryoqun I can't think of a good reason. binary comparison sounds good!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this as a separate pr for back-porting.

(keypairs, None)
} else {
generate_and_fund_keypairs(
Expand Down
6 changes: 6 additions & 0 deletions ci/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ if [[ -z "$SOLANA_DOCKER_RUN_NOSETUID" ]]; then
ARGS+=(--user "$(id -u):$(id -g)")
fi

if [[ -n $SOLANA_ALLOCATE_TTY ]]; then
# Colored output, progress bar and Ctrl-C:
# https://stackoverflow.com/a/41099052/10242004
ARGS+=(--interactive --tty)
fi

# Environment variables to propagate into the container
ARGS+=(
--env BUILDKITE
Expand Down
3 changes: 2 additions & 1 deletion ci/docker-rust-nightly/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM solanalabs/rust:1.43.0
FROM solanalabs/rust:1.44.0
ARG date

RUN set -x \
&& rustup install nightly-$date \
&& rustup component add clippy --toolchain=nightly-$date \
&& rustup component add rustfmt --toolchain=nightly-$date \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& rustup show \
&& rustc --version \
&& cargo --version \
Expand Down
10 changes: 7 additions & 3 deletions ci/docker-rust-nightly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ Docker image containing rust nightly and some preinstalled crates used in CI.

This image may be manually updated by running `CI=true ./build.sh` if you are a member
of the [Solana Labs](https://hub.docker.com/u/solanalabs/) Docker Hub
organization, but it is also automatically updated periodically by
[this automation](https://buildkite.com/solana-labs/solana-ci-docker-rust-nightly).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find this job?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was stale information

organization.

## Moving to a newer nightly

NOTE: Follow instructions in docker-rust/README.md before this when updating the stable
rust version as well.

We pin the version of nightly (see the `ARG nightly=xyz` line in `Dockerfile`)
to avoid the build breaking at unexpected times, as occasionally nightly will
introduce breaking changes.

To update the pinned version:
1. Edit `Dockerfile` to match the desired stable rust version to base on if needed.
1. Run `ci/docker-rust-nightly/build.sh` to rebuild the nightly image locally,
or potentially `ci/docker-rust-nightly/build.sh YYYY-MM-DD` if there's a
specific YYYY-MM-DD that is desired (default is today's build).
Check https://rust-lang.github.io/rustup-components-history/ for build
status
1. Update `ci/rust-version.sh` to reflect the new nightly `YYY-MM-DD`
1. Run `SOLANA_DOCKER_RUN_NOSETUID=1 ci/docker-run.sh --nopull solanalabs/rust-nightly:YYYY-MM-DD ci/test-coverage.sh`
1. Run `SOLANA_ALLOCATE_TTY=1 SOLANA_DOCKER_RUN_NOSETUID=1 ci/docker-run.sh --nopull solanalabs/rust-nightly:YYYY-MM-DD ci/test-checks.sh`
and `SOLANA_ALLOCATE_TTY=1 SOLANA_DOCKER_RUN_NOSETUID=1 ci/docker-run.sh --nopull solanalabs/rust-nightly:YYYY-MM-DD ci/test-coverage.sh [args]...`
to confirm the new nightly image builds. Fix any issues as needed
1. Run `docker login` to enable pushing images to Docker Hub, if you're authorized.
1. Run `CI=true ci/docker-rust-nightly/build.sh YYYY-MM-DD` to push the new nightly image to dockerhub.com.
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note: when the rust version is changed also modify
# ci/rust-version.sh to pick up the new image tag
FROM rust:1.43.0
FROM rust:1.44.0

# Add Google Protocol Buffers for Libra's metrics library.
ENV PROTOC_VERSION 3.8.0
Expand Down
6 changes: 5 additions & 1 deletion ci/docker-rust/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Docker image containing rust and some preinstalled packages used in CI.

NOTE: Recreate rust-nightly docker image after this when updating the stable rust
version! Both of docker images must be updated in tandem.

This image manually maintained:
1. Edit `Dockerfile` to match the desired rust version
2. Run `./build.sh` to publish the new image, if you are a member of the [Solana
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I didn't know it's not needed to manually increment those numbers... ;)

1. Run `docker login` to enable pushing images to Docker Hub, if you're authorized.
1. Run `./build.sh` to publish the new image, if you are a member of the [Solana
Labs](https://hub.docker.com/u/solanalabs/) Docker Hub organization.

4 changes: 2 additions & 2 deletions ci/rust-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION"
else
stable_version=1.43.0
stable_version=1.44.0
fi

if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION"
else
nightly_version=2020-04-23
nightly_version=2020-06-10
fi


Expand Down
7 changes: 5 additions & 2 deletions ci/test-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ echo --- build environment
export RUST_BACKTRACE=1
export RUSTFLAGS="-D warnings"

if _ scripts/cargo-for-all-lock-files.sh +"$rust_nightly" check --locked --all-targets; then
# Exclude --benches as it's not available in rust stable yet
if _ scripts/cargo-for-all-lock-files.sh +"$rust_stable" check --locked --tests --bins --examples; then
true
else
check_status=$?
echo "Some Cargo.lock is outdated; please update them as well"
echo "Some Cargo.lock might be outdated; update them (or just be a compilation error?)"
echo "protip: you can use ./scripts/cargo-for-all-lock-files.sh [check|update] ..."
exit "$check_status"
fi
# Ensure nightly and --benches
_ scripts/cargo-for-all-lock-files.sh +"$rust_nightly" check --locked --all-targets

_ ci/order-crates-for-publishing.py
_ cargo +"$rust_stable" fmt --all -- --check
Expand Down
6 changes: 5 additions & 1 deletion ci/test-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ annotate() {
source ci/upload-ci-artifact.sh
source scripts/ulimit-n.sh

scripts/coverage.sh
scripts/coverage.sh "$@"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to do like this:

$ SOLANA_ALLOCATE_TTY=1 SOLANA_DOCKER_RUN_NOSETUID=1 ci/docker-run.sh --nopull solanalabs/rust-nightly:2020-06-15 ci/test-coverage.sh -p solana-sdk test_slot_duration_from_slots_per_year


if [[ -z $CI ]]; then
Copy link
Contributor Author

@ryoqun ryoqun Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exit
fi

report=coverage-"${CI_COMMIT:0:9}".tar.gz
mv target/cov/report.tar.gz "$report"
Expand Down
2 changes: 1 addition & 1 deletion multinode-demo/validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ setup_validator_accounts() {
return 0
}

rpc_url=$($solana_gossip rpc-url --entrypoint "$gossip_entrypoint")
rpc_url=$($solana_gossip rpc-url --timeout 180 --entrypoint "$gossip_entrypoint")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, was hard to debug.... Well, this depended on exact build timing. ;)

Greatly increase from the default 15 seconds to 180 to prevent another sorrow. ;)


[[ -r "$identity" ]] || $solana_keygen new --no-passphrase -so "$identity"
[[ -r "$vote_account" ]] || $solana_keygen new --no-passphrase -so "$vote_account"
Expand Down
10 changes: 6 additions & 4 deletions sdk/src/timing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ pub fn years_as_slots(years: f64, tick_duration: &Duration, ticks_per_slot: u64)

/// From slots per year to slot duration
pub fn slot_duration_from_slots_per_year(slots_per_year: f64) -> Duration {
// Regarding division by zero potential below: for some reason, if Rust stores an `inf` f64 and
Copy link
Contributor Author

@ryoqun ryoqun Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CriesofCarrots This is added by https://github.com/solana-labs/solana/pull/7130/files#diff-826aa0353ee517a070e3c98cc61423eaR43

FYI, rust (stable rust 1.45+; this will be affected in our nightly CI builds after this pr) is actually fixing this behavior: https://github.com/rust-lang/rust/blob/master/RELEASES.md#compatibility-notes

I'm preserving the current behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, thanks!

// then converts it to a u64 on use, it always returns 0, as opposed to std::u64::MAX or any
// other huge value
let slot_in_ns = (SECONDS_PER_YEAR * 1_000_000_000.0) / slots_per_year;
// Recently, rust changed from infinity as usize being zero to 2^64-1; ensure it's zero here
let slot_in_ns = if slots_per_year != 0.0 {
(SECONDS_PER_YEAR * 1_000_000_000.0) / slots_per_year
} else {
0.0
};
Duration::from_nanos(slot_in_ns as u64)
}

Expand Down