Skip to content

Commit

Permalink
Change to lock-free data structures inside wsv
Browse files Browse the repository at this point in the history
Signed-off-by: i1i1 <[email protected]>
  • Loading branch information
i1i1 committed Apr 26, 2021
1 parent 0139017 commit cf131d6
Show file tree
Hide file tree
Showing 41 changed files with 1,488 additions and 969 deletions.
25 changes: 25 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions iroha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ iroha_logger = { version = "=0.1.0", path = "../iroha_logger"}
iroha_crypto = { version = "=0.1.0", path = "../iroha_crypto" }
iroha_http_server = { version = "=0.1.0", path = "../iroha_http_server" }
iroha_version = { version = "=0.1.0", path = "../iroha_version", features = ["http_error"] }
iroha_structs = { path = "../iroha_structs" }
async-std = { version = "=1.6.2", features = ["attributes", "unstable"] }
iroha_config = { version = "=0.1.0", path = "../iroha_config" }
chrono = "0.4"
Expand Down
5 changes: 2 additions & 3 deletions iroha/benches/sumeragi.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#![allow(missing_docs, clippy::restriction)]

use std::collections::BTreeSet;

use criterion::{criterion_group, criterion_main, Criterion};
use iroha::sumeragi::NetworkTopology;
use iroha_crypto::{Hash, KeyPair};
use iroha_data_model::prelude::*;
use iroha_structs::HashSet;

const N_PEERS: usize = 255;

fn get_n_peers(n: usize) -> BTreeSet<PeerId> {
fn get_n_peers(n: usize) -> HashSet<PeerId> {
(0..n)
.map(|i| PeerId {
address: format!("127.0.0.{}", i),
Expand Down
29 changes: 14 additions & 15 deletions iroha/benches/validation.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#![allow(missing_docs, clippy::restriction)]

use std::collections::{BTreeMap, BTreeSet};

use criterion::{criterion_group, criterion_main, Criterion};
use iroha::{prelude::*, tx::AcceptedTransaction};
use iroha_data_model::prelude::*;
use iroha_structs::{HashMap, HashSet};

const TRANSACTION_TIME_TO_LIVE_MS: u64 = 100_000;

Expand Down Expand Up @@ -43,14 +42,14 @@ fn build_test_transaction(keys: &KeyPair) -> Transaction {

fn build_test_wsv(keys: &KeyPair) -> WorldStateView {
WorldStateView::new({
let mut domains = BTreeMap::new();
let mut domain = Domain::new(START_DOMAIN);
let domains = HashMap::new();
let domain = Domain::new(START_DOMAIN);
let account_id = AccountId::new(START_ACCOUNT, START_DOMAIN);
let mut account = Account::new(account_id.clone());
account.signatories.push(keys.public_key.clone());
let _ = domain.accounts.insert(account_id, account);
let _ = domains.insert(START_DOMAIN.to_string(), domain);
World::with(domains, BTreeSet::new())
let account = Account::new(account_id.clone());
account.signatories.write().push(keys.public_key.clone());
drop(domain.accounts.insert(account_id, account));
drop(domains.insert(START_DOMAIN.to_string(), domain));
World::with(domains, HashSet::new())
})
}

Expand Down Expand Up @@ -161,19 +160,19 @@ fn validate_blocks(criterion: &mut Criterion) {
// Prepare WSV
let key_pair = KeyPair::generate().expect("Failed to generate KeyPair.");
let domain_name = "global".to_string();
let asset_definitions = BTreeMap::new();
let asset_definitions = HashMap::new();
let account_id = AccountId::new("root", &domain_name);
let account = Account::with_signatory(account_id.clone(), key_pair.public_key);
let mut accounts = BTreeMap::new();
let _ = accounts.insert(account_id, account);
let accounts = HashMap::new();
drop(accounts.insert(account_id, account));
let domain = Domain {
name: domain_name.clone(),
accounts,
asset_definitions,
};
let mut domains = BTreeMap::new();
let _ = domains.insert(domain_name, domain);
let world_state_view = WorldStateView::new(World::with(domains, BTreeSet::new()));
let domains = HashMap::new();
drop(domains.insert(domain_name, domain));
let world_state_view = WorldStateView::new(World::with(domains, HashSet::new()));
// Pepare test transaction
let keys = KeyPair::generate().expect("Failed to generate keys");
let transaction = AcceptedTransaction::from_transaction(build_test_transaction(&keys), 4096)
Expand Down
Loading

0 comments on commit cf131d6

Please sign in to comment.