Skip to content
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

Delete messages from coordinator after they become final #2471

Merged
merged 17 commits into from
Aug 16, 2024

Conversation

ganeshvanahalli
Copy link
Contributor

@ganeshvanahalli ganeshvanahalli commented Jul 10, 2024

This PR enables the chosen sequencer to delete finalized messages from redis. The sequencer is allowed to delete finalized messages if it is chosen for at least SeqCoordinatorConfig.UpdateInterval amount of time.

Note: Sequencer coordinator tests will see loud warnings as parent chain reader is not enabled in these tests and that is required to get current finalized message count

Resolves NIT-2605

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Jul 10, 2024
@ganeshvanahalli ganeshvanahalli marked this pull request as ready for review July 10, 2024 15:58
Copy link
Contributor

@diegoximenes diegoximenes left a comment

Choose a reason for hiding this comment

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

How about adding tests for this change?

arbnode/sync_monitor.go Show resolved Hide resolved
arbnode/sync_monitor.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
diegoximenes
diegoximenes previously approved these changes Aug 1, 2024
Copy link
Contributor

@tsahee tsahee left a comment

Choose a reason for hiding this comment

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

very good work!

Very minor comments. The important ones are:

  • using a separate default-on flag to disable deletion by finality
  • deleting keys in a look to avoid too-large redis requests.

arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
@@ -492,6 +511,56 @@ func (c *SeqCoordinator) updateWithLockout(ctx context.Context, nextChosen strin
return c.noRedisError()
}

func (c *SeqCoordinator) deleteFinalizedMsgsFromRedis(ctx context.Context, finalized arbutil.MessageIndex) error {
deleteMsgsAndUpdateFinalizedMsgCount := func(keys []string) error {
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 gain something by having this function defined that way and not as a normal functin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like we use a bunch of SeqCoordinator methods such as msgCountToSignedBytes, getRemoteMsgCountImpl, c.Client etc.. so thought having a method on SeqCoordinator is a better option over a standalone function

@@ -473,6 +483,15 @@ func (c *SeqCoordinator) updateWithLockout(ctx context.Context, nextChosen strin
return c.noRedisError()
}
// Was, and still is, the active sequencer
// Before proceeding, first try deleting finalized messages from redis and setting the finalizedMsgCount key
finalized, err := c.sync.GetFinalizedMsgCount(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

this could fail if parent chain doesn't support finalized..
For now, I think a good solution would be to have a boolean (default: true) option that enables deleting finalized messages

if err != nil {
log.Warn("Error getting finalizedMessageCount from syncMonitor: %w", err)
} else if finalized == 0 {
log.Warn("SyncMonitor returned zero finalizedMessageCount")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a specific reason you are checking for zero?
A little after initialization it is a valid return value and people will ask us if they get warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was checking for 0 because sequencer coordinator could be enabled without inboxreader/l1reader and l1reader is required to fetch finalizedMsgCount. In cases when inboxreader/l1reader is nil, sync monitor is made to return 0, nil this meant a reasonable return value to check if we should skip deleting of finalized messages

arbnode/seq_coordinator.go Outdated Show resolved Hide resolved
arbnode/seq_coordinator.go Show resolved Hide resolved
arbnode/seq_coordinator.go Show resolved Hide resolved
Copy link
Contributor

@tsahee tsahee left a comment

Choose a reason for hiding this comment

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

LGTM

@tsahee tsahee enabled auto-merge August 16, 2024 23:08
@tsahee tsahee merged commit 5d600df into master Aug 16, 2024
13 checks passed
@tsahee tsahee deleted the seqcoordinator-delete-finalizedmsgs branch August 16, 2024 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-approved s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants