Skip to content

Commit 9ca741f

Browse files
committed
fix: query block timestamp if missing from log
1 parent a414aa1 commit 9ca741f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

crates/watcher/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,19 @@ where
332332
for (raw_log, decoded_log, _) in group {
333333
let block_number =
334334
raw_log.block_number.ok_or(FilterLogError::MissingBlockNumber)?;
335-
let block_timestamp =
336-
raw_log.block_timestamp.ok_or(FilterLogError::MissingBlockTimestamp)?;
335+
let log_timestamp = raw_log.block_timestamp;
336+
// if the log is missing the block timestamp, we need to fetch it.
337+
// the block timestamp is necessary in order to derive the beacon
338+
// slot and query the blobs.
339+
let block_timestamp = if log_timestamp.is_none() {
340+
self.execution_provider
341+
.get_block(block_number.into())
342+
.await?
343+
.map(|b| b.header.timestamp)
344+
.ok_or(FilterLogError::MissingBlockTimestamp)?
345+
} else {
346+
log_timestamp.expect("checked for Some(...)")
347+
};
337348
let batch_index =
338349
decoded_log.batch_index.uint_try_to().expect("u256 to u64 conversion error");
339350

0 commit comments

Comments
 (0)