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

node: Improve OutOfSync code #2519

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

node: Improve OutOfSync code #2519

wants to merge 4 commits into from

Conversation

fed-franz
Copy link
Contributor

@fed-franz fed-franz commented Sep 28, 2024

Addresses unresolved comments in #2484

  • Resolves problems with borrow checker to set last_request in request_pool_missing_blocks
  • Handle sync timeout events the same way in on_heartbeat and on_block_event
    • This also fixes a potential flood attack from the sync peer
  • Improves logs and adds notes

Copy link
Member

@autholykos autholykos left a comment

Choose a reason for hiding this comment

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

LGTM (just a very little nit that can be ignored)

@@ -461,8 +467,9 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network>

if !inv.inv_list.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

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

nit: since we are at it, can we simply return early if inv.inv_list.is_empty() rather than nesting logic in the opposite case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally in favor!

Copy link
Member

@herr-seppia herr-seppia left a comment

Choose a reason for hiding this comment

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

RFT (Request for test)

// Transit back to InSync mode
// We check the timeout here to prevent the peer from keeping us in
// outofsync by flooding our node with blocks
if self.on_sync_timeout().await {
Copy link
Member

Choose a reason for hiding this comment

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

On_sync_timeout try to acquire a write lock from the acceptor (but you already acquired it, so probably it get stuck)

Try this before merge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

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