Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Implement new/tried peer list and peer bucket management Closes #3334 #4030

Merged
merged 65 commits into from
Aug 6, 2019

Conversation

ishantiw
Copy link
Contributor

@ishantiw ishantiw commented Jul 31, 2019

Description

Implementation of peer management according to the LIP0004.

Changes:

  • A new folder peer_directory that will encapsulate new/triedPeers list and the bucket management within it.
  • peer_directory/new_peers includes management of newPeers list and newPeers related eviction logic
  • peer_directory/tried_peers includes management of triedPeers list and triedPeers related eviction logic
  • peer_directory/peer_book exposes the interface for peer management at a higher level, it exposes,
    • addPeer
    • removePeer
    • updatePeer
    • downgradePeer
    • upgradePeer
    • getPeer
    • getAllPeers
  • p2p to use peer_book instead of dealing with new/triedPeers list separately

Review checklist

@ishantiw ishantiw self-assigned this Jul 31, 2019
@ishantiw ishantiw marked this pull request as ready for review July 31, 2019 15:19
@ishantiw ishantiw changed the title Implement new/tried peer list and peer bucket management Implement new/tried peer list and peer bucket management Closes #3334 Jul 31, 2019
Copy link

@diego-G diego-G left a comment

Choose a reason for hiding this comment

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

First batch of comments. I will go deep into the peer directory folder now. But before, what do you think about changing the folder name to directory only?

elements/lisk-p2p/src/p2p.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/p2p.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/p2p.ts Show resolved Hide resolved
Copy link
Contributor

@ManuGowda ManuGowda left a comment

Choose a reason for hiding this comment

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

@ishantiw just made few comments, otherwise, the PR looks good

elements/lisk-p2p/src/p2p.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_directory/peer_book.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_directory/peer_book.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_directory/new_peers.ts Outdated Show resolved Hide resolved
@ishantiw ishantiw force-pushed the 3334-peer_buckets branch 2 times, most recently from 258df5a to bd4f5b0 Compare August 2, 2019 12:03
@ishantiw ishantiw requested a review from diego-G August 2, 2019 12:51
Copy link

@diego-G diego-G left a comment

Choose a reason for hiding this comment

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

Another batch of comments. I will give you a third review after you solve them. It only remains me to have a deep look to new_peers and tried_peers files.

elements/lisk-p2p/src/p2p.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/p2p.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/p2p.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/utils.ts Show resolved Hide resolved
elements/lisk-p2p/src/directory/peer_book.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/peer_book.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/peer_book.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/peer_book.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/tried_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/tried_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/tried_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/p2p.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@mitsuaki-u mitsuaki-u left a comment

Choose a reason for hiding this comment

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

Few minor comments regarding function naming. Great job!

@ishantiw ishantiw changed the base branch from feature/implement-lip-p2p to development August 5, 2019 15:06
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/tried_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/tried_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/tried_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/index.ts Outdated Show resolved Hide resolved
Copy link

@diego-G diego-G left a comment

Choose a reason for hiding this comment

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

@ishantiw remember to add test integration scenarios to prove the eviction process, upgrades and downgrades are working as expected.

@ishantiw
Copy link
Contributor Author

ishantiw commented Aug 5, 2019

@diego-G There are unit tests related to downgrade and upgrade a peer. we need extra effort and time to test eligibleDaysForEviction and bucket full scenario as we need to populate buckets with valid peers that will be added to a specific bucket. Let's tackle that in a separate issue that I have created #4045

Copy link

@diego-G diego-G left a comment

Choose a reason for hiding this comment

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

I suggest again to add a scenario to check if peers get downgraded as expected. For the eviction process I agree we should tackle it in another PR.

elements/lisk-p2p/src/directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/directory/tried_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_directory/new_peers.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_directory/tried_peers.ts Outdated Show resolved Hide resolved
@ishantiw
Copy link
Contributor Author

ishantiw commented Aug 6, 2019

@diego-G I have added few more scenarios on PeerBook for upgrade/downgrade of a peer and its movement between the two lists.

@ishantiw ishantiw requested a review from diego-G August 6, 2019 11:01
@ishantiw ishantiw requested a review from diego-G August 6, 2019 12:41
@shuse2 shuse2 merged commit 1a16e6f into development Aug 6, 2019
@shuse2 shuse2 deleted the 3334-peer_buckets branch August 6, 2019 13:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce management of peer buckets within new/tried peers list
6 participants