Skip to content

feat(sim): dedup sim cache items #74

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

Merged
merged 23 commits into from
Jun 25, 2025
Merged

feat(sim): dedup sim cache items #74

merged 23 commits into from
Jun 25, 2025

Conversation

Evalir
Copy link
Member

@Evalir Evalir commented Jun 23, 2025

Uses an identifier to have a seen cache for items, keeping it up to date with the actual SimItem cache. This adds additional complexity in the inner structure of the cache, but this complexity is necessarily to avoid clones on most methods.

This also switches to parking_lot's RwLock, which is much faster than the standard std::sync one.

Closes ENG-1126

Uses an identifier to have a seen cache for items, keeping it up to date with the actual `SimItem` cache.
Copy link
Member Author

Evalir commented Jun 23, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Evalir Evalir marked this pull request as ready for review June 23, 2025 13:17
@Evalir Evalir requested a review from a team as a code owner June 23, 2025 13:17
@Evalir Evalir marked this pull request as draft June 23, 2025 13:18
@Evalir Evalir marked this pull request as ready for review June 23, 2025 13:55
@Evalir Evalir requested a review from prestwich June 23, 2025 18:47
@Evalir Evalir requested a review from prestwich June 24, 2025 16:59
@@ -9,14 +15,19 @@ use signet_bundle::SignetEthBundle;
pub enum SimItem {
/// A bundle to be simulated.
Bundle(SignetEthBundle),
Copy link
Member

Choose a reason for hiding this comment

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

qq, can't this be instantiated by downstream consumers via SimItem::Bundle(bundle)? If so, let's remove the ability to do that? that would allow constructing SimItems that violate the "must have UUID" invariant

Copy link
Member Author

Choose a reason for hiding this comment

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

will be done on a later pr, requires riffing on the least annoying way to do this since rust doesn't support this natively :D

Copy link
Member

@prestwich prestwich left a comment

Choose a reason for hiding this comment

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

okay just a few small things left

@Evalir Evalir requested a review from prestwich June 25, 2025 14:54
Copy link
Member

@prestwich prestwich left a comment

Choose a reason for hiding this comment

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

approving pending 2 nites

@Evalir Evalir enabled auto-merge (squash) June 25, 2025 14:58
@Evalir Evalir disabled auto-merge June 25, 2025 14:58
@Evalir Evalir merged commit df58e95 into main Jun 25, 2025
7 checks passed
@anna-carroll anna-carroll deleted the evalir/dedup-cache-items branch June 25, 2025 16:15
Copy link
Contributor

@anna-carroll anna-carroll left a comment

Choose a reason for hiding this comment

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

bug 🐞

let item = item.into();
let Ok(item) = SimItem::try_from(item) else {
// Skip invalid bundles
Copy link
Contributor

@anna-carroll anna-carroll Jun 26, 2025

Choose a reason for hiding this comment

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

should we log here that a bundle is being discarded as invalid?

items.retain(|_, item| {
// Retain only items that are not bundles or are valid in the current block.
if let SimItem::Bundle(bundle) = item {
let should_remove = bundle.bundle.block_number == block_number
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 remove bundles if they match the current block number? why?

Copy link
Contributor

Choose a reason for hiding this comment

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

this var looks more like should_keep, no?

  • bundle block number == current block number
  • bundle min timestamp <= current timestamp
  • bundle max timestamp >= current timestamp

these are validity conditions

@prestwich
Copy link
Member

dont submit a review after merge. create a ticket instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants