Skip to content

blockstream: make subscription channel size configurable - #91

Merged
sduchesneau merged 2 commits into
streamingfast:developfrom
pinax-network:feat/subscription-chan-size
Nov 4, 2026
Merged

sduchesneau merged 2 commits into
streamingfast:developfrom
pinax-network:feat/subscription-chan-size

Conversation

@matthewdarwin

@matthewdarwin matthewdarwin commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

The block stream server closes a subscription once 200 blocks are queued for it (chanSize := 200 in Server.subscribe). This adds ServerOptionWithSubscriptionChannelSize so the server's owner can set that size. The default stays at 200 (DefaultSubscriptionChannelSize), so nothing changes unless the option is passed.

How it was found

Setup: a reader-node with --reader-node-blocks-chan-capacity=20000 (a fast chain with small blocks), feeding two relayers on other hosts.

What happened:

  1. The reader stalled for about 17 seconds at an hour boundary, then caught up.
  2. Its backlog went out to subscribers in one burst, 300 blocks in 5 seconds.
  3. The reader logged reach max buffer size for subcription, closing channel {"capacity": 200} for the relayers, and the subscriptions were closed.
  4. A relayer reconnected with no burst available (the reader keeps a 1-block buffer). The next blocks it received didn't link to its chain, the one-block lookup couldn't bridge the gap, and after five unlinkable blocks it exited. It restarted three times before it recovered.

The reader's own queue can hold 20,000 blocks, but each subscriber could only hold 200 of them, and there was no setting to change that.

Reproduction

firecore from develop, running reader-node-stdin + relayer with reader-node-blocks-chan-capacity: 20000. A second, deliberately slow subscriber (a blockstream.NewSource client sleeping 2 ms per block) stands in for a relayer that can't keep up. stdin gets 20 blocks at 4 blocks/s, then 5,000 at once, then 40 more at 4 blocks/s.

before with this option set to the reader's channel capacity (firehose-core PR)
reach max buffer size logs 1 (capacity: 200) 0
slow subscriber dropped after 223 blocks; after reconnecting it resumed at the live head, so about 4,800 blocks never reached it received all 5,047 blocks from its start point, in order

Tests

  • TestBlockServerSubscriptionChannelSize: the default, a value below 1 (ignored), and a set size plus the burst.
  • TestBlockServerSubscriptionClosedWhenFull: a subscription holds exactly its size and is closed on the next block.

Companion change in firehose-core, which sets the size from the reader's blocks channel capacity: streamingfast/firehose-core#318

🤖 Generated with Claude Code

matthewdarwin and others added 2 commits November 4, 2026 10:41
The block stream server closed a subscription once 200 blocks were queued
for it. A reader catching up after a stall can push more than that in one
burst, which drops every connected relayer at the same time.

Add ServerOptionWithSubscriptionChannelSize, keeping 200 as the default.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The block stream server closed a subscription once 200 blocks were queued
for it. A reader catching up after a stall can push more than that in one
burst, which drops every connected relayer at the same time.

Add ServerOptionWithSubscriptionChannelSize, keeping 200 as the default.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@sduchesneau sduchesneau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@sduchesneau
sduchesneau merged commit 6a5b7e4 into streamingfast:develop Nov 4, 2026
3 checks passed
matthewdarwin added a commit to pinax-network/firehose-core that referenced this pull request Nov 4, 2026
Drops the temporary replace on the pinax-network fork now that
streamingfast/bstream#91 is merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matthewdarwin
matthewdarwin deleted the feat/subscription-chan-size branch November 6, 2026 16:39
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.

2 participants