Skip to content

Commit

Permalink
[BACKPORT] #4164: Fix topology update on restart
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <[email protected]>
  • Loading branch information
Erigara committed Dec 25, 2023
1 parent 78c359b commit e6dd2c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
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

0 comments on commit e6dd2c0

Please sign in to comment.