new blooms database (#8712)

* new blooms database

* fixed conflict in Cargo.lock

* removed bloomchain

* cleanup in progress

* all tests passing in trace db with new blooms-db

* added trace_blooms to BlockChainDB interface, fixed db flushing

* BlockChainDB no longer exposes RwLock in the interface

* automatically flush blooms-db after every insert

* blooms-db uses io::BufReader to read files, wrap blooms-db into Mutex, cause fs::File is just a shared file handle

* fix json_tests

* blooms-db can filter multiple possibilities at the same time

* removed enum trace/db.rs CacheId

* lint fixes

* fixed tests

* kvdb-rocksdb uses fs-swap crate

* update Cargo.lock

* use fs::rename

* fixed failing test on linux

* fix tests

* use fs_swap

* fixed failing test on linux

* cleanup after swap

* fix tests

* fixed osx permissions

* simplify parity database opening functions

* added migration to blooms-db

* address @niklasad1 grumbles

* fix license and authors field of blooms-db Cargo.toml

* restore blooms-db after snapshot
This commit is contained in:
Marek Kotewicz
2018-06-20 15:13:07 +02:00
committed by Afri Schoedon
parent cf5ae81ced
commit 458afcd230
81 changed files with 1222 additions and 2887 deletions

View File

@@ -29,7 +29,6 @@ use test_helpers::{
};
use types::filter::Filter;
use ethereum_types::{U256, Address};
use kvdb_rocksdb::{Database, DatabaseConfig};
use miner::{Miner, PendingOrdering};
use spec::Spec;
use views::BlockView;
@@ -38,18 +37,17 @@ use transaction::{PendingTransaction, Transaction, Action, Condition};
use miner::MinerService;
use rlp::{RlpStream, EMPTY_LIST_RLP};
use tempdir::TempDir;
use test_helpers;
#[test]
fn imports_from_empty() {
let tempdir = TempDir::new("").unwrap();
let db = test_helpers::new_db();
let spec = Spec::new_test();
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());
let client = Client::new(
ClientConfig::default(),
&spec,
client_db,
db,
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
).unwrap();
@@ -59,15 +57,14 @@ fn imports_from_empty() {
#[test]
fn should_return_registrar() {
let db = test_helpers::new_db();
let tempdir = TempDir::new("").unwrap();
let spec = ethereum::new_morden(&tempdir.path().to_owned());
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());
let client = Client::new(
ClientConfig::default(),
&spec,
client_db,
db,
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
).unwrap();
@@ -89,15 +86,13 @@ fn returns_state_root_basic() {
#[test]
fn imports_good_block() {
let tempdir = TempDir::new("").unwrap();
let db = test_helpers::new_db();
let spec = Spec::new_test();
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());
let client = Client::new(
ClientConfig::default(),
&spec,
client_db,
db,
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
).unwrap();
@@ -132,15 +127,13 @@ fn fails_to_import_block_with_invalid_rlp() {
#[test]
fn query_none_block() {
let tempdir = TempDir::new("").unwrap();
let db = test_helpers::new_db();
let spec = Spec::new_test();
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());
let client = Client::new(
ClientConfig::default(),
&spec,
client_db,
db,
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
).unwrap();
@@ -282,11 +275,9 @@ fn can_mine() {
#[test]
fn change_history_size() {
let tempdir = TempDir::new("").unwrap();
let db = test_helpers::new_db();
let test_spec = Spec::new_null();
let mut config = ClientConfig::default();
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());
config.history = 2;
let address = Address::random();
@@ -294,7 +285,7 @@ fn change_history_size() {
let client = Client::new(
ClientConfig::default(),
&test_spec,
client_db.clone(),
db.clone(),
Arc::new(Miner::new_for_tests(&test_spec, None)),
IoChannel::disconnected()
).unwrap();
@@ -312,7 +303,7 @@ fn change_history_size() {
let client = Client::new(
config,
&test_spec,
client_db,
db,
Arc::new(Miner::new_for_tests(&test_spec, None)),
IoChannel::disconnected(),
).unwrap();

View File

@@ -16,7 +16,6 @@
//! Client tests of tracing
use tempdir::TempDir;
use ethkey::KeyPair;
use hash::keccak;
use block::*;
@@ -26,7 +25,6 @@ use spec::*;
use client::*;
use test_helpers::get_temp_state_db;
use client::{BlockChainClient, Client, ClientConfig};
use kvdb_rocksdb::{Database, DatabaseConfig};
use std::sync::Arc;
use header::Header;
use miner::Miner;
@@ -34,22 +32,21 @@ use transaction::{Action, Transaction};
use views::BlockView;
use trace::{RewardType, LocalizedTrace};
use trace::trace::Action::Reward;
use test_helpers;
#[test]
fn can_trace_block_and_uncle_reward() {
let tempdir = TempDir::new("").unwrap();
let db = test_helpers::new_db();
let spec = Spec::new_test_with_reward();
let engine = &*spec.engine;
// Create client
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let mut client_config = ClientConfig::default();
client_config.tracing.enabled = true;
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());
let client = Client::new(
client_config,
&spec,
client_db,
db,
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
).unwrap();