Skip to content

Commit

Permalink
Refactored block body database scheme (paritytech#10779)
Browse files Browse the repository at this point in the history
* Refactored tx storage database scheme

* Bump parity-db

* fmt

* Fix handling invalid index size + test

* Removed superflous result

* Minor changes

* fmt
  • Loading branch information
arkpar authored and grishasobol committed Mar 28, 2022
1 parent 1acb138 commit 07fb82f
Show file tree
Hide file tree
Showing 15 changed files with 329 additions and 292 deletions.
3 changes: 1 addition & 2 deletions bin/node/cli/benches/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use sc_consensus::{
use sc_service::{
config::{
DatabaseSource, KeepBlocks, KeystoreConfig, NetworkConfiguration, OffchainWorkerConfig,
PruningMode, TransactionStorageMode, WasmExecutionMethod,
PruningMode, WasmExecutionMethod,
},
BasePath, Configuration, Role,
};
Expand Down Expand Up @@ -76,7 +76,6 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
state_cache_child_ratio: None,
state_pruning: PruningMode::ArchiveAll,
keep_blocks: KeepBlocks::All,
transaction_storage: TransactionStorageMode::BlockBody,
chain_spec: spec,
wasm_method: WasmExecutionMethod::Compiled,
execution_strategies: ExecutionStrategies {
Expand Down
3 changes: 1 addition & 2 deletions bin/node/cli/benches/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use sc_client_api::execution_extensions::ExecutionStrategies;
use sc_service::{
config::{
DatabaseSource, KeepBlocks, KeystoreConfig, NetworkConfiguration, OffchainWorkerConfig,
PruningMode, TransactionPoolOptions, TransactionStorageMode, WasmExecutionMethod,
PruningMode, TransactionPoolOptions, WasmExecutionMethod,
},
BasePath, Configuration, Role,
};
Expand Down Expand Up @@ -67,7 +67,6 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
state_cache_child_ratio: None,
state_pruning: PruningMode::ArchiveAll,
keep_blocks: KeepBlocks::All,
transaction_storage: TransactionStorageMode::BlockBody,
chain_spec: spec,
wasm_method: WasmExecutionMethod::Interpreted,
// NOTE: we enforce the use of the native runtime to make the errors more debuggable
Expand Down
1 change: 0 additions & 1 deletion bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ impl BenchDb {
state_pruning: PruningMode::ArchiveAll,
source: database_type.into_settings(dir.into()),
keep_blocks: sc_client_db::KeepBlocks::All,
transaction_storage: sc_client_db::TransactionStorageMode::BlockBody,
};
let task_executor = TaskExecutor::new();

Expand Down
11 changes: 1 addition & 10 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sc_service::{
NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcMethods,
TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod,
},
ChainSpec, KeepBlocks, TracingReceiver, TransactionStorageMode,
ChainSpec, KeepBlocks, TracingReceiver,
};
use sc_tracing::logging::LoggerBuilder;
use std::{net::SocketAddr, path::PathBuf};
Expand Down Expand Up @@ -203,14 +203,6 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
Ok(self.database_params().map(|x| x.database_cache_size()).unwrap_or_default())
}

/// Get the database transaction storage scheme.
fn database_transaction_storage(&self) -> Result<TransactionStorageMode> {
Ok(self
.database_params()
.map(|x| x.transaction_storage())
.unwrap_or(TransactionStorageMode::BlockBody))
}

/// Get the database backend variant.
///
/// By default this is retrieved from `DatabaseParams` if it is available. Otherwise its `None`.
Expand Down Expand Up @@ -526,7 +518,6 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
state_cache_child_ratio: self.state_cache_child_ratio()?,
state_pruning: self.state_pruning(unsafe_pruning, &role)?,
keep_blocks: self.keep_blocks()?,
transaction_storage: self.database_transaction_storage()?,
wasm_method: self.wasm_method()?,
wasm_runtime_overrides: self.wasm_runtime_overrides(),
execution_strategies: self.execution_strategies(
Expand Down
19 changes: 0 additions & 19 deletions client/cli/src/params/database_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use crate::arg_enums::Database;
use clap::Args;
use sc_service::TransactionStorageMode;

/// Parameters for block import.
#[derive(Debug, Clone, PartialEq, Args)]
Expand All @@ -36,15 +35,6 @@ pub struct DatabaseParams {
/// Limit the memory the database cache can use.
#[clap(long = "db-cache", value_name = "MiB")]
pub database_cache_size: Option<usize>,

/// Enable storage chain mode
///
/// This changes the storage format for blocks bodies.
/// If this is enabled, each transaction is stored separately in the
/// transaction database column and is only referenced by hash
/// in the block body column.
#[clap(long)]
pub storage_chain: bool,
}

impl DatabaseParams {
Expand All @@ -57,13 +47,4 @@ impl DatabaseParams {
pub fn database_cache_size(&self) -> Option<usize> {
self.database_cache_size
}

/// Transaction storage scheme.
pub fn transaction_storage(&self) -> TransactionStorageMode {
if self.storage_chain {
TransactionStorageMode::StorageChain
} else {
TransactionStorageMode::BlockBody
}
}
}
Loading

0 comments on commit 07fb82f

Please sign in to comment.