Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACKPORT] #4164: Fix topology update on restart #4169

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions client/tests/integration/offline_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ use iroha_client::{
crypto::KeyPair,
data_model::{peer::Peer as DataModelPeer, prelude::*},
};
use iroha_config::iroha::Configuration;
use test_network::*;
use tokio::runtime::Runtime;

use iroha_config::iroha::Configuration;

#[test]
fn genesis_block_is_committed_with_some_offline_peers() -> Result<()> {
// Given
Expand Down
13 changes: 8 additions & 5 deletions core/src/sumeragi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,14 @@ impl SumeragiHandle {
fn replay_block(
block: &SignedBlock,
wsv: &mut WorldStateView,
current_topology: &Topology,
mut current_topology: Topology,
) -> Topology {
let block = ValidBlock::validate(block.clone(), current_topology, wsv)
// NOTE: topology need to be updated up to block's view_change_index
current_topology.rotate_all_n(block.payload().header.view_change_index);

let block = ValidBlock::validate(block.clone(), &current_topology, wsv)
.expect("Kura blocks should be valid")
.commit(current_topology)
.commit(&current_topology)
.expect("Kura blocks should be valid");

if block.payload().header.is_genesis() {
Expand Down Expand Up @@ -293,14 +296,14 @@ impl SumeragiHandle {
let block_iter_except_last =
(&mut blocks_iter).take(block_count.saturating_sub(skip_block_count + 1));
for block in block_iter_except_last {
current_topology = Self::replay_block(&block, &mut wsv, &current_topology);
current_topology = Self::replay_block(&block, &mut wsv, current_topology);
}

// finalized_wsv is one block behind
let finalized_wsv = wsv.clone();

if let Some(block) = blocks_iter.next() {
current_topology = Self::replay_block(&block, &mut wsv, &current_topology);
current_topology = Self::replay_block(&block, &mut wsv, current_topology);
}

info!("Sumeragi has finished loading blocks and setting up the WSV");
Expand Down
Loading