Skip to content

Commit

Permalink
fix duplicate state machine height events
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 committed Oct 6, 2023
1 parent b6d02d0 commit 3b6cf81
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parachain/modules/ismp/ismp-rs/src/handlers/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ where
commitment_heights.sort_unstable_by(|a, b| a.height.cmp(&b.height));
let id = StateMachineId { state_id: id, consensus_state_id: msg.consensus_state_id };
let previous_latest_height = host.latest_commitment_height(id)?;
let mut last_commitment_height = None;
for commitment_height in commitment_heights.iter() {
let state_height = StateMachineHeight { id, height: commitment_height.height };
// If a state machine is frozen, we skip it
Expand All @@ -84,11 +85,12 @@ where
continue
}

last_commitment_height = Some(state_height);
host.store_state_machine_commitment(state_height, commitment_height.commitment)?;
host.store_state_machine_update_time(state_height, host.timestamp())?;
}

if let Some(latest_height) = commitment_heights.last() {
if let Some(latest_height) = last_commitment_height {
let latest_height = StateMachineHeight { id, height: latest_height.height };
state_updates
.insert((StateMachineHeight { id, height: previous_latest_height }, latest_height));
Expand Down

0 comments on commit 3b6cf81

Please sign in to comment.