Skip to content

Commit cffb527

Browse files
committed
cleanup
1 parent 6f31d1e commit cffb527

File tree

2 files changed

+6
-44
lines changed

2 files changed

+6
-44
lines changed

src/tasks/block/sim.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use init4_bin_base::{
99
};
1010
use signet_sim::{BlockBuild, BuiltBlock, SimCache};
1111
use signet_types::constants::SignetSystemConstants;
12-
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
12+
use std::time::{Duration, Instant};
1313
use tokio::{
1414
sync::{
1515
mpsc::{self},
@@ -94,7 +94,7 @@ impl Simulator {
9494
) -> eyre::Result<BuiltBlock> {
9595
debug!(
9696
block_number = block_env.number,
97-
deadline = ?self.instant_to_timestamp(finish_by),
97+
?finish_by,
9898
tx_count= sim_items.len(),
9999
"starting block build",
100100
);
@@ -208,14 +208,11 @@ impl Simulator {
208208
// We add a 1500 ms buffer to account for sequencer stopping signing.
209209
let deadline =
210210
Instant::now() + Duration::from_secs(remaining) - Duration::from_millis(1500);
211-
trace!(deadline = ?self.instant_to_timestamp(deadline), "calculated deadline for block simulation");
211+
trace!(?deadline, "calculated deadline for block simulation");
212212

213213
let buffered_deadline = deadline.max(Instant::now());
214214
trace!(?buffered_deadline, "final deadline for block simulation");
215215

216-
let timestamp = self.instant_to_timestamp(buffered_deadline);
217-
trace!(?timestamp, "deadline converted to timestamp");
218-
219216
buffered_deadline
220217
}
221218

@@ -245,23 +242,4 @@ impl Simulator {
245242
let wrapped_db: AlloyDatabaseProvider = WrapDatabaseAsync::new(alloy_db).unwrap();
246243
Some(wrapped_db)
247244
}
248-
249-
/// Converts an `Instant` to a UNIX timestamp in seconds and milliseconds.
250-
pub fn instant_to_timestamp(&self, instant: Instant) -> (u64, u128) {
251-
let now_instant = Instant::now();
252-
let now_system = SystemTime::now();
253-
254-
let duration_from_now = now_instant.duration_since(instant);
255-
256-
// Subtract that duration from the system time
257-
let target_system_time = now_system - duration_from_now;
258-
259-
let duration_since_epoch =
260-
target_system_time.duration_since(UNIX_EPOCH).expect("Time went backwards");
261-
262-
let seconds = duration_since_epoch.as_secs();
263-
let milliseconds = duration_since_epoch.as_millis();
264-
265-
(seconds, milliseconds)
266-
}
267245
}

src/tasks/submit.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,6 @@ impl SubmitTask {
509509
/// NB: This task assumes that the simulator will only send it blocks for
510510
/// slots that it's assigned.
511511
async fn task_future(self, mut inbound: mpsc::UnboundedReceiver<SimResult>) {
512-
// Holds a reference to the last block we attempted to submit
513-
let mut last_block_attempted: u64 = 0;
514-
515512
loop {
516513
// Wait to receive a new block
517514
let Some(result) = inbound.recv().await else {
@@ -520,23 +517,10 @@ impl SubmitTask {
520517
};
521518
debug!(block_number = result.block.block_number(), "submit channel received block");
522519

523-
// Only attempt each block number once
524-
if result.block.block_number() == last_block_attempted {
525-
debug!(
526-
block_number = result.block.block_number(),
527-
"block number is unchanged from last attempt - skipping"
528-
);
529-
continue;
520+
if let Err(e) = self.retrying_handle_inbound(&result.block, &result.env, 3).await {
521+
error!(error = %e, "error handling inbound block");
522+
continue;
530523
}
531-
532-
// This means we have encountered a new block, so reset the last block attempted
533-
last_block_attempted = result.block.block_number();
534-
debug!(last_block_attempted, "resetting last block attempted");
535-
536-
if self.retrying_handle_inbound(&result.block, &result.env, 3).await.is_err() {
537-
debug!("error handling inbound block");
538-
continue;
539-
};
540524
}
541525
}
542526

0 commit comments

Comments
 (0)