Skip to content

Conversation

@mirgee
Copy link
Contributor

@mirgee mirgee commented Dec 4, 2025

Adds --Xbal-perfect-parallelization-enabled config flag, enabled by default, which activates BAL-based perfect parallelization of transaction execution.

Adds a new interface, ParallelBlockTransactionProcessor, implemented by ParallelizedConcurrentTransactionProcessor (optimistic parallelization) and BalConcurrentTransactionProcessor (BAL-based parallelization), and used by ParallelTransactionPreprocessing to launch parallel block (pre)processing, which returns PreprocessingContext (unified for both processing types) currently containing only reference to the ParallelBlockTransactionProcessor used to obtain the transaction processing results later.

BalConcurrentTransactionProcessor launches and manages the futures processing individual transactions in the background. At the beginning of transaction processing, the prestate is loaded by applying corresponding state changes from the BAL. When the transaction processing result is ready, the state changes are imported to the block's accumulator in the main thread. Some categories of (pre)processing failures result in fallback to sequential processing.

The AbstractBlockProcessor trusts that the presence of absence of BALs in the block's body was validated before processBlock was called, and then uses the BALs if they are present, and, based on configuration, falls back to optimistic parallel or sequential processing. This is because the block may still be valid even if BALs are active and BAL is missing from the block body, e.g. in case of replaying a block older than BAL retention period.

These changes were tested by running a local devnet with spamoor and tx_fuzz, and it was verified all transactions are executed in parallel without conflicts.

An optional fail-fast transaction-wise validation of PartialBlockAccessListViews from TransactionProcessingResults against the blocks BlockAccessList (validating execution matches BAL) will be added separately, as well as BAL-based batch read prefetching.

Resolves #9079 .

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
…y `PreprocessingContext`, use single preprocessor

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee force-pushed the bal-perfect-parallel branch from 527422d to b2aafc3 Compare December 8, 2025 14:11
…mplementations

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
…or implementations

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee requested a review from matkt December 9, 2025 06:57
Copy link
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

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

really like the new implementation

@mirgee mirgee requested a review from matkt December 10, 2025 07:12
Copy link
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

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

LGTM, if we can just add tests for BALL //. I will run some nodes on mainnet with this PR to be sure we don't have any regression in the // part

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee requested a review from matkt December 11, 2025 07:26
@mirgee mirgee force-pushed the bal-perfect-parallel branch from 0f1c2c9 to 56b9830 Compare December 11, 2025 07:29
…plementation

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee force-pushed the bal-perfect-parallel branch 2 times, most recently from 263baec to f4f1d46 Compare December 11, 2025 08:49
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee force-pushed the bal-perfect-parallel branch from f4f1d46 to 9c08d04 Compare December 11, 2025 08:49
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>

public abstract class ParallelBlockTransactionProcessor {

protected CompletableFuture<ParallelizedTransactionContext>[] futures;
Copy link
Contributor

Choose a reason for hiding this comment

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

Java arrays are not thread safe. I would suggest using a ConcurrentHashMap with an Integer as an index.

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't a problem because we change each index separately. That's already how it's done in the current code. We'll never have the same index modified by multiple parts of the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should change it. Using a data structure that is not thread safe in a multi threaded environment can lead to inconsistent behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think adding synchronization where it's not necessary might impact performance. maybe not too much. It's not necessarily within the scope of this PR, but if Mirgee wants to change it, I'm not against it.

Copy link
Contributor

Choose a reason for hiding this comment

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

A ConcurrentHashMap does introduce some synchronization, but with fine-grained locking and reads are lock-free. The array can explain some of the edge cases where we still have errors on parallel transaction processing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is true that this would be a problem if multiple threads were modifying the array simultaneously, but in this case the array is always accessed exclusively by the main thread, so I don't see the need to use a synchronized data structure.

@mirgee mirgee requested review from ahamlat and matkt December 16, 2025 06:14
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee force-pushed the bal-perfect-parallel branch from e0f7e5a to db3cd34 Compare December 16, 2025 07:24
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
…el processing path

Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee force-pushed the bal-perfect-parallel branch from 0fd2a1d to 4aad685 Compare December 18, 2025 13:34
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@mirgee mirgee requested review from ahamlat and matkt December 19, 2025 08:38
Copy link
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

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

LGTM

@matkt matkt enabled auto-merge (squash) December 19, 2025 13:40
@matkt matkt merged commit a4de105 into hyperledger:main Dec 19, 2025
46 checks passed
@mirgee mirgee deleted the bal-perfect-parallel branch December 19, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Open PRs

Development

Successfully merging this pull request may close these issues.

EIP-7928 - Block-level Access Lists : Full Transaction Parallelization

3 participants