-
Notifications
You must be signed in to change notification settings - Fork 53
Circuit breaker plugin #688
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 all commits
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 |
---|---|---|
@@ -0,0 +1,180 @@ | ||
# Circuit Breaker for Warnet | ||
|
||
## Overview | ||
|
||
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. | ||
|
||
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. | ||
|
||
* **Repository**: https://github.com/lightningequipment/circuitbreaker | ||
* **Full Documentation**: See the main repository for detailed information about Circuit Breaker's features, operating modes, and configuration options | ||
|
||
## Usage in Warnet | ||
|
||
### Basic Configuration | ||
|
||
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: | ||
|
||
```yaml | ||
nodes: | ||
- name: tank-0003 | ||
addnode: | ||
- tank-0000 | ||
ln: | ||
lnd: true | ||
lnd: | ||
config: | | ||
bitcoin.timelockdelta=33 | ||
channels: | ||
- id: | ||
block: 300 | ||
index: 1 | ||
target: tank-0004-ln | ||
capacity: 100000 | ||
push_amt: 50000 | ||
circuitbreaker: | ||
enabled: true # This enables Circuit Breaker for this node | ||
httpPort: 9235 # Can override default port per-node (optional) | ||
``` | ||
|
||
### Configuration Options | ||
|
||
- `enabled`: Set to `true` to enable Circuit Breaker for the node | ||
- `httpPort`: Override the default HTTP port (9235) for the web UI (optional) | ||
|
||
### Complete Example | ||
|
||
Here's a complete `network.yaml` example with Circuit Breaker enabled on one node: | ||
|
||
```yaml | ||
nodes: | ||
- name: tank-0000 | ||
addnode: | ||
- tank-0001 | ||
ln: | ||
lnd: true | ||
|
||
- name: tank-0001 | ||
addnode: | ||
- tank-0002 | ||
ln: | ||
lnd: true | ||
|
||
- name: tank-0002 | ||
addnode: | ||
- tank-0000 | ||
ln: | ||
lnd: true | ||
|
||
- name: tank-0003 | ||
addnode: | ||
- tank-0000 | ||
ln: | ||
lnd: true | ||
lnd: | ||
config: | | ||
bitcoin.timelockdelta=33 | ||
channels: | ||
- id: | ||
block: 300 | ||
index: 1 | ||
target: tank-0004-ln | ||
capacity: 100000 | ||
push_amt: 50000 | ||
circuitbreaker: | ||
enabled: true | ||
httpPort: 9235 | ||
|
||
- name: tank-0004 | ||
addnode: | ||
- tank-0000 | ||
ln: | ||
lnd: true | ||
lnd: | ||
channels: | ||
- id: | ||
block: 300 | ||
index: 2 | ||
target: tank-0005-ln | ||
capacity: 50000 | ||
push_amt: 25000 | ||
|
||
- name: tank-0005 | ||
addnode: | ||
- tank-0000 | ||
ln: | ||
lnd: true | ||
``` | ||
|
||
## Accessing Circuit Breaker | ||
|
||
Circuit Breaker provides both a web-based interface and REST API endpoints for configuration and monitoring. | ||
|
||
### Web UI Access | ||
|
||
To access the web interface: | ||
|
||
1. **Port Forward to the Circuit Breaker service**: | ||
```bash | ||
kubectl port-forward pod/<node-name>-ln <local-port>:<httpPort> | ||
``` | ||
|
||
For example, if your node is named `tank-0003` and using the default port: | ||
```bash | ||
kubectl port-forward pod/tank-0003-ln 9235:9235 | ||
``` | ||
|
||
2. **Open your browser** and navigate to: | ||
``` | ||
http://localhost:9235 | ||
``` | ||
|
||
3. **Configure your firewall rules** through the web interface: | ||
- Set per-peer HTLC limits | ||
- Configure rate limiting parameters | ||
- Choose operating modes | ||
- Monitor HTLC statistics | ||
|
||
### API Access | ||
|
||
You can also interact with Circuit Breaker programmatically using kubectl commands to access the REST API: | ||
|
||
**Get node information:** | ||
```bash | ||
kubectl exec <node-name>-ln -c circuitbreaker -- wget -qO - 127.0.0.1:<httpPort>/api/info | ||
``` | ||
|
||
**Get current limits:** | ||
```bash | ||
kubectl exec <node-name>-ln -c circuitbreaker -- wget -qO - 127.0.0.1:<httpPort>/api/limits | ||
``` | ||
|
||
For example, with node `tank-0003-ln`: | ||
```bash | ||
kubectl exec tank-0003-ln -c circuitbreaker -- wget -qO - 127.0.0.1:9235/api/info | ||
kubectl exec tank-0003-ln -c circuitbreaker -- wget -qO - 127.0.0.1:9235/api/limits | ||
``` | ||
|
||
## Architecture | ||
|
||
Circuit Breaker runs as a sidecar container alongside your LND node in Warnet: | ||
- **LND Container**: Runs your Lightning node | ||
- **Circuit Breaker Container**: Connects to LND via RPC and provides firewall functionality | ||
- **Shared Volume**: Allows Circuit Breaker to access LND's TLS certificates and macaroons | ||
- **Web Interface**: Accessible via port forwarding for configuration | ||
|
||
## Requirements | ||
|
||
- **LND Version**: 0.15.4-beta or above | ||
- **Warnet**: Compatible with standard Warnet LND deployments | ||
|
||
## Support | ||
|
||
For issues and questions: | ||
- Circuit Breaker Repository: https://github.com/lightningequipment/circuitbreaker | ||
- Warnet Documentation: Refer to the Warnet installation guides [install.md](install.md) | ||
- LND Documentation: https://docs.lightning.engineering/ | ||
|
||
--- | ||
|
||
*Circuit Breaker integration for Warnet enables sophisticated HTLC management and protection for Lightning Network nodes in test environments.* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,16 +58,37 @@ spec: | |
- mountPath: /root/.lnd/tls.cert | ||
name: config | ||
subPath: tls.cert | ||
- name: shared-volume | ||
mountPath: /root/.lnd/ | ||
{{- with .Values.extraContainers }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.circuitbreaker.enabled }} | ||
- name: circuitbreaker | ||
Camillarhi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
image: {{ .Values.circuitbreaker.image | quote }} | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- "--network={{ .Values.global.chain }}" | ||
- "--rpcserver=localhost:{{ .Values.RPCPort }}" | ||
- "--tlscertpath=/tls.cert" | ||
- "--macaroonpath=/root/.lnd/data/chain/bitcoin/{{ .Values.global.chain }}/admin.macaroon" | ||
- "--httplisten=0.0.0.0:{{ .Values.circuitbreaker.httpPort }}" | ||
volumeMounts: | ||
- name: shared-volume | ||
mountPath: /root/.lnd/ | ||
- name: config | ||
mountPath: /tls.cert | ||
subPath: tls.cert | ||
{{- end }} | ||
Comment on lines
+66
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was there an issue including circuitbreaker as extraContainers container? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I was not able to access the value of the port and network variables as the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm the whole point of those There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I understand, but I could not access a dynamic network or port while using it. The current approach also gives the option of enabling circuitbreaker if needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pinheadmz I assume it is acceptable to define network(chain) in network.yaml or node-defaults.yaml based on user desired scenario. if so then extraContainers should be possible... |
||
volumes: | ||
{{- with .Values.volumes }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
- configMap: | ||
name: {{ include "lnd.fullname" . }} | ||
name: config | ||
- name: shared-volume | ||
emptyDir: {} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 4 }} | ||
|
Uh oh!
There was an error while loading. Please reload this page.