Skip to content

Conversation

@Evalir
Copy link
Member

@Evalir Evalir commented Jan 5, 2026

Closes ENG-1677

Copy link
Member Author

Evalir commented Jan 5, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Evalir Evalir marked this pull request as draft January 5, 2026 19:32
@Evalir Evalir requested a review from prestwich January 5, 2026 19:38
@Evalir Evalir marked this pull request as ready for review January 5, 2026 19:38
let sub = match self.host_provider.subscribe_blocks().await {
Ok(sub) => sub,
Err(err) => {
error!(error = ?err, "failed to subscribe to host chain blocks");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use display, not debug

additional nits:

  • could bind Err(error) to avoid the error = %err later
  • failed to subscribe to host chain blocks will appear in the event twice. once in the error field and once in the event message.

Is the error type useful since there only 1 possible failure mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, there's indeed only one failure mode (pubsub not being available on the provider), but, the error message itself is quite clear, so I don't mind just using it. we can remove the added string

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the error type useful? what does it provide that TransportError does not? Will our code be less useful or safe if we delete the type and use TransportError instead?

@Evalir Evalir requested a review from prestwich January 6, 2026 00:21
}

async fn task_future(self) {
let mut sub = match self.host_provider.subscribe_blocks().await {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reading again, this actually doesn't produce a BlockWatcherError. so the error is only produced by with_current_block, and in that context the error description ("failed to subscribe") is incorrect

at this point, i think the error type should be deleted

self.block_number.send_replace(block_number);
trace!(block_number, "updated host block number");
}
Err(RecvError::Lagged(missed)) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the downside of this? why is it a library warn?

warn!(%missed, "block subscription lagged");
}
Err(RecvError::Closed) => {
error!("block subscription closed");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not an error, it happens intentionally during normal program operation

/// can be read or awaited for changes. This allows multiple tasks to observe
/// block number updates.
#[derive(Debug, Clone)]
pub struct SharedBlockNumber(watch::Receiver<u64>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this type provide that watch::Receiver<u64> does not?

}

/// Spawns the block watcher task.
pub fn spawn(self) -> JoinHandle<()> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be possible to spawn the task without having a subscription to it. i.e. the spawn fn should either take a Sender as an arg, or return a Receiver as an arg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants