Skip to content
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

fix: try not deleting accepted blocks from signerDB #4514

Merged
merged 1 commit into from Mar 9, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions stacks-signer/src/signer.rs
Expand Up @@ -73,7 +73,7 @@ pub struct BlockInfo {
/// The associated packet nonce request if we have one
nonce_request: Option<NonceRequest>,
/// Whether this block is already being signed over
signed_over: bool,
pub signed_over: bool,
}

impl BlockInfo {
Expand Down Expand Up @@ -992,10 +992,12 @@ impl Signer {
return;
};

// TODO: proper garbage collection...This is currently our only cleanup of blocks
self.signer_db
.remove_block(&block_vote.signer_signature_hash)
.expect(&format!("{self}: Failed to remove block from to signer DB"));
// WIP: try not deleting a block from signerDB until we have a better garbage collection strategy.
// This causes issues when we have to reprocess a block and we have already deleted it from the signerDB
// // TODO: proper garbage collection...This is currently our only cleanup of blocks
// self.signer_db
// .remove_block(&block_vote.signer_signature_hash)
// .expect(&format!("{self}: Failed to remove block from to signer DB"));
Comment on lines -995 to +1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep -- I'd advocate just dropping this line permanently (no need to comment out). Now that this information is stored in a file, I don't think that there's a strong need to clean this state up.


let block_submission = if block_vote.rejected {
// We signed a rejection message. Return a rejection message
Expand Down
5 changes: 4 additions & 1 deletion stacks-signer/src/signerdb.rs
Expand Up @@ -91,8 +91,10 @@ impl SignerDb {
let block_json =
serde_json::to_string(&block_info).expect("Unable to serialize block info");
let hash = &block_info.signer_signature_hash();
let block_id = &block_info.block.block_id();
let signed_over = &block_info.signed_over;
debug!(
"Inserting block_info: sighash = {hash}, vote = {:?}",
"Inserting block_info: sighash = {hash}, block_id = {block_id}, signed = {signed_over} vote = {:?}",
block_info.vote.as_ref().map(|v| {
if v.rejected {
"REJECT"
Expand All @@ -117,6 +119,7 @@ impl SignerDb {

/// Remove a block
pub fn remove_block(&mut self, hash: &Sha512Trunc256Sum) -> Result<(), DBError> {
debug!("Deleting block_info: sighash = {hash}");
self.db.execute(
"DELETE FROM blocks WHERE signer_signature_hash = ?",
&[format!("{}", hash)],
Expand Down