Blockstore exact purge cleanup (#13946)
* Add failing test * Clean up signature get
This commit is contained in:
parent
34b68288c8
commit
85aa632be0
|
@ -273,21 +273,13 @@ impl Blockstore {
|
||||||
.cloned()
|
.cloned()
|
||||||
.flat_map(|entry| entry.transactions)
|
.flat_map(|entry| entry.transactions)
|
||||||
{
|
{
|
||||||
batch.delete::<cf::TransactionStatus>((0, transaction.signatures[0], slot))?;
|
if let Some(&signature) = transaction.signatures.get(0) {
|
||||||
batch.delete::<cf::TransactionStatus>((1, transaction.signatures[0], slot))?;
|
batch.delete::<cf::TransactionStatus>((0, signature, slot))?;
|
||||||
for pubkey in transaction.message.account_keys {
|
batch.delete::<cf::TransactionStatus>((1, signature, slot))?;
|
||||||
batch.delete::<cf::AddressSignatures>((
|
for pubkey in transaction.message.account_keys {
|
||||||
0,
|
batch.delete::<cf::AddressSignatures>((0, pubkey, slot, signature))?;
|
||||||
pubkey,
|
batch.delete::<cf::AddressSignatures>((1, pubkey, slot, signature))?;
|
||||||
slot,
|
}
|
||||||
transaction.signatures[0],
|
|
||||||
))?;
|
|
||||||
batch.delete::<cf::AddressSignatures>((
|
|
||||||
1,
|
|
||||||
pubkey,
|
|
||||||
slot,
|
|
||||||
transaction.signatures[0],
|
|
||||||
))?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +324,15 @@ impl Blockstore {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod tests {
|
pub mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{blockstore::tests::make_slot_entries_with_transactions, get_tmp_ledger_path};
|
use crate::{
|
||||||
|
blockstore::tests::make_slot_entries_with_transactions, entry::next_entry_mut,
|
||||||
|
get_tmp_ledger_path,
|
||||||
|
};
|
||||||
|
use bincode::serialize;
|
||||||
|
use solana_sdk::{
|
||||||
|
hash::{hash, Hash},
|
||||||
|
message::Message,
|
||||||
|
};
|
||||||
|
|
||||||
// check that all columns are either empty or start at `min_slot`
|
// check that all columns are either empty or start at `min_slot`
|
||||||
fn test_all_empty_or_min(blockstore: &Blockstore, min_slot: Slot) {
|
fn test_all_empty_or_min(blockstore: &Blockstore, min_slot: Slot) {
|
||||||
|
@ -1133,4 +1133,30 @@ pub mod tests {
|
||||||
}
|
}
|
||||||
Blockstore::destroy(&blockstore_path).expect("Expected successful database destruction");
|
Blockstore::destroy(&blockstore_path).expect("Expected successful database destruction");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_purge_special_columns_exact_no_sigs() {
|
||||||
|
let blockstore_path = get_tmp_ledger_path!();
|
||||||
|
{
|
||||||
|
let blockstore = Blockstore::open(&blockstore_path).unwrap();
|
||||||
|
|
||||||
|
let slot = 1;
|
||||||
|
let mut entries: Vec<Entry> = vec![];
|
||||||
|
for x in 0..5 {
|
||||||
|
let mut tx = Transaction::new_unsigned(Message::default());
|
||||||
|
tx.signatures = vec![];
|
||||||
|
entries.push(next_entry_mut(&mut Hash::default(), 0, vec![tx]));
|
||||||
|
let mut tick = create_ticks(1, 0, hash(&serialize(&x).unwrap()));
|
||||||
|
entries.append(&mut tick);
|
||||||
|
}
|
||||||
|
let shreds = entries_to_test_shreds(entries, slot, slot - 1, true, 0);
|
||||||
|
blockstore.insert_shreds(shreds, None, false).unwrap();
|
||||||
|
|
||||||
|
let mut write_batch = blockstore.db.batch().unwrap();
|
||||||
|
blockstore
|
||||||
|
.purge_special_columns_exact(&mut write_batch, slot, slot + 1)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
Blockstore::destroy(&blockstore_path).expect("Expected successful database destruction");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue