DatabaseSource::Auto (#9500)

* implement "auto" database backend in client/db, in progress, #9201

* move fn supports_ref_counting from DatabaseSource enum to Database trait to make it work correctly for all types of dbs

* update kvdb_rocksdb to 0.13 and use it's new config feature  to properly auto start existing database

* tests for auto database reopening

* introduce OpenDbError to cleanup opening database error handling and handle case when database is not enabled at the compile time

* cargo fmt strings again

* cargo fmt strings again

* rename DataSettingsSrc to fix test compilation

* fix the call to the new kvdb-rocksdb interdace in tests to fix compilation

* simplify OpenDbError and make it compile even when paritydb and rocksdb are disabled

* cargo fmt

* fix compilation without flag with-parity-db

* fix unused var compilation warning

* support different paths for rocksdb and paritydb in DatabaseSouce::Auto

* support "auto" database option in substrate cli

* enable Lz4 compression for some of the parity-db colums as per review suggestion

* applied review suggestions
This commit is contained in:
Marek Kotewicz
2021-08-09 15:22:28 +02:00
committed by GitHub
parent 4dc8db2b80
commit a2f7524138
21 changed files with 549 additions and 219 deletions
+2 -5
View File
@@ -19,10 +19,7 @@
//! Service configuration.
pub use sc_client_api::execution_extensions::{ExecutionStrategies, ExecutionStrategy};
pub use sc_client_db::{
Database, DatabaseSettingsSrc as DatabaseConfig, KeepBlocks, PruningMode,
TransactionStorageMode,
};
pub use sc_client_db::{Database, DatabaseSource, KeepBlocks, PruningMode, TransactionStorageMode};
pub use sc_executor::WasmExecutionMethod;
pub use sc_network::{
config::{
@@ -69,7 +66,7 @@ pub struct Configuration {
/// Remote URI to connect to for async keystore support
pub keystore_remote: Option<String>,
/// Configuration for the database.
pub database: DatabaseConfig,
pub database: DatabaseSource,
/// Size of internal state cache in Bytes
pub state_cache_size: usize,
/// Size in percent of cache size dedicated to child tries
+1 -1
View File
@@ -59,7 +59,7 @@ pub use self::{
error::Error,
};
pub use config::{
BasePath, Configuration, DatabaseConfig, KeepBlocks, PruningMode, Role, RpcMethods,
BasePath, Configuration, DatabaseSource, KeepBlocks, PruningMode, Role, RpcMethods,
TaskExecutor, TaskType, TransactionStorageMode,
};
pub use sc_chain_spec::{
@@ -22,7 +22,7 @@ use parity_scale_codec::{Decode, Encode, Joiner};
use sc_block_builder::BlockBuilderProvider;
use sc_client_api::{in_mem, BlockBackend, BlockchainEvents, StorageProvider};
use sc_client_db::{
Backend, DatabaseSettings, DatabaseSettingsSrc, KeepBlocks, PruningMode, TransactionStorageMode,
Backend, DatabaseSettings, DatabaseSource, KeepBlocks, PruningMode, TransactionStorageMode,
};
use sc_consensus::{
BlockCheckParams, BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult,
@@ -1433,7 +1433,7 @@ fn doesnt_import_blocks_that_revert_finality() {
state_pruning: PruningMode::ArchiveAll,
keep_blocks: KeepBlocks::All,
transaction_storage: TransactionStorageMode::BlockBody,
source: DatabaseSettingsSrc::RocksDb { path: tmp.path().into(), cache_size: 1024 },
source: DatabaseSource::RocksDb { path: tmp.path().into(), cache_size: 1024 },
},
u64::MAX,
)
@@ -1648,7 +1648,7 @@ fn returns_status_for_pruned_blocks() {
state_pruning: PruningMode::keep_blocks(1),
keep_blocks: KeepBlocks::All,
transaction_storage: TransactionStorageMode::BlockBody,
source: DatabaseSettingsSrc::RocksDb { path: tmp.path().into(), cache_size: 1024 },
source: DatabaseSource::RocksDb { path: tmp.path().into(), cache_size: 1024 },
},
u64::MAX,
)
+2 -2
View File
@@ -29,7 +29,7 @@ use sc_network::{
};
use sc_service::{
client::Client,
config::{BasePath, DatabaseConfig, KeystoreConfig},
config::{BasePath, DatabaseSource, KeystoreConfig},
ChainSpecExtension, Configuration, Error, GenericChainSpec, KeepBlocks, Role, RuntimeGenesis,
SpawnTaskHandle, TaskExecutor, TaskManager, TransactionStorageMode,
};
@@ -236,7 +236,7 @@ fn node_config<
network: network_config,
keystore_remote: Default::default(),
keystore: KeystoreConfig::Path { path: root.join("key"), password: None },
database: DatabaseConfig::RocksDb { path: root.join("db"), cache_size: 128 },
database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 },
state_cache_size: 16777216,
state_cache_child_ratio: None,
state_pruning: Default::default(),