Skip to content

Commit

Permalink
Merge pull request #2203 from subspace/fix-sending-duplicate-proofs
Browse files Browse the repository at this point in the history
Fix sending duplicate proofs
  • Loading branch information
nazar-pc authored Nov 7, 2023
2 parents f692927 + bcb5604 commit ee44e02
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
3 changes: 1 addition & 2 deletions crates/sc-consensus-subspace-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ where
slot = %slot_number,
%sector_index,
%public_key,
"Solution receiver is closed, likely because farmer was too \
slow"
"Solution receiver is closed, likely because farmer was too slow"
);
}
}
Expand Down
18 changes: 9 additions & 9 deletions crates/sc-proof-of-time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,17 @@ pub async fn start_slot_worker<Block, Client, SC, Worker, SO, CIDP>(

let mut worker = SimpleSlotWorkerToSlotWorker(worker);

let mut maybe_last_claimed_slot = None;
let mut maybe_last_proven_slot = None;

while let Some(PotSlotInfo { slot, checkpoints }) = slot_info_stream.next().await {
if let Some(last_proven_slot) = maybe_last_proven_slot {
if last_proven_slot >= slot {
// Already processed
continue;
}
}
maybe_last_proven_slot.replace(slot);

worker.0.on_proof(slot, checkpoints);

if sync_oracle.is_major_syncing() {
Expand All @@ -86,14 +94,6 @@ pub async fn start_slot_worker<Block, Client, SC, Worker, SO, CIDP>(
continue;
};

if let Some(last_claimed_slot) = maybe_last_claimed_slot {
if last_claimed_slot >= slot_to_claim {
// Already processed
continue;
}
}
maybe_last_claimed_slot.replace(slot_to_claim);

if let Some(slot_info) = slot_info_producer.produce_slot_info(slot_to_claim).await {
let _ = worker.on_slot(slot_info).await;
}
Expand Down
28 changes: 19 additions & 9 deletions crates/sc-proof-of-time/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub struct PotSourceWorker<Block, Client, SO> {
timekeeper_proofs_receiver: mpsc::Receiver<TimekeeperProof>,
to_gossip_sender: mpsc::Sender<ToGossipMessage>,
from_gossip_receiver: mpsc::Receiver<(PeerId, GossipProof)>,
last_slot_sent: Slot,
slot_sender: mpsc::Sender<PotSlotInfo>,
state: Arc<PotState>,
_block: PhantomData<Block>,
Expand Down Expand Up @@ -176,6 +177,7 @@ where
timekeeper_proofs_receiver,
to_gossip_sender,
from_gossip_receiver,
last_slot_sent: Slot::from(0),
slot_sender,
state,
_block: PhantomData,
Expand Down Expand Up @@ -268,9 +270,13 @@ where
);
}

// We don't care if block production is too slow or block production is not enabled on this
// node at all
let _ = self.slot_sender.try_send(PotSlotInfo { slot, checkpoints });
if slot > self.last_slot_sent {
self.last_slot_sent = slot;

// We don't care if block production is too slow or block production is not enabled on this
// node at all
let _ = self.slot_sender.try_send(PotSlotInfo { slot, checkpoints });
}
}

// TODO: Follow both verified and unverified checkpoints to start secondary timekeeper ASAP in
Expand All @@ -288,12 +294,16 @@ where
proof.checkpoints.output(),
None,
) {
// We don't care if block production is too slow or block production is not enabled on
// this node at all
let _ = self.slot_sender.try_send(PotSlotInfo {
slot: proof.slot,
checkpoints: proof.checkpoints,
});
if proof.slot > self.last_slot_sent {
self.last_slot_sent = proof.slot;

// We don't care if block production is too slow or block production is not enabled on
// this node at all
let _ = self.slot_sender.try_send(PotSlotInfo {
slot: proof.slot,
checkpoints: proof.checkpoints,
});
}

if self
.to_gossip_sender
Expand Down

0 comments on commit ee44e02

Please sign in to comment.