Skip to content

Commit

Permalink
fix(Store Validator / GC): State Headers and Parts upd (#2954)
Browse files Browse the repository at this point in the history
Fixing `state_header_block_exists` and saving State Header each time after State Part is calculated.
  • Loading branch information
Kouprin authored Jul 7, 2020
1 parent fcef91b commit 3abaad5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,9 @@ impl Chain {
let state_part =
self.runtime_adapter.obtain_state_part(shard_id, &state_root, part_id, num_parts);

// Before saving State Part data, we need to make sure we can calculate and save State Header
self.get_state_response_header(shard_id, sync_hash)?;

// Saving the part data
let mut store_update = self.store.owned_store().store_update();
store_update.set_ser(ColStateParts, &key, &state_part)?;
Expand Down
2 changes: 1 addition & 1 deletion chain/chain/src/store_validator/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ pub(crate) fn state_header_block_exists(
_header: &ShardStateSyncResponseHeader,
) -> Result<(), StoreValidatorError> {
unwrap_or_err_db!(
sv.store.get_ser::<ShardStateSyncResponseHeader>(ColBlock, key.1.as_ref()),
sv.store.get_ser::<Block>(ColBlock, key.1.as_ref()),
"Can't get Block from DB"
);
Ok(())
Expand Down

0 comments on commit 3abaad5

Please sign in to comment.