Skip to content

Update stale block time after resetting connections#275

Merged
rustaceanrob merged 1 commit intomasterfrom
stale-1-17
Jan 20, 2025
Merged

Update stale block time after resetting connections#275
rustaceanrob merged 1 commit intomasterfrom
stale-1-17

Conversation

@rustaceanrob
Copy link
Collaborator

If a block is considered stale, the advance_state function will reset connections with all peers. To reset the "staleness" of a block, the LastBlockMonitor::update function must be called. Currently that is done upon receiving new block headers, but no headers will ever be sent, as advance_state disconnects the peers before they can send them. That causes a loop that makes no progress. Here we patch this to reset the "staleness" of a block after disconnecting from all peers.

For context, the LastBlockMonitor is used to prevent a block withholding attack, where all connected peers refuse to advertise new blocks to us. After 30 minutes if there is no block found, we open new connections to see if there was a block being withheld. @nyonson

If a block is considered stale, the `advance_state` function will reset
connections with all peers. To reset the "staleness" of a block, the
`LastBlockMonitor::update` function must be called. Currently that is done
upon receiving new block headers, but no headers will ever be sent, as
`advance_state` disconnects the peers before they can send them once
a block is considered stale. Here we patch this to reset the "staleness"
of a block after disconnecting from all peers.
@rustaceanrob
Copy link
Collaborator Author

This patch resolved an instance of a stale block on Testnet4 and has been running with no issues since. Going to go ahead and merge

@rustaceanrob rustaceanrob merged commit 58a7929 into master Jan 20, 2025
14 checks passed
@rustaceanrob rustaceanrob deleted the stale-1-17 branch January 20, 2025 19:11
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