Skip to content

Commit

Permalink
Fix breaking changes in latest stable and nightly rust (#1375)
Browse files Browse the repository at this point in the history
### What

Pin the version of nightly in builds and CI, and make a few minor
changes.

### Why

The version is pinned because there's a bug in the next version of
nightly that we can't work around. The bug is:
- rust-lang/rust#131643

The other minor changes that are to prepare for updating to the next
nightly and were required by it when using it.

### Known limitations

N/A
  • Loading branch information
leighmcculloch authored Oct 23, 2024
1 parent b924717 commit fdd836d
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 136 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
# TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed.
- run: rustup install nightly-2024-10-10
- uses: stellar/binaries@v15
with:
name: cargo-fuzz
Expand All @@ -143,15 +144,17 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
# TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed.
- run: rustup install nightly-2024-10-10
- run: make doc

readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
# TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed.
- run: rustup install nightly-2024-10-10
- run: make readme
- run: git add -N . && git diff HEAD --exit-code

Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ CARGO_DOC_ARGS?=--open

doc: fmt
cargo test --doc -p soroban-sdk -p soroban-sdk-macros --features testutils,hazmat
# TODO: Upgrade to latest nightly after problem that was introduced in nightly-2024-02-05 (https://github.com/dalek-cryptography/curve25519-dalek/issues/618) is resolved.
cargo +nightly doc -p soroban-sdk --no-deps --all-features $(CARGO_DOC_ARGS)
# TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed.
cargo +nightly-2024-10-10 doc -p soroban-sdk --no-deps --all-features $(CARGO_DOC_ARGS)

test: fmt build
cargo hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test
Expand All @@ -24,20 +24,22 @@ check: build fmt
cargo hack check --release --target wasm32-unknown-unknown

build-fuzz:
cd tests/fuzz/fuzz && cargo +nightly fuzz check
# TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed.
cd tests/fuzz/fuzz && cargo +nightly-2024-10-10 fuzz check

readme:
# TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed.
cd soroban-sdk \
&& cargo +nightly rustdoc -- -Zunstable-options -wjson \
&& cargo +nightly-2024-10-10 rustdoc -- -Zunstable-options -wjson \
&& cat ../target/doc/soroban_sdk.json \
| jq -r '.index[.root].docs' \
| jq -r '.index[.root|tostring].docs' \
> README.md

watch:
cargo watch --clear --watch-when-idle --shell '$(MAKE)'

watch-doc:
cargo +nightly watch --clear --watch-when-idle --shell '$(MAKE) doc CARGO_DOC_ARGS='
cargo +nightly-2024-10-10 watch --clear --watch-when-idle --shell '$(MAKE) doc CARGO_DOC_ARGS='

fmt:
cargo fmt --all
Expand Down
5 changes: 3 additions & 2 deletions soroban-sdk/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};

pub mod bls12_381;
/// A BytesN<N> generated by a cryptographic hash function.
/// A `BytesN<N>` generated by a cryptographic hash function.
///
/// The `Hash<N>` type contains a `BytesN<N>` and can only be constructed in
/// contexts where the value has been generated by a secure cryptographic
Expand Down Expand Up @@ -177,7 +177,8 @@ impl Crypto {
CryptoHazmat::new(env).secp256r1_verify(public_key, &message_digest.0, signature)
}

/// Get a [Bls12_381] for accessing the bls12-381 functions.
/// Get a [Bls12_381][bls12_381::Bls12_381] for accessing the bls12-381
/// functions.
pub fn bls12_381(&self) -> bls12_381::Bls12_381 {
bls12_381::Bls12_381::new(self.env())
}
Expand Down
4 changes: 2 additions & 2 deletions soroban-sdk/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{env::internal, unwrap::UnwrapInfallible, BytesN, Env, TryIntoVal};
/// Ledger retrieves information about the current ledger.
///
/// For more details about the ledger and the ledger header that the values in the Ledger are derived from, see:
/// - https://developers.stellar.org/docs/learn/encyclopedia/network-configuration/ledger-headers
/// - <https://developers.stellar.org/docs/learn/encyclopedia/network-configuration/ledger-headers>
///
/// ### Examples
///
Expand Down Expand Up @@ -83,7 +83,7 @@ impl Ledger {
/// 00:00:00 UTC.
///
/// For more details see:
/// - https://developers.stellar.org/docs/learn/encyclopedia/network-configuration/ledger-headers#close-time
/// - <https://developers.stellar.org/docs/learn/encyclopedia/network-configuration/ledger-headers#close-time>
pub fn timestamp(&self) -> u64 {
internal::Env::get_ledger_timestamp(self.env())
.unwrap_infallible()
Expand Down
Loading

0 comments on commit fdd836d

Please sign in to comment.