# Week 9 ## Recap This week was spent mainly getting Discovery V5 properly configured in the Portal Client. I began by looking into different ways to implement Discovery and searched around different clients to see what solutions they had opted for. I decided to go with the Discovery V5 Java library offered by Consensys as it fit the Portal Clients needs and as an added bonus comes from Consensys. I looked through the library for a fair amount of time to learn how it was implemented as well as to learn how to use it. My main focus was to learn how to setup my Portal Client to start using Discovery V5 which required a proper initialization. I wasn't able to find many direct resources on how to do so but fortunately it is done similarily in Teku. I looked into both the Besu and Teku codebases to learn how I could properly initialize Discovery. Once I had learned how it was initialized I began implementing it. After it was done I just needed to get a bootnode to began interacting with other nodes. I ended up looking at the bootnodes listed in Trin as they were listed in Base64 which made it easy to add to the Portal Client initialization. After adding them the Portal Client was able to succesfully interact with other nodes through Discovery. From there I began working on setting up a network manager to handle both Discovery V5 and the Portal Wire Protocol once it is implemented. I connected the manager to the CLI to enable the configuring of different options and to remove the need to hardcode IP for when I was testing the Discovery initialization. ## Learning Most of my learning this week came from looking through codebases and libraries to learn how Discovery V5 is initialized. I also had to look through some Java cryptography docs to learn how to setup a proper key pair, and then ended up using the key pair implementation from Apache's Tuweni library. ### Concepts #### Besu and Teku Codebase When looking through both the Besu and Teku codebase I was mainly aiming to learn how the clients initialized Discovery. I first looked at Besu but found that the Teku implementation was more relevant to my use case. After learning how Teku initializes Discovery I also looked into its network handler design as inspiration for a handler on the Portal Client. ##### Resources 1. https://github.com/hyperledger/besu 2. https://github.com/Consensys/teku #### Consensys Discovery V5 Once I had decided on the Consesys Discovery library I had to go about learning how to use it. Although I am familiar with the actual Discovery V5 Specifications there was still a fair amount of learning to do for the actual implementation. I looked specifically into how nodes are stored and how the DiscoverySystem class manages the library. Once I had learned the general process for Initializing Discovery I looked into the specific components to do so in the Consensys library. I looked into the provided builder classes and was able to setup Discovery after building the necessary components. ##### Resources 1. https://github.com/Consensys/discovery ## Tasks As mentioned previously the main actual implementation tasks that I completed were to setup the Consensys library, implement a basic version of Discovery Initialization, design the first portion of a network handler for the client and then enable it to be configurable by command line. With this part of the client implementation I was able to get it to connect with other Discovery enabled nodes and send basic PING communication. Because of the Discovery library the client is also able to keep track of the clients that it communicates with. https://github.com/Dsorken/Java-Portal-Client/tree/discv5-setup ## Week 10 Plan Moving into Week 10 I aim to further revise the network handler design. This way it will also be better prepared to handle the Portal Wire Protocol. I am also looking to work on properly configuring a set of bootnodes for the client to use as well as potentially setting up the ability to configure the network that the client uses. I hope to be able to work on better setting up the Discovery initialization to include all proper logging for easier debugging. Outside of implementation I am hoping to meet with another EPF fellow to begin collaborating on the design of the Portal Client and potentially merging our existing projects.