statechannels / go-nitro-testground

1 stars 0 forks source link

Produce GEFX graph for each run #135

Open lalexgap opened 2 years ago

lalexgap commented 2 years ago

Fixes #104

This outputs a xml file containing a GEFX graph representing the state channel network.

GEFX is just a xml format for describing a graph by specifying nodes and edges. It also contains temporal information (ie an edge exists between two nodes for some amount of time) which lets us "animate" our state channel network over time.

In the graph this PR generates we describe clients as nodes and channels as edges. We record information about when a channel is started and stopped and include that information in the graph.

The file can be loaded into a tool like gephi to display and animate the graph. It lets you colour nodes and edges based on their attributes (ie: an edge being a "virtual" or "ledger" channel).

Unfortunately the GEPHI tool doesn't handle multiple edges nicely (it just draws them over each other, so only the top most edge is visible). This makes the diagram and animations a lot less impressive 😢

It's relatively easy to produce the graph and it doesn't hurt to include it in the artifacts we output. However it does add a bit more code to the repo, so I'm on the fence if we want this merged in.

I'll leave it up to the reviewer to decide 🙂

image

geoknee commented 1 year ago

I would lean towards including this code as it is fairly lightweight and easy to remove later if we want to.

I haven't yet reviewed the code in detail (TODO)

I do have several questions at this point:

  1. Do you have an example output gexf file which I can try with gephi?
  2. Can we play some tricks to get around the multiple edge viz problems -- for example, make the thickness of the line scale with the number of virtual channels?
  3. Can we get the graph into grafana somehow? At the very least, I imagine we could take a static snapshot of the ledger channel connectivity, and maybe extract an svg file and show that in grafana? That might be a nice way to see what's going on.
lalexgap commented 1 year ago

I would lean towards including this code as it is fairly lightweight and easy to remove later if we want to.

I haven't yet reviewed the code in detail (TODO)

I do have several questions at this point:

  1. Do you have an example output gexf file which I can try with gephi?

Here's one from this run: graph-cdml258nr2gjkljjjqdg.gexf.zip

  1. Can we play some tricks to get around the multiple edge viz problems -- for example, make the thickness of the line scale with the number of virtual channels?

We might be able to do something like that! I think edges can also have weights, which we could set to the number of virtual channels. I think this would allow the graph to auto arrange based on the busy parts of the network.

  1. Can we get the graph into grafana somehow? At the very least, I imagine we could take a static snapshot of the ledger channel connectivity, and maybe extract an svg file and show that in grafana? That might be a nice way to see what's going on.

Instead of trying to post an svg to grafana we could use this gephi JS library. It's a javascript library that provides a viewer for GEXF graph files. It displays the graph and also allows it to be interacted with. Here's an example. I think it provides a complete website to deploy to render your specific graph so it would be easy to spin up renders of different runs.