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

update kvdb & co #12312

Merged
merged 10 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
89 changes: 32 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bin/node/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ sp-state-machine = { version = "0.12.0", path = "../../../primitives/state-machi
serde = "1.0.136"
serde_json = "1.0.85"
derive_more = { version = "0.99.17", default-features = false, features = ["display"] }
kvdb = "0.11.0"
kvdb-rocksdb = "0.15.1"
kvdb = "0.12.0"
kvdb-rocksdb = "0.16.0"
sp-trie = { version = "6.0.0", path = "../../../primitives/trie" }
sp-core = { version = "6.0.0", path = "../../../primitives/core" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
Expand All @@ -37,7 +37,7 @@ fs_extra = "1"
hex = "0.4.0"
rand = { version = "0.7.2", features = ["small_rng"] }
lazy_static = "1.4.0"
parity-util-mem = { version = "0.11.0", default-features = false, features = ["primitive-types"] }
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
parity-db = { version = "0.3" }
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
Expand Down
13 changes: 4 additions & 9 deletions bin/node/bench/src/tempdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use kvdb::{DBTransaction, KeyValueDB};
use kvdb::{DBKeyValue, DBTransaction, KeyValueDB};
use kvdb_rocksdb::{Database, DatabaseConfig};
use std::{io, path::PathBuf, sync::Arc};

Expand All @@ -38,7 +38,7 @@ impl KeyValueDB for ParityDbWrapper {
}

/// Get a value by partial key. Only works for flushed data.
fn get_by_prefix(&self, _col: u32, _prefix: &[u8]) -> Option<Box<[u8]>> {
fn get_by_prefix(&self, _col: u32, _prefix: &[u8]) -> io::Result<Option<Vec<u8>>> {
unimplemented!()
}

Expand All @@ -56,7 +56,7 @@ impl KeyValueDB for ParityDbWrapper {
}

/// Iterate over flushed data for a given column.
fn iter<'a>(&'a self, _col: u32) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a> {
fn iter<'a>(&'a self, _col: u32) -> Box<dyn Iterator<Item = io::Result<DBKeyValue>> + 'a> {
unimplemented!()
}

Expand All @@ -65,12 +65,7 @@ impl KeyValueDB for ParityDbWrapper {
&'a self,
_col: u32,
_prefix: &'a [u8],
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a> {
unimplemented!()
}

/// Attempt to replace this database with a new one located at the given path.
fn restore(&self, _new_db: &str) -> io::Result<()> {
) -> Box<dyn Iterator<Item = io::Result<DBKeyValue>> + 'a> {
unimplemented!()
}
}
Expand Down
8 changes: 4 additions & 4 deletions client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
] }
hash-db = "0.15.2"
kvdb = "0.11.0"
kvdb-memorydb = "0.11.0"
kvdb-rocksdb = { version = "0.15.2", optional = true }
kvdb = "0.12.0"
kvdb-memorydb = "0.12.0"
kvdb-rocksdb = { version = "0.16.0", optional = true }
linked-hash-map = "0.5.4"
log = "0.4.17"
parity-db = "0.3.16"
Expand All @@ -36,7 +36,7 @@ sp-trie = { version = "6.0.0", path = "../../primitives/trie" }

[dev-dependencies]
criterion = "0.3.3"
kvdb-rocksdb = "0.15.1"
kvdb-rocksdb = "0.16.0"
rand = "0.8.4"
tempfile = "3.1.0"
quickcheck = { version = "1.0.3", default-features = false }
Expand Down
9 changes: 6 additions & 3 deletions client/db/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub fn upgrade_db<Block: BlockT>(db_path: &Path, db_type: DatabaseType) -> Upgra
/// 2) transactions column is added;
fn migrate_1_to_2<Block: BlockT>(db_path: &Path, _db_type: DatabaseType) -> UpgradeResult<()> {
let db_cfg = DatabaseConfig::with_columns(V1_NUM_COLUMNS);
let db = Database::open(&db_cfg, db_path)?;
let mut db = Database::open(&db_cfg, db_path)?;
db.add_column().map_err(Into::into)
}

Expand All @@ -126,7 +126,10 @@ fn migrate_2_to_3<Block: BlockT>(db_path: &Path, _db_type: DatabaseType) -> Upgr
let db = Database::open(&db_cfg, db_path)?;

// Get all the keys we need to update
let keys: Vec<_> = db.iter(columns::JUSTIFICATIONS).map(|entry| entry.0).collect();
let keys: Vec<_> = db
.iter(columns::JUSTIFICATIONS)
.map(|r| r.map(|e| e.0))
.collect::<Result<_, _>>()?;

// Read and update each entry
let mut transaction = db.transaction();
Expand All @@ -152,7 +155,7 @@ fn migrate_2_to_3<Block: BlockT>(db_path: &Path, _db_type: DatabaseType) -> Upgr
/// 2) BODY_INDEX column is added;
fn migrate_3_to_4<Block: BlockT>(db_path: &Path, _db_type: DatabaseType) -> UpgradeResult<()> {
let db_cfg = DatabaseConfig::with_columns(V3_NUM_COLUMNS);
let db = Database::open(&db_cfg, db_path)?;
let mut db = Database::open(&db_cfg, db_path)?;
db.add_column().map_err(Into::into)
}

Expand Down
2 changes: 1 addition & 1 deletion client/informant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ansi_term = "0.12.1"
futures = "0.3.21"
futures-timer = "3.0.1"
log = "0.4.17"
parity-util-mem = { version = "0.11.0", default-features = false, features = ["primitive-types"] }
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
Expand Down
2 changes: 1 addition & 1 deletion client/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ sp-tracing = { version = "5.0.0", path = "../../primitives/tracing" }
sc-sysinfo = { version = "6.0.0-dev", path = "../sysinfo" }
tracing = "0.1.29"
tracing-futures = { version = "0.2.4" }
parity-util-mem = { version = "0.11.0", default-features = false, features = [
parity-util-mem = { version = "0.12.0", default-features = false, features = [
"primitive-types",
] }
async-trait = "0.1.57"
Expand Down
2 changes: 1 addition & 1 deletion client/state-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
log = "0.4.17"
parity-util-mem = { version = "0.11.0", default-features = false, features = ["primitive-types"] }
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
parity-util-mem-derive = "0.1.0"
parking_lot = "0.12.1"
sc-client-api = { version = "4.0.0-dev", path = "../api" }
Expand Down
2 changes: 1 addition & 1 deletion client/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ futures = "0.3.21"
futures-timer = "3.0.2"
linked-hash-map = "0.5.4"
log = "0.4.17"
parity-util-mem = { version = "0.11.0", default-features = false, features = ["primitive-types"] }
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
parking_lot = "0.12.1"
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0.30"
Expand Down
2 changes: 1 addition & 1 deletion frame/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ serde_json = "1.0.85"
assert_matches = "1.3.0"
pretty_assertions = "1.2.1"
frame-system = { version = "4.0.0-dev", path = "../system" }
parity-util-mem = { version = "0.11.0", default-features = false, features = ["primitive-types"] }
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }

[features]
default = ["std"]
Expand Down
Loading