-
Notifications
You must be signed in to change notification settings - Fork 676
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
reintroduce clear_resharding_data #10211
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for looking into it!
/// `is_next_block_epoch_start` works even if we didn't fully process the provided block. | ||
/// This function works even if we garbage collected `BlockInfo` of the first block of the epoch. | ||
/// Thus, this function is better suited for use in garbage collection. | ||
fn is_last_block_in_finished_epoch(&self, hash: &CryptoHash) -> Result<bool, EpochError>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ the comment
@@ -475,6 +481,11 @@ impl EpochManagerAdapter for EpochManagerHandle { | |||
epoch_manager.is_next_block_epoch_start(parent_hash) | |||
} | |||
|
|||
fn is_last_block_in_finished_epoch(&self, hash: &CryptoHash) -> Result<bool, EpochError> { | |||
let epoch_manager = self.read(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is impl EpochManagerAdapter for EpochManagerHandle
nearcore/chain/epoch-manager/src/lib.rs
Line 61 in fdead43
pub struct EpochManagerHandle { |
The actual implementation of the method depends on specific EpochManager
implementation of get_epoch_info
. So we get EpochManager
out of EpochManagerHandle
and call is_last_block_in_finished_epoch
there.
@@ -1086,6 +1086,20 @@ impl EpochManager { | |||
self.is_next_block_in_next_epoch(&block_info) | |||
} | |||
|
|||
/// Relies on the fact that last block hash of an epoch is an EpochId of next next epoch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I didn't know that. Nice trick!
// self.epoch_manager.as_ref(), | ||
// *block_hash, | ||
// )?; | ||
chain_store_update.clear_resharding_data( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we enable the resharding tests test_shard_layout_upgrade_gc
and test_shard_layout_upgrade_gc_v2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you soo much for looking into this!!
This reverts commit 5fa5470.
Tested on updated #10193
is_next_block_epoch_start
readsBlockInfo
of the first block of the epoch, which is not correct in the case of garbage collection.The previous version of the test was passing, because that
BlockInfo
was still in the cache of the epoch manager (as we callis_next_block_epoch_start
on every block)Implemented safer version of
is_next_block_epoch_start
--is_last_block_in_finished_epoch
(didn't think too much about the name, open to suggestions).is_last_block_in_finished_epoch
works by relying on the fact that if we processed block, and it was the last block of an epoch according tois_next_block_epoch_start
, then we wrote anEpochInfo
with the hash of that block, andEpochInfo
is not garbage collectible.