Skip to content

refactor(ntx-builder): replace the account actors with a scheduler - #2585

Open
SantiagoPittella wants to merge 3 commits into
santiagopittella-ntx-extract-selectionfrom
santiagopittella-ntx-scheduler-swap
Open

SantiagoPittella wants to merge 3 commits into
santiagopittella-ntx-extract-selectionfrom
santiagopittella-ntx-scheduler-swap

Conversation

@SantiagoPittella

Copy link
Copy Markdown
Collaborator

Summary

Now the loop spawns a task per account, up to --max-concurrent-txs at 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

[[entry]]
scope       = "ntx-builder"
impact      = "breaking"
description = "Removed `--idle-timeout` and `--max-account-crashes`."

[[entry]]
scope       = "ntx-builder"
impact      = "added"
description = "Added `--max-concurrent-txs` to bound the number of network transactions computed concurrently."

[[entry]]
scope       = "ntx-builder"
impact      = "changed"
description = "Network transactions are now built by short-lived per-account attempts driven by the committed-block loop."

@SantiagoPittella
SantiagoPittella force-pushed the santiagopittella-ntx-scheduler-swap branch from c33fb3c to ccbc958 Compare September 7, 2026 14:18
@SantiagoPittella
SantiagoPittella force-pushed the santiagopittella-ntx-scheduler-swap branch from ccbc958 to 831b6f9 Compare September 8, 2026 13:33
@SantiagoPittella
SantiagoPittella force-pushed the santiagopittella-ntx-scheduler-swap branch from 831b6f9 to c5b29a1 Compare September 9, 2026 21:00
Comment thread bin/ntx-builder/src/attempt.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not a fan of attempt as a base name.

Perhaps something like NetworkTransactionContext and the current free standing functions could be methods?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good, addressed it in f72d84a

Comment thread bin/ntx-builder/src/scheduler.rs Outdated
Comment thread bin/ntx-builder/src/scheduler.rs Outdated
Comment thread bin/ntx-builder/src/scheduler.rs Outdated
Comment thread bin/ntx-builder/src/scheduler.rs Outdated
Comment on lines +294 to +298
pub async fn shutdown(&mut self) {
self.tasks.shutdown().await;
self.running.clear();
self.in_flight.clear();
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When is this called? I'm surprised this isn't shutdown(self), then no need to keep this re-useable afterwards.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

tokio;'s shutdown is also &mut so we just propagate it. This is called when a shutdown signal arrives

Comment thread bin/ntx-builder/src/scheduler.rs Outdated
Comment on lines +181 to +192
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;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This loop and cancellation check feel a bit weird?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Replaced it with a match

Comment thread bin/ntx-builder/src/scheduler.rs Outdated
Comment thread bin/ntx-builder/src/scheduler.rs Outdated
Comment on lines +263 to +264
// 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't quite understand why notes need to be corrected?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

@SantiagoPittella
SantiagoPittella force-pushed the santiagopittella-ntx-scheduler-swap branch from c5b29a1 to 14c5a4e Compare September 10, 2026 16:47
@SantiagoPittella
SantiagoPittella force-pushed the santiagopittella-ntx-scheduler-swap branch from 14c5a4e to d5adee5 Compare September 11, 2026 21:27
@SantiagoPittella
SantiagoPittella force-pushed the santiagopittella-ntx-scheduler-swap branch 2 times, most recently from 0fd2ad8 to 3ddd510 Compare September 17, 2026 14:30
@SantiagoPittella
SantiagoPittella force-pushed the santiagopittella-ntx-scheduler-swap branch 2 times, most recently from f72d84a to 3d3fa0c Compare September 21, 2026 12:11
@SantiagoPittella
SantiagoPittella force-pushed the santiagopittella-ntx-scheduler-swap branch from 3d3fa0c to 36fc7db Compare September 21, 2026 20:22

This branch has not been deployed

No deployments
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.

2 participants