-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Ability to Run as Full Simulator #2
base: bitcoin-dev-project-fresheyes-staging-main-165
Are you sure you want to change the base?
Add Ability to Run as Full Simulator #2
Conversation
This commit adds a ChannelState struct which is used to track the policy and state of a channel in the *outgoing* direction. This will be used to check forwards against the node's advertised policy and track the movement of outgoing HTLCs through the channel. Note that we choose to implement this state *unidirectionally*, so a single channel will be represented by two ChannelState structs (one in each direction).
Add a single representation of a simulated lightning channel which uses our state representation to add and remove htlcs. For simplicity, each side of the channel is represented as a separate state, with the only interaction between the two through the changes to local balance that happen when we settle htlcs.
Add an implementation of the LightningNode trait that represents the underlying lightning node. This implementation is intentionally kept simple, depending on some SimNetwork trait to handle the mechanics of actually simulating the flow of payments through a simulated graph.
We want to be able to distinguish between expected and critical payment errors in our simulated payments. An expected error occurs due to a lightning-related failure (such as running out of liquidity), and a critical one happens because something has gone wrong with our simulator (for example, an assertion failure about balances). This commit adds an some utilities to ForwardingError to make this distinction and display errors properly.
Add an implementation of our SimNetwork trait that will do the heavy lifting of propagating htlcs through a simulated network.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1871600658
at 2024/02/09, 03:20:28 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1871601468
at 2024/02/09, 03:22:07 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1871604036
at 2024/02/09, 03:27:37 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1871606322
at 2024/02/09, 03:32:26 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1871611910
at 2024/02/09, 03:43:42 UTC.
An author commented here with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1873037211
at 2024/02/09, 19:08:54 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1873084330
at 2024/02/09, 19:40:56 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1873125603
at 2024/02/09, 20:09:38 UTC.
An author commented here with:
|
An author commented here with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1881017094
at 2024/02/16, 19:52:41 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1898527379
at 2024/02/27, 13:48:49 UTC.
An author commented here with:
|
An author commented here with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1909512674
at 2024/02/29, 17:48:06 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1909521258
at 2024/02/29, 17:52:50 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1909551436
at 2024/02/29, 18:09:13 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1909580044
at 2024/02/29, 18:25:45 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1909608725
at 2024/02/29, 18:43:21 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1909670677
at 2024/02/29, 19:03:41 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1909674915
at 2024/02/29, 19:06:14 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1909723293
at 2024/02/29, 22:00:29 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1925235915
at 2024/03/08, 16:13:25 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1925238302
at 2024/03/08, 16:14:30 UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1929143410
at 2024/03/11, 20:19:59 UTC.
An author commented here with:
|
An author commented here with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/165#pullrequestreview-1932635987
at 2024/03/12, 21:13:29 UTC.
An author commented here with:
|
An author commented here with:
|
An author commented here with:
|
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: (
https://github.com/bitcoin-dev-project/sim-ln/blob/main/sim-lib/src/lib.rs#L180
) 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:https://github.com/bitcoin-dev-project/sim-ln/blob/main/sim-lib/src/lib.rs#L180
) on a SimNode struct which:SimGraph
struct to manage payment dispatch.Graph Abstraction
Management of payments through the simulated network is separated managed with the following layers:
`
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:
`
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
`