compute blob tx KZG commitments once per test class#10095
Merged
macfarla merged 6 commits intobesu-eth:mainfrom Mar 24, 2026
Merged
compute blob tx KZG commitments once per test class#10095macfarla merged 6 commits intobesu-eth:mainfrom
macfarla merged 6 commits intobesu-eth:mainfrom
Conversation
The 4 blob transaction fields in AbstractTransactionPoolTestBase were instance fields, causing ~1980 native KZG JNI operations per test run of LegacyTransactionPoolGasPriceTest (3 calls × 6 blobs × 2 ops × 55 test instances). Each BlobTestFixture starts from byteValue=0x00, so all instances produced identical blob data. Make the 4 blob transaction fields static final, computed once at class load via private static factory methods. The existing instance methods are retained for TransactionPoolSaveRestoreTest which calls createBlobTransaction() at test-method time with the real blockGasLimit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces expensive native KZG JNI work in transaction pool tests by caching blob-transaction test fixtures at class-load time rather than per test instance.
Changes:
- Converted blob-related transaction fixtures from instance fields to
static finalfields computed once. - Introduced private static factory methods for creating the cached blob transactions.
- Switched instance-time blob transaction creation to use a shared
static final BlobTestFixture.
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Show resolved
Hide resolved
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Outdated
Show resolved
Hide resolved
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Outdated
Show resolved
Hide resolved
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Show resolved
Hide resolved
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Show resolved
Hide resolved
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Show resolved
Hide resolved
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Show resolved
Hide resolved
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Show resolved
Hide resolved
...est/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java
Show resolved
Hide resolved
…thods The instance methods createBlobTransaction and createReplacementTransactionWithBlobs were updated to use the shared static BLOB_TEST_FIXTURE, which introduces order-dependent test behaviour and thread-safety concerns for tests that call these methods at test-run time (e.g. TransactionPoolSaveRestoreTest). Use a fresh BlobTestFixture per call in the instance methods instead. The fixture itself is cheap to construct (no KZG work); only the createBlobsWithCommitments call does native KZG computation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
…esu into optimiz-tx-pool-blob-fixtures
Contributor
Author
|
old time: new time: and there are 4 classes that extend from this same Abstract class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 4 blob transaction fields in AbstractTransactionPoolTestBase were instance fields, causing ~1980 native KZG JNI operations per test run of LegacyTransactionPoolGasPriceTest (3 calls × 6 blobs × 2 ops × 55 test instances). Each BlobTestFixture starts from byteValue=0x00, so all instances produced identical blob data.
Make the 4 blob transaction fields static final, computed once at class load via private static factory methods. The existing instance methods are retained for TransactionPoolSaveRestoreTest which calls createBlobTransaction() at test-method time with the real blockGasLimit.
AbstractTransactionPoolTestBase.java
Net effect: 1,980 native KZG JNI operations per test run → 36.
Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build