Skip to content

Commit

Permalink
Merge branch 'master' into ao-no-overlay
Browse files Browse the repository at this point in the history
* master:
  Memtest example for Rocksdb (#349)
  Prep for release (#361)
  • Loading branch information
ordian committed Mar 23, 2020
2 parents 2fe0a11 + 939151e commit 26ef26f
Show file tree
Hide file tree
Showing 40 changed files with 260 additions and 59 deletions.
3 changes: 3 additions & 0 deletions contract-address/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions contract-address/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "contract-address"
version = "0.3.0"
version = "0.4.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT/Apache2.0"
homepage = "https://github.com/paritytech/parity-common"
Expand All @@ -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 = []
Expand Down
2 changes: 2 additions & 0 deletions ethbloom/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions ethbloom/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethbloom"
version = "0.8.1"
version = "0.9.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Ethereum bloom filter"
license = "MIT/Apache2.0"
Expand All @@ -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 }

Expand Down
3 changes: 3 additions & 0 deletions ethereum-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions ethereum-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "ethereum-types"
version = "0.8.0"
version = "0.9.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT/Apache2.0"
homepage = "https://github.com/paritytech/parity-common"
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 }

Expand Down
2 changes: 2 additions & 0 deletions fixed-hash/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion fixed-hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fixed-hash"
version = "0.5.2"
version = "0.6.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT/Apache2.0"
homepage = "https://github.com/paritytech/parity-common"
Expand Down
3 changes: 3 additions & 0 deletions keccak-hash/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions keccak-hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <admin@parity.io>"]
repository = "https://github.com/paritytech/parity-common"
Expand All @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion kvdb-memorydb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ 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)
### 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)
- 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)

Expand Down
6 changes: 3 additions & 3 deletions kvdb-memorydb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "kvdb-memorydb"
version = "0.4.0"
version = "0.5.0"
authors = ["Parity Technologies <admin@parity.io>"]
repository = "https://github.com/paritytech/parity-common"
description = "A key-value in-memory database that implements the `KeyValueDB` trait"
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" }
5 changes: 4 additions & 1 deletion kvdb-rocksdb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ The format is based on [Keep a Changelog].
### Breaking
- Updated to the new `kvdb` interface. [#313](https://github.com/paritytech/parity-common/pull/313)

## [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)

Expand Down
10 changes: 7 additions & 3 deletions kvdb-rocksdb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kvdb-rocksdb"
version = "0.6.0"
version = "0.7.0"
authors = ["Parity Technologies <admin@parity.io>"]
repository = "https://github.com/paritytech/parity-common"
description = "kvdb implementation backed by RocksDB"
Expand All @@ -14,14 +14,14 @@ harness = false
[dependencies]
smallvec = "1.0.0"
fs-swap = "0.2.4"
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"
Expand All @@ -30,3 +30,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"
149 changes: 149 additions & 0 deletions kvdb-rocksdb/examples/memtest.rs
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

// 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<Self::Item> {
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;
}
}
2 changes: 1 addition & 1 deletion kvdb-shared-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
5 changes: 4 additions & 1 deletion kvdb-web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ 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)
### 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)
- 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)

Expand Down
Loading

0 comments on commit 26ef26f

Please sign in to comment.