Skip to content

Commit e46814a

Browse files
authored
fix: Allow incomming peers (#661)
Currently all new peers that are trial dial us, we reject. In principle, peers should only dial us if we are on a subnet that they need, so optimisitcally they should be useful peers. The current logic works as follows: New peer tries to connect -> We look to see if we know their ENR -> We don't know ENR or subnets as they are new -> We reject them because we don't know anything about them. I think we shouldn't blanket reject all incomming peers, rather we should let them connect, and then upon handshake figure out if they are of any use to us and then reject the connection. I had a quick look through the code, it looks like we don't fail the handshake if our subnets are not aligned, it also looks like we are hard-coding the subnets field. I think it's related to this: #645 cc: @dknopik @diegomrsantos - I think we need to not hard code the subnets in the handshake and use that to disconnect peers. We might get over-run with incoming peers that are no use to us if we don't have that logic. Co-Authored-By: Age Manning <[email protected]>
1 parent fc1f5a2 commit e46814a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

anchor/network/src/peer_manager/connection.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,13 @@ impl ConnectionManager {
207207
}
208208

209209
let Some(bitfield) = self.get_peer_subnets_with_enr_fallback(peer, peer_store) else {
210-
return false;
210+
// Most peers that connect to us, that we have never seen, we will not know of their
211+
// ENR. We should allow all incoming peers and then later reject them if
212+
// they pose no use to us.
213+
return true;
211214
};
212215

216+
// If we have seen this peer before, and we know it isn't useful, then we can reject it.
213217
self.bitfield_offers_any_subnet(&bitfield, needed)
214218
}
215219

0 commit comments

Comments
 (0)