-
Notifications
You must be signed in to change notification settings - Fork 1
Warnet project implementation with one-tank network and attack scenario #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
72e141e
266e04a
73db4c9
2119ceb
510a09a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1 +1,208 @@ | ||||||
| # warnet-demo-project | ||||||
| # Warnet Demo Project | ||||||
|
|
||||||
| A hands-on Warnet project to help you learn Bitcoin network analysis with a simple one-node network and attack scenario. | ||||||
|
|
||||||
| ## What is this? | ||||||
|
|
||||||
| This is a complete Warnet project that demonstrates how to: | ||||||
|
|
||||||
| - **Deploy a single-node Bitcoin network** using Warnet | ||||||
| - **Run a simple attack scenario** against the network | ||||||
| - **Monitor network behavior** and observe node responses | ||||||
| - **Understand basic Bitcoin network interactions** | ||||||
|
|
||||||
| The project includes a pre-configured network (`94.0.0-5k-inv`) and a beginner-friendly scenario (`my_first_attack_5kinv.py`) that you can run immediately. | ||||||
|
|
||||||
| ## Prerequisites | ||||||
|
|
||||||
| 1. Python 3.8+ | ||||||
| 2. Docker or Kubernetes (local) | ||||||
| 3. Basic understanding of Bitcoin concepts | ||||||
|
|
||||||
| ## Quick Start | ||||||
|
|
||||||
| ### 1. Set up Warnet | ||||||
|
|
||||||
| Follow the [Warnet installation guide](https://github.com/bitcoin-dev-project/warnet?tab=readme-ov-file#quick-start) for detailed setup instructions: | ||||||
|
|
||||||
| ```sh | ||||||
| # Create virtual environment | ||||||
| python3 -m venv .venv | ||||||
| source ./venv/bin/activate | ||||||
|
|
||||||
| # Install Warnet | ||||||
| pip install warnet | ||||||
|
|
||||||
| # Set up dependencies | ||||||
| warnet setup | ||||||
| ``` | ||||||
|
|
||||||
| When prompted, choose your preferred backend: | ||||||
|
|
||||||
| - **Minikube** - Local Kubernetes cluster (recommended for beginners) | ||||||
| - **Docker Desktop** - If you have Docker Desktop with Kubernetes enabled | ||||||
|
||||||
|
|
||||||
| ### 2. Deploy the one-node network | ||||||
|
|
||||||
| This project includes a pre-configured one-node network. Deploy it with: | ||||||
|
|
||||||
| ```sh | ||||||
| warnet deploy warnet-demo | ||||||
|
||||||
| ``` | ||||||
|
|
||||||
| This will create a simple Bitcoin network with 1 node for basic experimentation. | ||||||
|
|
||||||
| ### 3. Run the attack scenario | ||||||
|
|
||||||
| Execute the included scenario to see the network in action: | ||||||
|
|
||||||
| ```sh | ||||||
| warnet run warnet-demo/scenarios/my_first_attack_5kinv.py | ||||||
|
||||||
| warnet run warnet-demo/scenarios/my_first_attack_5kinv.py | |
| warnet run warnet-demo/scenarios/my_first_attack_5kinv.py --debug |
This might be more fun to show some running-time output of the scenario, but of course it will consume the shell foreground so for other commands like warnet dashboard we might not want to add --debug what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it will make it more engaging for users and for learning purposes to see what's happening....
perhaps incase when user is multitasking they can always omit --debug..
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I thought we were going to test an attack, literally https://github.com/bitcoin-dev-project/battle-of-galen-erso/blob/main/scenarios/my_first_attack_5kinv.py
What you have here is actually very cool and totally fine - but then we mine as well add 1-2 more nodes so we can actually see actual network propogation. Then go ahead and just rename the scenario something like propogation-check and instruct the user to do warnet dashboard etc
and THEN....
we can still run the attack from Galen Erso and watch a node die. (if you like?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try this command? It doesn't work for me.
I think the network you defined is missing the settings to enable the dashboard. Again, warnet new asks if you want these features, and will add to network.yaml:
caddy:
enabled: true
fork_observer:
configQueryInterval: 20
enabled: true
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
real time logs would need an -f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try these commands? They don't work. exec is not a warnet command. The correct syntax looks like this:
warnet bitcoin rpc tank-0000 getnetworkinfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops my bad!
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try these links? They don't work.
use
https://github.com/bitcoin-dev-project/warnet/blob/main/docs/scenarios.md
...etc.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can just drop this
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| # Warnet Demo Project | ||
|
||
|
|
||
| A hands-on Warnet project to help you learn Bitcoin network analysis with a simple 5-node network and attack scenario. | ||
|
|
||
| ## What is this? | ||
|
|
||
| This is a complete Warnet project that demonstrates how to: | ||
|
|
||
| - **Deploy a 5-node Bitcoin network** using Warnet | ||
| - **Run a simple attack scenario** against the network | ||
| - **Monitor network behavior** and observe node responses | ||
| - **Understand basic Bitcoin network interactions** | ||
|
|
||
| The project includes a pre-configured network (`94.0.0-5k-inv`) and a beginner-friendly scenario (`my_first_attack_5kinv.py`) that you can run immediately. | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| warnet-demo/ | ||
| ├── warnet.yaml # Project configuration | ||
| ├── node-defaults.yaml # Default node settings | ||
| ├── networks/ | ||
| │ └── 94.0.0-5k-inv.yaml # 5-node network configuration | ||
| ├── scenarios/ | ||
| │ ├── my_first_attack_5kinv.py # Your first attack scenario | ||
| │ ├── miner_std.py # Basic mining scenario | ||
| │ ├── tx_flood.py # Transaction flooding | ||
| │ ├── reconnaissance.py # Network discovery | ||
| │ └── ... # Other scenarios | ||
| └── plugins/ # Network plugins | ||
| ├── tor/ # Tor network integration | ||
| └── simln/ # Lightning Network simulation | ||
| ``` | ||
|
|
||
| ## The Network: 94.0.0-5k-inv | ||
|
|
||
| This is a simple 5-node Bitcoin network with the following topology: | ||
|
|
||
| ``` | ||
| tank-0000 ──── tank-0001 ──── tank-0003 | ||
| │ │ │ | ||
| └─── tank-0002 ────────┘ | ||
| ``` | ||
|
|
||
| Each node runs Bitcoin Core in regtest mode, making it perfect for learning and experimentation. | ||
|
|
||
| ## The Scenario: my_first_attack_5kinv.py | ||
|
|
||
| This scenario demonstrates basic network interaction: | ||
|
|
||
| 1. **Network Readiness Check**: Ensures all nodes are online and connected | ||
| 2. **Block Generation**: Creates initial funds by mining blocks | ||
| 3. **Transaction Creation**: Sends test transactions across the network | ||
| 4. **Propagation Monitoring**: Observes how transactions spread between nodes | ||
| 5. **Network State Analysis**: Shows the final state of all nodes | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### 1. Set up Warnet | ||
|
|
||
| Follow the [Warnet installation guide](https://github.com/bitcoin-dev-project/warnet?tab=readme-ov-file#quick-start): | ||
|
|
||
| ```sh | ||
| # Create virtual environment | ||
| python3 -m venv .venv | ||
| source ./venv/bin/activate | ||
|
|
||
| # Install Warnet | ||
| pip install warnet | ||
|
|
||
| # Set up dependencies | ||
| warnet setup | ||
| ``` | ||
|
|
||
| ### 2. Deploy the 5-node network | ||
|
|
||
| ```sh | ||
| warnet deploy warnet-demo | ||
| ``` | ||
|
|
||
| ### 3. Run the attack scenario | ||
|
|
||
| ```sh | ||
| warnet run warnet-demo/scenarios/my_first_attack_5kinv.py | ||
| ``` | ||
|
|
||
| ### 4. Monitor your network | ||
|
|
||
| ```sh | ||
| warnet dashboard | ||
| ``` | ||
|
|
||
| ### 5. Clean up | ||
|
|
||
| ```sh | ||
| warnet down | ||
| ``` | ||
|
|
||
| ## What You'll Learn | ||
|
|
||
| By running this project, you'll understand: | ||
|
|
||
| 1. **Network Deployment**: How Warnet creates and manages Bitcoin networks | ||
| 2. **Node Communication**: How Bitcoin nodes connect and share information | ||
| 3. **Transaction Propagation**: How transactions flow through the network | ||
| 4. **Network Monitoring**: How to observe network behavior in real-time | ||
| 5. **Scenario Execution**: How to run and create attack scenarios | ||
|
|
||
| ## Next Steps | ||
|
|
||
| After completing this tutorial, you can: | ||
|
|
||
| 1. **Modify the scenario**: Edit `my_first_attack_5kinv.py` to try different network interactions | ||
| 2. **Add more nodes**: Modify `94.0.0-5k-inv.yaml` to create larger networks | ||
| 3. **Try other scenarios**: Experiment with the other included scenarios | ||
| 4. **Create custom scenarios**: Use the existing scenarios as templates for your own | ||
| 5. **Explore advanced features**: Check out the main [Warnet documentation](https://github.com/bitcoin-dev-project/warnet) | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| - **Network won't start**: Make sure your chosen backend (Minikube/Docker Desktop) is running | ||
| - **Scenario fails**: Check that the network is fully deployed first with `warnet status` | ||
| - **Dashboard not accessible**: | ||
| - For Minikube: Run `minikube tunnel` in another terminal | ||
| - For Docker Desktop: Check that Kubernetes is enabled | ||
| - **Setup fails**: Make sure you have Docker installed and running | ||
|
|
||
| ## Resources | ||
|
|
||
| - [Warnet Documentation](https://github.com/bitcoin-dev-project/warnet) | ||
| - [Bitcoin Core Test Framework](https://github.com/bitcoin/bitcoin/tree/master/test/functional) | ||
| - [Bitcoin Development Guide](https://bitcoin.org/en/development) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Simple one-node Bitcoin network for learning Warnet | ||
| # This creates a tiny network topology for beginners | ||
|
|
||
| nodes: | ||
| - name: tank-0000 | ||
| bitcoin_config: | | ||
| server=1 | ||
| rpcuser=warnet | ||
| rpcpassword=warnet | ||
| rpcallowip=0.0.0.0/0 | ||
| regtest=1 | ||
| listen=1 | ||
| bind=0.0.0.0 | ||
| blockmintxfee=0.00001 | ||
| debug=net | ||
| logips=1 | ||
|
|
||
| # Network-wide settings | ||
| chain: regtest |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Simple one-node Bitcoin network for learning Warnet | ||
| # This creates a tiny network topology for beginners | ||
|
|
||
| nodes: | ||
| - name: tank-0000 | ||
| bitcoin_config: | | ||
| server=1 | ||
| rpcuser=warnet | ||
| rpcpassword=warnet | ||
| rpcallowip=0.0.0.0/0 | ||
| regtest=1 | ||
| listen=1 | ||
| bind=0.0.0.0 | ||
| blockmintxfee=0.00001 | ||
| debug=net | ||
| logips=1 | ||
|
|
||
| # Network-wide settings | ||
| chain: regtest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.