Connecting to specific nodes using addnode [university crypto class project]

Hello, sorry i’m very new to blockchain and zcash.

I’m an undergrad in a crypto class and my term project is on the security of zcash using ak-SNARKS. For my project I’m trying to replicate the PING attack described on the recent Standford publication.

I was a bit confused on how to ping a specific node, but I understand using the zcash-cli ping and zcash-cli getpeerinfo I can get the ping response time, which is what I need. But i’m having trouble adding specific nodes to my nodes peer’s list.

I have two machines set up running zcashd. I’m trying to make it so that the machines are connected to each other and the testnest. One node uses the outdated version v.2.0.7 that has the PING attack vulnerability and one node uses the latest V2.1.0-1

my config file for machine 1 running node 1 is:
testnet=1
addnode=testnet.z.cash
addnode=<ip address of machine 2 running node 2>
maxconnections=2

my config file for machine 2 running node 2 is:
testnet=1
addnode=testnet.z.cash
addnode=>ip address of machine 1 running node 1>
maxconnections=2

I’ve also tried using the connect= flag and a maxconnection=1, but then both nodes don’t make any connections, as if the ip address of both nodes are unreachable. (I’ve ping each ip address on both machines so they are reachable).

But when I start the zcashd on each machine neither of the two nodes are in the getpeerinfo list or JSON objects.

Both only have two connections, both have one connection to the testnet.z.cash ip address, but the second one is to some other node (both different).

I followed the download from source instructions on the website and launched them after following them that way. I haven’t enabled mining or created addresses for either one. Both are on a LAN and both are on my universities network.

If anyone has any advice on how I could recreate this attack, or get specific nodes on a getpeerinfo, or if you think I’m deeply misunderstanding something, any pointers in the right direction would be appreciated!

Thank you

2 Likes

Try this:

machine 1:

connect=testnet.z.cash
connect=ip_address_of_machine_2

machine 2:

connect=testnet.z.cash
connect=ip_address_of_machine_1

With this, I believe that each machine will respectively have the exact two connections that you want, and no other connections.

3 Likes

Addendum: Be sure to remove the maxconnections statement.

2 Likes

Thank you so much, I’ll have to wait to try it out tomorrow in the lab as I don’t have after hours access, I’ll give some updates!

3 Likes

Hey, sorry for late follow up.
Was able to get the nodes to connect to only each other and the testnet.z.cash node.
It looks like I needed to configure them as you suggested, the only change was to use addnode=testnet.z.cash instead of connect=testnet.z.cash. Using connect=testnet.z.cash, my zcash client was only running on port localhost:[port] and remote processes saw the [port] as cloded. Using addnode instead allowed it to run on 0.0.0.0:[port] and the port was open.
I’m finding that using addnode in this way doesn’t allow the node to connect to nodes not specified in the cofig file, which is a bit counter to my expectations from reading the docs about addnode.
But all is good what my needs now thank you!