Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Notification-based block pinning #13157

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d5c1427
Worker
skunert Dec 22, 2022
6131598
Reorganize and unpin onnotification drop
skunert Jan 6, 2023
ccdf8ed
Pin in state-db, pass block number
skunert Jan 9, 2023
0443235
Pin blocks in blockchain db
skunert Jan 10, 2023
c1a25dc
Switch to reference counted LRU
skunert Jan 10, 2023
9d824d4
Merge branch 'master' into skunert/notification-based-pinning
skunert Jan 10, 2023
2f7f943
Disable pinning when we keep all blocks
skunert Jan 11, 2023
65caa1a
Fix pinning hint for state-db
skunert Jan 12, 2023
cc000a3
Remove pinning from backend layer
skunert Jan 12, 2023
8a22325
Improve readability
skunert Jan 12, 2023
d3d208a
Add justifications to test
skunert Jan 12, 2023
bc2d40c
Fix justification behaviour
skunert Jan 12, 2023
da7a855
Remove debug prints
skunert Jan 12, 2023
7daf11c
Convert channels to tracing_unbounded
skunert Jan 16, 2023
2fb995c
Add comments to the test
skunert Jan 16, 2023
7a072dd
Documentation and Cleanup
skunert Jan 16, 2023
92e3928
Move task start to client
skunert Jan 16, 2023
3ec854e
Simplify cache
skunert Jan 16, 2023
d5e2b1d
Improve test, remove unwanted log
skunert Jan 16, 2023
03051ca
Add tracing logs, remove expect for block number
skunert Jan 16, 2023
c4434bb
Cleanup
skunert Jan 16, 2023
347c80a
Add conversion method for unpin handle to Finalitynotification
skunert Jan 17, 2023
1198568
Revert unwanted changes
skunert Jan 17, 2023
363f01a
Improve naming
skunert Jan 17, 2023
b220553
Make clippy happy
skunert Jan 17, 2023
10dfdf7
Fix docs
skunert Jan 17, 2023
e2ff001
Merge branch 'master' into skunert/notification-based-pinning
skunert Jan 17, 2023
c4608da
Use `NumberFor` instead of u64 in API
skunert Jan 17, 2023
68cc76f
Hand over weak reference to unpin worker task
skunert Jan 17, 2023
fe2d4cc
Unwanted
skunert Jan 17, 2023
f5d6b08
&Hash -> Hash
skunert Jan 17, 2023
946e06a
Remove number from interface, rename `_unpin_handle`, LOG_TARGET
skunert Jan 18, 2023
a48e44b
Move RwLock one layer up
skunert Jan 18, 2023
4014c16
Apply code style suggestions
skunert Jan 18, 2023
d547fc2
Improve comments
skunert Jan 18, 2023
de6aa36
Replace lru crate by schnellru
skunert Jan 18, 2023
81f7493
Merge remote-tracking branch 'origin' into skunert/notification-based…
skunert Jan 19, 2023
6fa6d5c
Only insert values for pinned items + better docs
skunert Jan 19, 2023
a177b50
Apply suggestions from code review
skunert Jan 19, 2023
cbd0868
Improve comments, log target and test
skunert Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Bastian Köcher <git@kchr.de>
  • Loading branch information
skunert and bkchr authored Jan 19, 2023
commit a177b50cb8bf5acd14c58e2c530d638971296e58
2 changes: 1 addition & 1 deletion client/api/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ pub trait Backend<Block: BlockT>: AuxStore + Send + Sync {

/// Pin the block to keep bodies, justification and state available after pruning.
skunert marked this conversation as resolved.
Show resolved Hide resolved
/// Number of pins are reference counted. Users need to make sure to perform
/// one call to `unpin_block` per call to `pin_block`.
/// one call to [`Self::unpin_block`] per call to [`Self::pin_block`].
fn pin_block(&self, hash: Block::Hash) -> sp_blockchain::Result<()>;

/// Unpin the block to allow pruning.
Expand Down
4 changes: 2 additions & 2 deletions client/api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl fmt::Display for UsageInfo {
#[derive(Debug)]
pub struct UnpinHandleInner<Block: BlockT> {
/// Hash of the block pinned by this handle
pub hash: Block::Hash,
hash: Block::Hash,
unpin_worker_sender: TracingUnboundedSender<Block::Hash>,
}

Expand All @@ -285,7 +285,7 @@ impl<Block: BlockT> UnpinHandleInner<Block> {
impl<Block: BlockT> Drop for UnpinHandleInner<Block> {
fn drop(&mut self) {
if let Err(err) = self.unpin_worker_sender.unbounded_send(self.hash) {
log::error!(target: "db", "Unable to unpin block with hash: {}, error: {:?}", self.hash, err);
log::debug!(target: "db", "Unable to unpin block with hash: {}, error: {:?}", self.hash, err);
};
}
}
Expand Down
7 changes: 3 additions & 4 deletions client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,7 @@ impl<Block: BlockT> BlockchainDb<Block> {

/// Empty the cache of pinned items.
fn clear_pinning_cache(&self) {
let mut cache = self.pinned_blocks_cache.write();
cache.clear();
self.pinned_blocks_cache.write().clear();
}

/// Load a justification into the cache of pinned items.
Expand Down Expand Up @@ -2520,14 +2519,14 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
self.storage.state_db.pin(&hash, number.saturated_into::<u64>(), hint).map_err(
|_| {
sp_blockchain::Error::UnknownBlock(format!(
"State already discarded for {:?}",
"State already discarded for `{:?}`",
hash
))
},
)?;
} else {
return Err(ClientError::UnknownBlock(format!(
"Can not pin block with hash {}. Block not found.",
"Can not pin block with hash `{:?}`. Block not found.",
hash
)))
}
Expand Down
4 changes: 2 additions & 2 deletions client/service/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,11 @@ where
if let Some(backend) = task_backend.upgrade() {
backend.unpin_block(message);
} else {
log::warn!("Terminating unpin-worker, backend reference was dropped.");
log::debug!("Terminating unpin-worker, backend reference was dropped.");
return
}
}
log::warn!("Terminating unpin-worker, stream terminated.")
log::debug!("Terminating unpin-worker, stream terminated.")
}
.boxed(),
);
Expand Down