mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 12:31:03 +00:00
Approval Voting improvements (#2781)
* extract database from av-store itself * generalize approval-voting over database type * modes (without handling) and pruning old wakeups * rework approval importing * add our_approval_sig to ApprovalEntry * import assignment * guide updates for check-full-approval changes * some aux functions * send messages when becoming active. * guide: network bridge sends view updates only when done syncing * network bridge: send view updates only when done syncing * tests for new network-bridge behavior * add a test for updating approval entry with sig * fix some warnings * test load-all-blocks * instantiate new parachains DB * fix network-bridge empty view updates * tweak * fix wasm build, i think * Update node/core/approval-voting/src/lib.rs Co-authored-by: Andronik Ordian <write@reusable.software> * add some versioning to parachains_db * warnings * fix merge changes * remove versioning again Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
committed by
GitHub
parent
01badafba6
commit
57b56770e0
@@ -21,10 +21,10 @@
|
||||
pub mod chain_spec;
|
||||
mod grandpa_support;
|
||||
mod client;
|
||||
mod parachains_db;
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
use {
|
||||
std::convert::TryInto,
|
||||
std::time::Duration,
|
||||
tracing::info,
|
||||
polkadot_node_core_av_store::Config as AvailabilityConfig,
|
||||
@@ -418,7 +418,9 @@ fn real_overseer<Spawner, RuntimeClient>(
|
||||
leaves: impl IntoIterator<Item = BlockInfo>,
|
||||
_: Arc<LocalKeystore>,
|
||||
_: Arc<RuntimeClient>,
|
||||
_parachains_db: (),
|
||||
_: AvailabilityConfig,
|
||||
_: ApprovalVotingConfig,
|
||||
_: Arc<sc_network::NetworkService<Block, Hash>>,
|
||||
_: AuthorityDiscoveryService,
|
||||
_request_multiplexer: (),
|
||||
@@ -426,7 +428,6 @@ fn real_overseer<Spawner, RuntimeClient>(
|
||||
spawner: Spawner,
|
||||
_: IsCollator,
|
||||
_: IsolationStrategy,
|
||||
_: ApprovalVotingConfig,
|
||||
) -> Result<(Overseer<Spawner>, OverseerHandler), Error>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
@@ -446,7 +447,9 @@ fn real_overseer<Spawner, RuntimeClient>(
|
||||
leaves: impl IntoIterator<Item = BlockInfo>,
|
||||
keystore: Arc<LocalKeystore>,
|
||||
runtime_client: Arc<RuntimeClient>,
|
||||
parachains_db: Arc<dyn kvdb::KeyValueDB>,
|
||||
availability_config: AvailabilityConfig,
|
||||
approval_voting_config: ApprovalVotingConfig,
|
||||
network_service: Arc<sc_network::NetworkService<Block, Hash>>,
|
||||
authority_discovery: AuthorityDiscoveryService,
|
||||
request_multiplexer: RequestMultiplexer,
|
||||
@@ -454,7 +457,6 @@ fn real_overseer<Spawner, RuntimeClient>(
|
||||
spawner: Spawner,
|
||||
is_collator: IsCollator,
|
||||
isolation_strategy: IsolationStrategy,
|
||||
approval_voting_config: ApprovalVotingConfig,
|
||||
) -> Result<(Overseer<Spawner>, OverseerHandler), Error>
|
||||
where
|
||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
||||
@@ -489,10 +491,11 @@ where
|
||||
),
|
||||
availability_recovery: AvailabilityRecoverySubsystem::with_chunks_only(
|
||||
),
|
||||
availability_store: AvailabilityStoreSubsystem::new_on_disk(
|
||||
availability_store: AvailabilityStoreSubsystem::new(
|
||||
parachains_db.clone(),
|
||||
availability_config,
|
||||
Metrics::register(registry)?,
|
||||
)?,
|
||||
),
|
||||
bitfield_distribution: BitfieldDistributionSubsystem::new(
|
||||
Metrics::register(registry)?,
|
||||
),
|
||||
@@ -537,9 +540,10 @@ where
|
||||
)
|
||||
},
|
||||
network_bridge: NetworkBridgeSubsystem::new(
|
||||
network_service,
|
||||
network_service.clone(),
|
||||
authority_discovery,
|
||||
request_multiplexer,
|
||||
Box::new(network_service.clone()),
|
||||
),
|
||||
provisioner: ProvisionerSubsystem::new(
|
||||
spawner.clone(),
|
||||
@@ -559,9 +563,11 @@ where
|
||||
),
|
||||
approval_voting: ApprovalVotingSubsystem::with_config(
|
||||
approval_voting_config,
|
||||
parachains_db,
|
||||
keystore.clone(),
|
||||
Box::new(network_service.clone()),
|
||||
Metrics::register(registry)?,
|
||||
)?,
|
||||
),
|
||||
gossip_support: GossipSupportSubsystem::new(
|
||||
keystore.clone(),
|
||||
runtime_client.clone(),
|
||||
@@ -843,17 +849,26 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
);
|
||||
}
|
||||
|
||||
let availability_config = config.database.clone().try_into().map_err(Error::Availability)?;
|
||||
let chain_spec = config.chain_spec.cloned_box();
|
||||
#[cfg(feature = "real-overseer")]
|
||||
let parachains_db = crate::parachains_db::open_creating(
|
||||
config.database.path().ok_or(Error::DatabasePathRequired)?.into(),
|
||||
crate::parachains_db::CacheSizes::default(),
|
||||
)?;
|
||||
|
||||
let approval_voting_config = ApprovalVotingConfig {
|
||||
path: config.database.path()
|
||||
.ok_or(Error::DatabasePathRequired)?
|
||||
.join("parachains").join("approval-voting"),
|
||||
slot_duration_millis: slot_duration.as_millis() as u64,
|
||||
cache_size: None, // default is fine.
|
||||
#[cfg(not(feature = "real-overseer"))]
|
||||
let parachains_db = ();
|
||||
|
||||
let availability_config = AvailabilityConfig {
|
||||
col_data: crate::parachains_db::REAL_COLUMNS.col_availability_data,
|
||||
col_meta: crate::parachains_db::REAL_COLUMNS.col_availability_meta,
|
||||
};
|
||||
|
||||
let approval_voting_config = ApprovalVotingConfig {
|
||||
col_data: crate::parachains_db::REAL_COLUMNS.col_approval_data,
|
||||
slot_duration_millis: slot_duration.as_millis() as u64,
|
||||
};
|
||||
|
||||
let chain_spec = config.chain_spec.cloned_box();
|
||||
let rpc_handlers = service::spawn_tasks(service::SpawnTasksParams {
|
||||
config,
|
||||
backend: backend.clone(),
|
||||
@@ -922,7 +937,9 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
active_leaves,
|
||||
keystore,
|
||||
overseer_client.clone(),
|
||||
parachains_db,
|
||||
availability_config,
|
||||
approval_voting_config,
|
||||
network.clone(),
|
||||
authority_discovery_service,
|
||||
request_multiplexer,
|
||||
@@ -930,7 +947,6 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
spawner,
|
||||
is_collator,
|
||||
isolation_strategy,
|
||||
approval_voting_config,
|
||||
)?;
|
||||
let overseer_handler_clone = overseer_handler.clone();
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
//! A RocksDB instance for storing parachain data; availability data, and approvals.
|
||||
|
||||
#[cfg(feature = "real-overseer")]
|
||||
use {
|
||||
std::io,
|
||||
std::path::PathBuf,
|
||||
std::sync::Arc,
|
||||
|
||||
kvdb::KeyValueDB,
|
||||
};
|
||||
|
||||
|
||||
mod columns {
|
||||
#[cfg(feature = "real-overseer")]
|
||||
pub const NUM_COLUMNS: u32 = 3;
|
||||
|
||||
|
||||
pub const COL_AVAILABILITY_DATA: u32 = 0;
|
||||
pub const COL_AVAILABILITY_META: u32 = 1;
|
||||
pub const COL_APPROVAL_DATA: u32 = 2;
|
||||
}
|
||||
|
||||
/// Columns used by different subsystems.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ColumnsConfig {
|
||||
/// The column used by the av-store for data.
|
||||
pub col_availability_data: u32,
|
||||
/// The column used by the av-store for meta information.
|
||||
pub col_availability_meta: u32,
|
||||
/// The column used by approval voting for data.
|
||||
pub col_approval_data: u32,
|
||||
}
|
||||
|
||||
/// The real columns used by the parachains DB.
|
||||
pub const REAL_COLUMNS: ColumnsConfig = ColumnsConfig {
|
||||
col_availability_data: columns::COL_AVAILABILITY_DATA,
|
||||
col_availability_meta: columns::COL_AVAILABILITY_META,
|
||||
col_approval_data: columns::COL_APPROVAL_DATA,
|
||||
};
|
||||
|
||||
/// The cache size for each column, in bytes.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CacheSizes {
|
||||
/// Cache used by availability data.
|
||||
pub availability_data: usize,
|
||||
/// Cache used by availability meta.
|
||||
pub availability_meta: usize,
|
||||
/// Cache used by approval data.
|
||||
pub approval_data: usize,
|
||||
}
|
||||
|
||||
impl Default for CacheSizes {
|
||||
fn default() -> Self {
|
||||
CacheSizes {
|
||||
availability_data: 25 * 1024 * 1024,
|
||||
availability_meta: 512 * 1024,
|
||||
approval_data: 5 * 1024 * 1024,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Open the database on disk, creating it if it doesn't exist.
|
||||
#[cfg(feature = "real-overseer")]
|
||||
pub fn open_creating(
|
||||
root: PathBuf,
|
||||
cache_sizes: CacheSizes,
|
||||
) -> io::Result<Arc<dyn KeyValueDB>> {
|
||||
use kvdb_rocksdb::{DatabaseConfig, Database};
|
||||
|
||||
let path = root.join("parachains").join("db");
|
||||
|
||||
let mut db_config = DatabaseConfig::with_columns(columns::NUM_COLUMNS);
|
||||
|
||||
let _ = db_config.memory_budget
|
||||
.insert(columns::COL_AVAILABILITY_DATA, cache_sizes.availability_data);
|
||||
let _ = db_config.memory_budget
|
||||
.insert(columns::COL_AVAILABILITY_META, cache_sizes.availability_meta);
|
||||
let _ = db_config.memory_budget
|
||||
.insert(columns::COL_APPROVAL_DATA, cache_sizes.approval_data);
|
||||
|
||||
let path = path.to_str().ok_or_else(|| io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("Bad database path: {:?}", path),
|
||||
))?;
|
||||
|
||||
std::fs::create_dir_all(&path)?;
|
||||
let db = Database::open(&db_config, &path)?;
|
||||
|
||||
Ok(Arc::new(db))
|
||||
}
|
||||
Reference in New Issue
Block a user