3.6 KiB
3.6 KiB
Eiger test
The solution to code challenge
Pick a publicly available P2P node
I picked tendermint at version 0.34.X
How to execute handshake
Running node:
- Clone tendermint repository:
git clone https://github.com/tendermint/tendermint - Checkout to 0.34.X branch
git checkout v0.34.x - Run node with (require docker and docker-compose installed)
** If you found any problems check this documentation: https://github.com/tendermint/tendermint/blob/0.35x/docs/tools/docker-compose.mdmake build-linux && make localnet-start - find
chain_idparameter (will be needed on the client side)cat build/node0/config/genesis.json | grep chain_id
Running code challenge
- Clone repository
git clone https://git.sdr.ovh/sr/eiger-p2p - in run application with trace logging level and replace
chain-D39Q88withchain_idparameter. You can also run it as below and find remotechain_idin logs.
** It's possible to specify node ID that you want to connect:RUST_LOG=eiger_p2p=trace cargo run -- --node 127.0.0.1:26659 --private-key 0x4d818e3802516dfb1c37a87576432bc210c9edf97e8b3217d806361c04d293fa --network chain-D39Q88RUST_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:
share_eph_pubkey.rsis blocker for not using AsyncRead/AsyncWrite from beginning. Create simple moduleporotbuf-length-delimitedthat could handle with async and protobuf variant would be enough here. It allow also to dropprotobufdependency.- errors should be improvement. for example
SecretConnectionError::HandshakeErrcan internally hold i/o error. But this will be improved on it's own with1. - secret key should be read from file and not pass as arg
Requirements check list:
- 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.
- secret connection
- node version exchange
- full node version verification
- 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:
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"
- The solution can not depend on the code of the target node (but it can share some of its dependencies).
- The submitted code can not reuse entire preexisting handshake implementations like libp2p_noise/XX.