Add Ability to Run as Full Simulator #6
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a WIP that adds the ability to run SimLN without any real lightning nodes, instead providing "simulated nodes" that copy the the routing policies and liquidity constraints of real nodes. The last commit hard-codes a graph to run this "full simulation" on as an example, whereas in reality we'd load from a json description of the desired topology/policies.
High Level Overview
Lightning implementations in SimLN are abstracted using the LightningNode trait. The steps that we follow to support a simulated implementation of this trait (SimNode) are as follows:
–from_graph option
, which allows starting the simulator with a graph file (format tbd) that provides channel policies and topology (not included in this PR).SimGraph
struct to manage:SimGraph
struct to manage payment dispatch.Graph Abstraction
Management of payments through the simulated network is separated managed with the following layers:
IMGPLACEHOLDER0
These structs are primarily used to provide send/track payment APIs, receiving updates on the state of their payments from SimGraph.
Channel State Machine
Implementation of channel state is broken down into three layers:
IMGPLACEHOLDER1
Each channel state is responsible for handling tracking of liquidity and HTLC limits in one direction, and the simulated channel is responsible for enforcing sanity checks across the channel (eg, that we don’t exceed our capacity).
An example state machine update is provided in the table below:
tl;dr
IMGPLACEHOLDER2