refactor(ntx-builder): replace the account actors with a scheduler - #2585
SantiagoPittella wants to merge 3 commits into
Conversation
c33fb3c to
ccbc958
Compare
ccbc958 to
831b6f9
Compare
831b6f9 to
c5b29a1
Compare
There was a problem hiding this comment.
I'm not a fan of attempt as a base name.
Perhaps something like NetworkTransactionContext and the current free standing functions could be methods?
| pub async fn shutdown(&mut self) { | ||
| self.tasks.shutdown().await; | ||
| self.running.clear(); | ||
| self.in_flight.clear(); | ||
| } |
There was a problem hiding this comment.
When is this called? I'm surprised this isn't shutdown(self), then no need to keep this re-useable afterwards.
There was a problem hiding this comment.
tokio;'s shutdown is also &mut so we just propagate it. This is called when a shutdown signal arrives
| loop { | ||
| match self.tasks.join_next_with_id().await { | ||
| Some(Ok((id, outcome))) => { | ||
| self.running.remove(&id); | ||
| return Ok(outcome); | ||
| }, | ||
| Some(Err(err)) => { | ||
| let account_id = self.running.remove(&err.id()); | ||
| // Cancelled tasks were aborted on shutdown. | ||
| if err.is_cancelled() { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
This loop and cancellation check feel a bit weird?
There was a problem hiding this comment.
Replaced it with a match
| // Applied before the failures so a note that is both corrected and penalized keeps the | ||
| // backoff block the penalty computes, which is the later of the two. |
There was a problem hiding this comment.
I don't quite understand why notes need to be corrected?
There was a problem hiding this comment.
The wording sucks, but it is for sponsorship notes that writes the block the sponsorship arrived at, whatever the note's hint says, so it can mismatch and needs correction
c5b29a1 to
14c5a4e
Compare
14c5a4e to
d5adee5
Compare
0fd2ad8 to
3ddd510
Compare
f72d84a to
3d3fa0c
Compare
3d3fa0c to
36fc7db
Compare
Summary
Now the loop spawns a task per account, up to
--max-concurrent-txsat a time. The task picks notes, executes, proves, submits, and returns what happened, also this loops does the writting.The scheduler doesn't hold anything in memory per account except which transactions it has submitted and not yet seen committed.
Changelog