Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(publisher): Resolve block publication race conditions and synchronization issues #329

Conversation

Jurshsmith
Copy link
Member

Problem

The current blocks stream publishing mechanism suffers from two critical synchronization challenges:

  1. Receipt Population Failure: Blocks were not being populated with receipts due to the OffchainDB being out of sync with the OnChainDB.

  2. Block Synchronization Bottleneck: The existing block import mechanism used a blocking synchronization approach that:

    • Introduced significant latency during block synchronization
    • Risked missing blocks during the import process
    • Blocked the block subscription until all historical blocks were processed

Solution

This commit introduces the UnpublishedBlocks abstraction to resolve these issues:

  • Implements a flexible, non-blocking block synchronization strategy
  • Ensures blocks are published in sequence based on their heights
  • Allows immediate block subscription while synchronizing historical blocks
  • Adds a mechanism to wait for OffchainDB to catch up before publishing streams

Future Improvements

As a potential optimization, when streams are separated into different processes, we can further refine the synchronization strategy to avoid waiting for OffchainDB sync for certain stream types.

References: DS-124

@Jurshsmith Jurshsmith force-pushed the fix/DS-124/fix-transactions-not-being-streamed-with-receipts branch from 4dcb1b7 to 452a400 Compare November 30, 2024 20:59
@Jurshsmith Jurshsmith self-assigned this Nov 30, 2024
@Jurshsmith Jurshsmith changed the title fix(publisher): Resolve block publication race conditions and synchronization issues fix(publisher): Resolve block publication race conditions and synchronization issues Nov 30, 2024
@Jurshsmith Jurshsmith force-pushed the fix/DS-124/fix-transactions-not-being-streamed-with-receipts branch from 452a400 to 63617d7 Compare November 30, 2024 21:30
… order

This commit addresses two key issues in the publisher module:

OffchainDB synchronization:
Previously, receipts were not being populated because the OffchainDB lagged behind the OnChainDB.
This has been resolved by ensuring the OffchainDB is fully synchronized to the current height before
publishing any streams. In the future, separating streams into distinct processes could avoid delays
for streams that do not depend on OffchainDB synchronization.

Old and new blocks synchronization:
The previous implementation used a blocking while loop to process old blocks until the latest block. This
approach delayed the subscription to new blocks, causing significant block misses in the subscription stream.
To resolve this, an UnpublishedBlocks abstraction has been introduced. It allows the system to subscribe to new
blocks immediately, even while syncing old blocks. Blocks are now published in the correct order based on their
heights, ensuring no data is missed or processed out of sequence.

References: DS-124
@Jurshsmith Jurshsmith force-pushed the fix/DS-124/fix-transactions-not-being-streamed-with-receipts branch from 63617d7 to aa7b930 Compare December 1, 2024 08:21
@pedronauck pedronauck merged commit 9b9a8d7 into main Dec 2, 2024
15 checks passed
@pedronauck pedronauck deleted the fix/DS-124/fix-transactions-not-being-streamed-with-receipts branch December 2, 2024 13:03
pedronauck pushed a commit that referenced this pull request Dec 2, 2024
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