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

optimize: extended expire time for sequencer block broadcasting #106

Merged

Conversation

krish-nr
Copy link
Contributor

@krish-nr krish-nr commented Jan 2, 2024

Description

This PR incorporates modifications to the block validator within the op-node, which is utilized by both the sender (sequencer) and receiver. The block expiration check has been increased from 60 seconds to 20 minutes. This change was prompted by scenarios where the sequencer could not maintain a block production rate of one block per second. Under the previous validation logic, if blocks were produced slowly for a period and the anticipated block time was more than 60 seconds apart from the current time, the sequencer would fail the check and be unable to broadcast the block, preventing other nodes from syncing unsafe blocks. With this change, the time has been increased to 20 minutes. Please note that the 20-minute duration is not the time we maintain synchronization, but a relative time difference. (For example, if the sequencer’s block production speed drops to half, at 2 seconds per block, then the actual duration for which the sequencer continues broadcasting blocks would be approximately 40 minutes.)

Rationale

Two adjustments have been made:
1.The time duration within the block validator has been extended from 60s to 20min.
2.Enhancements were made to the seenMessagesTTL and blockHeightLRU caches to guard against potential stale block attacks that could arise due to the validator changes. The seenMessagesTTL serves as a preliminary logic cache before entering the validator, where a block hitting this cache would not proceed to further validation and processing. The blockHeightLRU cache is used to keep track of the number of validations for duplicate blocks to signal other nodes with an 'ignore' or 'reject'. As our validation effective time has increased from 1 minute to 20 minutes, the corresponding caches also required expansion to prevent possible block broadcast attacks.

Example

N/A

Changes

Notable changes:

  • BuildBlocksValidator config change
  • seenMessagesTTL and blockHeightLRU extended

Copy link
Contributor

@welkin22 welkin22 left a comment

Choose a reason for hiding this comment

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

LGTM

@owen-reorg owen-reorg merged commit 387eb6c into bnb-chain:develop Jan 2, 2024
10 checks passed
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