-
Notifications
You must be signed in to change notification settings - Fork 645
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
[test_loop] Cleanup old test loop code #11525
Conversation
…f<Client> + AsRef<AccountId>
…essages across clients
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #11525 +/- ##
==========================================
+ Coverage 71.19% 71.44% +0.25%
==========================================
Files 794 783 -11
Lines 160944 159863 -1081
Branches 160944 159863 -1081
==========================================
- Hits 114578 114211 -367
+ Misses 41373 40674 -699
+ Partials 4993 4978 -15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…11520) Part 2 Change in interface of ClientQueries to not depend on `AsRef<AccountId>`. Note that we can get the account_id from Client using the validator signer module. ### Other PRs [Part 1](#11521): [test_loop] Introduce TestLoopV2 [Part 2](#11520): [test_loop] Change ClientQueries trait requirements in TestLoop util [Part 3](#11522): [test_loop] test_loop_sync_actor_maker implementation in TestLoopV2 [Part 4](#11523): [test_loop] Introduce TestLoopPeerManagerActor for handling network messages across clients [Part 5](#11524): [test_loop] Convert current tests to use TestLoopV2 [Part 6](#11525): [test_loop] Cleanup old test loop code [Part 7](#11528): [test_loop] Better visualizer support for TestLoopV2
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.
🎉🎉🎉🎉🎉
… of AsRef<Client> + AsRef<AccountId>" This reverts commit 8c33367.
Part 1 This PR has the set of major test loop infrastructure changes ## data.rs This is the new implementation of storage of data on test loop. The way it works is, we store any arbit data in a vec of type Any data and return a handle for the data stored. The handle is a lightweight "pointer" to the data (basically stores the index) that can be easily passed around. This effectively acts like a smart pointer to access specific data. We also have the ability to register actors which create a "sender" out of the actor handler and return it. Why was this needed? For managing ownership of data like client_actor, shards_manager_actor etc. We need to create "senders" for our actor handlers and they need to be lightweight, cloneable, implement Send + Sync for passing around threads etc. Alternatives? The most obvious one that I had tried first was to use Arc<Mutex<Actor>> but that was causing some concurrency related issues and wasn't an elegant solution. Additionally, only the senders then had access to the actor data which wasn't easily scalable for things like adhoc events etc. ## sender.rs TestLoopSender is a nice wrapper on top of actors that implements the `CanSend<Msg>` interface. This pattern is similar to what we have for actix wrapper (core/async/src/actix_wrapper.rs) for actors. TestLoopSender needs to implement `DelayedActionRunner` as well for things to function. We don't need to go too much into details of what this is, but it's effectively used by the actor to schedule events sometime in the future. Link to old TestLoopSender PR: #11450 ## futures.rs Newer implementation of future execution for TestLoopV2 using callbacks as the main event. The overall logic for how things work is still the same. I had to do some playing around with FutureSpawner but nothing much has changed functionality and implementation wise. ## test_loop.rs This file implements TestLoopV2 - Got rid of the builder as we don't need it. - "Events" are now of only one type, the CallbackEvent - `future_spawner`, `async_computation_spawner` are exposed by the testloop that can be passed to actors. - `register_actor` to store actor to test_loop_data and returns sender. ## Other PRs [Part 1](#11521): [test_loop] Introduce TestLoopV2 [Part 2](#11520): [test_loop] Change ClientQueries trait requirements in TestLoop util [Part 3](#11522): [test_loop] test_loop_sync_actor_maker implementation in TestLoopV2 [Part 4](#11523): [test_loop] Introduce TestLoopPeerManagerActor for handling network messages across clients [Part 5](#11524): [test_loop] Convert current tests to use TestLoopV2 [Part 6](#11525): [test_loop] Cleanup old test loop code [Part 7](#11528): [test_loop] Better visualizer support for TestLoopV2 [Part 8](#11539): [test_loop] Simple TestLoopEnvBuilder
…11522) Part 3 This PR has the implementation of sync_actor_maker function for test loop. We don't have control over when the sync_actor_maker function is called during execution so we use an adhoc callback event to register the newly created sync_actor with testloop. ### Other PRs [Part 1](#11521): [test_loop] Introduce TestLoopV2 [Part 2](#11520): [test_loop] Change ClientQueries trait requirements in TestLoop util [Part 3](#11522): [test_loop] test_loop_sync_actor_maker implementation in TestLoopV2 [Part 4](#11523): [test_loop] Introduce TestLoopPeerManagerActor for handling network messages across clients [Part 5](#11524): [test_loop] Convert current tests to use TestLoopV2 [Part 6](#11525): [test_loop] Cleanup old test loop code [Part 7](#11528): [test_loop] Better visualizer support for TestLoopV2 [Part 8](#11539): [test_loop] Simple TestLoopEnvBuilder
…essages across clients (#11523) Part 4 This PR adds TestLoopPeerManagerActor for managing network messages. Note that for handling messages between clients, the module needs to have full details of all clients to route the message to. The way TestLoopPeerManagerActor works is by registering a set of handler functions that direct the messages to specific actors. TestLoopPeerManagerActor comes with a set of default handlers, one for client, partial_witness, and shards_manager. On top of these default handlers, we have the ability to register override handlers which are tried before the default handlers. The override handlers can do a bunch of things like modify requests or drop requests. Note that each client/node gets ONE SEPARATE implementation of TestLoopPeerManagerActor. For a 4 client setup, we have 4 instances of the peer manager actor. Each can have their own separate overrides. ### Other PRs [Part 1](#11521): [test_loop] Introduce TestLoopV2 [Part 2](#11520): [test_loop] Change ClientQueries trait requirements in TestLoop util [Part 3](#11522): [test_loop] test_loop_sync_actor_maker implementation in TestLoopV2 [Part 4](#11523): [test_loop] Introduce TestLoopPeerManagerActor for handling network messages across clients [Part 5](#11524): [test_loop] Convert current tests to use TestLoopV2 [Part 6](#11525): [test_loop] Cleanup old test loop code [Part 7](#11528): [test_loop] Better visualizer support for TestLoopV2 [Part 8](#11539): [test_loop] Simple TestLoopEnvBuilder
Part 5 🎉🎉🎉🎉🎉 We can follow this up with a test loop builder to avoid duplicating logic. ### Other PRs [Part 1](#11521): [test_loop] Introduce TestLoopV2 [Part 2](#11520): [test_loop] Change ClientQueries trait requirements in TestLoop util [Part 3](#11522): [test_loop] test_loop_sync_actor_maker implementation in TestLoopV2 [Part 4](#11523): [test_loop] Introduce TestLoopPeerManagerActor for handling network messages across clients [Part 5](#11524): [test_loop] Convert current tests to use TestLoopV2 [Part 6](#11525): [test_loop] Cleanup old test loop code [Part 7](#11528): [test_loop] Better visualizer support for TestLoopV2 [Part 8](#11539): [test_loop] Simple TestLoopEnvBuilder
Part 7 Turns out for the visualizer tool to work, we require the "description" emitted in `EventStartLogOutput` to be of a very specific format `(node_id, Title(Subtitle(...)))` In this PR, we try to add these additional details during logging. This isn't as great as what we originally had as we don't pretty print the individual event types etc. but still should be good enough for debugging. We can further improve this later as per necessity. ### Other PRs [Part 1](#11521): [test_loop] Introduce TestLoopV2 [Part 2](#11520): [test_loop] Change ClientQueries trait requirements in TestLoop util [Part 3](#11522): [test_loop] test_loop_sync_actor_maker implementation in TestLoopV2 [Part 4](#11523): [test_loop] Introduce TestLoopPeerManagerActor for handling network messages across clients [Part 5](#11524): [test_loop] Convert current tests to use TestLoopV2 [Part 6](#11525): [test_loop] Cleanup old test loop code [Part 7](#11528): [test_loop] Better visualizer support for TestLoopV2 [Part 8](#11539): [test_loop] Simple TestLoopEnvBuilder
Part 8 Reduce code duplication by creating a simple test loop environment builder. Over time we can add more functionality to this as per requirements. [Part 1](#11521): [test_loop] Introduce TestLoopV2 [Part 2](#11520): [test_loop] Change ClientQueries trait requirements in TestLoop util [Part 3](#11522): [test_loop] test_loop_sync_actor_maker implementation in TestLoopV2 [Part 4](#11523): [test_loop] Introduce TestLoopPeerManagerActor for handling network messages across clients [Part 5](#11524): [test_loop] Convert current tests to use TestLoopV2 [Part 6](#11525): [test_loop] Cleanup old test loop code [Part 7](#11528): [test_loop] Better visualizer support for TestLoopV2 [Part 8](#11539): [test_loop] Simple TestLoopEnvBuilder
Part 6
🎉🎉🎉🎉🎉
Nothing more staisfying than seeing this
Other PRs
Part 1: [test_loop] Introduce TestLoopV2
Part 2: [test_loop] Change ClientQueries trait requirements in TestLoop util
Part 3: [test_loop] test_loop_sync_actor_maker implementation in TestLoopV2
Part 4: [test_loop] Introduce TestLoopPeerManagerActor for handling network messages across clients
Part 5: [test_loop] Convert current tests to use TestLoopV2
Part 6: [test_loop] Cleanup old test loop code
Part 7: [test_loop] Better visualizer support for TestLoopV2
Part 8: [test_loop] Simple TestLoopEnvBuilder