This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 456
Introduce management of peer buckets within new/tried peers list #3334
Comments
Note that buckets affect the |
Below is the raw idea of bucket system that I thought about a few months back. We instantiate it in P2P class and only add to a bucket or remove it, everything else could be managed inside the bucket itself and also banned peers list. import { PeerInfo } from './peer';
export class PeerBucket {
private readonly _bannedPeers: ReadonlyArray<PeerInfo>;
private readonly _newPeers: Map<number, Set<PeerInfo>>;
private readonly _triedPeers: Map<number, Set<PeerInfo>>;
public constructor() {
this._newPeers = new Map();
this._triedPeers = new Map();
this._bannedPeers = [];
}
public get newPeers(): Map<number, Set<PeerInfo>> {
return this._newPeers;
}
public get triedPeers(): Map<number, Set<PeerInfo>> {
return this._newPeers;
}
public get bannedPeers(): ReadonlyArray<PeerInfo> {
return this._bannedPeers;
}
// TODO: Add logic to calculate bucket and add it to bucket group based on LIPS
public calculateNewPeerBucketGroup(peerInfo: PeerInfo): number {
// TODO: Based on IP, IP prefix and hash of random node secret with bucket size of 128
return 1;
}
// TODO: Add logic to calculate bucket and add it to bucket group based on LIPS
public calculateTriedPeerBucketGroup(peerInfo: PeerInfo): number {
// TODO: Based on IP, IP prefix and hash of random node secret with bucket of 64
return 1;
}
// TODO: Add logic to calculate bucket and add it to bucket group
public addToNewPeers(peerInfo: PeerInfo): void {
const bucketGroup = this.calculateNewPeerBucketGroup(peerInfo);
const bucketId = this._newPeers.get(bucketGroup);
if (bucketId) {
bucketId.add(peerInfo);
} else {
const setForNewBucket = new Set();
this._newPeers.set(bucketGroup, setForNewBucket.add(peerInfo));
}
}
// TODO Add logic to calculate bucket and add it to bucket group
public addToTriedPeers(peerInfo: PeerInfo): void {
const bucketGroup = this.calculateNewPeerBucketGroup(peerInfo);
const bucketId = this._triedPeers.get(bucketGroup);
if (bucketId) {
bucketId.add(peerInfo);
} else {
const setForNewBucket = new Set();
this._triedPeers.set(bucketGroup, setForNewBucket.add(peerInfo));
}
}
} |
sridharmeganathan
modified the milestones:
P2P banning and efficiency improvements,
Sprint 2 - P2P
Jun 27, 2019
jondubois
modified the milestones:
P2P peer address book management and banning - Sprint 2,
P2P resilience
Jul 17, 2019
5 tasks
shuse2
added a commit
that referenced
this issue
Aug 6, 2019
Implement new/tried peer list and peer bucket management Closes #3334
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
Introduce a module to handle newPeers and triedPeers list and buckets within them according to LIP0004. With this, we can separate the concern of managing buckets within these lists from P2P class. Also, there will be one instance of a bucket management class which will make sure that discovery or selection processes use the updated buckets to select any peer.
Since we want to maintain banned peers temporarily and also move them back forth based on ban score and
banTime
from the newPeer and triedPeer list buckets.triedPeers
bucket system:To each IP address, we associate a bucket b contained in {0,1,..., 63}. For every bucket b, we only accept 32 addresses in the collection triedPeers. This way the collection triedPeers contains at most 2048 peers.
newPeers
bucket system:To each IP address, we associate a bucket b contained in {0,1,..., 127}
The bucket is computed from the IP address to be added, the IP address of the peer sending the addresses and a random secret of the node as follows:
Outgoing connections
. Additionally, at most 3 outgoing connections for every network group (/16 IPv4 prefix) are allowed in all cases.
The text was updated successfully, but these errors were encountered: