Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layered Transaction Pool #5290

Merged
merged 178 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 162 commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
c848491
Introduce experimental layered transaction pool
fab-10 Dec 21, 2022
9aabb1f
new Xlayered-tx-pool flag to enabled the new tx pool
fab-10 Dec 22, 2022
145b648
Move pending transaction sorter tests in the sorter folder
fab-10 Dec 22, 2022
e971cd7
Unit tests for new and old transaction pool
fab-10 Dec 22, 2022
ccd62a6
Fix: do not decrease size when promoting ready txs
fab-10 Dec 23, 2022
0eef31e
Fix: remove tx from orderByFee when replaced
fab-10 Dec 23, 2022
f0f4ca4
Fix: decrease size when removing confirmed txs
fab-10 Dec 23, 2022
748153e
Fix: always recreate orderByFee for London fee market
fab-10 Dec 23, 2022
e966c70
Fix: transaction removal counter when txs added to block
fab-10 Dec 23, 2022
c14e3fd
Fix: update expected nonce when demoting a prioritized transaction
fab-10 Dec 23, 2022
5fa1603
Fix: correctly remove expected nonce entry when removing the last pri…
fab-10 Dec 24, 2022
e2d1c2c
Fix NullPointerException when the replaced tx is not prioritized
fab-10 Jan 9, 2023
47386b0
Replace postponed with spare transactions
fab-10 Jan 11, 2023
ed3036e
Merge branch 'main' into txpoolng-spare
fab-10 Jan 11, 2023
d448c6a
WIP
fab-10 Jan 11, 2023
019132e
WIP
fab-10 Jan 11, 2023
4fe3b7d
Merge branch 'main' into txpoolng-spare
fab-10 Jan 12, 2023
9437ec3
Fix merge from main
fab-10 Jan 12, 2023
61c9819
Fixed most tests
fab-10 Jan 12, 2023
b423be4
Fix more tests
fab-10 Jan 12, 2023
b9e65d9
Rename and reorg some classes
fab-10 Jan 13, 2023
797734e
More renaming and code clean up
fab-10 Jan 15, 2023
05e24da
Refactor transaction pool metrics
fab-10 Jan 15, 2023
c4e124e
Stats log refined
fab-10 Jan 16, 2023
874c277
Cleanup unit tests
fab-10 Jan 16, 2023
96e5c08
Merge branch 'main' into txpoolng-spare
fab-10 Jan 16, 2023
19edef4
Improve stats log
fab-10 Jan 16, 2023
2ae9150
Merge branch 'main' into txpoolng-spare
fab-10 Jan 17, 2023
22b1c5c
Merge branch 'main' into txpoolng-spare
fab-10 Jan 18, 2023
f06cc1e
Remove unnecessary test parameters
fab-10 Jan 18, 2023
fa564d9
Merge branch 'main' into txpoolng-spare
fab-10 Jan 18, 2023
93f10a4
Merge branch 'main' into txpoolng-spare
fab-10 Jan 19, 2023
c29f83f
Fix unit test
fab-10 Jan 19, 2023
1caecbd
Merge branch 'main' into txpoolng-spare
fab-10 Jan 20, 2023
86a7980
Merge branch 'main' into txpoolng-spare
fab-10 Jan 20, 2023
97cb031
Merge branch 'main' into txpoolng-spare
fab-10 Jan 23, 2023
40f2953
Merge branch 'main' into txpoolng-spare
fab-10 Jan 23, 2023
832acd8
Merge branch 'main' into txpoolng-spare
fab-10 Jan 24, 2023
8dbe0c2
Merge branch 'main' into txpoolng-spare
fab-10 Jan 25, 2023
d53e279
Cancel older block creation tasks upon receiving a new one
siladu Feb 3, 2023
dd07102
Merge branch 'main' into txpoolng-spare
fab-10 Feb 7, 2023
b8e51d9
Merge branch 'main' into txpoolng-spare
fab-10 Feb 20, 2023
3393742
Merge branch 'main' into txpoolng-spare
fab-10 Feb 21, 2023
4548610
Fixes to expected next nonce for sender
fab-10 Feb 21, 2023
6f51eb8
Fix promotion filter and use synchronized methods instead of blocks
fab-10 Feb 22, 2023
3694828
Merge branch 'main' into txpoolng-spare
fab-10 Feb 22, 2023
35bfd7f
Fix metrics concurrent access issue
fab-10 Feb 22, 2023
891f869
Fixes
fab-10 Feb 22, 2023
5b8116f
Configuration options for the layered txpool
fab-10 Feb 22, 2023
794df58
Use long instead of Instant for PendingTransaction add time
fab-10 Feb 22, 2023
3362bca
Fixes
fab-10 Feb 22, 2023
ed27cef
Move layered txpool clasess in a dedicated package
fab-10 Feb 22, 2023
0fabe80
Fixes
fab-10 Feb 22, 2023
258396a
WIP
fab-10 Feb 22, 2023
b00d2b0
Remove confirmed transaction from sparse set too
fab-10 Feb 23, 2023
2a0c64c
Merge branch 'main' into txpoolng-spare
fab-10 Feb 23, 2023
1f3accd
Merge branch 'txpoolng-spare' into layered-txpool
fab-10 Feb 24, 2023
0143b27
WIP
fab-10 Feb 27, 2023
0a1b15f
WIP
fab-10 Feb 27, 2023
d7426d4
Fill gap on added tx
fab-10 Mar 2, 2023
8a30dcf
Fix eviction on sparse layer
fab-10 Mar 2, 2023
c8a575d
Merge branch 'main' into layered-txpool
fab-10 Mar 3, 2023
972b15b
Fix remove from ready layer
fab-10 Mar 3, 2023
c7f18fa
Fix remove from sparse layer
fab-10 Mar 3, 2023
cabbbc7
Fix for block added and confirmed txs
fab-10 Mar 3, 2023
1635bcf
Merge branch 'main' into layered-txpool
fab-10 Mar 5, 2023
9374afe
Fixes to sparse layer
fab-10 Mar 5, 2023
cefb91d
Merge branch 'main' into layered-txpool
fab-10 Mar 8, 2023
d842afa
Fix the filling of the gap when adding transactions
fab-10 Mar 8, 2023
e72218b
Layered pending transactions test and fixes
fab-10 Mar 8, 2023
2448472
Merge branch 'main' into layered-txpool
fab-10 Mar 9, 2023
6f0d10e
Distinguish between layer and comulative space used
fab-10 Mar 9, 2023
6e3863a
unit tests for expected next nonce for sender
fab-10 Mar 9, 2023
fbf45c1
Adding test for transaction selection
fab-10 Mar 9, 2023
9bb5bc2
Re-enable prioritized transaction tests and more fixes
fab-10 Mar 9, 2023
b1f9724
Merge branch 'main' into layered-txpool
fab-10 Mar 10, 2023
99d244d
log stats
fab-10 Mar 10, 2023
a1b581c
syncronized some methods, metrics update and dump transactions for re…
fab-10 Mar 10, 2023
fe302a6
Merge branch 'main' into layered-txpool
fab-10 Mar 13, 2023
415c8e9
Test that replay tx and fix for tx replacement across layers
fab-10 Mar 13, 2023
0f6e753
Merge branch 'main' into layered-txpool
fab-10 Mar 14, 2023
f0777d2
Add missing copyright and fix replay test
fab-10 Mar 14, 2023
b14b145
Add consistency check asserts
fab-10 Mar 14, 2023
471d549
Fix ready internalRemove
fab-10 Mar 14, 2023
cce108d
Metrics tests improvements
fab-10 Mar 15, 2023
0edb5c3
WIP: Transaction memory size estimation
fab-10 Mar 16, 2023
35341b1
Merge branch 'main' into layered-txpool
fab-10 Mar 17, 2023
5e73642
Complete pending transaction memory used computation
fab-10 Mar 17, 2023
d29bc72
Improve metrics
fab-10 Mar 17, 2023
283391c
Rename to specify that the limit is per layer
fab-10 Mar 17, 2023
f2788af
Update metric names in tests
fab-10 Mar 17, 2023
cb0c421
Adjust tx layer max capacity according to new tx memory size calculation
fab-10 Mar 17, 2023
78e05e8
Fix legacy transaction expiration tests
fab-10 Mar 17, 2023
b8c3f85
Fix IndexOutOfBoundsException in sparse layer
fab-10 Mar 20, 2023
e07ee59
Unique senders metric
fab-10 Mar 20, 2023
32b6371
Ignore ReplayTest by default, fix logging of stats
fab-10 Mar 20, 2023
ddcaf96
Log for replay renamings
fab-10 Mar 20, 2023
f0a5811
Document howto generate txpool replay
fab-10 Mar 20, 2023
30228bd
Merge branch 'main' into layered-txpool
fab-10 Mar 21, 2023
665579a
Reduce max layer capacity
fab-10 Mar 21, 2023
3b7ea28
exclude transaction replay resource
fab-10 Mar 21, 2023
96c428b
Improve compareByFee when effectivePriorityFee is 0
fab-10 Mar 21, 2023
b066a6e
More debug logs during transaction selection for a block
fab-10 Mar 22, 2023
cd559bf
Merge branch 'main' into layered-txpool
fab-10 Mar 22, 2023
a7ffd23
Merge branch 'main' into cancel-previous-proposal
fab-10 Mar 22, 2023
bd3a7f4
Use only one thread for building blocks so there is no risk of overla…
fab-10 Mar 22, 2023
d5095ef
Merge branch 'cancel-previous-proposal' into layered-txpool
fab-10 Mar 22, 2023
08d1d55
Improve transaction trace log making wei human readable
fab-10 Mar 23, 2023
a1673b2
Merge branch 'main' into layered-txpool
fab-10 Mar 24, 2023
81b6e2c
Use List instead of Set when getting all pending transactions
fab-10 Mar 24, 2023
e6d07c3
More detailed log on adding remote txs
fab-10 Mar 24, 2023
51bd8b6
Execute transaction broadcast aysnc after adding them to the txpool
fab-10 Mar 24, 2023
6859df9
Merge branch 'main' into layered-txpool
fab-10 Mar 28, 2023
1e94f5d
Log time taken to add remote txs before their broadcast
fab-10 Mar 28, 2023
abc84a5
Merge branch 'main' into layered-txpool
fab-10 Mar 29, 2023
3df503f
Merge branch 'main' into layered-txpool
fab-10 Mar 31, 2023
0c7e92f
Fix test
fab-10 Mar 31, 2023
dcb827e
Add missing header
fab-10 Mar 31, 2023
0f8acd5
Fix unit tests
fab-10 Apr 2, 2023
5d7aa03
Merge branch 'main' into layered-txpool
fab-10 Apr 3, 2023
5bcf462
Add CHANGELOG entry
fab-10 Apr 3, 2023
277d0ec
Delete unneeded file
fab-10 Apr 3, 2023
7c2ee91
Merge branch 'main' into layered-txpool
fab-10 Apr 4, 2023
b4a99ed
Merge branch 'main' into layered-txpool
fab-10 Apr 5, 2023
a6ba009
Merge branch 'main' into layered-txpool
fab-10 Apr 5, 2023
da84a62
Rename some layered txpool metrics to avoid conflict with existing me…
fab-10 Apr 5, 2023
6c0e861
Merge branch 'main' into layered-txpool
fab-10 Apr 7, 2023
145bad5
Fix pushing to next layers txs following an invalid one
fab-10 Apr 7, 2023
0cfa8d7
In case of an unexpected error, log more data and do a consistency check
fab-10 Apr 7, 2023
1736a24
Merge branch 'main' into layered-txpool
fab-10 Apr 11, 2023
735cb42
Fix null check on wrong var
fab-10 Apr 13, 2023
672fda9
Merge branch 'main' into layered-txpool
fab-10 Apr 13, 2023
71f8ef8
Merge branch 'main' into layered-txpool
fab-10 Apr 17, 2023
a757b37
Fix some codeql alerts
fab-10 Apr 17, 2023
3571a55
Fix sparse gap calculation when invalidating
fab-10 Apr 18, 2023
879c97c
Merge branch 'main' into layered-txpool
fab-10 Apr 18, 2023
94bc6be
Apply suggestions from doce review
fab-10 Apr 18, 2023
7b5edf3
Merge branch 'main' into layered-txpool
fab-10 Apr 19, 2023
f78fd04
Only trigger consistency check if trace log is enable in case of unex…
fab-10 Apr 19, 2023
fca36d9
Fix replay of blocks with no transactions
fab-10 Apr 19, 2023
3b3690a
Fix for negative gap when there is a reorg
fab-10 Apr 19, 2023
fe0fb97
Merge branch 'main' into layered-txpool
fab-10 Apr 20, 2023
1dc2187
Implement code review suggestions
fab-10 Apr 20, 2023
56fcd56
Fix for a case when deleting tx with zero gap in sparse layer
fab-10 Apr 20, 2023
8a71560
Delete redoundant tests
fab-10 Apr 20, 2023
28e76d8
Update CHANGELOG.md
fab-10 Apr 26, 2023
5d8e716
Update ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/t…
fab-10 Apr 26, 2023
536fb4a
Update ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/t…
fab-10 Apr 26, 2023
be0b21c
Update ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/t…
fab-10 Apr 26, 2023
4d7e271
Update ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/t…
fab-10 Apr 26, 2023
55babc4
Update ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/t…
fab-10 Apr 26, 2023
dd7aef5
Update besu/src/main/java/org/hyperledger/besu/cli/options/unstable/T…
fab-10 Apr 26, 2023
145d2ca
Update besu/src/main/java/org/hyperledger/besu/cli/options/unstable/T…
fab-10 Apr 26, 2023
fffd537
Address code review suggestions
fab-10 Apr 26, 2023
8d6d3d7
Merge branch 'main' into layered-txpool
fab-10 Apr 26, 2023
5064a45
Improve logSender when there are no sparse txs
fab-10 Apr 26, 2023
4cddd61
Fix off by one error
fab-10 Apr 27, 2023
ceee4ee
Update ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/t…
fab-10 Apr 27, 2023
195f7b5
Address code review suggestions
fab-10 Apr 27, 2023
c07ff09
Merge branch 'layered-txpool' of github.com:fab-10/besu into layered-…
fab-10 Apr 27, 2023
a14fd0d
Rename fix
fab-10 Apr 27, 2023
f71f0d9
Merge branch 'main' into layered-txpool
garyschulte Apr 28, 2023
5359f3e
Simplify the way reorgs are handled, by detecting a negative gap and …
fab-10 Apr 28, 2023
c7d72bd
Merge branch 'main' into layered-txpool
fab-10 Apr 28, 2023
71e2cf7
Merge branch 'layered-txpool' of github.com:fab-10/besu into layered-…
fab-10 Apr 28, 2023
099d12c
Merge branch 'main' into layered-txpool
garyschulte Apr 28, 2023
44af2ae
Merge branch 'main' into layered-txpool
fab-10 May 2, 2023
e9a4127
Do not run consistency check on internal error since it is too expens…
fab-10 May 2, 2023
accd498
Merge branch 'layered-txpool' of github.com:fab-10/besu into layered-…
fab-10 May 2, 2023
ba71304
Remove invalid txs after the selection is complete to avoid Concurren…
fab-10 May 2, 2023
414de9b
Merge branch 'main' into layered-txpool
macfarla May 3, 2023
00ac64f
Merge branch 'main' into layered-txpool
macfarla May 4, 2023
d5b28bc
Merge branch 'main' into layered-txpool
fab-10 May 4, 2023
de0402e
Update txpool defaults
fab-10 May 4, 2023
dd77949
Merge branch 'main' into layered-txpool
fab-10 May 5, 2023
7d28a93
Tune default
fab-10 May 5, 2023
c19e3f1
Fix merge
fab-10 May 5, 2023
01f1825
Merge branch 'main' into layered-txpool
fab-10 May 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*~.nib
*.iml
*.launch
*.swp
Copy link
Contributor

