In this commit, we teach the simulator to take the hidden balances out of
the graph file instead of drawing them. The describegraph loader now reads
the two fields an externally modelled graph adds, a node1-side `balance` in
sats and a `balance_certainty` between zero and one, and records them on the
channel ends without applying them. A new `from_graph` liquidity model is
what applies them: node1's end takes the balance the file gave it, the other
end takes the rest of the capacity, no rng involved.
The reason we want this is circularity. Our mainnet tier is real topology
and real policies with our own generator's liquidity painted over it, and
that generator is the one the evolved routers' priors were fit to
(`sim_liquidity.go` draws `ExpFloat64()*0.05`, atomic1's low mode is
`exp(-x/0.055)`). A graph whose balances someone else modelled is the first
liquidity family in the program we did not write, so scoring on it is the
cheapest de-circularization left short of replaying real payment data.
Which side a balance lands on is the one thing here that can be silently
wrong: a balance on the wrong end is still a plausible looking network and
would fail no aggregate, so we key off the pubkey the file calls node1
rather than assuming it is the lexicographically smaller end, and pin both
orderings in the tests. For the same reason a graph that only partly carries
balances is a loud error with a count instead of a fallback, since a
fallback would report a mixture of two liquidity families under the name of
one.
Everything is inert with the model unset. The new fields parse and go
unread, so a snapshot carrying neither, which is every snapshot we have
scored so far, loads exactly as it always did. Seven scenario files across
hard-test, ood-test and corpus-mix run byte-identical on both routers
against a binary built from the tree before this change.
The routing package implements authentication+validation of channel
announcements, pruning of the channel graph, path finding within the network,
sending outgoing payments into the network and synchronizing new peers to our
channel graph state.
Installation and Updating
$ go get -u github.com/lightningnetwork/lnd/routing