Skip to content
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
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ opt-level = 2
opt-level = 1
lto = "off"

# rgb-lib needs secp256k1 ^0.32.0-beta.2, which is yanked from crates.io. Without a committed
# lockfile a fresh resolve can't select it, so take it from its git tag (tag secp256k1-0.32.0-beta.2)
[patch.crates-io]
secp256k1 = { git = "https://github.com/rust-bitcoin/rust-secp256k1", rev = "6e5c556e566d6ca1954daa1d8592efac70e75d06" }

[profile.release]
opt-level = 3
lto = true
Expand Down
2 changes: 1 addition & 1 deletion lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ impl BackgroundProcessor {
SCORER_PERSISTENCE_KEY,
scorer.encode(),
) {
log_error!(logger, "Error: Failed to persist scorer, check your disk and permissions {}", e)
log_error!(logger, "Error: Failed to persist scorer, check your disk and permissions {}", e);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ impl Bolt11Invoice {
pub fn would_expire(&self, at_time: Duration) -> bool {
self.duration_since_epoch()
.checked_add(self.expiry_time())
.unwrap_or_else(|| Duration::new(u64::max_value(), 1_000_000_000 - 1))
.unwrap_or_else(|| Duration::new(u64::MAX, 1_000_000_000 - 1))
< at_time
}

Expand Down
2 changes: 2 additions & 0 deletions lightning-liquidity/src/lsps2/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,8 @@ where
) -> Option<LSPS2Request> {
match peer_state_lock.pending_requests.remove(request_id) {
Some(req) => {
// `try_update` is the new name, but is far newer than our MSRV
#[allow(deprecated)]
let res = self.total_pending_requests.fetch_update(
Ordering::Relaxed,
Ordering::Relaxed,
Expand Down
14 changes: 7 additions & 7 deletions lightning/src/blinded_path/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl BlindedPaymentPath {
{
// This value is not considered in pathfinding for 1-hop blinded paths, because it's intended to
// be in relation to a specific channel.
let htlc_maximum_msat = u64::max_value();
let htlc_maximum_msat = u64::MAX;
Self::new(
&[],
payee_node_id,
Expand Down Expand Up @@ -886,7 +886,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
htlc_maximum_msat: u64::max_value(),
htlc_maximum_msat: u64::MAX,
},
PaymentForwardNode {
node_id: dummy_pk,
Expand All @@ -904,7 +904,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
htlc_maximum_msat: u64::max_value(),
htlc_maximum_msat: u64::MAX,
},
];
let recv_tlvs = UnauthenticatedReceiveTlvs {
Expand Down Expand Up @@ -961,7 +961,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
htlc_maximum_msat: u64::max_value(),
htlc_maximum_msat: u64::MAX,
},
PaymentForwardNode {
node_id: dummy_pk,
Expand All @@ -979,7 +979,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
htlc_maximum_msat: u64::max_value(),
htlc_maximum_msat: u64::MAX,
},
];
let recv_tlvs = UnauthenticatedReceiveTlvs {
Expand Down Expand Up @@ -1020,7 +1020,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
htlc_maximum_msat: u64::max_value(),
htlc_maximum_msat: u64::MAX,
},
PaymentForwardNode {
node_id: dummy_pk,
Expand All @@ -1038,7 +1038,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
htlc_maximum_msat: u64::max_value(),
htlc_maximum_msat: u64::MAX,
},
];
let recv_tlvs = UnauthenticatedReceiveTlvs {
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/chain/chaininterface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use bitcoin::transaction::Transaction;

// TODO: Define typed abstraction over feerates to handle their conversions.
pub(crate) fn compute_feerate_sat_per_1000_weight(fee_sat: u64, weight: u64) -> u32 {
(fee_sat * 1000 / weight).try_into().unwrap_or(u32::max_value())
(fee_sat * 1000 / weight).try_into().unwrap_or(u32::MAX)
}
pub(crate) const fn fee_for_weight(feerate_sat_per_1000_weight: u32, weight: u64) -> u64 {
((feerate_sat_per_1000_weight as u64 * weight) + 1000 - 1) / 1000
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7219,7 +7219,7 @@ mod tests {
let witness = $sighash_parts.witness_mut($idx).unwrap();
witness.push(ser_sig);
if *$weight == WEIGHT_REVOKED_OUTPUT {
witness.push(vec!(1));
witness.push(vec![1]);
} else if *$weight == weight_revoked_offered_htlc($opt_anchors) || *$weight == weight_revoked_received_htlc($opt_anchors) {
witness.push(pubkey.clone().serialize().to_vec());
} else if *$weight == weight_received_htlc($opt_anchors) {
Expand Down
6 changes: 3 additions & 3 deletions lightning/src/chain/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ impl PackageSolvingData {
let mut ser_sig = sig.serialize_der().to_vec();
ser_sig.push(EcdsaSighashType::All as u8);
bumped_tx.input[i].witness.push(ser_sig);
bumped_tx.input[i].witness.push(vec!(1));
bumped_tx.input[i].witness.push(vec![1]);
bumped_tx.input[i].witness.push(witness_script.clone().into_bytes());
} else { return false; }
},
Expand Down Expand Up @@ -1546,7 +1546,7 @@ impl PackageTemplate {
) -> u32 where F::Target: FeeEstimator {
let feerate_estimate = fee_estimator.bounded_sat_per_1000_weight(conf_target);
if self.feerate_previous != 0 {
let previous_feerate = self.feerate_previous.try_into().unwrap_or(u32::max_value());
let previous_feerate = self.feerate_previous.try_into().unwrap_or(u32::MAX);
match feerate_strategy {
FeerateStrategy::RetryPrevious => previous_feerate,
FeerateStrategy::HighestOfPreviousOrNew => cmp::max(previous_feerate, feerate_estimate),
Expand All @@ -1558,7 +1558,7 @@ impl PackageTemplate {
// so we choose to bump our previous feerate by 25%, making sure we don't use a
// lower feerate or overpay by a large margin by limiting it to 5x the new fee
// estimate.
let previous_feerate = self.feerate_previous.try_into().unwrap_or(u32::max_value());
let previous_feerate = self.feerate_previous.try_into().unwrap_or(u32::MAX);
let mut new_feerate = previous_feerate.saturating_add(previous_feerate / 4);
if new_feerate > feerate_estimate * 5 {
new_feerate = cmp::max(feerate_estimate * 5, previous_feerate);
Expand Down
14 changes: 7 additions & 7 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5873,9 +5873,9 @@ where
dust_exposure_dust_limit_msat = cmp::max(dust_exposure_dust_limit_msat, buffer_dust_limit_success_sat * 1000);
}

if htlc_stats.on_holder_tx_dust_exposure_msat as i64 + buffer_dust_limit_timeout_sat as i64 * 1000 - 1 > max_dust_htlc_exposure_msat.try_into().unwrap_or(i64::max_value()) {
if htlc_stats.on_holder_tx_dust_exposure_msat as i64 + buffer_dust_limit_timeout_sat as i64 * 1000 - 1 > max_dust_htlc_exposure_msat.try_into().unwrap_or(i64::MAX) {
remaining_msat_below_dust_exposure_limit = Some(cmp::min(
remaining_msat_below_dust_exposure_limit.unwrap_or(u64::max_value()),
remaining_msat_below_dust_exposure_limit.unwrap_or(u64::MAX),
max_dust_htlc_exposure_msat.saturating_sub(htlc_stats.on_holder_tx_dust_exposure_msat)));
dust_exposure_dust_limit_msat = cmp::max(dust_exposure_dust_limit_msat, buffer_dust_limit_timeout_sat * 1000);
}
Expand Down Expand Up @@ -7407,7 +7407,7 @@ where
// on-chain ChannelsMonitors during block rescan. Ideally we'd figure out a way to drop
// these, but for now we just have to treat them as normal.

let mut pending_idx = core::usize::MAX;
let mut pending_idx = usize::MAX;
let mut htlc_value_msat = 0;
for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
if htlc.htlc_id == htlc_id_arg {
Expand Down Expand Up @@ -7444,7 +7444,7 @@ where
break;
}
}
if pending_idx == core::usize::MAX {
if pending_idx == usize::MAX {
return UpdateFulfillFetch::DuplicateClaim {};
}

Expand Down Expand Up @@ -7648,7 +7648,7 @@ where
// on-chain ChannelsMonitors during block rescan. Ideally we'd figure out a way to drop
// these, but for now we just have to treat them as normal.

let mut pending_idx = core::usize::MAX;
let mut pending_idx = usize::MAX;
for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
if htlc.htlc_id == htlc_id_arg {
match htlc.state {
Expand All @@ -7664,7 +7664,7 @@ where
pending_idx = idx;
}
}
if pending_idx == core::usize::MAX {
if pending_idx == usize::MAX {
return Err(ChannelError::Ignore(format!("Unable to find a pending HTLC which matched the given HTLC ID ({})", htlc_id_arg)));
}

Expand Down Expand Up @@ -10353,7 +10353,7 @@ where
let normal_feerate =
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::NonAnchorChannelFee);
let mut proposed_max_feerate =
if self.funding.is_outbound() { normal_feerate } else { u32::max_value() };
if self.funding.is_outbound() { normal_feerate } else { u32::MAX };

// The spec requires that (when the channel does not have anchors) we only send absolute
// channel fees no greater than the absolute channel fee on the current commitment
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6428,7 +6428,7 @@ where
}
}

if funding_transaction.output.len() > u16::max_value() as usize {
if funding_transaction.output.len() > u16::MAX as usize {
result = result.and(Err(APIError::APIMisuseError {
err: "Transaction had more than 2^16 outputs, which is not supported".to_owned()
}));
Expand Down
5 changes: 1 addition & 4 deletions lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4350,10 +4350,7 @@ impl QueryChannelRange {
///
/// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
pub fn end_blocknum(&self) -> u32 {
match self.first_blocknum.checked_add(self.number_of_blocks) {
Some(block) => block,
None => u32::max_value(),
}
self.first_blocknum.checked_add(self.number_of_blocks).unwrap_or(u32::MAX)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/onion_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3264,7 +3264,7 @@ mod tests {
// Note that we represent the test vector payloads 2 and 5 through RawOnionHopData::data
// with raw hex instead of our in-memory enums, as the payloads contains custom types, and
// we have no way of representing that with our enums.
let payloads = vec!(
let payloads = vec![
RawOnionHopData::new(msgs::OutboundOnionPayload::Forward {
short_channel_id: 1,
amt_to_forward: 15000,
Expand Down Expand Up @@ -3319,7 +3319,7 @@ mod tests {
RawOnionHopData {
data: <Vec<u8>>::from_hex("fd011002022710040203e8082224a33562c54507a9334e79f0dc4f17d407e6d7c61f0e2f3d0d38599502f617042710fd012de02a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a").unwrap(),
},
);
];

// Verify that the serialized OnionHopDataFormat::NonFinalNode tlv payloads matches the test vectors
let mut w = VecWriter(Vec::new());
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/outbound_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ impl OutboundPayments {
continue 'path_check;
}
let dest_hop_idx = if path.blinded_tail.is_some() && path.blinded_tail.as_ref().unwrap().hops.len() > 1 {
usize::max_value() } else { path.hops.len() - 1 };
usize::MAX } else { path.hops.len() - 1 };
for (idx, hop) in path.hops.iter().enumerate() {
if idx != dest_hop_idx && hop.pubkey == our_node_id {
path_errs.push(Err(APIError::InvalidRoute{err: "Path went through us but wasn't a simple rebalance loop to us".to_owned()}));
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/peer_channel_encryptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use core::ops::Deref;
/// Maximum Lightning message data length according to
/// [BOLT-8](https://github.com/lightning/bolts/blob/v1.0/08-transport.md#lightning-message-specification)
/// and [BOLT-1](https://github.com/lightning/bolts/blob/master/01-messaging.md#lightning-message-format):
pub const LN_MAX_MSG_LEN: usize = ::core::u16::MAX as usize; // Must be equal to 65535
pub const LN_MAX_MSG_LEN: usize = u16::MAX as usize; // Must be equal to 65535

/// The (rough) size buffer to pre-allocate when encoding a message. Messages should reliably be
/// smaller than this size by at least 32 bytes or so.
Expand Down Expand Up @@ -1052,7 +1052,7 @@ mod tests {
#[test]
fn max_msg_len_limit_value() {
assert_eq!(LN_MAX_MSG_LEN, 65535);
assert_eq!(LN_MAX_MSG_LEN, ::core::u16::MAX as usize);
assert_eq!(LN_MAX_MSG_LEN, u16::MAX as usize);
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions lightning/src/ln/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3607,8 +3607,7 @@ where
// be absurd. We ensure this by checking that at least 100 (our stated public contract on when
// broadcast_node_announcement panics) of the maximum-length addresses would fit in a 64KB
// message...
const HALF_MESSAGE_IS_ADDRS: u32 =
::core::u16::MAX as u32 / (SocketAddress::MAX_LEN as u32 + 1) / 2;
const HALF_MESSAGE_IS_ADDRS: u32 = u16::MAX as u32 / (SocketAddress::MAX_LEN as u32 + 1) / 2;
#[allow(dead_code)]
// ...by failing to compile if the number of addresses that would be half of a message is
// smaller than 100:
Expand Down
26 changes: 13 additions & 13 deletions lightning/src/routing/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ where
msg: GossipTimestampFilter {
chain_hash: self.network_graph.chain_hash,
first_timestamp: gossip_start_time as u32, // 2106 issue!
timestamp_range: u32::max_value(),
timestamp_range: u32::MAX,
},
});
Ok(())
Expand Down Expand Up @@ -1198,8 +1198,8 @@ impl Readable for ChannelInfo {
announcement_received_time,
(default_value, 0)
),
node_one_counter: u32::max_value(),
node_two_counter: u32::max_value(),
node_one_counter: u32::MAX,
node_two_counter: u32::MAX,
contract_id: _init_tlv_based_struct_field!(contract_id, option),
})
}
Expand Down Expand Up @@ -1361,7 +1361,7 @@ impl EffectiveCapacity {
EffectiveCapacity::AdvertisedMaxHTLC { amount_msat } => *amount_msat,
EffectiveCapacity::Total { capacity_msat, .. } => *capacity_msat,
EffectiveCapacity::HintMaxHTLC { amount_msat } => *amount_msat,
EffectiveCapacity::Infinite => u64::max_value(),
EffectiveCapacity::Infinite => u64::MAX,
EffectiveCapacity::Unknown => UNKNOWN_CHANNEL_CAPACITY_MSAT,
}
}
Expand Down Expand Up @@ -1641,7 +1641,7 @@ impl Readable for NodeInfo {
Ok(NodeInfo {
announcement_info: announcement_info_wrap.map(|w| w.0),
channels,
node_counter: u32::max_value(),
node_counter: u32::MAX,
})
}
}
Expand Down Expand Up @@ -1698,7 +1698,7 @@ where
let nodes_count: u64 = Readable::read(reader)?;
// There shouldn't be anywhere near `u32::MAX` nodes, and we need some headroom to insert
// new nodes during sync, so reject any graphs claiming more than `u32::MAX / 2` nodes.
if nodes_count > u32::max_value() as u64 / 2 {
if nodes_count > u32::MAX as u64 / 2 {
return Err(DecodeError::InvalidValue);
}
let mut nodes = IndexedMap::with_capacity(NODE_COUNT_ESTIMATE);
Expand Down Expand Up @@ -1814,7 +1814,7 @@ where
let nodes = self.nodes.read().unwrap();
let removed_node_counters = self.removed_node_counters.lock().unwrap();
let next_counter = self.next_node_counter.load(Ordering::Acquire);
assert!(next_counter < (u32::max_value() as usize) / 2);
assert!(next_counter < (u32::MAX as usize) / 2);
let mut used_node_counters = vec![0u8; next_counter / 8 + 1];

for counter in removed_node_counters.iter() {
Expand Down Expand Up @@ -2047,8 +2047,8 @@ where
capacity_sats,
announcement_message: None,
announcement_received_time: timestamp,
node_one_counter: u32::max_value(),
node_two_counter: u32::max_value(),
node_one_counter: u32::MAX,
node_two_counter: u32::MAX,
contract_id: None,
};

Expand Down Expand Up @@ -2240,8 +2240,8 @@ where
None
},
announcement_received_time,
node_one_counter: u32::max_value(),
node_two_counter: u32::max_value(),
node_one_counter: u32::MAX,
node_two_counter: u32::MAX,
contract_id: msg.contract_id,
};

Expand Down Expand Up @@ -2373,7 +2373,7 @@ where
pub fn remove_stale_channels_and_tracking_with_time(&self, current_time_unix: u64) {
let mut channels = self.channels.write().unwrap();
// Time out if we haven't received an update in at least 14 days.
if current_time_unix > u32::max_value() as u64 {
if current_time_unix > u32::MAX as u64 {
return;
} // Remove by 2106
if current_time_unix < STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS {
Expand Down Expand Up @@ -3877,7 +3877,7 @@ pub(crate) mod tests {
(msg.first_timestamp as u64)
< expected_timestamp - 60 * 60 * 24 * 7 * 2 + 10
);
assert_eq!(msg.timestamp_range, u32::max_value());
assert_eq!(msg.timestamp_range, u32::MAX);
},
_ => panic!("Expected MessageSendEvent::SendChannelRangeQuery"),
};
Expand Down
Loading
Loading