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
6 changes: 2 additions & 4 deletions beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,10 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> {
chain: &BeaconChain<T>,
) -> Result<Self, Error> {
Self::verify_slashable(signed_aggregate, chain)
.map(|verified_aggregate| {
.inspect(|verified_aggregate| {
if let Some(slasher) = chain.slasher.as_ref() {
slasher.accept_attestation(verified_aggregate.indexed_attestation.clone());
}
verified_aggregate
})
.map_err(|slash_info| process_slash_info(slash_info, chain))
}
Expand Down Expand Up @@ -892,11 +891,10 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
chain: &BeaconChain<T>,
) -> Result<Self, Error> {
Self::verify_slashable(attestation.to_ref(), subnet_id, chain)
.map(|verified_unaggregated| {
.inspect(|verified_unaggregated| {
if let Some(slasher) = chain.slasher.as_ref() {
slasher.accept_attestation(verified_unaggregated.indexed_attestation.clone());
}
verified_unaggregated
})
.map_err(|slash_info| process_slash_info(slash_info, chain))
}
Expand Down
27 changes: 9 additions & 18 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let _timer =
metrics::start_timer(&metrics::UNAGGREGATED_ATTESTATION_GOSSIP_VERIFICATION_TIMES);

VerifiedUnaggregatedAttestation::verify(unaggregated_attestation, subnet_id, self).map(
VerifiedUnaggregatedAttestation::verify(unaggregated_attestation, subnet_id, self).inspect(
|v| {
// This method is called for API and gossip attestations, so this covers all unaggregated attestation events
if let Some(event_handler) = self.event_handler.as_ref() {
Expand All @@ -2046,7 +2046,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
metrics::inc_counter(&metrics::UNAGGREGATED_ATTESTATION_PROCESSING_SUCCESSES);
v
},
)
}
Expand Down Expand Up @@ -2074,7 +2073,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let _timer =
metrics::start_timer(&metrics::AGGREGATED_ATTESTATION_GOSSIP_VERIFICATION_TIMES);

VerifiedAggregatedAttestation::verify(signed_aggregate, self).map(|v| {
VerifiedAggregatedAttestation::verify(signed_aggregate, self).inspect(|v| {
// This method is called for API and gossip attestations, so this covers all aggregated attestation events
if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_attestation_subscribers() {
Expand All @@ -2084,7 +2083,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
metrics::inc_counter(&metrics::AGGREGATED_ATTESTATION_PROCESSING_SUCCESSES);
v
})
}

Expand All @@ -2098,9 +2096,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
metrics::inc_counter(&metrics::SYNC_MESSAGE_PROCESSING_REQUESTS);
let _timer = metrics::start_timer(&metrics::SYNC_MESSAGE_GOSSIP_VERIFICATION_TIMES);

VerifiedSyncCommitteeMessage::verify(sync_message, subnet_id, self).map(|v| {
VerifiedSyncCommitteeMessage::verify(sync_message, subnet_id, self).inspect(|_| {
metrics::inc_counter(&metrics::SYNC_MESSAGE_PROCESSING_SUCCESSES);
v
})
}

Expand All @@ -2112,7 +2109,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
) -> Result<VerifiedSyncContribution<T>, SyncCommitteeError> {
metrics::inc_counter(&metrics::SYNC_CONTRIBUTION_PROCESSING_REQUESTS);
let _timer = metrics::start_timer(&metrics::SYNC_CONTRIBUTION_GOSSIP_VERIFICATION_TIMES);
VerifiedSyncContribution::verify(sync_contribution, self).map(|v| {
VerifiedSyncContribution::verify(sync_contribution, self).inspect(|v| {
if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_contribution_subscribers() {
event_handler.register(EventKind::ContributionAndProof(Box::new(
Expand All @@ -2121,7 +2118,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
metrics::inc_counter(&metrics::SYNC_CONTRIBUTION_PROCESSING_SUCCESSES);
v
})
}

Expand All @@ -2136,9 +2132,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
self,
seen_timestamp,
)
.map(|v| {
.inspect(|_| {
metrics::inc_counter(&metrics::FINALITY_UPDATE_PROCESSING_SUCCESSES);
v
})
}

Expand All @@ -2149,9 +2144,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
) -> Result<GossipVerifiedDataColumn<T>, GossipDataColumnError> {
metrics::inc_counter(&metrics::DATA_COLUMN_SIDECAR_PROCESSING_REQUESTS);
let _timer = metrics::start_timer(&metrics::DATA_COLUMN_SIDECAR_GOSSIP_VERIFICATION_TIMES);
GossipVerifiedDataColumn::new(data_column_sidecar, subnet_id, self).map(|v| {
GossipVerifiedDataColumn::new(data_column_sidecar, subnet_id, self).inspect(|_| {
metrics::inc_counter(&metrics::DATA_COLUMN_SIDECAR_PROCESSING_SUCCESSES);
v
})
}

Expand All @@ -2162,9 +2156,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
) -> Result<GossipVerifiedBlob<T>, GossipBlobError> {
metrics::inc_counter(&metrics::BLOBS_SIDECAR_PROCESSING_REQUESTS);
let _timer = metrics::start_timer(&metrics::BLOBS_SIDECAR_GOSSIP_VERIFICATION_TIMES);
GossipVerifiedBlob::new(blob_sidecar, subnet_id, self).map(|v| {
GossipVerifiedBlob::new(blob_sidecar, subnet_id, self).inspect(|_| {
metrics::inc_counter(&metrics::BLOBS_SIDECAR_PROCESSING_SUCCESSES);
v
})
}

Expand All @@ -2179,9 +2172,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
self,
seen_timestamp,
)
.map(|v| {
.inspect(|_| {
metrics::inc_counter(&metrics::OPTIMISTIC_UPDATE_PROCESSING_SUCCESSES);
v
})
}

Expand Down Expand Up @@ -2485,7 +2477,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.observed_voluntary_exits
.lock()
.verify_and_observe_at(exit, wall_clock_epoch, head_state, &self.spec)
.map(|exit| {
.inspect(|exit| {
// this method is called for both API and gossip exits, so this covers all exit events
if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_exit_subscribers() {
Expand All @@ -2494,7 +2486,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
}
exit
})?)
}

Expand Down
3 changes: 1 addition & 2 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,12 +834,11 @@ pub trait IntoExecutionPendingBlock<T: BeaconChainTypes>: Sized {
notify_execution_layer: NotifyExecutionLayer,
) -> Result<ExecutionPendingBlock<T>, BlockError> {
self.into_execution_pending_block_slashable(block_root, chain, notify_execution_layer)
.map(|execution_pending| {
.inspect(|execution_pending| {
// Supply valid block to slasher.
if let Some(slasher) = chain.slasher.as_ref() {
slasher.accept_block_header(execution_pending.block.signed_block_header());
}
execution_pending
})
.map_err(|slash_info| process_block_slash_info::<_, BlockError>(chain, slash_info))
}
Expand Down
5 changes: 1 addition & 4 deletions beacon_node/eth1/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ impl Inner {
SszEth1Cache::from_ssz_bytes(bytes)
.map_err(|e| format!("Ssz decoding error: {:?}", e))?
.to_inner(config, spec)
.map(|inner| {
inner.block_cache.write().rebuild_by_hash_map();
inner
})
.inspect(|inner| inner.block_cache.write().rebuild_by_hash_map())
}

/// Returns a reference to the specification.
Expand Down
3 changes: 1 addition & 2 deletions beacon_node/store/src/leveldb_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ impl<E: EthSpec> KeyValueStore<E> for LevelDB<E> {
.get(self.read_options(), BytesKey::from_vec(column_key))
.map_err(Into::into)
.map(|opt| {
opt.map(|bytes| {
opt.inspect(|bytes| {
metrics::inc_counter_vec_by(
&metrics::DISK_DB_READ_BYTES,
&[col],
bytes.len() as u64,
);
metrics::stop_timer(timer);
bytes
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion common/account_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl ZeroizeString {

/// Remove any number of newline or carriage returns from the end of a vector of bytes.
pub fn without_newlines(&self) -> ZeroizeString {
let stripped_string = self.0.trim_end_matches(|c| c == '\r' || c == '\n').into();
let stripped_string = self.0.trim_end_matches(['\r', '\n']).into();
Self(stripped_string)
}
}
Expand Down
5 changes: 1 addition & 4 deletions common/logging/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ impl<'a> AlignedRecordDecorator<'a> {
self.ignore_comma = false;
Ok(buf.len())
} else if self.message_active {
self.wrapped.write(buf).map(|n| {
self.message_count += n;
n
})
self.wrapped.write(buf).inspect(|n| self.message_count += n)
} else {
self.wrapped.write(buf)
}
Expand Down
Loading