bitcoin-dev-project / warnet

Monitor and analyze the emergent behaviors of Bitcoin networks
https://warnet.dev
MIT License
63 stars 28 forks source link

Tor: install and run tor daemon #50

Closed pinheadmz closed 9 months ago

pinheadmz commented 9 months ago

bitcoin listens and connects to Tor, even connects to other warnet nodes over Tor:

Screen Shot 2023-08-18 at 3 36 18 PM
willcl-ark commented 9 months ago

Does it not start automagically?

pinheadmz commented 9 months ago

Does it not start automagically?

It should but you may need to wipe docker cache

willcl-ark commented 9 months ago

That seems acceptable?

pinheadmz commented 9 months ago

This PR got a bit out of scope with a few extra bug fixes but I now have the sensitive relay PR running perfectly in Warnet, with real Tor connections.

I think we should consider 11 nodes as the minimum network size, kinda how like you need at least 100 blocks in a chain before anything really works. I removed a bunch of unused stuff from the graphml file. Also, that default graphml file is kinda like our single integration test: it just does all the features!

willcl-ark commented 9 months ago

Can we proxy these Tor connections and spoof tor latency using #49, so that it doesn't screw up the real Tor network?

pinheadmz commented 9 months ago

Update: this branch now deploys a local Tor network! Inspired by https://github.com/antitree/private-tor-network

Here's how it works:

To see it all in action, checkout this branch then: Start: warnet start from-file src/templates/example.graphml Watch in one terminal: watch docker exec -it tank_000010 bitcoin-cli -netinfo 4 Run: warnet run sens_relay

You should see the srelay onion connection pop up for a moment when the test node sends its transaction.

TODO:

willcl-ark commented 9 months ago

So as I was (trying) to do with bind, it should be possible to just update torrc after the DA is assigned to one node and restart tor on each tank?

Edit: in fact, perhaps we should have a specific step between generating the docker compose (and all starting tank ip addresses are known), where various roles can be assigned, and config file (templates) can be updated. This would currently be the zone file and torrc, but could be others in the future...

pinheadmz commented 9 months ago

We may not even need to restart anything:

    wn = Warnet.from_graph_file(graph_file, network)  # <-- All IP addresses are generated in this step
    wn.write_bitcoin_confs()
    wn.write_docker_compose()

    # write zone file and torrc files

    wn.write_prometheus_config()
    wn.docker_compose_up()
    wn.apply_network_conditions()
    wn.connect_edges()
willcl-ark commented 9 months ago

We may not even need to restart anything:


    wn = Warnet.from_graph_file(graph_file, network)  # <-- All IP addresses are generated in this step

    wn.write_bitcoin_confs()

    wn.write_docker_compose()

    # write zone file and torrc files

    wn.write_prometheus_config()

    wn.docker_compose_up()

    wn.apply_network_conditions()

    wn.connect_edges()

Yes this is what I was envisioning

pinheadmz commented 9 months ago

or actually, write the files before docker-compose so the volumes can include the files from the tmp dir