Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions cmd/gencluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"sort"
"strings"

"github.com/bottlepay/lightning-benchmark/graphreader"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -36,13 +37,50 @@ func main() {
}
}

func writeVisualization(graph *graphreader.YamlGraph, outFile string) error {
var b strings.Builder
b.WriteString("graph {\n")
b.WriteString(" nodesep=1\n")

for alias, node := range graph.Nodes {
b.WriteString(fmt.Sprintf(
" %v[label=\"%v\\n[%v]\"]\n", alias, alias, node.Policy,
))
for peerAlias, peer := range node.Channels {
for _, channel := range peer {
b.WriteString(fmt.Sprintf(
" %v -- %v [taillabel=\"%vk\", headlabel=\"%vk\"]\n",
alias, peerAlias,
(channel.Capacity-channel.RemoteBalance)/1e3, channel.RemoteBalance/1e3,
))

}
}
}

b.WriteString("}\n")

text := b.String()
err := os.WriteFile(outFile, []byte(text), 0644)
if err != nil {
return err
}

return nil
}

// This function generates a docker-compose.yml file from a graph definition.
func run() error {
graph, err := graphreader.Read("graph.yml")
if err != nil {
return err
}

err = writeVisualization(graph, "graph.dot")
if err != nil {
return err
}

cfg := config{
Services: map[string]service{
"bitcoind": {
Expand Down
118 changes: 118 additions & 0 deletions graph.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
graph {
nodesep=1
black_hole[label="black_hole\n[cheap]"]
black_hole -- no_liquidity_5 [taillabel="10k", headlabel="140k"]
black_hole -- no_liquidity_0 [taillabel="10k", headlabel="140k"]
black_hole -- no_liquidity_1 [taillabel="10k", headlabel="140k"]
black_hole -- no_liquidity_2 [taillabel="10k", headlabel="140k"]
black_hole -- no_liquidity_3 [taillabel="10k", headlabel="140k"]
black_hole -- no_liquidity_4 [taillabel="10k", headlabel="140k"]
shortcut_x[label="shortcut_x\n[cheap]"]
shortcut_x -- shortcut_b [taillabel="90k", headlabel="0k"]
shortcut_x -- shortcut_y [taillabel="70k", headlabel="0k"]
long_route_f[label="long_route_f\n[cheap]"]
long_route_f -- long_route_g [taillabel="10000k", headlabel="0k"]
no_liquidity_3[label="no_liquidity_3\n[cheap]"]
no_liquidity_3 -- destination1 [taillabel="10k", headlabel="140k"]
no_liquidity_3 -- destination2 [taillabel="10k", headlabel="140k"]
mpp1_1[label="mpp1_1\n[normal]"]
mpp1_1 -- destination3 [taillabel="450k", headlabel="50k"]
long_route_d[label="long_route_d\n[cheap]"]
long_route_d -- long_route_e [taillabel="10000k", headlabel="0k"]
long_route_e[label="long_route_e\n[cheap]"]
long_route_e -- long_route_f [taillabel="10000k", headlabel="0k"]
destination2[label="destination2\n[normal]"]
node1_0[label="node1_0\n[normal]"]
node1_0 -- node2_0 [taillabel="10k", headlabel="140k"]
node1_0 -- node2_1 [taillabel="10k", headlabel="140k"]
node3_1[label="node3_1\n[expensive]"]
node3_1 -- node4_0 [taillabel="10k", headlabel="140k"]
node3_1 -- node4_1 [taillabel="150k", headlabel="0k"]
node3_1 -- destination2 [taillabel="150k", headlabel="0k"]
long_route_y[label="long_route_y\n[cheap]"]
long_route_y -- long_route_destination [taillabel="10k", headlabel="40k"]
node3_0[label="node3_0\n[normal]"]
node3_0 -- node4_0 [taillabel="10k", headlabel="140k"]
node3_0 -- node4_1 [taillabel="10k", headlabel="140k"]
no_liquidity_1[label="no_liquidity_1\n[cheap]"]
no_liquidity_1 -- destination1 [taillabel="10k", headlabel="140k"]
no_liquidity_1 -- destination2 [taillabel="10k", headlabel="140k"]
no_liquidity_5[label="no_liquidity_5\n[cheap]"]
no_liquidity_5 -- destination1 [taillabel="10k", headlabel="140k"]
no_liquidity_5 -- destination2 [taillabel="10k", headlabel="140k"]
destination1[label="destination1\n[normal]"]
long_route_destination[label="long_route_destination\n[cheap]"]
node0_0[label="node0_0\n[normal]"]
node0_0 -- black_hole [taillabel="150k", headlabel="0k"]
node0_0 -- black_hole_indirect [taillabel="150k", headlabel="0k"]
node0_0 -- node1_0 [taillabel="10k", headlabel="140k"]
node0_0 -- node1_1 [taillabel="150k", headlabel="0k"]
node2_0[label="node2_0\n[expensive]"]
node2_0 -- node3_0 [taillabel="10k", headlabel="140k"]
node2_0 -- node3_1 [taillabel="150k", headlabel="0k"]
node2_1[label="node2_1\n[normal]"]
node2_1 -- node3_0 [taillabel="10k", headlabel="140k"]
node2_1 -- node3_1 [taillabel="10k", headlabel="140k"]
mpp0_0[label="mpp0_0\n[normal]"]
mpp0_0 -- mpp1_0 [taillabel="30k", headlabel="70k"]
mpp0_0 -- mpp1_1 [taillabel="30k", headlabel="70k"]
node1_1[label="node1_1\n[expensive]"]
node1_1 -- node2_0 [taillabel="150k", headlabel="0k"]
node1_1 -- node2_1 [taillabel="10k", headlabel="140k"]
no_liquidity_2[label="no_liquidity_2\n[cheap]"]
no_liquidity_2 -- destination1 [taillabel="10k", headlabel="140k"]
no_liquidity_2 -- destination2 [taillabel="10k", headlabel="140k"]
no_liquidity_4[label="no_liquidity_4\n[cheap]"]
no_liquidity_4 -- destination1 [taillabel="10k", headlabel="140k"]
no_liquidity_4 -- destination2 [taillabel="10k", headlabel="140k"]
mpp1_0[label="mpp1_0\n[normal]"]
mpp1_0 -- destination3 [taillabel="450k", headlabel="50k"]
shortcut_y[label="shortcut_y\n[cheap]"]
shortcut_y -- shortcut_destination [taillabel="15k", headlabel="30k"]
destination3[label="destination3\n[normal]"]
start[label="start\n[normal]"]
start -- mpp0_0 [taillabel="50k", headlabel="50k"]
start -- mpp0_1 [taillabel="50k", headlabel="50k"]
start -- shortcut_a [taillabel="26k", headlabel="0k"]
start -- shortcut_x [taillabel="16k", headlabel="10k"]
start -- long_route_a [taillabel="10000k", headlabel="0k"]
start -- long_route_z [taillabel="100k", headlabel="0k"]
start -- node0_0 [taillabel="150k", headlabel="0k"]
start -- node0_1 [taillabel="10k", headlabel="140k"]
long_route_g[label="long_route_g\n[cheap]"]
long_route_g -- long_route_destination [taillabel="10000k", headlabel="0k"]
black_hole_indirect[label="black_hole_indirect\n[normal]"]
black_hole_indirect -- no_liquidity_0 [taillabel="150k", headlabel="0k"]
black_hole_indirect -- no_liquidity_1 [taillabel="150k", headlabel="0k"]
black_hole_indirect -- no_liquidity_2 [taillabel="150k", headlabel="0k"]
black_hole_indirect -- no_liquidity_3 [taillabel="150k", headlabel="0k"]
black_hole_indirect -- no_liquidity_4 [taillabel="150k", headlabel="0k"]
black_hole_indirect -- no_liquidity_5 [taillabel="150k", headlabel="0k"]
shortcut_b[label="shortcut_b\n[cheap]"]
shortcut_b -- shortcut_destination [taillabel="15k", headlabel="30k"]
long_route_a[label="long_route_a\n[cheap]"]
long_route_a -- long_route_b [taillabel="10000k", headlabel="0k"]
long_route_z[label="long_route_z\n[cheap]"]
long_route_z -- long_route_y [taillabel="50k", headlabel="0k"]
long_route_z -- long_route_destination [taillabel="10k", headlabel="40k"]
mpp0_1[label="mpp0_1\n[normal]"]
mpp0_1 -- mpp1_0 [taillabel="30k", headlabel="70k"]
mpp0_1 -- mpp1_1 [taillabel="30k", headlabel="70k"]
shortcut_a[label="shortcut_a\n[cheap]"]
shortcut_a -- shortcut_b [taillabel="25k", headlabel="0k"]
long_route_b[label="long_route_b\n[cheap]"]
long_route_b -- long_route_c [taillabel="10000k", headlabel="0k"]
shortcut_destination[label="shortcut_destination\n[cheap]"]
node0_1[label="node0_1\n[normal]"]
node0_1 -- node1_0 [taillabel="10k", headlabel="140k"]
node0_1 -- node1_1 [taillabel="10k", headlabel="140k"]
node4_0[label="node4_0\n[normal]"]
node4_0 -- destination1 [taillabel="150k", headlabel="0k"]
node4_1[label="node4_1\n[expensive]"]
node4_1 -- destination1 [taillabel="150k", headlabel="0k"]
no_liquidity_0[label="no_liquidity_0\n[cheap]"]
no_liquidity_0 -- destination1 [taillabel="10k", headlabel="140k"]
no_liquidity_0 -- destination2 [taillabel="10k", headlabel="140k"]
long_route_c[label="long_route_c\n[cheap]"]
long_route_c -- long_route_d [taillabel="10000k", headlabel="0k"]
}