Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"

[workspace.package]
version = "0.4.0"
version = "0.4.1"
edition = "2021"
rust-version = "1.81"
authors = ["init4"]
Expand Down
12 changes: 12 additions & 0 deletions crates/bundle/src/send/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ impl SignetEthBundle {
self.bundle.replacement_uuid.as_deref()
}

/// Checks if the bundle is valid at a given timestamp.
pub fn is_valid_at_timestamp(&self, timestamp: u64) -> bool {
let min_timestamp = self.bundle.min_timestamp.unwrap_or(0);
let max_timestamp = self.bundle.max_timestamp.unwrap_or(u64::MAX);
timestamp >= min_timestamp && timestamp <= max_timestamp
}

/// Checks if the bundle is valid at a given block number.
pub const fn is_valid_at_block_number(&self, block_number: u64) -> bool {
self.bundle.block_number == block_number
}

/// Decode and validate the transactions in the bundle.
pub fn decode_and_validate_txs<Db: Database>(
&self,
Expand Down
12 changes: 5 additions & 7 deletions crates/sim/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,14 @@ impl SimCache {
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
&& bundle.min_timestamp().is_some_and(|ts| ts <= block_timestamp)
&& bundle.max_timestamp().is_some_and(|ts| ts >= block_timestamp);
let should_keep = bundle.is_valid_at_block_number(block_number)
&& bundle.is_valid_at_timestamp(block_timestamp);

let retain = !should_remove;

if should_remove {
if !should_keep {
seen.remove(item.identifier().as_bytes());
}
retain

should_keep
} else {
true // Non-bundle items are retained
}
Expand Down