From 32f8d96f051195197c3e6a266531690fd4e6ef20 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 16 Mar 2020 19:56:57 +0100 Subject: [PATCH 1/5] Prep for release (#361) * Prep for release * Removing a feature is a breaking change * Update ethereum-types/CHANGELOG.md Co-Authored-By: Andronik Ordian * Update keccak-hash/CHANGELOG.md Co-Authored-By: Andronik Ordian * Update parity-util-mem/CHANGELOG.md Co-Authored-By: Andronik Ordian * Update rlp/CHANGELOG.md Co-Authored-By: Andronik Ordian * Breaking where breaking is due Co-authored-by: Andronik Ordian --- contract-address/CHANGELOG.md | 3 +++ contract-address/Cargo.toml | 6 +++--- ethbloom/CHANGELOG.md | 2 ++ ethbloom/Cargo.toml | 4 ++-- ethereum-types/CHANGELOG.md | 3 +++ ethereum-types/Cargo.toml | 8 ++++---- fixed-hash/CHANGELOG.md | 2 ++ fixed-hash/Cargo.toml | 2 +- keccak-hash/CHANGELOG.md | 3 +++ keccak-hash/Cargo.toml | 4 ++-- kvdb-memorydb/CHANGELOG.md | 3 +++ kvdb-memorydb/Cargo.toml | 6 +++--- kvdb-rocksdb/CHANGELOG.md | 5 ++++- kvdb-rocksdb/Cargo.toml | 6 +++--- kvdb-shared-tests/Cargo.toml | 2 +- kvdb-web/CHANGELOG.md | 3 +++ kvdb-web/Cargo.toml | 8 ++++---- kvdb/CHANGELOG.md | 3 +++ kvdb/Cargo.toml | 4 ++-- parity-bytes/CHANGELOG.md | 2 ++ parity-bytes/Cargo.toml | 2 +- parity-crypto/CHANGELOG.md | 3 +++ parity-crypto/Cargo.toml | 24 ++++++++++++------------ parity-path/CHANGELOG.md | 2 ++ parity-path/Cargo.toml | 2 +- parity-util-mem/CHANGELOG.md | 5 ++++- parity-util-mem/Cargo.toml | 6 +++--- plain_hasher/CHANGELOG.md | 2 ++ plain_hasher/Cargo.toml | 2 +- primitive-types/CHANGELOG.md | 2 ++ primitive-types/Cargo.toml | 4 ++-- rlp/CHANGELOG.md | 4 ++++ rlp/Cargo.toml | 4 ++-- trace-time/CHANGELOG.md | 2 ++ trace-time/Cargo.toml | 2 +- transaction-pool/CHANGELOG.md | 2 ++ transaction-pool/Cargo.toml | 4 ++-- triehash/CHANGELOG.md | 3 ++- triehash/Cargo.toml | 4 ++-- 39 files changed, 103 insertions(+), 55 deletions(-) diff --git a/contract-address/CHANGELOG.md b/contract-address/CHANGELOG.md index 546bc458e..a9b2a3a0b 100644 --- a/contract-address/CHANGELOG.md +++ b/contract-address/CHANGELOG.md @@ -5,4 +5,7 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.9.0] - 2020-03-16 - License changed from MIT to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) diff --git a/contract-address/Cargo.toml b/contract-address/Cargo.toml index 21486e7a2..19ee6b363 100644 --- a/contract-address/Cargo.toml +++ b/contract-address/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "contract-address" -version = "0.3.0" +version = "0.4.0" authors = ["Parity Technologies "] license = "MIT/Apache2.0" homepage = "https://github.com/paritytech/parity-common" @@ -11,9 +11,9 @@ edition = "2018" readme = "README.md" [dependencies] -ethereum-types = { version = "0.8.0", path = "../ethereum-types" } +ethereum-types = { version = "0.9.0", path = "../ethereum-types" } rlp = { version = "0.4", path = "../rlp" } -keccak-hash = { version = "0.4", path = "../keccak-hash", default-features = false } +keccak-hash = { version = "0.5", path = "../keccak-hash", default-features = false } [features] default = [] diff --git a/ethbloom/CHANGELOG.md b/ethbloom/CHANGELOG.md index 6c13f6f0a..de418cd9d 100644 --- a/ethbloom/CHANGELOG.md +++ b/ethbloom/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.9.0] - 2020-03-16 - Removed `libc` feature. [#317](https://github.com/paritytech/parity-common/pull/317) - License changed from MIT to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) diff --git a/ethbloom/Cargo.toml b/ethbloom/Cargo.toml index cbf9112a0..da4b20047 100644 --- a/ethbloom/Cargo.toml +++ b/ethbloom/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethbloom" -version = "0.8.1" +version = "0.9.0" authors = ["Parity Technologies "] description = "Ethereum bloom filter" license = "MIT/Apache2.0" @@ -12,7 +12,7 @@ edition = "2018" [dependencies] tiny-keccak = { version = "2.0", features = ["keccak"] } crunchy = { version = "0.2.2", default-features = false, features = ["limit_256"] } -fixed-hash = { path = "../fixed-hash", version = "0.5", default-features = false } +fixed-hash = { path = "../fixed-hash", version = "0.6", default-features = false } impl-serde = { path = "../primitive-types/impls/serde", version = "0.3", default-features = false, optional = true } impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-features = false } diff --git a/ethereum-types/CHANGELOG.md b/ethereum-types/CHANGELOG.md index 6b214e75b..9455e7bba 100644 --- a/ethereum-types/CHANGELOG.md +++ b/ethereum-types/CHANGELOG.md @@ -5,7 +5,10 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.9.0] - 2020-03-16 - License changed from MIT to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) ### Added - Uint error type is re-exported. [#244](https://github.com/paritytech/parity-common/pull/244) diff --git a/ethereum-types/Cargo.toml b/ethereum-types/Cargo.toml index b706f2873..00b49ac7a 100644 --- a/ethereum-types/Cargo.toml +++ b/ethereum-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethereum-types" -version = "0.8.0" +version = "0.9.0" authors = ["Parity Technologies "] license = "MIT/Apache2.0" homepage = "https://github.com/paritytech/parity-common" @@ -8,10 +8,10 @@ description = "Ethereum types" edition = "2018" [dependencies] -ethbloom = { path = "../ethbloom", version = "0.8", default-features = false } -fixed-hash = { path = "../fixed-hash", version = "0.5", default-features = false, features = ["byteorder", "rustc-hex"] } +ethbloom = { path = "../ethbloom", version = "0.9", default-features = false } +fixed-hash = { path = "../fixed-hash", version = "0.6", default-features = false, features = ["byteorder", "rustc-hex"] } uint-crate = { path = "../uint", package = "uint", version = "0.8", default-features = false } -primitive-types = { path = "../primitive-types", version = "0.6", features = ["rlp", "byteorder", "rustc-hex"], default-features = false } +primitive-types = { path = "../primitive-types", version = "0.7", features = ["rlp", "byteorder", "rustc-hex"], default-features = false } impl-serde = { path = "../primitive-types/impls/serde", version = "0.3.0", default-features = false, optional = true } impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-features = false } diff --git a/fixed-hash/CHANGELOG.md b/fixed-hash/CHANGELOG.md index f486d7847..da5ec524d 100644 --- a/fixed-hash/CHANGELOG.md +++ b/fixed-hash/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.6.0] - 2020-03-16 - Removed `libc` feature. [#317](https://github.com/paritytech/parity-common/pull/317) - License changed from MIT to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) diff --git a/fixed-hash/Cargo.toml b/fixed-hash/Cargo.toml index 41bf7d237..324804592 100644 --- a/fixed-hash/Cargo.toml +++ b/fixed-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fixed-hash" -version = "0.5.2" +version = "0.6.0" authors = ["Parity Technologies "] license = "MIT/Apache2.0" homepage = "https://github.com/paritytech/parity-common" diff --git a/keccak-hash/CHANGELOG.md b/keccak-hash/CHANGELOG.md index 429e3bc13..13f73c4a9 100644 --- a/keccak-hash/CHANGELOG.md +++ b/keccak-hash/CHANGELOG.md @@ -5,7 +5,10 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.4.2] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) ## [0.4.1] - 2019-10-24 ### Dependencies diff --git a/keccak-hash/Cargo.toml b/keccak-hash/Cargo.toml index 49c9506dd..ca317f522 100644 --- a/keccak-hash/Cargo.toml +++ b/keccak-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "keccak-hash" -version = "0.4.1" +version = "0.5.0" description = "`keccak-hash` is a set of utility functions to facilitate working with Keccak hashes (256/512 bits long)." authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" @@ -10,7 +10,7 @@ edition = "2018" [dependencies] tiny-keccak = { version = "2.0", features = ["keccak"] } -primitive-types = { path = "../primitive-types", version = "0.6", default-features = false } +primitive-types = { path = "../primitive-types", version = "0.7", default-features = false } [dev-dependencies] tempdir = "0.3.7" diff --git a/kvdb-memorydb/CHANGELOG.md b/kvdb-memorydb/CHANGELOG.md index 3da9b9203..a8c74772d 100644 --- a/kvdb-memorydb/CHANGELOG.md +++ b/kvdb-memorydb/CHANGELOG.md @@ -5,7 +5,10 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.5.0] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) ## [0.4.0] - 2019-02-05 - Bump parking_lot to 0.10. [#332](https://github.com/paritytech/parity-common/pull/332) diff --git a/kvdb-memorydb/Cargo.toml b/kvdb-memorydb/Cargo.toml index 24d6a9991..90a5dc980 100644 --- a/kvdb-memorydb/Cargo.toml +++ b/kvdb-memorydb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kvdb-memorydb" -version = "0.4.0" +version = "0.5.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "A key-value in-memory database that implements the `KeyValueDB` trait" @@ -8,9 +8,9 @@ license = "MIT/Apache-2.0" edition = "2018" [dependencies] -parity-util-mem = { path = "../parity-util-mem", version = "0.5", default-features = false, features = ["std"] } +parity-util-mem = { path = "../parity-util-mem", version = "0.6", default-features = false, features = ["std"] } parking_lot = "0.10.0" -kvdb = { version = "0.4", path = "../kvdb" } +kvdb = { version = "0.5", path = "../kvdb" } [dev-dependencies] kvdb-shared-tests = { path = "../kvdb-shared-tests", version = "0.2" } diff --git a/kvdb-rocksdb/CHANGELOG.md b/kvdb-rocksdb/CHANGELOG.md index 840e60b2f..e7561c059 100644 --- a/kvdb-rocksdb/CHANGELOG.md +++ b/kvdb-rocksdb/CHANGELOG.md @@ -6,7 +6,10 @@ The format is based on [Keep a Changelog]. ## [Unreleased] -## [0.6.0] - 2019-02-28 +## [0.7.0] - 2020-03-16 +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) + +## [0.6.0] - 2020-02-28 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) - Added `get_statistics` method and `enable_statistics` config parameter. [#347](https://github.com/paritytech/parity-common/pull/347) diff --git a/kvdb-rocksdb/Cargo.toml b/kvdb-rocksdb/Cargo.toml index bfd75a14d..c4d573bf8 100644 --- a/kvdb-rocksdb/Cargo.toml +++ b/kvdb-rocksdb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kvdb-rocksdb" -version = "0.6.0" +version = "0.7.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "kvdb implementation backed by RocksDB" @@ -15,14 +15,14 @@ harness = false smallvec = "1.0.0" fs-swap = "0.2.4" interleaved-ordered = "0.1.1" -kvdb = { path = "../kvdb", version = "0.4" } +kvdb = { path = "../kvdb", version = "0.5" } log = "0.4.8" num_cpus = "1.10.1" parking_lot = "0.10.0" regex = "1.3.1" rocksdb = { version = "0.13", features = ["snappy"], default-features = false } owning_ref = "0.4.0" -parity-util-mem = { path = "../parity-util-mem", version = "0.5", default-features = false, features = ["std", "smallvec"] } +parity-util-mem = { path = "../parity-util-mem", version = "0.6", default-features = false, features = ["std", "smallvec"] } [dev-dependencies] alloc_counter = "0.0.4" diff --git a/kvdb-shared-tests/Cargo.toml b/kvdb-shared-tests/Cargo.toml index 367eef8b6..ff461caac 100644 --- a/kvdb-shared-tests/Cargo.toml +++ b/kvdb-shared-tests/Cargo.toml @@ -7,4 +7,4 @@ description = "Shared tests for kvdb functionality, to be executed against actua license = "MIT/Apache2.0" [dependencies] -kvdb = { path = "../kvdb", version = "0.4" } +kvdb = { path = "../kvdb", version = "0.5" } diff --git a/kvdb-web/CHANGELOG.md b/kvdb-web/CHANGELOG.md index 0d4a23ad9..f8e952bf3 100644 --- a/kvdb-web/CHANGELOG.md +++ b/kvdb-web/CHANGELOG.md @@ -5,7 +5,10 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.5.0] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) ## [0.4.0] - 2019-02-05 - Bump parking_lot to 0.10. [#332](https://github.com/paritytech/parity-common/pull/332) diff --git a/kvdb-web/Cargo.toml b/kvdb-web/Cargo.toml index 284418ca5..8d5fc7be4 100644 --- a/kvdb-web/Cargo.toml +++ b/kvdb-web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kvdb-web" -version = "0.4.0" +version = "0.5.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "A key-value database for use in browsers" @@ -11,12 +11,12 @@ edition = "2018" [dependencies] wasm-bindgen = "0.2.54" js-sys = "0.3.31" -kvdb = { version = "0.4", path = "../kvdb" } -kvdb-memorydb = { version = "0.4", path = "../kvdb-memorydb" } +kvdb = { version = "0.5", path = "../kvdb" } +kvdb-memorydb = { version = "0.5", path = "../kvdb-memorydb" } futures = "0.3" log = "0.4.8" send_wrapper = "0.3.0" -parity-util-mem = { path = "../parity-util-mem", version = "0.5", default-features = false } +parity-util-mem = { path = "../parity-util-mem", version = "0.6", default-features = false } [dependencies.web-sys] version = "0.3.31" diff --git a/kvdb/CHANGELOG.md b/kvdb/CHANGELOG.md index d1e24ebb3..18f484117 100644 --- a/kvdb/CHANGELOG.md +++ b/kvdb/CHANGELOG.md @@ -5,8 +5,11 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.5.0] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) - Remove dependency on parity-bytes. [#351](https://github.com/paritytech/parity-common/pull/351) +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) ## [0.4.0] - 2019-01-06 - Bump parking_lot to 0.10. [#332](https://github.com/paritytech/parity-common/pull/332) diff --git a/kvdb/Cargo.toml b/kvdb/Cargo.toml index 722ebcc20..669b19762 100644 --- a/kvdb/Cargo.toml +++ b/kvdb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kvdb" -version = "0.4.0" +version = "0.5.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "Generic key-value trait" @@ -9,4 +9,4 @@ edition = "2018" [dependencies] smallvec = "1.0.0" -parity-util-mem = { path = "../parity-util-mem", version = "0.5", default-features = false } +parity-util-mem = { path = "../parity-util-mem", version = "0.6", default-features = false } diff --git a/parity-bytes/CHANGELOG.md b/parity-bytes/CHANGELOG.md index ef8a2633d..49b2d0857 100644 --- a/parity-bytes/CHANGELOG.md +++ b/parity-bytes/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.1.2] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) ## [0.1.1] - 2019-10-24 diff --git a/parity-bytes/Cargo.toml b/parity-bytes/Cargo.toml index 582d6560e..384489203 100644 --- a/parity-bytes/Cargo.toml +++ b/parity-bytes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "parity-bytes" -version = "0.1.1" +version = "0.1.2" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "byte utilities for Parity" diff --git a/parity-crypto/CHANGELOG.md b/parity-crypto/CHANGELOG.md index c955084f9..14290d54d 100644 --- a/parity-crypto/CHANGELOG.md +++ b/parity-crypto/CHANGELOG.md @@ -5,7 +5,10 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.6.0] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) ## [0.5.0] - 2020-02-08 - Remove `inv()` from `SecretKey` (breaking). [#258](https://github.com/paritytech/parity-common/pull/258) diff --git a/parity-crypto/Cargo.toml b/parity-crypto/Cargo.toml index 0af20678b..f51bbd88f 100644 --- a/parity-crypto/Cargo.toml +++ b/parity-crypto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "parity-crypto" -version = "0.5.0" +version = "0.6.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "Crypto utils used by ethstore and network." @@ -14,23 +14,23 @@ harness = false required-features = ["publickey"] [dependencies] -tiny-keccak = { version = "2.0", features = ["keccak"] } -scrypt = { version = "0.2.0", default-features = false } -secp256k1 = { version = "0.17.2", optional = true, features = ["recovery", "rand-std"] } -ethereum-types = { version = "0.8.0", optional = true } -lazy_static = { version = "1.0", optional = true } -ripemd160 = "0.8.0" -sha2 = "0.8.0" -digest = "0.8" -hmac = "0.7" aes = "0.3.2" aes-ctr = "0.3.0" block-modes = "0.3.3" +digest = "0.8" +ethereum-types = { version = "0.9.0", optional = true, path = "../ethereum-types" } +hmac = "0.7" +lazy_static = { version = "1.0", optional = true } pbkdf2 = "0.3.0" -subtle = "2.2.1" -zeroize = { version = "1.0.0", default-features = false } rand = "0.7.2" +ripemd160 = "0.8.0" rustc-hex = { version = "2.1.0", default-features = false, optional = true } +scrypt = { version = "0.2.0", default-features = false } +secp256k1 = { version = "0.17.2", optional = true, features = ["recovery", "rand-std"] } +sha2 = "0.8.0" +subtle = "2.2.1" +tiny-keccak = { version = "2.0", features = ["keccak"] } +zeroize = { version = "1.0.0", default-features = false } [dev-dependencies] criterion = "0.3.0" diff --git a/parity-path/CHANGELOG.md b/parity-path/CHANGELOG.md index fc0263835..ed9aa8162 100644 --- a/parity-path/CHANGELOG.md +++ b/parity-path/CHANGELOG.md @@ -5,4 +5,6 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.1.3] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) diff --git a/parity-path/Cargo.toml b/parity-path/Cargo.toml index 0c783cf6c..8f272ad51 100644 --- a/parity-path/Cargo.toml +++ b/parity-path/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "parity-path" -version = "0.1.2" +version = "0.1.3" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "Path utilities" diff --git a/parity-util-mem/CHANGELOG.md b/parity-util-mem/CHANGELOG.md index 211d42145..fdb3f5f7b 100644 --- a/parity-util-mem/CHANGELOG.md +++ b/parity-util-mem/CHANGELOG.md @@ -6,7 +6,10 @@ The format is based on [Keep a Changelog]. ## [Unreleased] -## [0.5.2] - 2019-03-13 +## [0.6.0] - 2020-03-13 +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) + +## [0.5.2] - 2020-03-13 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) - Updated mimalloc dependency. [#352](https://github.com/paritytech/parity-common/pull/352) - Use malloc for `usable_size` on Android. [#355](https://github.com/paritytech/parity-common/pull/355) diff --git a/parity-util-mem/Cargo.toml b/parity-util-mem/Cargo.toml index 96b1f2508..9f5e77039 100644 --- a/parity-util-mem/Cargo.toml +++ b/parity-util-mem/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "parity-util-mem" -version = "0.5.2" +version = "0.6.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "Collection of memory related utilities" @@ -19,9 +19,9 @@ parity-util-mem-derive = { path = "derive", version = "0.1" } impl-trait-for-tuples = "0.1.3" smallvec = { version = "1.0.0", optional = true } -ethereum-types = { version = "0.8.0", optional = true, path = "../ethereum-types" } +ethereum-types = { version = "0.9.0", optional = true, path = "../ethereum-types" } parking_lot = { version = "0.10.0", optional = true } -primitive-types = { version = "0.6", path = "../primitive-types", default-features = false, optional = true } +primitive-types = { version = "0.7", path = "../primitive-types", default-features = false, optional = true } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3.8", features = ["heapapi"] } diff --git a/plain_hasher/CHANGELOG.md b/plain_hasher/CHANGELOG.md index afc302090..c3f142cfd 100644 --- a/plain_hasher/CHANGELOG.md +++ b/plain_hasher/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.2.3] - 2020-03-16 - License changed from MIT to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) ## [0.2.2] - 2019-10-24 diff --git a/plain_hasher/Cargo.toml b/plain_hasher/Cargo.toml index 57cf4d0c1..7e0812571 100644 --- a/plain_hasher/Cargo.toml +++ b/plain_hasher/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "plain_hasher" description = "Hasher for 32-byte keys." -version = "0.2.2" +version = "0.2.3" authors = ["Parity Technologies "] license = "MIT/Apache2.0" keywords = ["hash", "hasher"] diff --git a/primitive-types/CHANGELOG.md b/primitive-types/CHANGELOG.md index 0689eab5a..4c6f65713 100644 --- a/primitive-types/CHANGELOG.md +++ b/primitive-types/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.7.0] - 2020-03-16 - Removed `libc` feature. [#317](https://github.com/paritytech/parity-common/pull/317) ## [0.6.2] - 2019-01-03 diff --git a/primitive-types/Cargo.toml b/primitive-types/Cargo.toml index e6b53391c..3169b5c2e 100644 --- a/primitive-types/Cargo.toml +++ b/primitive-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "primitive-types" -version = "0.6.2" +version = "0.7.0" authors = ["Parity Technologies "] license = "MIT/Apache2.0" homepage = "https://github.com/paritytech/parity-common" @@ -8,7 +8,7 @@ description = "Primitive types shared by Ethereum and Substrate" edition = "2018" [dependencies] -fixed-hash = { version = "0.5", path = "../fixed-hash", default-features = false } +fixed-hash = { version = "0.6", path = "../fixed-hash", default-features = false } uint = { version = "0.8.1", path = "../uint", default-features = false } impl-serde = { version = "0.3.0", path = "impls/serde", default-features = false, optional = true } impl-codec = { version = "0.4.1", path = "impls/codec", default-features = false, optional = true } diff --git a/rlp/CHANGELOG.md b/rlp/CHANGELOG.md index c817dc6b9..cee20902d 100644 --- a/rlp/CHANGELOG.md +++ b/rlp/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog]. ## [Unreleased] +## [0.4.5] - 2020-03-16 +### Dependencies +- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) + ## [0.4.4] - 2019-11-20 ### Added - Method `Rlp::at_with_offset`. [#269](https://github.com/paritytech/parity-common/pull/269) diff --git a/rlp/Cargo.toml b/rlp/Cargo.toml index ea0da9b10..947418a6b 100644 --- a/rlp/Cargo.toml +++ b/rlp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rlp" -version = "0.4.4" +version = "0.4.5" description = "Recursive-length prefix encoding, decoding, and compression" repository = "https://github.com/paritytech/parity-common" license = "MIT/Apache-2.0" @@ -13,7 +13,7 @@ rustc-hex = { version = "2.0.1", default-features = false } [dev-dependencies] criterion = "0.3.0" hex-literal = "0.2.1" -primitive-types = { path = "../primitive-types", version = "0.6", features = ["impl-rlp"] } +primitive-types = { path = "../primitive-types", version = "0.7", features = ["impl-rlp"] } [features] default = ["std"] diff --git a/trace-time/CHANGELOG.md b/trace-time/CHANGELOG.md index 300ce6461..0f666b438 100644 --- a/trace-time/CHANGELOG.md +++ b/trace-time/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [0.1.3] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) ## [0.1.2] - 2019-10-24 diff --git a/trace-time/Cargo.toml b/trace-time/Cargo.toml index fca5a7619..225cdec27 100644 --- a/trace-time/Cargo.toml +++ b/trace-time/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "trace-time" description = "Easily trace time to execute a scope." -version = "0.1.2" +version = "0.1.3" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" license = "MIT/Apache2.0" diff --git a/transaction-pool/CHANGELOG.md b/transaction-pool/CHANGELOG.md index 431effd94..334625f2d 100644 --- a/transaction-pool/CHANGELOG.md +++ b/transaction-pool/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] + +## [2.0.3] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) ## [2.0.2] - 2019-10-24 diff --git a/transaction-pool/Cargo.toml b/transaction-pool/Cargo.toml index 0da12d924..2bf1dbb59 100644 --- a/transaction-pool/Cargo.toml +++ b/transaction-pool/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Generic transaction pool." name = "transaction-pool" -version = "2.0.2" +version = "2.0.3" license = "MIT/Apache2.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" @@ -13,4 +13,4 @@ smallvec = "0.6.10" trace-time = { path = "../trace-time", version = "0.1" } [dev-dependencies] -ethereum-types = { version = "0.8.0", path = "../ethereum-types" } +ethereum-types = { version = "0.9.0", path = "../ethereum-types" } diff --git a/triehash/CHANGELOG.md b/triehash/CHANGELOG.md index 88acd4dd1..b5f0357b1 100644 --- a/triehash/CHANGELOG.md +++ b/triehash/CHANGELOG.md @@ -5,8 +5,9 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] -- License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) +## [0.8.3] - 2020-03-16 +- License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) ## [0.8.2] - 2019-12-15 - Added no-std support. [#280](https://github.com/paritytech/parity-common/pull/280) ## [0.8.1] - 2019-10-24 diff --git a/triehash/Cargo.toml b/triehash/Cargo.toml index 407489469..19496503a 100644 --- a/triehash/Cargo.toml +++ b/triehash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "triehash" -version = "0.8.2" +version = "0.8.3" authors = ["Parity Technologies "] description = "In-memory patricia trie operations" repository = "https://github.com/paritytech/parity-common" @@ -14,7 +14,7 @@ rlp = { version = "0.4", path = "../rlp", default-features = false } [dev-dependencies] criterion = "0.3.0" keccak-hasher = "0.15.2" -ethereum-types = { version = "0.8.0", path = "../ethereum-types" } +ethereum-types = { version = "0.9.0", path = "../ethereum-types" } tiny-keccak = { version = "2.0", features = ["keccak"] } trie-standardmap = "0.15.2" hex-literal = "0.2.1" From 939151e23b132110628739e8458e6cece1f1c8d0 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Tue, 17 Mar 2020 06:25:26 -0700 Subject: [PATCH 2/5] Memtest example for Rocksdb (#349) * memtest * address review * Update kvdb-rocksdb/examples/memtest.rs * return time 0.1 --- kvdb-rocksdb/Cargo.toml | 4 + kvdb-rocksdb/examples/memtest.rs | 149 +++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 kvdb-rocksdb/examples/memtest.rs diff --git a/kvdb-rocksdb/Cargo.toml b/kvdb-rocksdb/Cargo.toml index c4d573bf8..3204bbd79 100644 --- a/kvdb-rocksdb/Cargo.toml +++ b/kvdb-rocksdb/Cargo.toml @@ -31,3 +31,7 @@ ethereum-types = { path = "../ethereum-types" } kvdb-shared-tests = { path = "../kvdb-shared-tests", version = "0.2" } rand = "0.7.2" tempdir = "0.3.7" +keccak-hash = { path = "../keccak-hash" } +sysinfo = "0.11.7" +ctrlc = "3.1.4" +time = "0.1" diff --git a/kvdb-rocksdb/examples/memtest.rs b/kvdb-rocksdb/examples/memtest.rs new file mode 100644 index 000000000..59fa1a137 --- /dev/null +++ b/kvdb-rocksdb/examples/memtest.rs @@ -0,0 +1,149 @@ +// Copyright 2020 Parity Technologies (UK) Ltd. +// This file is part of Parity Ethereum. + +// Parity Ethereum 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. + +// Parity Ethereum 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. + +// You should have received a copy of the GNU General Public License +// along with Parity Ethereum. If not, see . + +// This program starts writing random data to the database with 100 (COLUMN_COUNT) +// columns and never stops until interrupted. + +use ethereum_types::H256; +use keccak_hash::keccak; +use kvdb_rocksdb::{Database, DatabaseConfig}; +use std::sync::{atomic::AtomicBool, atomic::Ordering as AtomicOrdering, Arc}; +use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; + +const COLUMN_COUNT: u32 = 100; + +#[derive(Clone)] +struct KeyValueSeed { + seed: H256, + key: H256, + val: H256, +} + +fn next(seed: H256) -> H256 { + let mut buf = [0u8; 33]; + buf[0..32].copy_from_slice(&seed[..]); + buf[32] = 1; + + keccak(&buf[..]) +} + +impl KeyValueSeed { + fn with_seed(seed: H256) -> Self { + KeyValueSeed { seed, key: next(seed), val: next(next(seed)) } + } + + fn new() -> Self { + Self::with_seed(H256::random()) + } +} + +impl Iterator for KeyValueSeed { + type Item = (H256, H256); + + fn next(&mut self) -> Option { + let result = (self.key, self.val); + self.key = next(self.val); + self.val = next(self.key); + + Some(result) + } +} + +fn proc_memory_usage() -> u64 { + let mut sys = System::new(); + let self_pid = get_current_pid().ok(); + let memory = if let Some(self_pid) = self_pid { + if sys.refresh_process(self_pid) { + let proc = sys.get_process(self_pid).expect("Above refresh_process succeeds, this should be Some(), qed"); + proc.memory() + } else { + 0 + } + } else { + 0 + }; + + memory +} + +fn main() { + let mb_per_col = std::env::args() + .nth(1) + .map(|arg| arg.parse().expect("Megabytes per col - should be integer or missing")) + .unwrap_or(1); + + let exit = Arc::new(AtomicBool::new(false)); + let ctrlc_exit = exit.clone(); + + ctrlc::set_handler(move || { + println!("\nRemoving temp database...\n"); + ctrlc_exit.store(true, AtomicOrdering::Relaxed); + }) + .expect("Error setting Ctrl-C handler"); + + let mut config = DatabaseConfig::with_columns(COLUMN_COUNT); + + for c in 0..=COLUMN_COUNT { + config.memory_budget.insert(c, mb_per_col); + } + let dir = tempdir::TempDir::new("rocksdb-example").unwrap(); + + println!("Database is put in: {} (maybe check if it was deleted)", dir.path().to_string_lossy()); + let db = Database::open(&config, &dir.path().to_string_lossy()).unwrap(); + + let mut step = 0; + let mut keyvalues = KeyValueSeed::new(); + while !exit.load(AtomicOrdering::Relaxed) { + let col = step % 100; + + let key_values: Vec<(H256, H256)> = keyvalues.clone().take(128).collect(); + let mut transaction = db.transaction(); + for (k, v) in key_values.iter() { + transaction.put(col, k.as_ref(), v.as_ref()); + } + db.write(transaction).expect("writing failed"); + + let mut seed = H256::zero(); + for (k, _) in key_values.iter() { + let mut buf = [0u8; 64]; + buf[0..32].copy_from_slice(seed.as_ref()); + let val = db.get(col, k.as_ref()).expect("Db fail").expect("Was put above"); + buf[32..64].copy_from_slice(val.as_ref()); + + seed = keccak(&buf[..]); + } + + let mut transaction = db.transaction(); + // delete all but one to avoid too much bloating + for (k, _) in key_values.iter().take(127) { + transaction.delete(col, k.as_ref()); + } + db.write(transaction).expect("delete failed"); + + keyvalues = KeyValueSeed::with_seed(seed); + + if step % 10000 == 9999 { + let timestamp = time::strftime("%Y-%m-%d %H:%M:%S", &time::now()).expect("Error formatting log timestamp"); + + println!("{}", timestamp); + println!("\tData written: {} keys - {} Mb", step + 1, ((step + 1) * 64 * 128) / 1024 / 1024); + println!("\tProcess memory used as seen by the OS: {} Mb", proc_memory_usage() / 1024); + println!("\tMemory used as reported by rocksdb: {} Mb\n", parity_util_mem::malloc_size(&db) / 1024 / 1024); + } + + step += 1; + } +} From 791f5524da0de25a061fa1c71164b036af43e172 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 25 Mar 2020 09:45:49 +0100 Subject: [PATCH 3/5] Use correct license ID (#362) * Use correct license ID * SPDX format for license ID --- contract-address/Cargo.toml | 2 +- ethbloom/Cargo.toml | 2 +- ethereum-types/Cargo.toml | 2 +- fixed-hash/Cargo.toml | 2 +- keccak-hash/Cargo.toml | 2 +- kvdb-memorydb/Cargo.toml | 2 +- kvdb-rocksdb/Cargo.toml | 2 +- kvdb-shared-tests/Cargo.toml | 2 +- kvdb-web/Cargo.toml | 2 +- kvdb/Cargo.toml | 2 +- parity-bytes/Cargo.toml | 2 +- parity-crypto/Cargo.toml | 2 +- parity-path/Cargo.toml | 2 +- parity-util-mem/Cargo.toml | 2 +- parity-util-mem/derive/Cargo.toml | 2 +- plain_hasher/Cargo.toml | 2 +- primitive-types/Cargo.toml | 2 +- primitive-types/impls/codec/Cargo.toml | 2 +- primitive-types/impls/rlp/Cargo.toml | 2 +- primitive-types/impls/serde/Cargo.toml | 2 +- rlp-derive/Cargo.toml | 2 +- rlp/Cargo.toml | 2 +- trace-time/Cargo.toml | 2 +- transaction-pool/Cargo.toml | 2 +- triehash/Cargo.toml | 2 +- uint/Cargo.toml | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/contract-address/Cargo.toml b/contract-address/Cargo.toml index 19ee6b363..b8a0b7993 100644 --- a/contract-address/Cargo.toml +++ b/contract-address/Cargo.toml @@ -2,7 +2,7 @@ name = "contract-address" version = "0.4.0" authors = ["Parity Technologies "] -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" homepage = "https://github.com/paritytech/parity-common" repository = "https://github.com/paritytech/parity-common" description = "A utility crate to create an ethereum contract address" diff --git a/ethbloom/Cargo.toml b/ethbloom/Cargo.toml index da4b20047..038378a64 100644 --- a/ethbloom/Cargo.toml +++ b/ethbloom/Cargo.toml @@ -3,7 +3,7 @@ name = "ethbloom" version = "0.9.0" authors = ["Parity Technologies "] description = "Ethereum bloom filter" -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" documentation = "https://docs.rs/ethbloom" homepage = "https://github.com/paritytech/parity-common" repository = "https://github.com/paritytech/parity-common" diff --git a/ethereum-types/Cargo.toml b/ethereum-types/Cargo.toml index 00b49ac7a..b04c87bbd 100644 --- a/ethereum-types/Cargo.toml +++ b/ethereum-types/Cargo.toml @@ -2,7 +2,7 @@ name = "ethereum-types" version = "0.9.0" authors = ["Parity Technologies "] -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" homepage = "https://github.com/paritytech/parity-common" description = "Ethereum types" edition = "2018" diff --git a/fixed-hash/Cargo.toml b/fixed-hash/Cargo.toml index 324804592..93903ef7d 100644 --- a/fixed-hash/Cargo.toml +++ b/fixed-hash/Cargo.toml @@ -2,7 +2,7 @@ name = "fixed-hash" version = "0.6.0" authors = ["Parity Technologies "] -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" homepage = "https://github.com/paritytech/parity-common" repository = "https://github.com/paritytech/parity-common" description = "Macros to define custom fixed-size hash types" diff --git a/keccak-hash/Cargo.toml b/keccak-hash/Cargo.toml index ca317f522..ea36f7288 100644 --- a/keccak-hash/Cargo.toml +++ b/keccak-hash/Cargo.toml @@ -5,7 +5,7 @@ description = "`keccak-hash` is a set of utility functions to facilitate working authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" readme = "README.md" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/kvdb-memorydb/Cargo.toml b/kvdb-memorydb/Cargo.toml index 90a5dc980..0ea7119a8 100644 --- a/kvdb-memorydb/Cargo.toml +++ b/kvdb-memorydb/Cargo.toml @@ -4,7 +4,7 @@ version = "0.5.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "A key-value in-memory database that implements the `KeyValueDB` trait" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/kvdb-rocksdb/Cargo.toml b/kvdb-rocksdb/Cargo.toml index 3204bbd79..322d0865f 100644 --- a/kvdb-rocksdb/Cargo.toml +++ b/kvdb-rocksdb/Cargo.toml @@ -4,7 +4,7 @@ version = "0.7.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "kvdb implementation backed by RocksDB" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2018" [[bench]] diff --git a/kvdb-shared-tests/Cargo.toml b/kvdb-shared-tests/Cargo.toml index ff461caac..c5987c5c7 100644 --- a/kvdb-shared-tests/Cargo.toml +++ b/kvdb-shared-tests/Cargo.toml @@ -4,7 +4,7 @@ version = "0.2.0" authors = ["Parity Technologies "] edition = "2018" description = "Shared tests for kvdb functionality, to be executed against actual implementations" -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" [dependencies] kvdb = { path = "../kvdb", version = "0.5" } diff --git a/kvdb-web/Cargo.toml b/kvdb-web/Cargo.toml index 8d5fc7be4..331ef1fa6 100644 --- a/kvdb-web/Cargo.toml +++ b/kvdb-web/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "A key-value database for use in browsers" documentation = "https://docs.rs/kvdb-web/" -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/kvdb/Cargo.toml b/kvdb/Cargo.toml index 669b19762..f6851ef33 100644 --- a/kvdb/Cargo.toml +++ b/kvdb/Cargo.toml @@ -4,7 +4,7 @@ version = "0.5.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "Generic key-value trait" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/parity-bytes/Cargo.toml b/parity-bytes/Cargo.toml index 384489203..651369f1c 100644 --- a/parity-bytes/Cargo.toml +++ b/parity-bytes/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.2" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "byte utilities for Parity" -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/parity-crypto/Cargo.toml b/parity-crypto/Cargo.toml index f51bbd88f..763fc4b74 100644 --- a/parity-crypto/Cargo.toml +++ b/parity-crypto/Cargo.toml @@ -4,7 +4,7 @@ version = "0.6.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "Crypto utils used by ethstore and network." -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" autobenches = false edition = "2018" diff --git a/parity-path/Cargo.toml b/parity-path/Cargo.toml index 8f272ad51..d23442c8f 100644 --- a/parity-path/Cargo.toml +++ b/parity-path/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.3" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "Path utilities" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/parity-util-mem/Cargo.toml b/parity-util-mem/Cargo.toml index 9f5e77039..af3916902 100644 --- a/parity-util-mem/Cargo.toml +++ b/parity-util-mem/Cargo.toml @@ -4,7 +4,7 @@ version = "0.6.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "Collection of memory related utilities" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/parity-util-mem/derive/Cargo.toml b/parity-util-mem/derive/Cargo.toml index b7648ebd2..d41ba12f5 100644 --- a/parity-util-mem/derive/Cargo.toml +++ b/parity-util-mem/derive/Cargo.toml @@ -2,7 +2,7 @@ name = "parity-util-mem-derive" version = "0.1.0" authors = ["Parity Technologies "] -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" description = "Crate for memory reporting" repository = "https://github.com/paritytech/pariry-common/parity-util-mem/derive" diff --git a/plain_hasher/Cargo.toml b/plain_hasher/Cargo.toml index 7e0812571..bb5a1668d 100644 --- a/plain_hasher/Cargo.toml +++ b/plain_hasher/Cargo.toml @@ -3,7 +3,7 @@ name = "plain_hasher" description = "Hasher for 32-byte keys." version = "0.2.3" authors = ["Parity Technologies "] -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" keywords = ["hash", "hasher"] homepage = "https://github.com/paritytech/parity-common" categories = ["no-std"] diff --git a/primitive-types/Cargo.toml b/primitive-types/Cargo.toml index 3169b5c2e..06e6e154d 100644 --- a/primitive-types/Cargo.toml +++ b/primitive-types/Cargo.toml @@ -2,7 +2,7 @@ name = "primitive-types" version = "0.7.0" authors = ["Parity Technologies "] -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" homepage = "https://github.com/paritytech/parity-common" description = "Primitive types shared by Ethereum and Substrate" edition = "2018" diff --git a/primitive-types/impls/codec/Cargo.toml b/primitive-types/impls/codec/Cargo.toml index 4b39c10af..df837fd01 100644 --- a/primitive-types/impls/codec/Cargo.toml +++ b/primitive-types/impls/codec/Cargo.toml @@ -2,7 +2,7 @@ name = "impl-codec" version = "0.4.2" authors = ["Parity Technologies "] -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" homepage = "https://github.com/paritytech/parity-common" description = "Parity Codec serialization support for uint and fixed hash." edition = "2018" diff --git a/primitive-types/impls/rlp/Cargo.toml b/primitive-types/impls/rlp/Cargo.toml index 85db3c328..fbc12c7fb 100644 --- a/primitive-types/impls/rlp/Cargo.toml +++ b/primitive-types/impls/rlp/Cargo.toml @@ -2,7 +2,7 @@ name = "impl-rlp" version = "0.2.1" authors = ["Parity Technologies "] -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" homepage = "https://github.com/paritytech/parity-common" description = "RLP serialization support for uint and fixed hash." edition = "2018" diff --git a/primitive-types/impls/serde/Cargo.toml b/primitive-types/impls/serde/Cargo.toml index 641a59e6a..ab923bb63 100644 --- a/primitive-types/impls/serde/Cargo.toml +++ b/primitive-types/impls/serde/Cargo.toml @@ -3,7 +3,7 @@ name = "impl-serde" version = "0.3.0" authors = ["Parity Technologies "] edition = "2018" -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" homepage = "https://github.com/paritytech/parity-common" description = "Serde serialization support for uint and fixed hash." diff --git a/rlp-derive/Cargo.toml b/rlp-derive/Cargo.toml index de3824a2f..5059d6d02 100644 --- a/rlp-derive/Cargo.toml +++ b/rlp-derive/Cargo.toml @@ -2,7 +2,7 @@ name = "rlp-derive" version = "0.1.0" authors = ["Parity Technologies "] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" description = "Derive macro for #[derive(RlpEncodable, RlpDecodable)]" homepage = "http://parity.io" edition = "2018" diff --git a/rlp/Cargo.toml b/rlp/Cargo.toml index 947418a6b..cb8694c9e 100644 --- a/rlp/Cargo.toml +++ b/rlp/Cargo.toml @@ -3,7 +3,7 @@ name = "rlp" version = "0.4.5" description = "Recursive-length prefix encoding, decoding, and compression" repository = "https://github.com/paritytech/parity-common" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/trace-time/Cargo.toml b/trace-time/Cargo.toml index 225cdec27..81877e186 100644 --- a/trace-time/Cargo.toml +++ b/trace-time/Cargo.toml @@ -4,7 +4,7 @@ description = "Easily trace time to execute a scope." version = "0.1.3" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/transaction-pool/Cargo.toml b/transaction-pool/Cargo.toml index 2bf1dbb59..a13bc5767 100644 --- a/transaction-pool/Cargo.toml +++ b/transaction-pool/Cargo.toml @@ -2,7 +2,7 @@ description = "Generic transaction pool." name = "transaction-pool" version = "2.0.3" -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" edition = "2018" diff --git a/triehash/Cargo.toml b/triehash/Cargo.toml index 19496503a..358161a80 100644 --- a/triehash/Cargo.toml +++ b/triehash/Cargo.toml @@ -4,7 +4,7 @@ version = "0.8.3" authors = ["Parity Technologies "] description = "In-memory patricia trie operations" repository = "https://github.com/paritytech/parity-common" -license = "MIT/Apache2.0" +license = "MIT OR Apache-2.0" edition = "2018" [dependencies] diff --git a/uint/Cargo.toml b/uint/Cargo.toml index 3a61567a6..257b3fa7f 100644 --- a/uint/Cargo.toml +++ b/uint/Cargo.toml @@ -2,7 +2,7 @@ description = "Large fixed-size integer arithmetic" homepage = "http://parity.io" repository = "https://github.com/paritytech/parity-common" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" name = "uint" version = "0.8.2" authors = ["Parity Technologies "] From 8a29232801708e2679ee1f444136d76e6e340837 Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Wed, 25 Mar 2020 18:46:49 +0100 Subject: [PATCH 4/5] Ban duplicates of parity-uil-mem from being linked into the same program (#363) * Prevent multiple versions of parity-uil-mem from being linked into the same program * fmt * parity-util-mem: add a warning about defining global allocs * parity-util-mem: document empty build script * parity-util-mem: extend the warning based on David comments --- parity-util-mem/CHANGELOG.md | 2 ++ parity-util-mem/Cargo.toml | 7 +++++++ parity-util-mem/README.md | 14 ++++++++++++++ parity-util-mem/build.rs | 1 + 4 files changed, 24 insertions(+) create mode 100644 parity-util-mem/build.rs diff --git a/parity-util-mem/CHANGELOG.md b/parity-util-mem/CHANGELOG.md index fdb3f5f7b..ec8ef91f9 100644 --- a/parity-util-mem/CHANGELOG.md +++ b/parity-util-mem/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Breaking +- Prevent multiple versions from being linked into the same program. [#363](https://github.com/paritytech/parity-common/pull/363) ## [0.6.0] - 2020-03-13 - Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) diff --git a/parity-util-mem/Cargo.toml b/parity-util-mem/Cargo.toml index af3916902..700061c32 100644 --- a/parity-util-mem/Cargo.toml +++ b/parity-util-mem/Cargo.toml @@ -7,6 +7,13 @@ description = "Collection of memory related utilities" license = "MIT OR Apache-2.0" edition = "2018" +# Prevent multiple versions from being linked into the same program. +links = "parity-util-mem-ban-duplicates" +# `links` requires a build script to be present: +# https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key +# so we use an empty build script +build = "build.rs" + [dependencies] cfg-if = "0.1.10" dlmalloc = { version = "0.1.3", features = ["global"], optional = true } diff --git a/parity-util-mem/README.md b/parity-util-mem/README.md index 14d6e6c19..a6f15b90b 100644 --- a/parity-util-mem/README.md +++ b/parity-util-mem/README.md @@ -2,6 +2,20 @@ Collection of memory related utilities. +## WARNING + +When `parity-util-mem` is used as a dependency with any of the global allocator features enabled, +it must be the sole place where a global allocator is defined. +The only exception to this rule is when used in a `no_std` context or when the `estimate-heapsize` feature is used. + +Because of that, it must be present in the dependency tree with a single version. +Starting from version 0.7, having duplicate versions of `parity-util-mem` will lead +to a compile-time error. It still will be possible to have 0.6 and 0.7 versions in the same binary though. + +Unless heeded you risk UB; see discussion in [issue 364]. + +[issue 364]: https://github.com/paritytech/parity-common/issues/364 + ## Features - estimate-heapsize : Do not use allocator, but `size_of` or `size_of_val`. diff --git a/parity-util-mem/build.rs b/parity-util-mem/build.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/parity-util-mem/build.rs @@ -0,0 +1 @@ +fn main() {} From 7093b7e63304b236ab5d654b137c656d8bf833f9 Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Thu, 26 Mar 2020 15:18:49 +0100 Subject: [PATCH 5/5] kvdb: no overlay (#313) * kvdb-rocksdb: no overlay experiment * kvdb-rocksdb: remove unused dep * kvdb-rocksdb: panic on write failure * kvdb: remove write_buffered and flush * kvdb: update changelog * kvdb-rocksdb: update changelog * kvdb-web: update changelog * kvdb-memory: update changelog * kvdb-rocksdb: fix the bench * kvdb-rocksdb: fix the bench #2 * kvdb: cargo fmt * Apply suggestions from code review Co-Authored-By: David * kvdb-rocksdb: s/acquired_val/value * kvdb-rocksdb: update the changelog Co-authored-by: David --- kvdb-memorydb/CHANGELOG.md | 2 + kvdb-memorydb/src/lib.rs | 5 +- kvdb-rocksdb/CHANGELOG.md | 2 + kvdb-rocksdb/Cargo.toml | 1 - kvdb-rocksdb/benches/bench_read_perf.rs | 2 - kvdb-rocksdb/src/lib.rs | 186 +++--------------------- kvdb-shared-tests/src/lib.rs | 13 +- kvdb-web/CHANGELOG.md | 2 + kvdb-web/src/lib.rs | 10 +- kvdb-web/tests/indexed_db.rs | 2 +- kvdb/CHANGELOG.md | 2 + kvdb/src/lib.rs | 30 +--- 12 files changed, 48 insertions(+), 209 deletions(-) diff --git a/kvdb-memorydb/CHANGELOG.md b/kvdb-memorydb/CHANGELOG.md index a8c74772d..4db19fc7a 100644 --- a/kvdb-memorydb/CHANGELOG.md +++ b/kvdb-memorydb/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Breaking +- Updated to the new `kvdb` interface. [#313](https://github.com/paritytech/parity-common/pull/313) ## [0.5.0] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) diff --git a/kvdb-memorydb/src/lib.rs b/kvdb-memorydb/src/lib.rs index 51bac41f0..6977fbf4e 100644 --- a/kvdb-memorydb/src/lib.rs +++ b/kvdb-memorydb/src/lib.rs @@ -52,7 +52,7 @@ impl KeyValueDB for InMemory { } } - fn write_buffered(&self, transaction: DBTransaction) { + fn write(&self, transaction: DBTransaction) -> io::Result<()> { let mut columns = self.columns.write(); let ops = transaction.ops; for op in ops { @@ -69,9 +69,6 @@ impl KeyValueDB for InMemory { } } } - } - - fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/kvdb-rocksdb/CHANGELOG.md b/kvdb-rocksdb/CHANGELOG.md index e7561c059..43cf44408 100644 --- a/kvdb-rocksdb/CHANGELOG.md +++ b/kvdb-rocksdb/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Breaking +- Updated to the new `kvdb` interface. [#313](https://github.com/paritytech/parity-common/pull/313) ## [0.7.0] - 2020-03-16 - Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361) diff --git a/kvdb-rocksdb/Cargo.toml b/kvdb-rocksdb/Cargo.toml index 322d0865f..315b4d864 100644 --- a/kvdb-rocksdb/Cargo.toml +++ b/kvdb-rocksdb/Cargo.toml @@ -14,7 +14,6 @@ harness = false [dependencies] smallvec = "1.0.0" fs-swap = "0.2.4" -interleaved-ordered = "0.1.1" kvdb = { path = "../kvdb", version = "0.5" } log = "0.4.8" num_cpus = "1.10.1" diff --git a/kvdb-rocksdb/benches/bench_read_perf.rs b/kvdb-rocksdb/benches/bench_read_perf.rs index 8c17d8981..3a14ac752 100644 --- a/kvdb-rocksdb/benches/bench_read_perf.rs +++ b/kvdb-rocksdb/benches/bench_read_perf.rs @@ -76,8 +76,6 @@ fn populate(db: &Database) -> io::Result> { batch.put(0, &key.as_bytes(), &n_random_bytes(140)); } db.write(batch)?; - // Clear the overlay - db.flush()?; Ok(needles) } diff --git a/kvdb-rocksdb/src/lib.rs b/kvdb-rocksdb/src/lib.rs index ac8958919..8755f207f 100644 --- a/kvdb-rocksdb/src/lib.rs +++ b/kvdb-rocksdb/src/lib.rs @@ -12,15 +12,14 @@ mod stats; use std::{cmp, collections::HashMap, convert::identity, error, fs, io, mem, path::Path, result}; use parity_util_mem::MallocSizeOf; -use parking_lot::{Mutex, MutexGuard, RwLock}; +use parking_lot::RwLock; use rocksdb::{ BlockBasedOptions, ColumnFamily, ColumnFamilyDescriptor, Error, Options, ReadOptions, WriteBatch, WriteOptions, DB, }; use crate::iter::KeyValuePair; use fs_swap::{swap, swap_nonatomic}; -use interleaved_ordered::interleave_ordered; -use kvdb::{DBKey, DBOp, DBTransaction, DBValue, KeyValueDB}; +use kvdb::{DBOp, DBTransaction, DBValue, KeyValueDB}; use log::{debug, warn}; #[cfg(target_os = "linux")] @@ -51,12 +50,6 @@ pub const DB_DEFAULT_COLUMN_MEMORY_BUDGET_MB: MiB = 128; /// The default memory budget in MiB. pub const DB_DEFAULT_MEMORY_BUDGET_MB: MiB = 512; -#[derive(MallocSizeOf)] -enum KeyState { - Insert(DBValue), - Delete, -} - /// Compaction profile for the database settings /// Note, that changing these parameters may trigger /// the compaction process of RocksDB on startup. @@ -281,15 +274,8 @@ pub struct Database { read_opts: ReadOptions, #[ignore_malloc_size_of = "insignificant"] block_opts: BlockBasedOptions, - // Dirty values added with `write_buffered`. Cleaned on `flush`. - overlay: RwLock>>, #[ignore_malloc_size_of = "insignificant"] stats: stats::RunningDbStats, - // Values currently being flushed. Cleared when `flush` completes. - flushing: RwLock>>, - // Prevents concurrent flushes. - // Value indicates if a flush is in progress. - flushing_lock: Mutex, } #[inline] @@ -418,9 +404,6 @@ impl Database { Ok(Database { db: RwLock::new(Some(DBAndColumns { db, column_names })), config: config.clone(), - overlay: RwLock::new((0..config.columns).map(|_| HashMap::new()).collect()), - flushing: RwLock::new((0..config.columns).map(|_| HashMap::new()).collect()), - flushing_lock: Mutex::new(false), path: path.to_owned(), opts, read_opts, @@ -435,75 +418,6 @@ impl Database { DBTransaction::new() } - /// Commit transaction to database. - pub fn write_buffered(&self, tr: DBTransaction) { - let mut overlay = self.overlay.write(); - let ops = tr.ops; - for op in ops { - match op { - DBOp::Insert { col, key, value } => overlay[col as usize].insert(key, KeyState::Insert(value)), - DBOp::Delete { col, key } => overlay[col as usize].insert(key, KeyState::Delete), - }; - } - } - - /// Commit buffered changes to database. Must be called under `flush_lock` - fn write_flushing_with_lock(&self, _lock: &mut MutexGuard<'_, bool>) -> io::Result<()> { - match *self.db.read() { - Some(ref cfs) => { - let mut batch = WriteBatch::default(); - let mut ops: usize = 0; - let mut bytes: usize = 0; - mem::swap(&mut *self.overlay.write(), &mut *self.flushing.write()); - { - for (c, column) in self.flushing.read().iter().enumerate() { - ops += column.len(); - for (key, state) in column.iter() { - let cf = cfs.cf(c); - match *state { - KeyState::Delete => { - bytes += key.len(); - batch.delete_cf(cf, key).map_err(other_io_err)? - } - KeyState::Insert(ref value) => { - bytes += key.len() + value.len(); - batch.put_cf(cf, key, value).map_err(other_io_err)? - } - }; - } - } - } - - check_for_corruption(&self.path, cfs.db.write_opt(batch, &self.write_opts))?; - self.stats.tally_transactions(1); - self.stats.tally_writes(ops as u64); - self.stats.tally_bytes_written(bytes as u64); - - for column in self.flushing.write().iter_mut() { - column.clear(); - column.shrink_to_fit(); - } - Ok(()) - } - None => Err(other_io_err("Database is closed")), - } - } - - /// Commit buffered changes to database. - pub fn flush(&self) -> io::Result<()> { - let mut lock = self.flushing_lock.lock(); - // If RocksDB batch allocation fails the thread gets terminated and the lock is released. - // The value inside the lock is used to detect that. - if *lock { - // This can only happen if another flushing thread is terminated unexpectedly. - return Err(other_io_err("Database write failure. Running low on memory perhaps?")); - } - *lock = true; - let result = self.write_flushing_with_lock(&mut lock); - *lock = false; - result - } - /// Commit transaction to database. pub fn write(&self, tr: DBTransaction) -> io::Result<()> { match *self.db.read() { @@ -517,9 +431,6 @@ impl Database { let mut stats_total_bytes = 0; for op in ops { - // remove any buffered operation for this key - self.overlay.write()[op.col() as usize].remove(op.key()); - let cf = cfs.cf(op.col() as usize); match op { @@ -546,84 +457,55 @@ impl Database { pub fn get(&self, col: u32, key: &[u8]) -> io::Result> { match *self.db.read() { Some(ref cfs) => { - self.stats.tally_reads(1); - let guard = self.overlay.read(); - let overlay = - guard.get(col as usize).ok_or_else(|| other_io_err("kvdb column index is out of bounds"))?; - match overlay.get(key) { - Some(&KeyState::Insert(ref value)) => Ok(Some(value.clone())), - Some(&KeyState::Delete) => Ok(None), - None => { - let flushing = &self.flushing.read()[col as usize]; - match flushing.get(key) { - Some(&KeyState::Insert(ref value)) => Ok(Some(value.clone())), - Some(&KeyState::Delete) => Ok(None), - None => { - let acquired_val = cfs - .db - .get_pinned_cf_opt(cfs.cf(col as usize), key, &self.read_opts) - .map(|r| r.map(|v| v.to_vec())) - .map_err(other_io_err); - - match acquired_val { - Ok(Some(ref v)) => self.stats.tally_bytes_read((key.len() + v.len()) as u64), - Ok(None) => self.stats.tally_bytes_read(key.len() as u64), - _ => {} - }; - - acquired_val - } - } - } + if cfs.column_names.get(col as usize).is_none() { + return Err(other_io_err("column index is out of bounds")); } + self.stats.tally_reads(1); + let value = cfs + .db + .get_pinned_cf_opt(cfs.cf(col as usize), key, &self.read_opts) + .map(|r| r.map(|v| v.to_vec())) + .map_err(other_io_err); + + match value { + Ok(Some(ref v)) => self.stats.tally_bytes_read((key.len() + v.len()) as u64), + Ok(None) => self.stats.tally_bytes_read(key.len() as u64), + _ => {} + }; + + value } None => Ok(None), } } - /// Get value by partial key. Prefix size should match configured prefix size. Only searches flushed values. - // TODO: support prefix seek for unflushed data + /// Get value by partial key. Prefix size should match configured prefix size. pub fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option> { self.iter_from_prefix(col, prefix).next().map(|(_, v)| v) } - /// Get database iterator for flushed data. + /// Iterator over the data in the given database column index. /// Will hold a lock until the iterator is dropped /// preventing the database from being closed. pub fn iter<'a>(&'a self, col: u32) -> impl Iterator + 'a { let read_lock = self.db.read(); let optional = if read_lock.is_some() { - let overlay_data = { - let overlay = &self.overlay.read()[col as usize]; - let mut overlay_data = overlay - .iter() - .filter_map(|(k, v)| match *v { - KeyState::Insert(ref value) => { - Some((k.clone().into_vec().into_boxed_slice(), value.clone().into_boxed_slice())) - } - KeyState::Delete => None, - }) - .collect::>(); - overlay_data.sort(); - overlay_data - }; - let guarded = iter::ReadGuardedIterator::new(read_lock, col, &self.read_opts); - Some(interleave_ordered(overlay_data, guarded)) + Some(guarded) } else { None }; optional.into_iter().flat_map(identity) } - /// Get database iterator from prefix for flushed data. + /// Iterator over data in the `col` database column index matching the given prefix. /// Will hold a lock until the iterator is dropped /// preventing the database from being closed. fn iter_from_prefix<'a>(&'a self, col: u32, prefix: &'a [u8]) -> impl Iterator + 'a { let read_lock = self.db.read(); let optional = if read_lock.is_some() { let guarded = iter::ReadGuardedIterator::new_from_prefix(read_lock, col, prefix, &self.read_opts); - Some(interleave_ordered(Vec::new(), guarded)) + Some(guarded) } else { None }; @@ -636,8 +518,6 @@ impl Database { /// Close the database fn close(&self) { *self.db.write() = None; - self.overlay.write().clear(); - self.flushing.write().clear(); } /// Restore the database from a copy at given path. @@ -671,8 +551,6 @@ impl Database { // reopen the database and steal handles into self let db = Self::open(&self.config, &self.path)?; *self.db.write() = mem::replace(&mut *db.db.write(), None); - *self.overlay.write() = mem::replace(&mut *db.overlay.write(), Vec::new()); - *self.flushing.write() = mem::replace(&mut *db.flushing.write(), Vec::new()); Ok(()) } @@ -687,7 +565,6 @@ impl Database { } /// The number of keys in a column (estimated). - /// Does not take into account the unflushed data. pub fn num_keys(&self, col: u32) -> io::Result { const ESTIMATE_NUM_KEYS: &str = "rocksdb.estimate-num-keys"; match *self.db.read() { @@ -751,18 +628,10 @@ impl KeyValueDB for Database { Database::get_by_prefix(self, col, prefix) } - fn write_buffered(&self, transaction: DBTransaction) { - Database::write_buffered(self, transaction) - } - fn write(&self, transaction: DBTransaction) -> io::Result<()> { Database::write(self, transaction) } - fn flush(&self) -> io::Result<()> { - Database::flush(self) - } - fn iter<'a>(&'a self, col: u32) -> Box + 'a> { let unboxed = Database::iter(self, col); Box::new(unboxed.into_iter()) @@ -805,13 +674,6 @@ impl KeyValueDB for Database { } } -impl Drop for Database { - fn drop(&mut self) { - // write all buffered changes if we can. - let _ = self.flush(); - } -} - #[cfg(test)] mod tests { use super::*; @@ -888,8 +750,6 @@ mod tests { } db.write(batch).unwrap(); - db.flush().unwrap(); - { let db = db.db.read(); db.as_ref().map(|db| { diff --git a/kvdb-shared-tests/src/lib.rs b/kvdb-shared-tests/src/lib.rs index ca82dc8cd..35de99239 100644 --- a/kvdb-shared-tests/src/lib.rs +++ b/kvdb-shared-tests/src/lib.rs @@ -17,7 +17,7 @@ pub fn test_put_and_get(db: &dyn KeyValueDB) -> io::Result<()> { let mut transaction = db.transaction(); transaction.put(0, key1, b"horse"); - db.write_buffered(transaction); + db.write(transaction)?; assert_eq!(&*db.get(0, key1)?.unwrap(), b"horse"); Ok(()) } @@ -28,12 +28,12 @@ pub fn test_delete_and_get(db: &dyn KeyValueDB) -> io::Result<()> { let mut transaction = db.transaction(); transaction.put(0, key1, b"horse"); - db.write_buffered(transaction); + db.write(transaction)?; assert_eq!(&*db.get(0, key1)?.unwrap(), b"horse"); let mut transaction = db.transaction(); transaction.delete(0, key1); - db.write_buffered(transaction); + db.write(transaction)?; assert!(db.get(0, key1)?.is_none()); Ok(()) } @@ -49,7 +49,7 @@ pub fn test_get_fails_with_non_existing_column(db: &dyn KeyValueDB) -> io::Resul pub fn test_write_clears_buffered_ops(db: &dyn KeyValueDB) -> io::Result<()> { let mut batch = db.transaction(); batch.put(0, b"foo", b"bar"); - db.write_buffered(batch); + db.write(batch)?; assert_eq!(db.get(0, b"foo")?.unwrap(), b"bar"); @@ -69,7 +69,7 @@ pub fn test_iter(db: &dyn KeyValueDB) -> io::Result<()> { let mut transaction = db.transaction(); transaction.put(0, key1, key1); transaction.put(0, key2, key2); - db.write_buffered(transaction); + db.write(transaction)?; let contents: Vec<_> = db.iter(0).into_iter().collect(); assert_eq!(contents.len(), 2); @@ -224,11 +224,10 @@ pub fn test_complex(db: &dyn KeyValueDB) -> io::Result<()> { let mut transaction = db.transaction(); transaction.put(0, key1, b"horse"); transaction.delete(0, key3); - db.write_buffered(transaction); + db.write(transaction)?; assert!(db.get(0, key3)?.is_none()); assert_eq!(&*db.get(0, key1)?.unwrap(), b"horse"); - db.flush()?; assert!(db.get(0, key3)?.is_none()); assert_eq!(&*db.get(0, key1)?.unwrap(), b"horse"); Ok(()) diff --git a/kvdb-web/CHANGELOG.md b/kvdb-web/CHANGELOG.md index f8e952bf3..97fa61f4f 100644 --- a/kvdb-web/CHANGELOG.md +++ b/kvdb-web/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Breaking +- Updated to the new `kvdb` interface. [#313](https://github.com/paritytech/parity-common/pull/313) ## [0.5.0] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) diff --git a/kvdb-web/src/lib.rs b/kvdb-web/src/lib.rs index 5d9878ec2..f0179c085 100644 --- a/kvdb-web/src/lib.rs +++ b/kvdb-web/src/lib.rs @@ -71,7 +71,7 @@ impl Database { txn.put_vec(column, key.as_ref(), value); } // write each column into memory - in_memory.write_buffered(txn); + in_memory.write(txn).expect("writing in memory always succeeds; qed"); } Ok(Database { name: name_clone, version, columns, in_memory, indexed_db: inner }) } @@ -102,13 +102,9 @@ impl KeyValueDB for Database { self.in_memory.get_by_prefix(col, prefix) } - fn write_buffered(&self, transaction: DBTransaction) { + fn write(&self, transaction: DBTransaction) -> io::Result<()> { let _ = indexed_db::idb_commit_transaction(&*self.indexed_db, &transaction, self.columns); - self.in_memory.write_buffered(transaction); - } - - fn flush(&self) -> io::Result<()> { - Ok(()) + self.in_memory.write(transaction) } // NOTE: clones the whole db diff --git a/kvdb-web/tests/indexed_db.rs b/kvdb-web/tests/indexed_db.rs index 81a765a05..43c7ce83c 100644 --- a/kvdb-web/tests/indexed_db.rs +++ b/kvdb-web/tests/indexed_db.rs @@ -66,7 +66,7 @@ async fn reopen_the_database_with_more_columns() { // Write a value into the database let mut batch = db.transaction(); batch.put(0, b"hello", b"world"); - db.write_buffered(batch); + db.write(batch).unwrap(); assert_eq!(db.get(0, b"hello").unwrap().unwrap(), b"world"); diff --git a/kvdb/CHANGELOG.md b/kvdb/CHANGELOG.md index 18f484117..6cfa99a6e 100644 --- a/kvdb/CHANGELOG.md +++ b/kvdb/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Breaking +- Removed `write_buffered` and `flush` methods. [#313](https://github.com/paritytech/parity-common/pull/313) ## [0.5.0] - 2020-03-16 - License changed from GPL3 to dual MIT/Apache2. [#342](https://github.com/paritytech/parity-common/pull/342) diff --git a/kvdb/src/lib.rs b/kvdb/src/lib.rs index 723714de5..0fd28d9b8 100644 --- a/kvdb/src/lib.rs +++ b/kvdb/src/lib.rs @@ -84,19 +84,10 @@ impl DBTransaction { /// Generic key-value database. /// -/// This makes a distinction between "buffered" and "flushed" values. Values which have been -/// written can always be read, but may be present in an in-memory buffer. Values which have -/// been flushed have been moved to backing storage, like a RocksDB instance. There are certain -/// operations which are only guaranteed to operate on flushed data and not buffered, -/// although implementations may differ in this regard. -/// -/// The contents of an interior buffer may be explicitly flushed using the `flush` method. -/// -/// The `KeyValueDB` also deals in "column families", which can be thought of as distinct +/// The `KeyValueDB` deals with "column families", which can be thought of as distinct /// stores within a database. Keys written in one column family will not be accessible from /// any other. The number of column families must be specified at initialization, with a -/// differing interface for each database. The `None` argument in place of a column index -/// is always supported. +/// differing interface for each database. /// /// The API laid out here, along with the `Sync` bound implies interior synchronization for /// implementation. @@ -109,25 +100,16 @@ pub trait KeyValueDB: Sync + Send + parity_util_mem::MallocSizeOf { /// Get a value by key. fn get(&self, col: u32, key: &[u8]) -> io::Result>; - /// Get a value by partial key. Only works for flushed data. + /// Get the first value matching the given prefix. fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option>; - /// Write a transaction of changes to the buffer. - fn write_buffered(&self, transaction: DBTransaction); - /// Write a transaction of changes to the backing store. - fn write(&self, transaction: DBTransaction) -> io::Result<()> { - self.write_buffered(transaction); - self.flush() - } - - /// Flush all buffered data. - fn flush(&self) -> io::Result<()>; + fn write(&self, transaction: DBTransaction) -> io::Result<()>; - /// Iterate over flushed data for a given column. + /// Iterate over the data for a given column. fn iter<'a>(&'a self, col: u32) -> Box, Box<[u8]>)> + 'a>; - /// Iterate over flushed data for a given column, starting from a given prefix. + /// Iterate over the data for a given column, starting from a given prefix. fn iter_from_prefix<'a>( &'a self, col: u32,