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

Commit

Permalink
update kvdb & co (#12312)
Browse files Browse the repository at this point in the history
* upgrade kvdb & co

* remove patch

* update Cargo.lock

* upgrade impl-serde

* fix parsing test

* actually fix it

* FFS
  • Loading branch information
ordian committed Oct 5, 2022
1 parent eefba93 commit fc67cbb
Show file tree
Hide file tree
Showing 24 changed files with 73 additions and 103 deletions.
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 @@ -23,8 +23,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 @@ tempfile = "3.1.0"
fs_extra = "1"
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
4 changes: 2 additions & 2 deletions bin/node/inspect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ mod tests {
let b2 = ExtrinsicAddress::from_str("0 0");
let b3 = ExtrinsicAddress::from_str("0x0012345f");

assert_eq!(e0, Err("Extrinsic index missing: example \"5:0\"".into()));
assert_eq!(e0, Ok(ExtrinsicAddress::Bytes(vec![0x12, 0x34])));
assert_eq!(
b0,
Ok(ExtrinsicAddress::Block(
Expand All @@ -305,7 +305,7 @@ mod tests {
))
);
assert_eq!(b1, Ok(ExtrinsicAddress::Block(BlockAddress::Number(1234), 0)));
assert_eq!(b2, Ok(ExtrinsicAddress::Block(BlockAddress::Number(0), 0)));
assert_eq!(b2, Ok(ExtrinsicAddress::Bytes(vec![0, 0])));
assert_eq!(b3, Ok(ExtrinsicAddress::Bytes(vec![0, 0x12, 0x34, 0x5f])));
}
}
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 @@ -80,7 +80,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
Loading

0 comments on commit fc67cbb

Please sign in to comment.