Go to file
Sylwester Rąpała 7dd891a763 init commit 2023-09-04 00:57:09 +02:00
proto_files init commit 2023-09-04 00:57:09 +02:00
src init commit 2023-09-04 00:57:09 +02:00
.gitignore init commit 2023-09-04 00:57:09 +02:00
Cargo.lock init commit 2023-09-04 00:57:09 +02:00
Cargo.toml init commit 2023-09-04 00:57:09 +02:00
README.md init commit 2023-09-04 00:57:09 +02:00
build.rs init commit 2023-09-04 00:57:09 +02:00

README.md

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:

  1. Clone tendermint repository:
    git clone https://github.com/tendermint/tendermint
    
  2. Checkout to 0.34.X branch
    git checkout v0.34.x
    
  3. Run node with (require docker and docker-compose installed)
    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)
    cat build/node0/config/genesis.json | grep chain_id
    

Running code challenge

  1. Clone repository
    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.
    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:
    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:

  • 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.