Skip to content

Commit

Permalink
feat(storage, tree): respect Sender Recovery pruning in the blockch…
Browse files Browse the repository at this point in the history
…ain tree (#4431)
  • Loading branch information
shekhirin authored Sep 5, 2023
1 parent 3e7e651 commit 001cbd7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions crates/storage/provider/src/providers/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ mod tests {
{
let provider = factory.provider_rw().unwrap();
assert_matches!(provider.insert_block(block.clone(), None, None), Ok(_));
assert_matches!(
provider.transaction_sender(0), Ok(Some(sender))
if sender == block.body[0].recover_signer().unwrap()
);
assert_matches!(provider.transaction_id(block.body[0].hash), Ok(Some(0)));
}

Expand All @@ -478,12 +482,14 @@ mod tests {
block.clone(),
None,
Some(&PruneModes {
sender_recovery: Some(PruneMode::Full),
transaction_lookup: Some(PruneMode::Full),
..PruneModes::none()
})
),
Ok(_)
);
assert_matches!(provider.transaction_sender(0), Ok(None));
assert_matches!(provider.transaction_id(block.body[0].hash), Ok(None));
}
}
Expand Down
10 changes: 9 additions & 1 deletion crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,15 @@ impl<'this, TX: DbTxMut<'this> + DbTx<'this>> BlockWriter for DatabaseProvider<'

for (transaction, sender) in tx_iter {
let hash = transaction.hash();
self.tx.put::<tables::TxSenders>(next_tx_num, sender)?;

if prune_modes
.and_then(|modes| modes.sender_recovery)
.filter(|prune_mode| prune_mode.is_full())
.is_none()
{
self.tx.put::<tables::TxSenders>(next_tx_num, sender)?;
}

self.tx.put::<tables::Transactions>(next_tx_num, transaction.into())?;

if prune_modes
Expand Down

0 comments on commit 001cbd7

Please sign in to comment.