Skip to content

Commit d3e7936

Browse files
committed
Switch to let-chains where possible
Bump MSRV to 1.88
1 parent 21c3679 commit d3e7936

File tree

14 files changed

+145
-146
lines changed

14 files changed

+145
-146
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG RUST_VERSION=1.85.1
1+
ARG RUST_VERSION=1.88.0
22
FROM rust:${RUST_VERSION}-bullseye AS builder
33
RUN apt update && apt dist-upgrade -y && apt install -y cmake libclang-dev
44
COPY . anchor

Dockerfile.devnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG RUST_VERSION=1.85.1
1+
ARG RUST_VERSION=1.88.0
22
FROM rust:${RUST_VERSION}-bullseye AS builder
33
RUN apt update && apt dist-upgrade -y && apt install -y cmake libclang-dev
44
COPY . anchor

anchor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "anchor"
33
version = "0.2.0"
44
edition = { workspace = true }
55
authors = ["Sigma Prime <[email protected]>"]
6-
rust-version = "1.85.0"
6+
rust-version = "1.88.0"
77
default-run = "anchor"
88

99
[features]

anchor/common/qbft/src/lib.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -874,23 +874,22 @@ where
874874
vec![]
875875
};
876876

877-
if matches!(msg_type, QbftMessageType::RoundChange) {
878-
if let (Some(last_prepared_value), Some(last_prepared_round)) =
877+
if matches!(msg_type, QbftMessageType::RoundChange)
878+
&& let (Some(last_prepared_value), Some(last_prepared_round)) =
879879
(self.last_prepared_value, self.last_prepared_round)
880-
{
881-
return MessageData::new(
882-
last_prepared_round.get() as u64,
883-
self.current_round.get() as u64,
884-
last_prepared_value,
885-
self.data
886-
.get(&last_prepared_value)
887-
.map(|d| d.as_ssz_bytes())
888-
.unwrap_or_else(|| {
889-
warn!("Data misisng for last prepared value");
890-
vec![]
891-
}),
892-
);
893-
}
880+
{
881+
return MessageData::new(
882+
last_prepared_round.get() as u64,
883+
self.current_round.get() as u64,
884+
last_prepared_value,
885+
self.data
886+
.get(&last_prepared_value)
887+
.map(|d| d.as_ssz_bytes())
888+
.unwrap_or_else(|| {
889+
warn!("Data misisng for last prepared value");
890+
vec![]
891+
}),
892+
);
894893
}
895894

896895
// Standard message data for Proposal, Prepare, and Commit

anchor/common/qbft/src/msg_container.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ impl MessageContainer {
8686
/// If we have a quorum for the round, get all of the messages that correspond to that quorum
8787
pub fn get_quorum_of_messages(&self, round: Round) -> Vec<WrappedQbftMessage> {
8888
let mut msgs = vec![];
89-
if let Some(hash) = self.has_quorum(round) {
90-
// collect all of the messages where root = quorum hash
91-
if let Some(round_messages) = self.messages.get(&round) {
92-
for msg in round_messages.values() {
93-
if msg.qbft_message.root == hash {
94-
msgs.push(msg.clone());
95-
}
89+
// collect all of the messages where root = quorum hash
90+
if let Some(hash) = self.has_quorum(round)
91+
&& let Some(round_messages) = self.messages.get(&round)
92+
{
93+
for msg in round_messages.values() {
94+
if msg.qbft_message.root == hash {
95+
msgs.push(msg.clone());
9696
}
9797
}
9898
}

anchor/database/src/state.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,18 @@ impl NetworkState {
9999
);
100100

101101
// Process this validators shares
102-
if let Some(share_map) = &share_map {
103-
if let Some(shares) = share_map.get(cluster_id) {
104-
for share in shares {
105-
if share.validator_pubkey == validator.public_key {
106-
shares_multi.insert(
107-
&validator.public_key,
108-
cluster_id,
109-
&cluster.owner,
110-
&cluster.committee_id(),
111-
share.clone(),
112-
);
113-
}
102+
if let Some(share_map) = &share_map
103+
&& let Some(shares) = share_map.get(cluster_id)
104+
{
105+
for share in shares {
106+
if share.validator_pubkey == validator.public_key {
107+
shares_multi.insert(
108+
&validator.public_key,
109+
cluster_id,
110+
&cluster.owner,
111+
&cluster.committee_id(),
112+
share.clone(),
113+
);
114114
}
115115
}
116116
}

anchor/http_metrics/src/lib.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,46 +84,46 @@ async fn metrics_handler<E: EthSpec>(
8484

8585
{
8686
let shared = state.read();
87-
if let Some(genesis_time) = shared.genesis_time {
88-
if let Ok(now) = SystemTime::now().duration_since(UNIX_EPOCH) {
89-
let distance = now.as_secs() as i64 - genesis_time as i64;
90-
set_gauge(&GENESIS_DISTANCE, distance);
91-
}
87+
if let Some(genesis_time) = shared.genesis_time
88+
&& let Ok(now) = SystemTime::now().duration_since(UNIX_EPOCH)
89+
{
90+
let distance = now.as_secs() as i64 - genesis_time as i64;
91+
set_gauge(&GENESIS_DISTANCE, distance);
9292
}
9393

9494
// Duties services
95-
if let Some(duties_service) = &shared.duties_service {
96-
if let Some(slot) = duties_service.slot_clock.now() {
97-
let current_epoch = slot.epoch(E::slots_per_epoch());
98-
let next_epoch = current_epoch + 1;
99-
100-
set_int_gauge(
101-
&PROPOSER_COUNT,
102-
&[CURRENT_EPOCH],
103-
duties_service.proposer_count(current_epoch) as i64,
104-
);
105-
set_int_gauge(
106-
&ATTESTER_COUNT,
107-
&[CURRENT_EPOCH],
108-
duties_service.attester_count(current_epoch) as i64,
109-
);
110-
set_int_gauge(
111-
&ATTESTER_COUNT,
112-
&[NEXT_EPOCH],
113-
duties_service.attester_count(next_epoch) as i64,
114-
);
115-
}
95+
if let Some(duties_service) = &shared.duties_service
96+
&& let Some(slot) = duties_service.slot_clock.now()
97+
{
98+
let current_epoch = slot.epoch(E::slots_per_epoch());
99+
let next_epoch = current_epoch + 1;
100+
101+
set_int_gauge(
102+
&PROPOSER_COUNT,
103+
&[CURRENT_EPOCH],
104+
duties_service.proposer_count(current_epoch) as i64,
105+
);
106+
set_int_gauge(
107+
&ATTESTER_COUNT,
108+
&[CURRENT_EPOCH],
109+
duties_service.attester_count(current_epoch) as i64,
110+
);
111+
set_int_gauge(
112+
&ATTESTER_COUNT,
113+
&[NEXT_EPOCH],
114+
duties_service.attester_count(next_epoch) as i64,
115+
);
116116
}
117117

118-
if let Some(network_metrics) = &shared.network_registry {
119-
// Network metrics
120-
if let Err(e) = encode(&mut buffer, network_metrics) {
121-
return (
122-
StatusCode::INTERNAL_SERVER_ERROR,
123-
format!("Failed to encode promethus data: {e}"),
124-
)
125-
.into_response();
126-
}
118+
// Network metrics
119+
if let Some(network_metrics) = &shared.network_registry
120+
&& let Err(e) = encode(&mut buffer, network_metrics)
121+
{
122+
return (
123+
StatusCode::INTERNAL_SERVER_ERROR,
124+
format!("Failed to encode promethus data: {e}"),
125+
)
126+
.into_response();
127127
}
128128
}
129129

anchor/logging/src/tracing_libp2p_discv5_layer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ pub fn create_libp2p_discv5_tracing_layer(
6464
// Ensure that `tracing_log_path` only contains directories.
6565
for p in tracing_log_path.clone().iter() {
6666
tracing_log_path = tracing_log_path.join(p);
67-
if let Ok(metadata) = tracing_log_path.metadata() {
68-
if !metadata.is_dir() {
69-
tracing_log_path.pop();
70-
break;
71-
}
67+
if let Ok(metadata) = tracing_log_path.metadata()
68+
&& !metadata.is_dir()
69+
{
70+
tracing_log_path.pop();
71+
break;
7272
}
7373
}
7474

anchor/message_sender/src/network.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,19 @@ impl<S: SlotClock + 'static, D: DutiesProvider> NetworkMessageSender<S, D> {
129129
fn do_send(&self, message: SignedSSVMessage, committee_id: CommitteeId) {
130130
let message_bytes = message.as_ssz_bytes();
131131

132-
if let Some(validator) = self.validator.as_ref() {
133-
if let Err(err) = validator.validate(&message_bytes).as_result() {
134-
// `Reject` is more severe and can be punished by other peers. We should not have
135-
// created this message ever, while `Ignore` can be triggered simply because the
136-
// message is irrelevant by now.
137-
if let MessageAcceptance::Reject = MessageAcceptance::from(err) {
138-
warn!(?err, "Validation of outgoing message failed (Reject)");
139-
debug!(msg = %message, "Failing message");
140-
} else {
141-
debug!(?err, "Validation of outgoing message failed (Ignore)");
142-
}
143-
return;
132+
if let Some(validator) = self.validator.as_ref()
133+
&& let Err(err) = validator.validate(&message_bytes).as_result()
134+
{
135+
// `Reject` is more severe and can be punished by other peers. We should not have
136+
// created this message ever, while `Ignore` can be triggered simply because the message
137+
// is irrelevant by now.
138+
if let MessageAcceptance::Reject = MessageAcceptance::from(err) {
139+
warn!(?err, "Validation of outgoing message failed (Reject)");
140+
debug!(msg = %message, "Failing message");
141+
} else {
142+
debug!(?err, "Validation of outgoing message failed (Ignore)");
144143
}
144+
return;
145145
}
146146

147147
let subnet = SubnetId::from_committee(committee_id, self.subnet_count);

anchor/network/src/network.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ impl<R: MessageReceiver> Network<R> {
230230
event = self.message_rx.recv() => {
231231
match event {
232232
Some((subnet_id, message)) => {
233-
if let Err(err) = self.gossipsub().publish(subnet_to_topic(subnet_id), message) {
234-
if !matches!(err, PublishError::Duplicate) {
235-
error!(?err, "Failed to publish message");
236-
}
233+
if let Err(err) = self.gossipsub().publish(subnet_to_topic(subnet_id), message)
234+
&& let PublishError::Duplicate = err
235+
{
236+
error!(?err, "Failed to publish message");
237237
}
238238
}
239239
None => {
@@ -368,10 +368,10 @@ impl<R: MessageReceiver> Network<R> {
368368

369369
// update enr and metadata to new state
370370
self.discovery().set_subscribed(subnet, subscribed);
371-
if let Some(metadata) = &mut self.node_info.metadata {
372-
if let Err(err) = metadata.set_subscribed(subnet, subscribed) {
373-
error!(?err, "unable to update node info");
374-
}
371+
if let Some(metadata) = &mut self.node_info.metadata
372+
&& let Err(err) = metadata.set_subscribed(subnet, subscribed)
373+
{
374+
error!(?err, "unable to update node info");
375375
}
376376
}
377377

0 commit comments

Comments
 (0)