Choose a reason for hiding this comment

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

accidental commit?

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 a dupe of line 2

*.log
.classpath
.DS_Store
Expand All @@ -29,4 +28,5 @@ site/
/kubernetes/reports/
/kubernetes/besu-*.tar.gz
**/src/*/generated
jitpack.yml
jitpack.yml
/ethereum/eth/src/test/resources/tx.csv.gz
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Breaking Changes

### Additions and Improvements
- Early access - layered transaction pool implementation [#5290](https://github.com/hyperledger/besu/pull/5290)

### Bug Fixes

Expand Down
3 changes: 2 additions & 1 deletion besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,8 @@ static class TxPoolOptionGroup {
description =
"Maximum number of pending transactions that will be kept in the transaction pool (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer txPoolMaxSize = TransactionPoolConfiguration.MAX_PENDING_TRANSACTIONS;
private final Integer txPoolMaxSize =
TransactionPoolConfiguration.DEFAULT_MAX_PENDING_TRANSACTIONS;

@Option(
names = {"--tx-pool-retention-hours"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@
import java.util.Arrays;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine;

/** The Transaction pool Cli options. */
public class TransactionPoolOptions
implements CLIOptions<ImmutableTransactionPoolConfiguration.Builder> {
private static final Logger LOG = LoggerFactory.getLogger(TransactionPoolOptions.class);

private static final String TX_MESSAGE_KEEP_ALIVE_SEC_FLAG =
"--Xincoming-tx-messages-keep-alive-seconds";

Expand All @@ -41,6 +45,14 @@ public class TransactionPoolOptions
private static final String TX_POOL_LIMIT_BY_ACCOUNT_PERCENTAGE =
"--tx-pool-limit-by-account-percentage";

private static final String LAYERED_TX_POOL_ENABLED_FLAG = "--Xlayered-tx-pool";
private static final String LAYERED_TX_POOL_LAYER_MAX_CAPACITY =
"--Xlayered-tx-pool-layer-max-capacity";
private static final String LAYERED_TX_POOL_MAX_PRIORITIZED =
"--Xlayered-tx-pool-max-prioritized";
private static final String LAYERED_TX_POOL_MAX_FUTURE_BY_SENDER =
"--Xlayered-tx-pool-max-future-by-sender";

@CommandLine.Option(
names = {STRICT_TX_REPLAY_PROTECTION_ENABLED_FLAG},
paramLabel = "<Boolean>",
Expand Down Expand Up @@ -78,7 +90,46 @@ public class TransactionPoolOptions
"Maximum portion of the transaction pool which a single account may occupy with future transactions (default: ${DEFAULT-VALUE})",
arity = "1")
private Float txPoolLimitByAccountPercentage =
TransactionPoolConfiguration.LIMIT_TXPOOL_BY_ACCOUNT_PERCENTAGE;
TransactionPoolConfiguration.DEFAULT_LIMIT_TX_POOL_BY_ACCOUNT_PERCENTAGE;

@CommandLine.Option(
names = {LAYERED_TX_POOL_ENABLED_FLAG},
paramLabel = "<Boolean>",
hidden = true,
description = "Enable the Layered Transaction Pool (default: ${DEFAULT-VALUE})",
arity = "0..1")
private Boolean layeredTxPoolEnabled =
TransactionPoolConfiguration.DEFAULT_LAYERED_TX_POOL_ENABLED;

@CommandLine.Option(
names = {LAYERED_TX_POOL_LAYER_MAX_CAPACITY},
paramLabel = "<Long>",
hidden = true,
description =
"Max amount of memory space, in bytes, that any layer within the transaction pool could occupy (default: ${DEFAULT-VALUE})",
arity = "1")
private long layeredTxPoolLayerMaxCapacity =
TransactionPoolConfiguration.DEFAULT_PENDING_TRANSACTIONS_LAYER_MAX_CAPACITY_BYTES;

@CommandLine.Option(
names = {LAYERED_TX_POOL_MAX_PRIORITIZED},
paramLabel = "<Int>",
hidden = true,
description =
"Max number of pending transactions that are prioritized and thus kept sorted (default: ${DEFAULT-VALUE})",
arity = "1")
private int layeredTxPoolMaxPrioritized =
TransactionPoolConfiguration.DEFAULT_MAX_PRIORITIZED_TRANSACTIONS;

@CommandLine.Option(
names = {LAYERED_TX_POOL_MAX_FUTURE_BY_SENDER},
paramLabel = "<Int>",
hidden = true,
description =
"Max number of future pending transactions allowed for a single sender (default: ${DEFAULT-VALUE})",
arity = "1")
private int layeredTxPoolMaxFutureBySender =
TransactionPoolConfiguration.DEFAULT_MAX_FUTURE_BY_SENDER;

private TransactionPoolOptions() {}

Expand All @@ -104,16 +155,30 @@ public static TransactionPoolOptions fromConfig(final TransactionPoolConfigurati
config.getEth65TrxAnnouncedBufferingPeriod().toMillis();
options.strictTxReplayProtectionEnabled = config.getStrictTransactionReplayProtectionEnabled();
options.txPoolLimitByAccountPercentage = config.getTxPoolLimitByAccountPercentage();
options.layeredTxPoolEnabled = config.getLayeredTxPoolEnabled();
options.layeredTxPoolLayerMaxCapacity = config.getPendingTransactionsLayerMaxCapacityBytes();
options.layeredTxPoolMaxPrioritized = config.getMaxPrioritizedTransactions();
options.layeredTxPoolMaxFutureBySender = config.getMaxFutureBySender();
return options;
}

@Override
public ImmutableTransactionPoolConfiguration.Builder toDomainObject() {
if (layeredTxPoolEnabled) {
LOG.warn(
"Layered transaction pool enabled, ignoring settings for "
+ "--tx-pool-max-size and --tx-pool-limit-by-account-percentage");
}

return ImmutableTransactionPoolConfiguration.builder()
.strictTransactionReplayProtectionEnabled(strictTxReplayProtectionEnabled)
.txMessageKeepAliveSeconds(txMessageKeepAliveSeconds)
.eth65TrxAnnouncedBufferingPeriod(Duration.ofMillis(eth65TrxAnnouncedBufferingPeriod))
.txPoolLimitByAccountPercentage(txPoolLimitByAccountPercentage);
.txPoolLimitByAccountPercentage(txPoolLimitByAccountPercentage)
.layeredTxPoolEnabled(layeredTxPoolEnabled)
.pendingTransactionsLayerMaxCapacityBytes(layeredTxPoolLayerMaxCapacity)
.maxPrioritizedTransactions(layeredTxPoolMaxPrioritized)
.maxFutureBySender(layeredTxPoolMaxFutureBySender);
}

@Override
Expand All @@ -125,6 +190,13 @@ public List<String> getCLIOptions() {
TX_MESSAGE_KEEP_ALIVE_SEC_FLAG,
OptionParser.format(txMessageKeepAliveSeconds),
ETH65_TX_ANNOUNCED_BUFFERING_PERIOD_FLAG,
OptionParser.format(eth65TrxAnnouncedBufferingPeriod));
OptionParser.format(eth65TrxAnnouncedBufferingPeriod),
LAYERED_TX_POOL_ENABLED_FLAG + "=" + layeredTxPoolEnabled,
LAYERED_TX_POOL_LAYER_MAX_CAPACITY,
OptionParser.format(layeredTxPoolLayerMaxCapacity),
LAYERED_TX_POOL_MAX_PRIORITIZED,
OptionParser.format(layeredTxPoolMaxPrioritized),
LAYERED_TX_POOL_MAX_FUTURE_BY_SENDER,
OptionParser.format(layeredTxPoolMaxFutureBySender));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.LIMIT_TXPOOL_BY_ACCOUNT_PERCENTAGE;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.DEFAULT_LIMIT_TX_POOL_BY_ACCOUNT_PERCENTAGE;

