Skip to content
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

Random Activity Generator #113

Merged
merged 7 commits into from
Oct 4, 2023

Conversation

carlaKC
Copy link
Contributor

@carlaKC carlaKC commented Sep 25, 2023

Fixes #72 (see #111 for design doc).

Some design considerations:

  • Tracking network state (nodes / capacity / WeightedIndex) is where we take the biggest memory hit, so that's pulled out into its own manager which all tasks use (ie, we don't want to make copies of it).
  • I haven't done much work on surfacing this via config/readme (rn, if you have no activity descriptions we'll just default to random). I'd like to do that in a follow up so this PR can focus on functionality and once Allows using aliases within the config file #103 is in so I can build on that.

@carlaKC carlaKC force-pushed the 111-randomactivity branch 3 times, most recently from 144f971 to f363587 Compare September 27, 2023 21:40
@carlaKC carlaKC marked this pull request as ready for review September 27, 2023 21:59
@carlaKC carlaKC requested review from sr-gi and okjodom September 27, 2023 21:59
@carlaKC carlaKC changed the title WIP: Random Activity Generator Random Activity Generator Sep 27, 2023
Copy link
Member

@sr-gi sr-gi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

I've reviewed this commit by commit so there may be comments that build on top of each other.

sim-lib/src/lib.rs Show resolved Hide resolved
sim-lib/src/cln.rs Outdated Show resolved Hide resolved
sim-lib/src/cln.rs Outdated Show resolved Hide resolved
sim-lib/src/cln.rs Show resolved Hide resolved
sim-lib/src/lib.rs Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
@carlaKC
Copy link
Contributor Author

carlaKC commented Sep 29, 2023

Thanks for the review @sr-gi! I've just resolved some of the obvious rust improvements, but please re-open if I missed any of them (and thank you for 🦀 wisdom). My main takeaway is that we need to think about the ways that our magical expected_payment_amt could mess things up.

I wonder whether we shouldn't just prune anything where:
sum(channel capacity for node) / 2 < expected_payment_amount?

Because that would mean that we always succeed in picking a payment amount, which would simplify things a little. We can log warnings when we do this pruning so that people know to re-configure (or leave as-is) their simulation?

Main changes on push are: rust cleanups, lots of docs and move retries into NewtorkView!

sim-lib/src/lib.rs Outdated Show resolved Hide resolved
@carlaKC carlaKC force-pushed the 111-randomactivity branch 2 times, most recently from 2f1c4be to 45c4d95 Compare October 2, 2023 15:38
@carlaKC carlaKC requested a review from sr-gi October 2, 2023 15:52
sim-lib/src/random_activity.rs Outdated Show resolved Hide resolved
sim-lib/src/random_activity.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Show resolved Hide resolved
sim-lib/src/random_activity.rs Outdated Show resolved Hide resolved
sim-lib/src/random_activity.rs Outdated Show resolved Hide resolved
sim-lib/src/random_activity.rs Outdated Show resolved Hide resolved
sim-lib/src/random_activity.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@sr-gi sr-gi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, especially regarding sigma and how we pick the NetworkGraphView. I may go over the whole PR again after we agree on this just in case.

sim-lib/src/lib.rs Show resolved Hide resolved
sim-lib/src/random_activity.rs Outdated Show resolved Hide resolved
@carlaKC carlaKC force-pushed the 111-randomactivity branch from 45c4d95 to f2740e9 Compare October 3, 2023 14:19
@carlaKC carlaKC force-pushed the 111-randomactivity branch from f2740e9 to 8116679 Compare October 4, 2023 13:53
@carlaKC carlaKC requested a review from sr-gi October 4, 2023 14:00
@carlaKC
Copy link
Contributor Author

carlaKC commented Oct 4, 2023

Jumped the gun on rebasing on #104 so diff from last review will be a bit muddled (apologies!).

Major change is just adding the loop for selecting a destination and logging if we can't find one after an unreasonably high number of retries + some validation to ensure that we have at least 2 nodes for NetworkGenerator / non-zero capacities.

@carlaKC carlaKC force-pushed the 111-randomactivity branch from 8116679 to 9fc4a06 Compare October 4, 2023 14:19
Copy link
Member

@sr-gi sr-gi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few final notes, mostly nits.

Looks good functionality-wise

PS: I've gone over the whole PR again given all the rebasing

sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/random_activity.rs Outdated Show resolved Hide resolved
sim-lib/src/cln.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
sim-lib/src/lib.rs Outdated Show resolved Hide resolved
When we add random activity generation, we're going to want consumers
for every node that we have execution on. Previously, we only ran
consumers for nodes that are listed as the source in activity
description. This change separates consumer and producer spin up and
allows the caller to specify which nodes to run consumers for.
@carlaKC carlaKC force-pushed the 111-randomactivity branch 2 times, most recently from ddffe97 to d896cdd Compare October 4, 2023 17:52
When we want to simulate random activity in large network, keeping track
of our graph will be the most expensive part of the simulation. This is
because we'll want to cache node capacities for easy lookup, and
because a weighted index has a large memory footprint (N -1 u64s for
our use). To minimize the cost of tracking these values, we use a single
NetworkGraphView tracker that will provide expensive operations in a
single location.
Allow parsing of empty activity descriptions to facilitate default run
with random activity generation. We still use a vector in the
Simulation struct to allow a path where we have a combination of
random and specific activity.

This commit also adds validation that we have at least two nodes when
running random activity. This is required because destination nodes
are chosen from within the nodes that we have execution on (to prevent
liquidity draining and eventual death spirals).
@carlaKC carlaKC force-pushed the 111-randomactivity branch from d896cdd to 46566b2 Compare October 4, 2023 18:23
@sr-gi sr-gi merged commit 843d797 into bitcoin-dev-project:main Oct 4, 2023
@sr-gi
Copy link
Member

sr-gi commented Oct 4, 2023

Merging this. A post-merge review would be nice if you find some time @okjodom

@okjodom
Copy link
Collaborator

okjodom commented Oct 4, 2023

Merging this. A post-merge review would be nice if you find some time @okjodom

Ack. I haven't been able to dive deep into this one but will do

@okjodom
Copy link
Collaborator

okjodom commented Oct 5, 2023

I'm happy dancing after looking through this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Generate Activity From Graph Topology
3 participants