Skip to content

Commit

Permalink
[refactor] #2664: Introduce new wsv
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <shanin1000@yandex.ru>
  • Loading branch information
Erigara committed Nov 21, 2023
1 parent af85650 commit dc0cc41
Show file tree
Hide file tree
Showing 49 changed files with 3,091 additions and 2,180 deletions.
55 changes: 52 additions & 3 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ serde_with = { version = "3.3.0", default-features = false }
parity-scale-codec = { version = "3.6.5", default-features = false }
json5 = "0.4.1"

storage = { git = "https://github.com/Erigara/storage.git", branch="main" }

[workspace.lints]
rust.anonymous_parameters = "deny"
rust.future_incompatible = "deny"
Expand Down
18 changes: 12 additions & 6 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use iroha_core::{
gossiper::{TransactionGossiper, TransactionGossiperHandle},
handler::ThreadHandler,
kura::Kura,
prelude::{World, WorldStateView},
query::store::LiveQueryStore,
queue::Queue,
smartcontracts::isi::Registrable as _,
snapshot::{try_read_snapshot, SnapshotMaker, SnapshotMakerHandle},
sumeragi::{SumeragiHandle, SumeragiStartArgs},
tx::PeerId,
wsv::{State, World},
IrohaNetwork,
};
use iroha_data_model::prelude::*;
Expand Down Expand Up @@ -95,6 +95,8 @@ pub struct Iroha {
pub torii: Option<Torii>,
/// Snapshot service
pub snapshot_maker: SnapshotMakerHandle,
/// State of blockchain
pub wsv: Arc<State>,
/// Thread handlers
thread_handlers: Vec<ThreadHandler>,

Expand Down Expand Up @@ -256,7 +258,7 @@ impl Iroha {
.map_or_else(
|error| {
iroha_logger::warn!(%error, "Failed to load wsv from snapshot, creating empty wsv");
WorldStateView::from_configuration(
State::from_configuration(
*config.wsv,
world,
Arc::clone(&kura),
Expand All @@ -265,12 +267,13 @@ impl Iroha {
},
|wsv| {
iroha_logger::info!(
at_height = wsv.height(),
at_height = wsv.view().height(),
"Successfully loaded wsv from snapshot"
);
wsv
},
);
let wsv = Arc::new(wsv);

let queue = Arc::new(Queue::from_configuration(&config.queue));
if Self::start_telemetry(telemetry, &config).await? {
Expand All @@ -284,7 +287,7 @@ impl Iroha {
let sumeragi = SumeragiHandle::start(SumeragiStartArgs {
configuration: &config.sumeragi,
events_sender: events_sender.clone(),
wsv,
wsv: Arc::clone(&wsv),
queue: Arc::clone(&queue),
kura: Arc::clone(&kura),
network: network.clone(),
Expand All @@ -298,14 +301,15 @@ impl Iroha {
Arc::clone(&kura),
PeerId::new(&config.torii.p2p_addr, &config.public_key),
network.clone(),
Arc::clone(&wsv),
)
.start();

let gossiper = TransactionGossiper::from_configuration(
&config.sumeragi,
network.clone(),
Arc::clone(&queue),
sumeragi.clone(),
Arc::clone(&wsv),
)
.start();

Expand All @@ -326,7 +330,7 @@ impl Iroha {
.start();

let snapshot_maker =
SnapshotMaker::from_configuration(&config.snapshot, sumeragi.clone()).start();
SnapshotMaker::from_configuration(&config.snapshot, Arc::clone(&wsv)).start();

let torii = Torii::from_configuration(
config.clone(),
Expand All @@ -336,6 +340,7 @@ impl Iroha {
sumeragi.clone(),
live_query_store_handle,
Arc::clone(&kura),
Arc::clone(&wsv),
);

Self::start_listening_signal(Arc::clone(&notify_shutdown))?;
Expand All @@ -349,6 +354,7 @@ impl Iroha {
kura,
torii,
snapshot_maker,
wsv,
thread_handlers: vec![kura_thread_handler],
#[cfg(debug_assertions)]
freeze_status,
Expand Down
2 changes: 2 additions & 0 deletions cli/src/torii/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use iroha_core::{
query::store::LiveQueryStoreHandle,
queue::{self, Queue},
sumeragi::SumeragiHandle,
wsv::State,
EventsSender,
};
use tokio::sync::Notify;
Expand All @@ -40,6 +41,7 @@ pub struct Torii {
sumeragi: SumeragiHandle,
query_service: LiveQueryStoreHandle,
kura: Arc<Kura>,
wsv: Arc<State>,
}

/// Torii errors.
Expand Down

0 comments on commit dc0cc41

Please sign in to comment.