Skip to content

refactor: ntx builder start up#1610

Merged
Mirko-von-Leipzig merged 7 commits intonextfrom
santiagopittella-ntx-builder-initialization
Feb 2, 2026
Merged

refactor: ntx builder start up#1610
Mirko-von-Leipzig merged 7 commits intonextfrom
santiagopittella-ntx-builder-initialization

Conversation

@SantiagoPittella
Copy link
Collaborator

closes #1573

Refactors NTX Builder startup into distinct phases and introduces typed configuration.

  • Split NetworkTransactionBuilder initialization phases
  • Added NtxBuilderConfig struct

Regarding the new InitializedBuilder:

The initialize() method creates a gRPC subscription stream that needs to be stored for later use in run(). Rust's impl TryStream return types are opaque, causing lifetime errors when stored in a struct. Boxing the stream with Pin<Box<dyn Stream + 'static>> forces it to own its data, but this requires a separate struct to hold the boxed stream between initialization and execution. Couldn't thought of anything better cc @Mirko-von-Leipzig

@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-ntx-builder-initialization branch from 0cc662b to 7d9fdb9 Compare January 28, 2026 18:54
@SantiagoPittella SantiagoPittella force-pushed the santiagopittella-ntx-builder-initialization branch from 7d9fdb9 to bbe4d47 Compare January 28, 2026 19:07
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.

Looking good; will do another pass next week

@@ -77,6 +78,20 @@ pub struct NtxBuilderConfig {
pub script_cache_size: NonZeroUsize,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is more a thought experiment, but I wonder if we ever want to set this to zero? Seems unlikely, but that would effectively be the same as disabling it.

I think NonZero is used because that's what LRU requires, so we would have to do struct MyLru<T>(Option<Lru<T>>) which is a bit more work but not too much.

I kind of like the idea that we can disable caching e.g. for performance testing. wdyt? As a separate issue though, if anything. Could also easily be a YAGNI thing so maybe we just leave as is until we do need it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe to test performance of the underlaying implementation? Otherwise I don't see why we need that


impl NtxBuilderConfig {
/// Converts this CLI config into the ntx-builder's internal config.
pub fn into_builder_config(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bit confusing with the stuttering builder/builder naming, but that's not this PRs fault. We should come up with something better than network transaction builder..

Maybe network transaction..

  • producer
  • service
  • component (bleh)
  • handler
  • .. hm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I agree. We tend to use a lot the builder pattern so it is a bit confusing. I like both "producer" and "service", and even "consumer". I'll create a separate issue to discuss and rename the component since it touches too many files for this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I opened #1620

SantiagoPittella and others added 2 commits January 30, 2026 12:06
Co-authored-by: Mirko <48352201+Mirko-von-Leipzig@users.noreply.github.com>
@Mirko-von-Leipzig Mirko-von-Leipzig merged commit ce05e7a into next Feb 2, 2026
7 checks passed
@Mirko-von-Leipzig Mirko-von-Leipzig deleted the santiagopittella-ntx-builder-initialization branch February 2, 2026 11:19
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.

Improve ntx builder start up

3 participants