diff --git a/eth/p2p/rlpx_protocols/bzz_protocol.nim b/eth/p2p/rlpx_protocols/bzz_protocol.nim deleted file mode 100644 index 49544c4..0000000 --- a/eth/p2p/rlpx_protocols/bzz_protocol.nim +++ /dev/null @@ -1,86 +0,0 @@ -import - chronos, chronicles, - ../../p2p - -# Limited bzz protocol that allows for doing a handshake with a peer running -# ethersphere/swarm client rev. c535b271536d0dee5bd97c2541ca32a42f272d4f - -const - bzzVersion = 12 - hiveVersion = 10 - swarmNetworkId* = 4 - # Faking our capabilities to make handshake work, "bit" 0, 1, 4, 5, 15. - supportedCapabilities = [1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] - -type - # Need object (or extra seq) here as swarm expects list(list(Capability)) - Capabilities = object - caps: seq[Capability] - - Capability = object - id: uint - # Swarm expects here list(bool), thus bool or int (values <= 1 byte, as rlp - # writer has currently no int8 support). Guess this could be a bitvector. - # Also looks like per id the list can have a different size, so lets stick - # with seq instead of array. - value: seq[int] - - OverlayAddress = array[32, byte] - - AddressData = object - oaddr: OverlayAddress - uaddr: string - - Handshake = object - version: uint - networkId: uint - addressData: AddressData - capabilities: Capabilities - - BzzNetwork = ref object - thisENode*: ENode - -p2pProtocol Hive(version = hiveVersion, - rlpxName = "hive"): - - proc peersMsg(peer: Peer) - proc subPeersMsg(peer:Peer) - - onPeerConnected do (peer: Peer): - debug "Hive peer connected" - -proc initProtocolState*(network: BzzNetwork, node: EthereumNode) {.gcsafe.} = - network.thisENode = node.toENode() - -p2pProtocol Bzz(version = bzzVersion, - rlpxName = "bzz", - networkState = BzzNetwork): - - handshake: - proc hs(peer: Peer, hs: Handshake) = - trace "Incoming bzz handshake", version = hs.version, - addressData = hs.addressData - - onPeerConnected do (peer: Peer): - debug "Bzz peer connected" - - # Now all zeroes, this needs to be the Hash of the ECDSA Public Key - # of the used Ethereum account - var oaddr: OverlayAddress - let - # TODO: could do ENode RLP serialisation - # Why do we need to send the ENode? Doesn't the peer already have this? - # Or should it be a different one? - uaddr = $peer.networkState.thisENode - addressData = AddressData(oaddr: oaddr, - uaddr: uaddr) - - caps = Capabilities(caps: @[Capability(id: 0, - value: @supportedCapabilities)]) - handshake = Handshake(version: bzzVersion, - networkId: swarmNetworkId, - addressData: addressData, - capabilities: caps) - - m = await peer.hs(handshake, timeout = chronos.seconds(10)) - # TODO: validate the handshake... diff --git a/tests/p2p/bzz_basic_client.nim b/tests/p2p/bzz_basic_client.nim deleted file mode 100644 index 757ca74..0000000 --- a/tests/p2p/bzz_basic_client.nim +++ /dev/null @@ -1,20 +0,0 @@ -import - std/tables, - chronos, - ../../eth/p2p, ../../eth/p2p/peer_pool, - ../../eth/p2p/rlpx_protocols/bzz_protocol, - ./p2p_test_helper - -# Basic bzz test to test handshake with ethersphere/swarm node -# Fixed enode string for now - -var node = setupTestNode(Bzz, Hive) - -let nodeId = "enode://10420addaa648ffcf09c4ba9df7ce876f276f77aae015bc9346487780c9c04862dc47cec17c86be10d4fb7d93f2cae3f8e702f94cb6dea5807bfedad218a53df@127.0.0.1:30399" -let enode = ENode.fromString(nodeId)[] -waitFor node.peerPool.connectToNode(newNode(enode)) - -doAssert node.peerPool.connectedNodes.len() == 1 - -while true: - poll()