polkadot: pin one block per session (#1220)

* polkadot: propagate UnpinHandle to ActiveLeafUpdate

Also extract the leaf creation for tests
into a common function.

* dispute-coordinator: try pinned blocks for slashin

* apparently 1.72 is smarter than 1.70

* address nits

* rename fresh_leaf to new_leaf
This commit is contained in:
ordian
2023-09-07 12:24:40 +02:00
committed by GitHub
parent 1346143194
commit 15503883e2
33 changed files with 387 additions and 620 deletions
+1
View File
@@ -19,6 +19,7 @@ sc-network = { path = "../../../substrate/client/network" }
sp-api = { path = "../../../substrate/primitives/api" }
sp-consensus-babe = { path = "../../../substrate/primitives/consensus/babe" }
sp-authority-discovery = { path = "../../../substrate/primitives/authority-discovery" }
sc-client-api = { path = "../../../substrate/client/api" }
sc-transaction-pool-api = { path = "../../../substrate/client/transaction-pool/api" }
smallvec = "1.8.0"
substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" }
+13 -2
View File
@@ -22,10 +22,19 @@
#![warn(missing_docs)]
use smallvec::SmallVec;
use std::{fmt, sync::Arc};
pub use polkadot_primitives::{BlockNumber, Hash};
use smallvec::SmallVec;
pub use polkadot_primitives::{Block, BlockNumber, Hash};
/// Keeps the state of a specific block pinned in memory while the handle is alive.
///
/// The handle is reference counted and once the last is dropped, the
/// block is unpinned.
///
/// This is useful for runtime API calls to blocks that are
/// racing against finality, e.g. for slashing purposes.
pub type UnpinHandle = sc_client_api::UnpinHandle<Block>;
pub mod errors;
pub mod messages;
@@ -80,6 +89,8 @@ pub struct ActivatedLeaf {
pub number: BlockNumber,
/// The status of the leaf.
pub status: LeafStatus,
/// A handle to unpin the block on drop.
pub unpin_handle: UnpinHandle,
/// An associated [`jaeger::Span`].
///
/// NOTE: Each span should only be kept active as long as the leaf is considered active and