Skip to content

Bump MSRV to 1.85.0 #4002

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 7 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
fail-fast: false
matrix:
platform: [ self-hosted, windows-latest, macos-latest ]
toolchain: [ stable, beta, 1.63.0 ] # 1.63.0 is the MSRV for all crates but `lightning-transaction-sync`.
toolchain: [ stable, beta, 1.85.0 ] # 1.85.0 is the MSRV for all crates but `lightning-transaction-sync`.
exclude:
- platform: windows-latest
toolchain: 1.63.0
toolchain: 1.85.0
- platform: windows-latest
toolchain: beta
- platform: macos-latest
Expand All @@ -60,7 +60,7 @@ jobs:
shellcheck ci/*.sh -aP ci
shellcheck contrib/*.sh -aP contrib
- name: Set RUSTFLAGS to deny warnings
if: "matrix.toolchain == '1.63.0'"
if: "matrix.toolchain == '1.85.0'"
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
- name: Run CI script
shell: bash # Default on Winblows is powershell
Expand All @@ -71,7 +71,7 @@ jobs:
fail-fast: false
matrix:
platform: [ ubuntu-latest, macos-latest ]
toolchain: [ stable, beta, 1.75.0 ] # 1.75.0 is the MSRV for `lightning-transaction-sync`.
toolchain: [ stable, beta, 1.85.0 ]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout source code
Expand All @@ -80,7 +80,7 @@ jobs:
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
- name: Set RUSTFLAGS to deny warnings
if: "matrix.toolchain == '1.75.0'"
if: "matrix.toolchain == '1.85.0'"
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
- name: Enable caching for bitcoind
id: cache-bitcoind
Expand Down Expand Up @@ -236,17 +236,13 @@ jobs:
fuzz:
runs-on: self-hosted
env:
TOOLCHAIN: 1.63
TOOLCHAIN: 1.85
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
- name: Pin the regex dependency
run: |
cd fuzz && cargo update -p regex --precise "1.9.6" --verbose
cd write-seeds && cargo update -p regex --precise "1.9.6" --verbose
- name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
run: |
cd fuzz
Expand Down Expand Up @@ -275,7 +271,7 @@ jobs:
rustfmt:
runs-on: ubuntu-latest
env:
TOOLCHAIN: 1.63.0
TOOLCHAIN: 1.85.0
steps:
- name: Checkout source code
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ be covered by functional tests.
When refactoring, structure your PR to make it easy to review and don't
hesitate to split it into multiple small, focused PRs.

The Minimum Supported Rust Version (MSRV) currently is 1.63.0 (enforced by
The Minimum Supported Rust Version (MSRV) currently is 1.85.0 (enforced by
our GitHub Actions). We support reading serialized LDK objects written by any
version of LDK 0.0.99 and above. We support LDK versions 0.0.113 and above
reading serialized LDK objects written by modern LDK. Any expected issues with
Expand Down Expand Up @@ -124,7 +124,7 @@ display fine at any tab-length display setting. We use `rustfmt` to establish
uniform coding standards throughout the codebase. Please run

```bash
cargo +1.63.0 fmt
cargo +1.85.0 fmt
```

before committing and pushing any changes, as compliance will also be checked
Expand Down
3 changes: 0 additions & 3 deletions ci/check-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ CLIPPY() {
-A clippy::len_without_is_empty \
-A clippy::len_zero \
-A clippy::let_and_return \
-A clippy::manual_div_ceil `# to be removed once we hit MSRV 1.73.0` \
-A clippy::manual_filter \
-A clippy::manual_map \
-A clippy::manual_memcpy \
Expand Down Expand Up @@ -104,9 +103,7 @@ CLIPPY() {
-A clippy::unnecessary_unwrap \
-A clippy::unused_unit \
-A clippy::useless_conversion \
-A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` \
-A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` \
-A clippy::io_other_error `# to be removed once we hit MSRV 1.74` \
-A clippy::uninlined-format-args
}

Expand Down
28 changes: 2 additions & 26 deletions ci/ci-tests.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
#!/bin/bash
set -eox pipefail

RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
# Currently unused as we don't have to pin anything for MSRV:
#RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')

# Some crates require pinning to meet our MSRV even for our downstream users,
# which we do here.
# Further crates which appear only as dev-dependencies are pinned further down.
function PIN_RELEASE_DEPS {
# Starting with version 1.39.0, the `tokio` crate has an MSRV of rustc 1.70.0
[ "$RUSTC_MINOR_VERSION" -lt 70 ] && cargo update -p tokio --precise "1.38.1" --verbose

return 0 # Don't fail the script if our rustc is higher than the last check
}

PIN_RELEASE_DEPS # pin the release dependencies in our main workspace

# Starting with version 1.10.0, the `regex` crate has an MSRV of rustc 1.65.0.
[ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose

# The addr2line v0.21 crate (a dependency of `backtrace` starting with 0.3.69) relies on rustc 1.65
[ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p backtrace --precise "0.3.68" --verbose

# The once_cell v1.21.0 crate (a dependency of `proptest`) relies on rustc 1.70
[ "$RUSTC_MINOR_VERSION" -lt 70 ] && cargo update -p once_cell --precise "1.20.3" --verbose

# proptest 1.3.0 requires rustc 1.64.0
[ "$RUSTC_MINOR_VERSION" -lt 64 ] && cargo update -p proptest --precise "1.2.0" --verbose

# parking_lot 0.12.4 requires rustc 1.64.0
[ "$RUSTC_MINOR_VERSION" -lt 64 ] && cargo update -p parking_lot --precise "0.12.3" --verbose

# parking_lot_core 0.9.11 requires rustc 1.64.0
[ "$RUSTC_MINOR_VERSION" -lt 64 ] && cargo update -p parking_lot_core --precise "0.9.10" --verbose

# lock_api 0.4.13 requires rustc 1.64.0
[ "$RUSTC_MINOR_VERSION" -lt 64 ] && cargo update -p lock_api --precise "0.4.12" --verbose

export RUST_BACKTRACE=1

echo -e "\n\nChecking the workspace, except lightning-transaction-sync."
Expand Down Expand Up @@ -64,7 +41,6 @@ cargo test --verbose --color always

echo -e "\n\nTesting upgrade from prior versions of LDK"
pushd lightning-tests
[ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose
cargo test
popd

Expand Down
9 changes: 2 additions & 7 deletions ci/ci-tx-sync-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
set -eox pipefail

RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
# Currently unused as we don't have to pin anything for MSRV:
#RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')

pushd lightning-transaction-sync

Expand All @@ -14,12 +15,6 @@ function PIN_RELEASE_DEPS {

PIN_RELEASE_DEPS # pin the release dependencies

# Starting with version 0.5.11, the `home` crate has an MSRV of rustc 1.81.0.
[ "$RUSTC_MINOR_VERSION" -lt 81 ] && cargo update -p home --precise "0.5.9" --verbose

# Starting with version 1.2.0, the `idna_adapter` crate has an MSRV of rustc 1.81.0.
[ "$RUSTC_MINOR_VERSION" -lt 81 ] && cargo update -p idna_adapter --precise "1.1.0" --verbose

export RUST_BACKTRACE=1

echo -e "\n\nChecking Transaction Sync Clients with features."
Expand Down
34 changes: 9 additions & 25 deletions lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ impl<
G,
&'a (dyn UtxoLookup + Send + Sync),
L,
> where
>
where
L::Target: Logger,
{
/// Initializes a new [`GossipSync::Rapid`] variant.
Expand All @@ -276,7 +277,8 @@ impl<'a, L: Deref>
&'a NetworkGraph<L>,
&'a (dyn UtxoLookup + Send + Sync),
L,
> where
>
where
L::Target: Logger,
{
/// Initializes a new [`GossipSync::None`] variant.
Expand Down Expand Up @@ -335,7 +337,7 @@ pub(crate) mod futures_util {
use core::future::Future;
use core::marker::Unpin;
use core::pin::Pin;
use core::task::{Poll, RawWaker, RawWakerVTable, Waker};
use core::task::Poll;
pub(crate) struct Selector<
A: Future<Output = ()> + Unpin,
B: Future<Output = ()> + Unpin,
Expand Down Expand Up @@ -426,24 +428,6 @@ pub(crate) mod futures_util {
}
}

// If we want to poll a future without an async context to figure out if it has completed or
// not without awaiting, we need a Waker, which needs a vtable...we fill it with dummy values
// but sadly there's a good bit of boilerplate here.
fn dummy_waker_clone(_: *const ()) -> RawWaker {
RawWaker::new(core::ptr::null(), &DUMMY_WAKER_VTABLE)
}
fn dummy_waker_action(_: *const ()) {}

const DUMMY_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(
dummy_waker_clone,
dummy_waker_action,
dummy_waker_action,
dummy_waker_action,
);
pub(crate) fn dummy_waker() -> Waker {
unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &DUMMY_WAKER_VTABLE)) }
}

enum JoinerResult<E, F: Future<Output = Result<(), E>> + Unpin> {
Pending(Option<F>),
Ready(Result<(), E>),
Expand Down Expand Up @@ -556,7 +540,7 @@ pub(crate) mod futures_util {
}
}
use core::task;
use futures_util::{dummy_waker, Joiner, OptionalSelector, Selector, SelectorOutput};
use futures_util::{Joiner, OptionalSelector, Selector, SelectorOutput};

/// Processes background events in a future.
///
Expand Down Expand Up @@ -948,7 +932,7 @@ where
// below. This will get it moving but won't block us for too long if the underlying
// future is actually async.
use core::future::Future;
let mut waker = dummy_waker();
let mut waker = task::Waker::noop();
let mut ctx = task::Context::from_waker(&mut waker);
match core::pin::Pin::new(&mut fut).poll(&mut ctx) {
task::Poll::Ready(res) => futures.set_a_res(res),
Expand Down Expand Up @@ -1166,7 +1150,7 @@ where
NETWORK_GRAPH_PERSISTENCE_KEY,
network_graph.encode(),
)
.await?;
.await?
}
Ok(())
}
Expand All @@ -1176,7 +1160,7 @@ fn check_and_reset_sleeper<
>(
fut: &mut SleepFuture, mut new_sleeper: impl FnMut() -> SleepFuture,
) -> Option<bool> {
let mut waker = dummy_waker();
let mut waker = task::Waker::noop();
let mut ctx = task::Context::from_waker(&mut waker);
match core::pin::Pin::new(&mut *fut).poll(&mut ctx) {
task::Poll::Ready(exit) => {
Expand Down
2 changes: 1 addition & 1 deletion lightning-invoice/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl FromBase32 for Bolt11InvoiceFeatures {
// Carry bits, 0, 1, 2, 3, or 4 bits
let mut carry_bits = 0;
let mut carry = 0u8;
let expected_raw_length = (field_data.len() * 5 + 7) / 8;
let expected_raw_length = (field_data.len() * 5).div_ceil(8);
let mut output = Vec::<u8>::with_capacity(expected_raw_length);

// Iterate over input in reverse
Expand Down
2 changes: 1 addition & 1 deletion lightning-invoice/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ fn encode_int_be_base32(int: u64) -> impl ExactSizeIterator<Item = Fe32> {
/// The length of the output of `encode_int_be_base32`.
fn encoded_int_be_base32_size(int: u64) -> usize {
let bit_len = 64 - int.leading_zeros() as usize; // cast ok as value is in 0..=64.
(bit_len + 4) / 5
bit_len.div_ceil(5)
}

impl Base32Iterable for RawDataPart {
Expand Down
10 changes: 10 additions & 0 deletions lightning-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ lightning_0_0_125 = { package = "lightning", version = "0.0.125", features = ["_
bitcoin = { version = "0.32.2", default-features = false }

[dev-dependencies]

[lints.rust.unexpected_cfgs]
level = "forbid"
# When adding a new cfg attribute, ensure that it is added to this list.
#
# Note that Cargo automatically declares corresponding cfgs for every feature
# defined in the member-level [features] tables as "expected".
check-cfg = [
"cfg(taproot)",
]
14 changes: 7 additions & 7 deletions lightning-transaction-sync/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ where

#[derive(Debug)]
enum TestConfirmableEvent {
Confirmed(Txid, BlockHash, u32),
Confirmed(Txid),
Unconfirmed(Txid),
BestBlockUpdated(BlockHash, u32),
BestBlockUpdated,
}

struct TestConfirmable {
Expand Down Expand Up @@ -140,7 +140,7 @@ impl Confirm for TestConfirmable {
let block_hash = header.block_hash();
self.confirmed_txs.lock().unwrap().insert(txid, (block_hash, height));
self.unconfirmed_txs.lock().unwrap().remove(&txid);
let event = TestConfirmableEvent::Confirmed(txid, block_hash, height);
let event = TestConfirmableEvent::Confirmed(txid);
self.events.lock().unwrap().push(event);
}
}
Expand All @@ -154,7 +154,7 @@ impl Confirm for TestConfirmable {
fn best_block_updated(&self, header: &Header, height: u32) {
let block_hash = header.block_hash();
*self.best_block.lock().unwrap() = (block_hash, height);
let event = TestConfirmableEvent::BestBlockUpdated(block_hash, height);
let event = TestConfirmableEvent::BestBlockUpdated;
self.events.lock().unwrap().push(event);
}

Expand Down Expand Up @@ -281,20 +281,20 @@ macro_rules! test_syncing {
}

match events[2] {
TestConfirmableEvent::BestBlockUpdated(..) => {},
TestConfirmableEvent::BestBlockUpdated => {},
_ => panic!("Unexpected event"),
}

match events[3] {
TestConfirmableEvent::Confirmed(t, _, _) => {
TestConfirmableEvent::Confirmed(t) => {
assert!(t == txid || t == second_txid);
assert!(seen_txids.remove(&t));
},
_ => panic!("Unexpected event"),
}

match events[4] {
TestConfirmableEvent::Confirmed(t, _, _) => {
TestConfirmableEvent::Confirmed(t) => {
assert!(t == txid || t == second_txid);
assert!(seen_txids.remove(&t));
},
Expand Down
2 changes: 1 addition & 1 deletion lightning-types/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ mod sealed {
);
// By default, allocate enough bytes to cover up to SimpleClose. Update this as new features are
// added which we expect to appear commonly across contexts.
pub(super) const MIN_FEATURES_ALLOCATION_BYTES: usize = (61 + 7) / 8;
pub(super) const MIN_FEATURES_ALLOCATION_BYTES: usize = 61_usize.div_ceil(8);
define_feature!(
259,
DnsResolver,
Expand Down
Loading
Loading