-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(node/bft): suppress benign message about certificate already exis… #4284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: testnet
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1764,7 +1764,10 @@ impl<N: Network> Primary<N> { | |
|
|
||
| // Store the certified batch. | ||
| let (storage, certificate_) = (self.storage.clone(), certificate.clone()); | ||
| spawn_blocking!(storage.insert_certificate(certificate_, transmissions, Default::default()))?; | ||
| tokio::task::spawn_blocking(move || { | ||
| storage.insert_certificate(certificate_, transmissions, Default::default()) | ||
| }) | ||
| .await??; | ||
| debug!("Stored a batch certificate for round {}", certificate.round()); | ||
| // The batch is now in storage, so late-arriving signatures can find it via contains_batch. | ||
| // Transition from Certified back to None. | ||
|
|
@@ -1860,18 +1863,30 @@ impl<N: Network> Primary<N> { | |
| self.sync_with_batch_header_from_peer::<IS_SYNCING, false>(peer_ip, batch_header).await?; | ||
|
|
||
| // Check if the certificate needs to be stored. | ||
| if !self.storage.contains_certificate(certificate.id()) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now caught by |
||
| // Store the batch certificate. | ||
| let (storage, certificate_) = (self.storage.clone(), certificate.clone()); | ||
| spawn_blocking!(storage.insert_certificate(certificate_, missing_transmissions, Default::default()))?; | ||
| debug!("Stored a batch certificate for round {batch_round} from '{peer_ip}'"); | ||
| // If a BFT sender was provided, send the round and certificate to the BFT. | ||
| if let Some(cb) = self.primary_callback.get() { | ||
| cb.add_new_certificate(certificate).await.with_context(|| "Failed to update the DAG from sync")?; | ||
| // Store the batch certificate. | ||
| let (storage, certificate_) = (self.storage.clone(), certificate.clone()); | ||
| match tokio::task::spawn_blocking(move || { | ||
| storage.insert_certificate(certificate_, missing_transmissions, Default::default()) | ||
| }) | ||
| .await | ||
| { | ||
| Ok(Ok(_)) => {} // continue | ||
| Ok(Err(err)) if err.is_benign() => { | ||
| trace!("Skipping insertion for certificate - {err}"); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this should even be logged, but it can always be removed in the future |
||
| return Ok(()); | ||
| } | ||
| // Wake the round-increment task to re-check quorum. | ||
| self.round_increment_notify.notify_one(); | ||
| Ok(Err(err)) => return Err(anyhow!("{err}")), | ||
| Err(err) => return Err(anyhow!("[tokio::spawn_blocking] {err}")), | ||
| } | ||
|
|
||
| debug!("Stored a batch certificate for round {batch_round} from '{peer_ip}'"); | ||
| // If a BFT sender was provided, send the round and certificate to the BFT. | ||
| if let Some(cb) = self.primary_callback.get() { | ||
| cb.add_new_certificate(certificate).await.with_context(|| "Failed to update the DAG from sync")?; | ||
| } | ||
| // Wake the round-increment task to re-check quorum. | ||
| self.round_increment_notify.notify_one(); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These subsequent checks happen without any locking. Otherwise, this second check would only trigger if there are two certificates with same author+round with different IDs.
It would make sense to merge the two checks to at least do this part atomically, and have a dedicated error for the more severe case where two certificates with different IDs exist.