Skip to content

Commit da8b2dc

Browse files
committed
Add minTimestamp and maxTimestamp as optional fields to bundle
1 parent 046a730 commit da8b2dc

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

crates/op-rbuilder/src/primitives/bundle.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ pub struct Bundle {
2828
skip_serializing_if = "Option::is_none"
2929
)]
3030
pub block_number_min: Option<u64>,
31+
32+
// Not recommended because this is subject to the builder node clock
33+
#[serde(
34+
default,
35+
rename = "minTimestamp",
36+
skip_serializing_if = "Option::is_none"
37+
)]
38+
pub min_timestamp: Option<u64>,
39+
40+
// Not recommended because this is subject to the builder node clock
41+
#[serde(
42+
default,
43+
rename = "maxTimestamp",
44+
skip_serializing_if = "Option::is_none"
45+
)]
46+
pub max_timestamp: Option<u64>,
3147
}
3248

3349
impl From<BundleConditionalError> for EthApiError {
@@ -110,8 +126,8 @@ impl Bundle {
110126
block_number_min,
111127
block_number_max,
112128
known_accounts: Default::default(),
113-
timestamp_max: None,
114-
timestamp_min: None,
129+
timestamp_max: self.max_timestamp,
130+
timestamp_min: self.min_timestamp,
115131
})
116132
}
117133
}
@@ -133,6 +149,8 @@ mod tests {
133149
reverting_hashes: None,
134150
block_number_max: None,
135151
block_number_min: None,
152+
min_timestamp: None,
153+
max_timestamp: None,
136154
};
137155

138156
let last_block = 1000;
@@ -152,6 +170,8 @@ mod tests {
152170
reverting_hashes: None,
153171
block_number_max: Some(1005),
154172
block_number_min: Some(1002),
173+
min_timestamp: None,
174+
max_timestamp: None,
155175
};
156176

157177
let last_block = 1000;
@@ -168,6 +188,8 @@ mod tests {
168188
reverting_hashes: None,
169189
block_number_max: Some(1005),
170190
block_number_min: Some(1010),
191+
min_timestamp: None,
192+
max_timestamp: None,
171193
};
172194

173195
let last_block = 1000;
@@ -189,6 +211,8 @@ mod tests {
189211
reverting_hashes: None,
190212
block_number_max: Some(999),
191213
block_number_min: None,
214+
min_timestamp: None,
215+
max_timestamp: None,
192216
};
193217

194218
let last_block = 1000;
@@ -210,6 +234,8 @@ mod tests {
210234
reverting_hashes: None,
211235
block_number_max: Some(1020),
212236
block_number_min: None,
237+
min_timestamp: None,
238+
max_timestamp: None,
213239
};
214240

215241
let last_block = 1000;
@@ -232,6 +258,8 @@ mod tests {
232258
reverting_hashes: None,
233259
block_number_max: None,
234260
block_number_min: Some(1015),
261+
min_timestamp: None,
262+
max_timestamp: None,
235263
};
236264

237265
let last_block = 1000;
@@ -253,6 +281,8 @@ mod tests {
253281
reverting_hashes: None,
254282
block_number_max: None,
255283
block_number_min: Some(1005),
284+
min_timestamp: None,
285+
max_timestamp: None,
256286
};
257287

258288
let last_block = 1000;
@@ -269,6 +299,8 @@ mod tests {
269299
reverting_hashes: None,
270300
block_number_max: Some(1008),
271301
block_number_min: None,
302+
min_timestamp: None,
303+
max_timestamp: None,
272304
};
273305

274306
let last_block = 1000;
@@ -285,6 +317,8 @@ mod tests {
285317
reverting_hashes: None,
286318
block_number_max: None,
287319
block_number_min: Some(999),
320+
min_timestamp: None,
321+
max_timestamp: None,
288322
};
289323

290324
let last_block = 1000;

crates/op-rbuilder/src/tests/framework/txs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ use super::FUNDED_PRIVATE_KEYS;
2727
pub struct BundleOpts {
2828
pub block_number_max: Option<u64>,
2929
pub block_number_min: Option<u64>,
30+
pub min_timestamp: Option<u64>,
31+
pub max_timestamp: Option<u64>,
3032
}
3133

3234
#[derive(Clone)]
@@ -194,6 +196,8 @@ impl TransactionBuilder {
194196
},
195197
block_number_max: bundle_opts.block_number_max,
196198
block_number_min: bundle_opts.block_number_min,
199+
min_timestamp: bundle_opts.min_timestamp,
200+
max_timestamp: bundle_opts.max_timestamp,
197201
};
198202

199203
let result: BundleResult = provider

crates/op-rbuilder/src/tests/vanilla/revert.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ async fn bundle_min_block_number() -> eyre::Result<()> {
188188
.with_bundle(BundleOpts {
189189
block_number_max: None,
190190
block_number_min: Some(2),
191+
min_timestamp: None,
192+
max_timestamp: None,
191193
})
192194
.send()
193195
.await?;
@@ -206,6 +208,8 @@ async fn bundle_min_block_number() -> eyre::Result<()> {
206208
.with_bundle(BundleOpts {
207209
block_number_max: Some(4),
208210
block_number_min: Some(4),
211+
min_timestamp: None,
212+
max_timestamp: None,
209213
})
210214
.send()
211215
.await?;
@@ -242,6 +246,8 @@ async fn bundle_range_limits() -> eyre::Result<()> {
242246
.with_bundle(BundleOpts {
243247
block_number_max,
244248
block_number_min,
249+
min_timestamp: None,
250+
max_timestamp: None,
245251
})
246252
.send()
247253
.await

0 commit comments

Comments
 (0)