import org.hyperledger.besu.cli.options.unstable.TransactionPoolOptions;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
Expand Down Expand Up @@ -100,7 +100,7 @@ public void senderLimitedTxPoolCeiling_violated() {
final TransactionPoolOptions options = getOptionsFromBesuCommand(cmd);
final TransactionPoolConfiguration config = options.toDomainObject().build();
assertThat(config.getTxPoolLimitByAccountPercentage())
.isEqualTo(LIMIT_TXPOOL_BY_ACCOUNT_PERCENTAGE);
.isEqualTo(DEFAULT_LIMIT_TX_POOL_BY_ACCOUNT_PERCENTAGE);

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
Expand Down Expand Up @@ -160,7 +160,12 @@ ImmutableTransactionPoolConfiguration.Builder createDefaultDomainObject() {
.strictTransactionReplayProtectionEnabled(false)
.txMessageKeepAliveSeconds(defaultValue.getTxMessageKeepAliveSeconds())
.eth65TrxAnnouncedBufferingPeriod(defaultValue.getEth65TrxAnnouncedBufferingPeriod())
.txPoolLimitByAccountPercentage(defaultValue.getTxPoolLimitByAccountPercentage());
.txPoolLimitByAccountPercentage(defaultValue.getTxPoolLimitByAccountPercentage())
.layeredTxPoolEnabled(defaultValue.getLayeredTxPoolEnabled())
.pendingTransactionsLayerMaxCapacityBytes(
defaultValue.getPendingTransactionsLayerMaxCapacityBytes())
.maxPrioritizedTransactions(defaultValue.getMaxPrioritizedTransactions())
.maxFutureBySender(defaultValue.getMaxFutureBySender());
}

@Override
Expand All @@ -171,7 +176,11 @@ ImmutableTransactionPoolConfiguration.Builder createCustomizedDomainObject() {
.eth65TrxAnnouncedBufferingPeriod(
TransactionPoolConfiguration.ETH65_TRX_ANNOUNCED_BUFFERING_PERIOD.plus(
Duration.ofMillis(100)))
.txPoolLimitByAccountPercentage(0.5f);
.txPoolLimitByAccountPercentage(0.5f)
.layeredTxPoolEnabled(true)
.pendingTransactionsLayerMaxCapacityBytes(1_000_000L)
.maxPrioritizedTransactions(1000)
.maxFutureBySender(10);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionBroadcaster;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolMetrics;
import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTransactionsSorter;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.data.TransactionType;
Expand Down Expand Up @@ -84,7 +86,7 @@ public class EthGetFilterChangesIntegrationTest {
private TransactionPool transactionPool;
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();

private GasPricePendingTransactionsSorter transactions;
private PendingTransactions transactions;

private static final int MAX_TRANSACTIONS = 5;
private static final KeyPair keyPair = SignatureAlgorithmFactory.getInstance().generateKeyPair();
Expand Down Expand Up @@ -116,7 +118,7 @@ public void setUp() {
batchAddedListener,
ethContext,
new MiningParameters.Builder().minTransactionGasPrice(Wei.ZERO).build(),
metricsSystem,
new TransactionPoolMetrics(metricsSystem),
TransactionPoolConfiguration.DEFAULT);
final BlockchainQueries blockchainQueries =
new BlockchainQueries(blockchain, protocolContext.getWorldStateArchive());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionBroadcaster;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolMetrics;
import org.hyperledger.besu.ethereum.eth.transactions.sorter.BaseFeePendingTransactionsSorter;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.data.TransactionType;
Expand Down Expand Up @@ -84,7 +86,7 @@ public class EthGetFilterChangesIntegrationTest {
private TransactionPool transactionPool;
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();

private BaseFeePendingTransactionsSorter transactions;
private PendingTransactions transactions;

private static final int MAX_TRANSACTIONS = 5;
private static final KeyPair keyPair = SignatureAlgorithmFactory.getInstance().generateKeyPair();
Expand Down Expand Up @@ -116,7 +118,7 @@ public void setUp() {
batchAddedListener,
ethContext,
new MiningParameters.Builder().minTransactionGasPrice(Wei.ZERO).build(),
metricsSystem,
new TransactionPoolMetrics(metricsSystem),
TransactionPoolConfiguration.DEFAULT);
final BlockchainQueries blockchainQueries =
new BlockchainQueries(blockchain, protocolContext.getWorldStateArchive());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class TxPoolBesuPendingTransactions implements JsonRpcMethod {
Expand Down Expand Up @@ -56,7 +56,7 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
.map(PendingTransactionsParams::filters)
.orElse(Collections.emptyList());

final Set<Transaction> pendingTransactionsFiltered =
final Collection<Transaction> pendingTransactionsFiltered =
pendingTransactionFilter.reduce(
pendingTransactions.getPendingTransactions(), filters, limit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions;

import java.util.Set;
import java.util.Collection;

public class TxPoolBesuStatistics implements JsonRpcMethod {

Expand All @@ -43,7 +43,8 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
}

private PendingTransactionsStatisticsResult statistics() {
final Set<PendingTransaction> pendingTransaction = pendingTransactions.getPendingTransactions();
final Collection<PendingTransaction> pendingTransaction =
pendingTransactions.getPendingTransactions();
final long localCount =
pendingTransaction.stream().filter(PendingTransaction::isReceivedFromLocalSource).count();
final long remoteCount = pendingTransaction.size() - localCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PendingTransactionResult implements TransactionResult {
public PendingTransactionResult(final PendingTransaction pendingTransaction) {
hash = pendingTransaction.getHash().toString();
isReceivedFromLocalSource = pendingTransaction.isReceivedFromLocalSource();
addedToPoolAt = pendingTransaction.getAddedToPoolAt();
addedToPoolAt = Instant.ofEpochMilli(pendingTransaction.getAddedAt());
}

@JsonGetter(value = "hash")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@

import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;

import java.util.Set;
import java.util.stream.Collectors;
import java.util.Collection;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonValue;

public class PendingTransactionsResult implements TransactionResult {

private final Set<PendingTransactionResult> pendingTransactionResults;
private final List<PendingTransactionResult> pendingTransactionResults;

public PendingTransactionsResult(final Set<PendingTransaction> pendingTransactionSet) {
public PendingTransactionsResult(final Collection<PendingTransaction> pendingTransactionSet) {
pendingTransactionResults =
pendingTransactionSet.stream()
.map(PendingTransactionResult::new)
.collect(Collectors.toSet());
pendingTransactionSet.stream().map(PendingTransactionResult::new).toList();
}

@JsonValue
public Set<PendingTransactionResult> getResults() {
public List<PendingTransactionResult> getResults() {
return pendingTransactionResults;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

/**
* This class allows to filter a list of pending transactions
Expand All @@ -43,16 +42,16 @@ public class PendingTransactionFilter {
public static final String VALUE_FIELD = "value";
public static final String NONCE_FIELD = "nonce";

public Set<Transaction> reduce(
final Set<PendingTransaction> pendingTransactions,
public Collection<Transaction> reduce(
final Collection<PendingTransaction> pendingTransactions,
final List<Filter> filters,
final int limit)
throws InvalidJsonRpcParameters {
return pendingTransactions.stream()
.filter(pendingTx -> applyFilters(pendingTx, filters))
.limit(limit)
.map(PendingTransaction::getTransaction)
.collect(Collectors.toSet());
.toList();
}

private boolean applyFilters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.SubscriptionManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.SubscriptionType;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactionListener;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactionAddedListener;

import java.util.List;

public class PendingTransactionSubscriptionService implements PendingTransactionListener {
public class PendingTransactionSubscriptionService implements PendingTransactionAddedListener {

private final SubscriptionManager subscriptionManager;

Expand Down
Loading