|
| 1 | +# Circuit Breaker for Warnet |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Circuit Breaker is a Lightning Network firewall that protects LND nodes from being flooded with HTLCs. When integrated with Warnet, Circuit Breaker runs as a sidecar container alongside your LND nodes. |
| 6 | + |
| 7 | +Circuit Breaker is to Lightning what firewalls are to the internet - it allows nodes to protect themselves by setting maximum limits on in-flight HTLCs on a per-peer basis and applying rate limits to forwarded HTLCs. |
| 8 | + |
| 9 | +* **Repository**: https://github.com/lightningequipment/circuitbreaker |
| 10 | +* **Full Documentation**: See the main repository for detailed information about Circuit Breaker's features, operating modes, and configuration options |
| 11 | + |
| 12 | +## Usage in Warnet |
| 13 | + |
| 14 | +### Basic Configuration |
| 15 | + |
| 16 | +To enable Circuit Breaker for an LND node in your `network.yaml` file, add the `circuitbreaker` section under the `lnd` configuration. When enabled, Circuit Breaker will automatically start as a sidecar container and connect to your LND node: |
| 17 | + |
| 18 | +```yaml |
| 19 | +nodes: |
| 20 | + - name: tank-0003 |
| 21 | + addnode: |
| 22 | + - tank-0000 |
| 23 | + ln: |
| 24 | + lnd: true |
| 25 | + lnd: |
| 26 | + config: | |
| 27 | + bitcoin.timelockdelta=33 |
| 28 | + channels: |
| 29 | + - id: |
| 30 | + block: 300 |
| 31 | + index: 1 |
| 32 | + target: tank-0004-ln |
| 33 | + capacity: 100000 |
| 34 | + push_amt: 50000 |
| 35 | + circuitbreaker: |
| 36 | + enabled: true # This enables Circuit Breaker for this node |
| 37 | + httpPort: 9235 # Can override default port per-node (optional) |
| 38 | +``` |
| 39 | +
|
| 40 | +### Configuration Options |
| 41 | +
|
| 42 | +- `enabled`: Set to `true` to enable Circuit Breaker for the node |
| 43 | +- `httpPort`: Override the default HTTP port (9235) for the web UI (optional) |
| 44 | + |
| 45 | +### Complete Example |
| 46 | + |
| 47 | +Here's a complete `network.yaml` example with Circuit Breaker enabled on one node: |
| 48 | + |
| 49 | +```yaml |
| 50 | +nodes: |
| 51 | + - name: tank-0000 |
| 52 | + addnode: |
| 53 | + - tank-0001 |
| 54 | + ln: |
| 55 | + lnd: true |
| 56 | +
|
| 57 | + - name: tank-0001 |
| 58 | + addnode: |
| 59 | + - tank-0002 |
| 60 | + ln: |
| 61 | + lnd: true |
| 62 | +
|
| 63 | + - name: tank-0002 |
| 64 | + addnode: |
| 65 | + - tank-0000 |
| 66 | + ln: |
| 67 | + lnd: true |
| 68 | +
|
| 69 | + - name: tank-0003 |
| 70 | + addnode: |
| 71 | + - tank-0000 |
| 72 | + ln: |
| 73 | + lnd: true |
| 74 | + lnd: |
| 75 | + config: | |
| 76 | + bitcoin.timelockdelta=33 |
| 77 | + channels: |
| 78 | + - id: |
| 79 | + block: 300 |
| 80 | + index: 1 |
| 81 | + target: tank-0004-ln |
| 82 | + capacity: 100000 |
| 83 | + push_amt: 50000 |
| 84 | + circuitbreaker: |
| 85 | + enabled: true |
| 86 | + httpPort: 9235 |
| 87 | +
|
| 88 | + - name: tank-0004 |
| 89 | + addnode: |
| 90 | + - tank-0000 |
| 91 | + ln: |
| 92 | + lnd: true |
| 93 | + lnd: |
| 94 | + channels: |
| 95 | + - id: |
| 96 | + block: 300 |
| 97 | + index: 2 |
| 98 | + target: tank-0005-ln |
| 99 | + capacity: 50000 |
| 100 | + push_amt: 25000 |
| 101 | +
|
| 102 | + - name: tank-0005 |
| 103 | + addnode: |
| 104 | + - tank-0000 |
| 105 | + ln: |
| 106 | + lnd: true |
| 107 | +``` |
| 108 | + |
| 109 | +## Accessing Circuit Breaker |
| 110 | + |
| 111 | +Circuit Breaker provides both a web-based interface and REST API endpoints for configuration and monitoring. |
| 112 | + |
| 113 | +### Web UI Access |
| 114 | + |
| 115 | +To access the web interface: |
| 116 | + |
| 117 | +1. **Port Forward to the Circuit Breaker service**: |
| 118 | + ```bash |
| 119 | + kubectl port-forward pod/<node-name>-ln <local-port>:<httpPort> |
| 120 | + ``` |
| 121 | + |
| 122 | + For example, if your node is named `tank-0003` and using the default port: |
| 123 | + ```bash |
| 124 | + kubectl port-forward pod/tank-0003-ln 9235:9235 |
| 125 | + ``` |
| 126 | + |
| 127 | +2. **Open your browser** and navigate to: |
| 128 | + ``` |
| 129 | + http://localhost:9235 |
| 130 | + ``` |
| 131 | + |
| 132 | +3. **Configure your firewall rules** through the web interface: |
| 133 | + - Set per-peer HTLC limits |
| 134 | + - Configure rate limiting parameters |
| 135 | + - Choose operating modes |
| 136 | + - Monitor HTLC statistics |
| 137 | + |
| 138 | +### API Access |
| 139 | + |
| 140 | +You can also interact with Circuit Breaker programmatically using kubectl commands to access the REST API: |
| 141 | + |
| 142 | +**Get node information:** |
| 143 | +```bash |
| 144 | +kubectl exec <node-name>-ln -c circuitbreaker -- wget -qO - 127.0.0.1:<httpPort>/api/info |
| 145 | +``` |
| 146 | + |
| 147 | +**Get current limits:** |
| 148 | +```bash |
| 149 | +kubectl exec <node-name>-ln -c circuitbreaker -- wget -qO - 127.0.0.1:<httpPort>/api/limits |
| 150 | +``` |
| 151 | + |
| 152 | +For example, with node `tank-0003-ln`: |
| 153 | +```bash |
| 154 | +kubectl exec tank-0003-ln -c circuitbreaker -- wget -qO - 127.0.0.1:9235/api/info |
| 155 | +kubectl exec tank-0003-ln -c circuitbreaker -- wget -qO - 127.0.0.1:9235/api/limits |
| 156 | +``` |
| 157 | + |
| 158 | +## Architecture |
| 159 | + |
| 160 | +Circuit Breaker runs as a sidecar container alongside your LND node in Warnet: |
| 161 | +- **LND Container**: Runs your Lightning node |
| 162 | +- **Circuit Breaker Container**: Connects to LND via RPC and provides firewall functionality |
| 163 | +- **Shared Volume**: Allows Circuit Breaker to access LND's TLS certificates and macaroons |
| 164 | +- **Web Interface**: Accessible via port forwarding for configuration |
| 165 | + |
| 166 | +## Requirements |
| 167 | + |
| 168 | +- **LND Version**: 0.15.4-beta or above |
| 169 | +- **Warnet**: Compatible with standard Warnet LND deployments |
| 170 | + |
| 171 | +## Support |
| 172 | + |
| 173 | +For issues and questions: |
| 174 | +- Circuit Breaker Repository: https://github.com/lightningequipment/circuitbreaker |
| 175 | +- Warnet Documentation: Refer to the Warnet installation guides [install.md](install.md) |
| 176 | +- LND Documentation: https://docs.lightning.engineering/ |
| 177 | + |
| 178 | +--- |
| 179 | + |
| 180 | +*Circuit Breaker integration for Warnet enables sophisticated HTLC management and protection for Lightning Network nodes in test environments.* |
0 commit comments