Skip to content

chore(refactor): catch-up scan uses stale received_at timestamp #128

@ikwuoz

Description

@ikwuoz

// arrival time of the first notification.
// TODO: should we use the blocks' timestamps?
if block_sender
.send(BlockEvent { block, received_at })
.await
.is_err()

In block_stream.rs, catch_up_scan propagates the received_at time of the first post-reconnect notification to all missed blocks, rather than timestamping each catch-up block at the moment it is actually fetched.

Impact:

All N catch-up blocks share an identical latency value (the reconnect moment), artificially flattening the latency distribution during gap scans. For example, if the spammer reconnects after a 5-second gap covering 10 blocks, all 10 blocks report the same received_at — making it appear they were all observed simultaneously, which is incorrect.

Suggested Fix:

Replace the shared received_at parameter with a per-block timestamp_now() call inside the catch-up loop

    FetchResult::Ok(block) => {
            let received_at = timestamp_now();  // timestamps each block individually
            if block_sender
                .send(BlockEvent { block, received_at })
                .await
                .is_err()
            {
                return Ok(());
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions