Skip to content

Conversation

@sergerad
Copy link
Collaborator

@sergerad sergerad commented Nov 3, 2025

Context

There is an edge case whereby transactions that relate to not yet existent network accounts are never processed by the NTB. See #1317.

Closes #1317.

No changelog as this is being merged into tracking branch.

Changes

  • Move mempool events to Arc to reduce cost of cloning.
  • Update NTB Coordinator to determine which actors should receive which events rather than broadcasting to all.
  • Update NTB Coordinator to keep track of mempool events with transactions that predate corresponding network accounts.

// Cache notes that predate corresponding accounts if there are any.
if let Ok(prefix) = NetworkAccountPrefix::try_from(account_delta.id()) {
self.coordinator.cache_predating_events(prefix, &event, id);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bobbinth this is probably not sufficient. I suppose I need to search the prefixes involved within every note of the transaction? Not just the one pertaining to the account delta?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, in fact, I don't think the account from account delta is relevant in this context. Basically, for every transaction we need to get a list of output notes (we only care about network notes addressed to a single account), and then route them to their respective accounts. The notes that remain "unassigned" after this process should be treated separately (i.e., put into some pool from which they can be assigned to an account if/when it gets created).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The model we have right now is that we broadcast every event to the actors. Initially we did instead filter out irrelevant actors but we removed that logic for some reason (lost in sea of resolved comments in first PR).

This commit shows the logic we removed. Essentially:

    fn find_affected_accounts(
        account_delta: Option<&AccountUpdateDetails>,
        network_notes: &[NetworkNote],
    ) -> HashSet<NetworkAccountPrefix> {

We might want to go back to this both for this PR and in the future if we decide to only spawn ephemeral tasks rather than keeping a task around for every actor.

@sergerad sergerad changed the title Sergerad note predate account feat: NTX Actor support for notes that predate account creation Nov 3, 2025
@sergerad sergerad requested a review from bobbinth November 6, 2025 00:31
@sergerad sergerad marked this pull request as ready for review November 10, 2025 06:13
@sergerad sergerad added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Nov 10, 2025
Copy link
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

Not a full review, but one issue I did pick up which needs thinking about

Copy link
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

I think this works.

I would like us to work on simplifying the overall flow somehow. I've been thinking about what assumptions we can make to do this and I have an idea I'll write up soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants