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

Spawn GC task from RecentBlockCache constructor #2109

Merged
merged 3 commits into from
Dec 1, 2023

Conversation

MartinquaXD
Copy link
Contributor

Description

As pointed out by @fleupold here we did not prune the cached balancer v2 liquidity.
This happened because we used the Maintaining trait in the past which is quite error prone. The old concept was to expose a function that does GC and have 1 centralized component call that function.
In the case of balancer v2 we implemented the GC function but forget to hook it up in the driver.

Changes

The new strategy I would like to use instead of the Maintaining trait is that every component that requires GC simply spins up its own task that takes care of it.
That way you can never forget by accident to run GC.

The specific changes in this PR are:

  • Move most of the RecentBlockCache logic into a private Inner struct
  • spawn a GC task in RecentBlockCache::new() that uses the now sharable Inner type
  • remove all the old code related to the Maintaining trait

How to test

All unit and e2e tests still pass

@MartinquaXD MartinquaXD requested a review from a team as a code owner December 1, 2023 14:54
Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

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

Awesome! Agree that Maintaining was a mistake, let's kill it with 🔥

break;
};
if let Err(err) = inner.update_cache_at_block(block.number).await {
tracing::warn!(?err, "filed to update cache");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tracing::warn!(?err, "filed to update cache");
tracing::warn!(?err, "failed to update cache");


let inner_cloned = Arc::downgrade(&inner);
tokio::task::spawn(
async move {
Copy link
Contributor

Choose a reason for hiding this comment

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

nanonit: given the size and branch complexity of this nested task could be nice to factor it into a free method and keep new more contained.

@MartinquaXD MartinquaXD merged commit 0c1fcb0 into main Dec 1, 2023
7 of 8 checks passed
@MartinquaXD MartinquaXD deleted the always-run-gc-on-recentblockcache branch December 1, 2023 16:57
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2023
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.

2 participants