Skip to content

feat(p2p): tx validation cache#22998

Closed
fcarreiro wants to merge 1 commit into
merge-train/spartanfrom
fc/tx-validation-cache
Closed

feat(p2p): tx validation cache#22998
fcarreiro wants to merge 1 commit into
merge-train/spartanfrom
fc/tx-validation-cache

Conversation

@fcarreiro
Copy link
Copy Markdown
Contributor

@fcarreiro fcarreiro commented May 6, 2026

  • Creates a TxValidationCache that holds validation results and acts in an LRU manner for eviction.
  • The cache is then used by a CachedTxValidator which wraps an inner validator.
  • Expensive low-level validators are explicitly cached (Proof, TxData).
  • One aggregate validator is also cached at that level. The other aggregate validators shouldn't be cached because they are state-dependent.
  • Cache can be disabled by setting P2P_TX_VALIDATION_CACHE_SIZE to 0. Just in case, you know, not that I would introduce any bug.

Note that proof verification batching is done at the BB level and therefore is orthogonal to this.

Closes https://linear.app/aztec-labs/issue/A-934/dont-repeatedly-verify-retrieved-transactions .

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fcarreiro fcarreiro force-pushed the fc/tx-validation-cache branch 2 times, most recently from edcb0f0 to 8565228 Compare May 6, 2026 19:07
@fcarreiro fcarreiro marked this pull request as ready for review May 6, 2026 19:12
@fcarreiro fcarreiro force-pushed the fc/tx-validation-cache branch from 8565228 to d253021 Compare May 6, 2026 19:18
@fcarreiro fcarreiro force-pushed the fc/tx-validation-cache branch from d253021 to 4b5a440 Compare May 6, 2026 19:26
): Promise<TxValidationResult>;
}

/** Node in the doubly-linked list used for LRU ordering. Head = least recent, tail = most recent. */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wouldn't mind simplifying and using some kind of FIFO eviction order with just a list, if I can come up with it, instead of a self-made linked list (even if it was done by Claude). For a big enough cache size it should be ok. WDYT?

#log: Logger;

private readonly values = new Map<string, Promise<TxValidationResult>>();
private readonly nodes = new Map<string, LruNode>();
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.

Could we break this out into something re-usable in foundation? We already have an LruSet in foundation/collection.

@fcarreiro
Copy link
Copy Markdown
Contributor Author

Superseded by #23377 .

@fcarreiro fcarreiro closed this May 19, 2026
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