Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/upstream/dev' into remove-…
Browse files Browse the repository at this point in the history
…lane-constants
  • Loading branch information
darthsiroftardis committed Feb 26, 2025
2 parents 601fa5f + 708cacd commit adbfe64
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 27 deletions.
3 changes: 1 addition & 2 deletions node/src/components/consensus/era_supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ impl EraSupervisor {

if self
.current_era()
.map_or(true, |current_era| era_id < current_era)
.is_none_or(|current_era| era_id < current_era)
{
trace!(era = era_id.value(), "executed block in old era");
return effects;
Expand Down Expand Up @@ -1526,7 +1526,6 @@ impl ProposedBlock<ClContext> {
.iter()
.flat_map(|ancestor| ancestor.all_transaction_hashes())
.find(|typed_txn_hash| block_txns_set.contains(typed_txn_hash))
.map(TransactionHash::from)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<C: Context> ActiveValidator<C> {
{
if self
.latest_unit(state)
.map_or(true, |latest_unit| latest_unit.round_id() != r_id)
.is_none_or(|latest_unit| latest_unit.round_id() != r_id)
{
info!(round_id = %r_id, "sending witness in round with no proposal");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ fn crank_until_time<DS: DeliveryStrategy>(
crank_until(hth, rng, |hth| {
hth.virtual_net
.peek_message()
.map_or(true, |qe| qe.delivery_time > timestamp)
.is_none_or(|qe| qe.delivery_time > timestamp)
})
}

Expand Down
15 changes: 7 additions & 8 deletions node/src/components/consensus/protocols/zug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,9 +1302,10 @@ impl<C: Context + 'static> Zug<C> {

let hashed_prop = HashedProposal::new(proposal);

if self.round(round_id).map_or(true, |round| {
!round.has_echoes_for_proposal(hashed_prop.hash())
}) {
if self
.round(round_id)
.is_none_or(|round| !round.has_echoes_for_proposal(hashed_prop.hash()))
{
log_proposal!(
Level::DEBUG,
hashed_prop.inner(),
Expand Down Expand Up @@ -1555,7 +1556,7 @@ impl<C: Context + 'static> Zug<C> {
fn add_content(&mut self, signed_msg: SignedMessage<C>) -> bool {
if self.active[signed_msg.validator_idx]
.as_ref()
.map_or(true, |old_msg| old_msg.round_id < signed_msg.round_id)
.is_none_or(|old_msg| old_msg.round_id < signed_msg.round_id)
{
if self.active[signed_msg.validator_idx].is_none() {
// We considered this validator inactive until now, and didn't accept proposals that
Expand Down Expand Up @@ -2053,7 +2054,7 @@ impl<C: Context + 'static> Zug<C> {
if now >= timestamp {
return Some((Some(round_id), timestamp));
}
if maybe_parent.map_or(true, |(_, timestamp2)| timestamp2 > timestamp) {
if maybe_parent.is_none_or(|(_, timestamp2)| timestamp2 > timestamp) {
maybe_parent = Some((Some(round_id), timestamp));
}
}
Expand Down Expand Up @@ -2194,9 +2195,7 @@ impl<C: Context + 'static> Zug<C> {
/// Marks a round as dirty so that the next `upgrade` call will reevaluate it.
fn mark_dirty(&mut self, round_id: RoundId) {
if round_id <= self.current_round
&& self
.maybe_dirty_round_id
.map_or(true, |r_id| r_id > round_id)
&& self.maybe_dirty_round_id.is_none_or(|r_id| r_id > round_id)
{
self.maybe_dirty_round_id = Some(round_id);
}
Expand Down
1 change: 0 additions & 1 deletion node/src/components/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,6 @@ impl Storage {
transaction_hashes
.map(|transaction_hash| {
Self::get_transaction_with_finalized_approvals(&ro_txn, transaction_hash)
.map_err(FatalStorageError::from)
})
.collect()
}
Expand Down
2 changes: 1 addition & 1 deletion node/src/reactor/main_reactor/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ fn node_has_lowest_available_block_at_or_below_height(
node_id: NodeId,
) -> impl Fn(&Nodes) -> bool {
move |nodes: &Nodes| {
nodes.get(&node_id).map_or(true, |runner| {
nodes.get(&node_id).is_none_or(|runner| {
let available_block_range = runner.main_reactor().storage().get_available_block_range();
if available_block_range.low() == 0 && available_block_range.high() == 0 {
false
Expand Down
7 changes: 3 additions & 4 deletions node/src/reactor/main_reactor/tests/binary_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ fn validate_metadata(
response.is_success()
&& response.returned_data_type_tag()
== expected_payload_type.map(|payload_type| payload_type as u8)
&& expected_payload_type.map_or(true, |_| !response.payload().is_empty())
&& expected_payload_type.is_none_or(|_| !response.payload().is_empty())
}

fn validate_deserialization<T>(response: &BinaryResponse) -> Option<T>
Expand All @@ -391,9 +391,8 @@ where
F: FnOnce(T) -> bool,
{
validate_metadata(response, payload_type)
&& payload_type.map_or(true, |_| {
validate_deserialization::<T>(response).is_some_and(validator)
})
&& payload_type
.is_none_or(|_| validate_deserialization::<T>(response).is_some_and(validator))
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion node/src/types/sync_leap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl SyncLeap {
.filter(move |block_header| {
block_protocol_versions
.get(&(block_header.height() + 1))
.map_or(true, |other_protocol_version| {
.is_none_or(|other_protocol_version| {
if block_header.protocol_version() == *other_protocol_version {
true
} else if *other_protocol_version == current_protocol_version {
Expand Down
2 changes: 1 addition & 1 deletion node/src/utils/block_signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
continue;
}
Some(validator_weight) => {
if minimum_weight.map_or(true, |min_w| *validator_weight < min_w) {
if minimum_weight.is_none_or(|min_w| *validator_weight < min_w) {
minimum_weight = Some(*validator_weight);
}
signature_weight += *validator_weight;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.84.1"
channel = "1.85.0"
1 change: 0 additions & 1 deletion storage/src/global_state/transaction_source/lmdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ impl Readable for RwTransaction<'_> {
impl Writable for RwTransaction<'_> {
fn write(&mut self, handle: Self::Handle, key: &[u8], value: &[u8]) -> Result<(), Self::Error> {
self.put(handle, &key, &value, WriteFlags::empty())
.map_err(Into::into)
}
}

Expand Down
6 changes: 2 additions & 4 deletions storage/src/system/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,10 @@ pub trait Auction:
debug!(?validator_public_key, "validator payout finished");

// mint new token and put it to the recipients' purses
self.mint_into_existing_purse(reward_info.validator_reward, validator_bonding_purse)
.map_err(Error::from)?;
self.mint_into_existing_purse(reward_info.validator_reward, validator_bonding_purse)?;

for (_delegator_account_hash, delegator_payout, bonding_purse) in delegator_payouts {
self.mint_into_existing_purse(delegator_payout, bonding_purse)
.map_err(Error::from)?;
self.mint_into_existing_purse(delegator_payout, bonding_purse)?;
}
debug!("rewards minted into recipient purses");
}
Expand Down
2 changes: 1 addition & 1 deletion utils/highway-state-grapher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl Graph {
for unit_hash in &units_set.order {
let unit = state.unit(unit_hash);
let block = state.block(&unit.block);
if highest_block.map_or(true, |(height, _)| height < block.height) {
if highest_block.is_none_or( |(height, _)| height < block.height) {
highest_block = Some((block.height, unit.block));
}
let block_id = if let Some(b_id) = blocks.get(&unit.block) {
Expand Down

0 comments on commit adbfe64

Please sign in to comment.