net: be more aggresive wrt removing from known peers DB#31
Open
torkelrogstad wants to merge 2 commits intomasterfrom
Open
net: be more aggresive wrt removing from known peers DB#31torkelrogstad wants to merge 2 commits intomasterfrom
torkelrogstad wants to merge 2 commits intomasterfrom
Conversation
Separate the two distinct problems: 1. We're unable to connect to mainchain 2. Mainchain doesn't support the functionality we need
Prior to this commit we end up trying to reconnect to peers every time we start up. Be more aggressive in removing bad peers from the DB list of known peers. Also make sure to re-add the seed node every time we start up, if we have an empty list of known peers.
114d784 to
9fb290d
Compare
Ash-L2L
requested changes
Feb 3, 2025
| // might end up with this peer misbehaving, causing us to | ||
| // disconnect and delete it from the database. always try | ||
| // and stick it back in, if it's missing! | ||
| if net.known_peers.is_empty(&txn)? { |
Collaborator
There was a problem hiding this comment.
Why start a new db txn? This could happen in the same db txn that creates/opens the DB
| #[allow(clippy::let_and_return)] | ||
| let known_peers: Vec<_> = { | ||
| let rotxn = env.read_txn()?; | ||
| let mut txn = env.write_txn()?; |
Collaborator
There was a problem hiding this comment.
Nit: Prefer rotxn/rwtxn to clearly indicate DB locks, and to disambiguate w.r.t. network/block txs
| #[instrument(skip_all, fields(addr))] | ||
| pub fn remove_active_peer( | ||
| &self, | ||
| env: &heed::Env, |
| let () = self | ||
| .ctxt | ||
| .net | ||
| .remove_active_peer(&self.ctxt.env, addr)?; |
Collaborator
There was a problem hiding this comment.
If remove_active_peer also removes from known peers, then this seems wrong. A disconnected peer should still be in known peers
| let () = self | ||
| .ctxt | ||
| .net | ||
| .remove_active_peer(&self.ctxt.env, addr)?; |
Collaborator
There was a problem hiding this comment.
A peer connection error could have many causes, not sure if it is correct to remove from known peers here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prior to this commit we end up trying to reconnect to peers every time
we start up. Be more aggressive in removing bad peers from the DB list
of known peers.
Also make sure to re-add the seed node every time we start up, if we
have an empty list of known peers.