Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Method to list incomplete checkpoints #207

Merged
merged 18 commits into from
Sep 28, 2023
Merged

Method to list incomplete checkpoints #207

merged 18 commits into from
Sep 28, 2023

Conversation

dnkolegov
Copy link
Contributor

@dnkolegov dnkolegov commented Sep 21, 2023

This PR adds a method to list incomplete checkpoints described in consensus-shipyard/ipc#299 and a method to garbage collect completed checkpoints

Copy link
Contributor

@adlrocha adlrocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few cosmetic changes to make the code more understandable but overall LGTM. Thanks. I am curious how the end-to-end will work, and the gas cost from this (but it probably doesn't apply for now).

src/gateway/GatewayRouterFacet.sol Outdated Show resolved Hide resolved

/// @notice garbage collect all checkpoints and related data for heights lower than `newIndex`.
/// @param newIndex - new retention index
function pruneBottomUpCheckpoints(uint64 newIndex) external systemActorOnly {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is this function expected to be called externally? The idea is that this function should be called when there is no longer need to store the checkpoint signatures because it has already been submitted up, right?

If this is the case, would you mind adding this description in the comments so we are explcit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that this function should be called when there is no longer need to store the checkpoint signatures because it has already been submitted up, right

correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated description


/// @notice garbage collect all checkpoints and related data for heights lower than `newIndex`.
/// @param newIndex - new retention index
function pruneBottomUpCheckpoints(uint64 newIndex) external systemActorOnly {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we expect to set the newIndex for a specific garbage collection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, the caller should know what checkpoints have been processed in the parent and can be removed in the child

/// @notice The height of the last bottom-up checkpoint registered in the parent.
/// All checkpoint with the height less than or equal to that number can be garbage collected in the child subnet.
/// @dev Initial retention index is 1.
uint64 bottomUpCheckpointRetentionIndex;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind explaining here that the retention is needed so the checkpoint and signatures are available so relayers can submit the chceckpoint? It wasn't clear to me the purpose of the RetentionIndex on a first read. Thanks!

Copy link
Contributor Author

@dnkolegov dnkolegov Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All checkpoints with a height less than retentionIndex may be removed from the history if we want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant in the code, so it is clear :) But no need if you feel it may be redundant or clear once the end-to-end is implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code

Copy link
Contributor

@adlrocha adlrocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless @aakoshh and @cryptoAtwill want to have a final look, I think is ready to 🚢

for (uint64 h = oldRetentionIndex; h < newRetentionIndex; ) {
delete s.bottomUpCheckpoints[h];
delete s.bottomUpCheckpointInfo[h];
delete s.bottomUpCollectedSignatures[h];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also clear the bottomUpCheckpointsLegacy while it exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those two bottom-up checkpoint types are probably misleading. But bottomUpCheckpointsLegacy is not used in implementing the new bottom-up checkpoint mechanism. It is in the code just to build it without removing all libraries, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I understand we want to get rid of it, just wanted to highlight that since I'm relying on it in consensus-shipyard/fendermint#286 due to the lack of any alternatives, technically it will have data in it as long as it exists and someone sends a bottom-up message this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be fixed in #214

Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
Copy link
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, cheers!

@dnkolegov dnkolegov merged commit a24474f into dev Sep 28, 2023
5 checks passed
@dnkolegov dnkolegov deleted the fendermint258 branch September 28, 2023 15:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants