Skip to content

Commit

Permalink
Merge pull request #760 from Phala-Network/fix_empty_state_root
Browse files Browse the repository at this point in the history
Don't overwrite the last state_root if given headers is empty
  • Loading branch information
jasl authored Apr 29, 2022
2 parents 9523182 + 0dc0c2f commit 96e2eb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion crates/phactory/api/src/storage_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ impl<Validator: BlockValidator> StorageSynchronizer for ParachainSynchronizer<Va
let last_header =
self.sync_state
.sync_header(headers, authority_set_change, &mut state_roots)?;
self.last_relaychain_state_root = state_roots.pop_back();
// Don't overwrite the last state_root if given headers is empty
if let Some(last_root) = state_roots.pop_back() {
self.last_relaychain_state_root = Some(last_root);
}
Ok(last_header)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/phactory/src/prpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<Platform: pal::Platform + Serialize + DeserializeOwned> Phactory<Platform>
let counters = self.runtime_state()?.storage_synchronizer.counters();
blocks.retain(|b| b.block_header.number >= counters.next_block_number);

let mut last_block = 0;
let mut last_block = counters.next_block_number - 1;
for block in blocks.into_iter() {
info!("Dispatching block: {}", block.block_header.number);
let state = self.runtime_state()?;
Expand Down

0 comments on commit 96e2eb4

Please sign in to comment.