bitcoin-dev-project / sim-ln

Payment activity generator for the lightning network
MIT License
63 stars 27 forks source link

Feature: Allow random and defined activity simulation #161

Open carlaKC opened 9 months ago

carlaKC commented 9 months ago

Right now, the type of activity that we will simulate is determined by the sim-file:

We should allow users to specify both random and defined activity to support more complicated use cases, while still preserving the "easy start" nature of just being able to specify nodes for random activity.

Suggested Sim File Interpretation

Random Activity - All Nodes

sim.json:

nodes {
    A ...
    B ...
}

Action: run default random activity on A and B.

Defined Activity

sim.json:

nodes {
    A ...
    B ....
}
activity{
    A -> B 10 sats
}

Action: run only the defined activity specified between A and B.

Defined and Random Activity

sim.json:

nodes {
    A ...
    B ....
    C ....
}
activity{
    A -> B 10 sats
}
no_random{
    B
}

Action: run defined activity specified between A and B and random activity between A and C.

Rationale for no_random is that I think the likely use case is specifying a few specific activity flows and then wanting those nodes to be excluded from the random activity.

Eg: Running a jamming simulation

sr-gi commented 9 months ago

Eg: Running a jamming simulation

I want D and E to run a jamming attack. I don't want D and E to send random payments. I want all other nodes to be processing random payments, so I just set D and E in no_random.

Can you provide an example of how the file would look for this?

carlaKC commented 9 months ago

Can you provide an example of how the file would look for this?

The following sim file would:

Not sure that this is the best way to express it tbh, I specifically want to keep the feature that only specifying nodes runs random activity (good quick start). Very open to suggestions for other/better ways to express the rest!

sr-gi commented 9 months ago

I'm trying to think about the implications that this will have in the codebase. Would the no_random section translate to anything there won't be picked as source, anything there won't be picked as destination, or both?

I guess in the case of the former we can simply filter the node collection to remove whatever is in no_radom before passing it to the RandomActivityGenerator, in the case of the latter we can create a exclude list that will extend the current policy (do not send to yourself) and if you meant both just do both.

All in all, I think it makes sense, it should be less work to define an exclusion list as far as we assume that the default behavior for channels is to be sending payments between them instead of being stale (which it's a reasonable assumption for me at least)

carlaKC commented 9 months ago

Would the no_random section translate to anything there won't be picked as source, anything there won't be picked as destination, or both?

Both - our current implementation of random activity is that each node sends and receives, so we'd just exclude no_random completely.

we can simply filter the node collection to remove whatever is in no_radom before passing it to the RandomActivityGenerator

Yeah exactly what I was thinking 👍