# Eiger test The solution to [code challenge](https://github.com/eqlabs/recruitment-exercises/blob/c3455b538b1f4462edf8a212645505da38819160/node-handshake.md) > Pick a publicly available P2P node I picked tendermint at version [`0.34.X`] ## How to execute handshake ### Running node: 1. Clone tendermint repository: ```sh git clone https://github.com/tendermint/tendermint ``` 2. Checkout to 0.34.X branch ```sh git checkout v0.34.x ``` 3. Run node with (require docker and docker-compose installed) ```sh make build-linux && make localnet-start ``` ** If you found any problems check this documentation: https://github.com/tendermint/tendermint/blob/0.35x/docs/tools/docker-compose.md 4. find `chain_id` parameter (will be needed on the client side) ```sh cat build/node0/config/genesis.json | grep chain_id ``` ### Running code challenge 1. Clone repository ```sh git clone https://git.sdr.ovh/sr/eiger-p2p ``` 2. in run application with trace logging level and replace `chain-D39Q88` with `chain_id` parameter. You can also run it as below and find remote `chain_id` in logs. ```sh RUST_LOG=eiger_p2p=trace cargo run -- --node 127.0.0.1:26659 --private-key 0x4d818e3802516dfb1c37a87576432bc210c9edf97e8b3217d806361c04d293fa --network chain-D39Q88 ``` ** It's possible to specify node ID that you want to connect: ```sh RUST_LOG=eiger_p2p=trace cargo run -- --node 127.0.0.1:26659 --private-key 0x4d818e3802516dfb1c37a87576432bc210c9edf97e8b3217d806361c04d293fa --network chain-D39Q88 ``` It may require installed `protoc` check `proto-build` documentation if build fail. ## Possible improvements: 1. `share_eph_pubkey.rs` is blocker for not using AsyncRead/AsyncWrite from beginning. Create simple module `porotbuf-length-delimited` that could handle with async and protobuf variant would be enough here. It allow also to drop `protobuf` dependency. 2. errors should be improvement. for example `SecretConnectionError::HandshakeErr` can internally hold i/o error. But this will be improved on it's own with `1.` 3. secret key should be read from file and not pass as arg ## Requirements check list: - [X] Both the target node and the handshake code should compile at least on Linux. - [ ] The solution has to perform a full protocol-level (post-TCP/etc.) handshake with the target node. - [X] secret connection - [X] node version exchange - [ ] full node version verification - [X] The provided instructions should include information on how to verify that the handshake has concluded. - **If handshake fail the application will exit with non-zero status code and error message** - **If handshake succeed the application will block on loop reading protobuf messages when debug level is enabled**: ```sh 2023-09-03T21:34:04.532535Z DEBUG eiger_p2p::peer: received raw protobuf frame (ping, pong, channelMsg): b"\n\x1a\x08\x08@\x10\x01\x1a\x02*\0\x1d\x1a\x1b\x08 \x10\x01\x1a\x15\n\x13\x08\x01\x18\x04 \xd5\x83\x02(\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01" 2023-09-03T21:34:05.622605Z DEBUG eiger_p2p::peer: received raw protobuf frame (ping, pong, channelMsg): b"\x08\x1a\x06\x10\x01\x1a\x02\n\0" 2023-09-03T21:35:04.432639Z DEBUG eiger_p2p::peer: received raw protobuf frame (ping, pong, channelMsg): b"\x02\n\0" ``` - [X] The solution can not depend on the code of the target node (but it can share some of its dependencies). - [X] The submitted code can not reuse entire preexisting handshake implementations like libp2p_noise/XX. [`0.34.X`]: https://github.com/tendermint/tendermint/blob/v0.34.x/spec/p2p/peer.md