Skip to content

Commit c58f5e0

Browse files
committed
beacon_node, consensus: fix possible deadlocks when comparing with itself
1 parent ce10db1 commit c58f5e0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

beacon_node/operation_pool/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ fn prune_validator_hash_map<T, F, E: EthSpec>(
408408
/// Compare two operation pools.
409409
impl<T: EthSpec + Default> PartialEq for OperationPool<T> {
410410
fn eq(&self, other: &Self) -> bool {
411+
if self as *const _ == other as *const _ {
412+
return true;
413+
}
411414
*self.attestations.read() == *other.attestations.read()
412415
&& *self.attester_slashings.read() == *other.attester_slashings.read()
413416
&& *self.proposer_slashings.read() == *other.proposer_slashings.read()

consensus/proto_array_fork_choice/src/proto_array_fork_choice.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub struct ProtoArrayForkChoice {
5151

5252
impl PartialEq for ProtoArrayForkChoice {
5353
fn eq(&self, other: &Self) -> bool {
54+
if self as *const _ == other as *const _ {
55+
return true;
56+
}
5457
*self.proto_array.read() == *other.proto_array.read()
5558
&& *self.votes.read() == *other.votes.read()
5659
&& *self.balances.read() == *other.balances.read()

0 commit comments

Comments
 (0)