4646import org .hyperledger .besu .chainimport .RlpBlockImporter ;
4747import org .hyperledger .besu .cli .config .EthNetworkConfig ;
4848import org .hyperledger .besu .cli .config .NetworkName ;
49- import org .hyperledger .besu .cli .converter .FractionConverter ;
5049import org .hyperledger .besu .cli .converter .MetricCategoryConverter ;
5150import org .hyperledger .besu .cli .converter .PercentageConverter ;
5251import org .hyperledger .besu .cli .custom .CorsAllowedOriginsProperty ;
5958import org .hyperledger .besu .cli .options .stable .LoggingLevelOption ;
6059import org .hyperledger .besu .cli .options .stable .NodePrivateKeyFileOption ;
6160import org .hyperledger .besu .cli .options .stable .P2PTLSConfigOptions ;
61+ import org .hyperledger .besu .cli .options .stable .TransactionPoolOptions ;
6262import org .hyperledger .besu .cli .options .unstable .ChainPruningOptions ;
6363import org .hyperledger .besu .cli .options .unstable .DnsOptions ;
6464import org .hyperledger .besu .cli .options .unstable .EthProtocolOptions ;
7373import org .hyperledger .besu .cli .options .unstable .PrivacyPluginOptions ;
7474import org .hyperledger .besu .cli .options .unstable .RPCOptions ;
7575import org .hyperledger .besu .cli .options .unstable .SynchronizerOptions ;
76- import org .hyperledger .besu .cli .options .unstable .TransactionPoolOptions ;
7776import org .hyperledger .besu .cli .presynctasks .PreSynchronizationTaskRunner ;
7877import org .hyperledger .besu .cli .presynctasks .PrivateDatabaseMigrationPreSyncTask ;
7978import org .hyperledger .besu .cli .subcommands .PasswordSubCommand ;
127126import org .hyperledger .besu .ethereum .core .PrivacyParameters ;
128127import org .hyperledger .besu .ethereum .eth .sync .SyncMode ;
129128import org .hyperledger .besu .ethereum .eth .sync .SynchronizerConfiguration ;
129+ import org .hyperledger .besu .ethereum .eth .transactions .ImmutableTransactionPoolConfiguration ;
130130import org .hyperledger .besu .ethereum .eth .transactions .TransactionPoolConfiguration ;
131131import org .hyperledger .besu .ethereum .mainnet .FrontierTargetingGasLimitCalculator ;
132132import org .hyperledger .besu .ethereum .p2p .config .DiscoveryConfiguration ;
@@ -280,7 +280,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
280280 final SynchronizerOptions unstableSynchronizerOptions = SynchronizerOptions .create ();
281281 final EthProtocolOptions unstableEthProtocolOptions = EthProtocolOptions .create ();
282282 final MetricsCLIOptions unstableMetricsCLIOptions = MetricsCLIOptions .create ();
283- final TransactionPoolOptions unstableTransactionPoolOptions = TransactionPoolOptions .create ();
283+ final org .hyperledger .besu .cli .options .unstable .TransactionPoolOptions
284+ unstableTransactionPoolOptions =
285+ org .hyperledger .besu .cli .options .unstable .TransactionPoolOptions .create ();
284286 private final DnsOptions unstableDnsOptions = DnsOptions .create ();
285287 private final MiningOptions unstableMiningOptions = MiningOptions .create ();
286288 private final NatOptions unstableNatOptions = NatOptions .create ();
@@ -298,6 +300,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
298300 NodePrivateKeyFileOption .create ();
299301 private final LoggingLevelOption loggingLevelOption = LoggingLevelOption .create ();
300302
303+ @ CommandLine .ArgGroup (validate = false , heading = "@|bold Tx Pool Common Options|@%n" )
304+ final org .hyperledger .besu .cli .options .stable .TransactionPoolOptions
305+ stableTransactionPoolOptions = TransactionPoolOptions .create ();
306+
301307 private final RunnerBuilder runnerBuilder ;
302308 private final BesuController .Builder controllerBuilderFactory ;
303309 private final BesuPluginContextImpl besuPluginContext ;
@@ -454,10 +460,8 @@ static class P2PDiscoveryOptionGroup {
454460 "The maximum percentage of P2P connections that can be initiated remotely. Must be between 0 and 100 inclusive. (default: ${DEFAULT-VALUE})" ,
455461 arity = "1" ,
456462 converter = PercentageConverter .class )
457- private final Integer maxRemoteConnectionsPercentage =
458- Fraction .fromFloat (DEFAULT_FRACTION_REMOTE_WIRE_CONNECTIONS_ALLOWED )
459- .toPercentage ()
460- .getValue ();
463+ private final Percentage maxRemoteConnectionsPercentage =
464+ Fraction .fromFloat (DEFAULT_FRACTION_REMOTE_WIRE_CONNECTIONS_ALLOWED ).toPercentage ();
461465
462466 @ SuppressWarnings ({"FieldCanBeFinal" , "FieldMayBeFinal" }) // PicoCLI requires non-final Strings.
463467 @ CommandLine .Option (
@@ -1111,13 +1115,6 @@ static class MinerOptionGroup {
11111115 arity = "1" )
11121116 private final Wei minTransactionGasPrice = DEFAULT_MIN_TRANSACTION_GAS_PRICE ;
11131117
1114- @ Option (
1115- names = {"--rpc-tx-feecap" },
1116- description =
1117- "Maximum transaction fees (in Wei) accepted for transaction submitted through RPC (default: ${DEFAULT-VALUE})" ,
1118- arity = "1" )
1119- private final Wei txFeeCap = DEFAULT_RPC_TX_FEE_CAP ;
1120-
11211118 @ Option (
11221119 names = {"--min-block-occupancy-ratio" },
11231120 description = "Minimum occupancy ratio for a mined block (default: ${DEFAULT-VALUE})" ,
@@ -1209,75 +1206,6 @@ static class PermissionsOptionGroup {
12091206 "Sets target gas limit per block. If set, each block's gas limit will approach this setting over time if the current gas limit is different." )
12101207 private final Long targetGasLimit = null ;
12111208
1212- // Tx Pool Option Group
1213- @ CommandLine .ArgGroup (validate = false , heading = "@|bold Tx Pool Options|@%n" )
1214- TxPoolOptionGroup txPoolOptionGroup = new TxPoolOptionGroup ();
1215-
1216- static class TxPoolOptionGroup {
1217- @ CommandLine .Option (
1218- names = {"--tx-pool-disable-locals" },
1219- paramLabel = "<Boolean>" ,
1220- description =
1221- "Set to true if transactions sent via RPC should have the same checks and not be prioritized over remote ones (default: ${DEFAULT-VALUE})" ,
1222- fallbackValue = "true" ,
1223- arity = "0..1" )
1224- private Boolean disableLocalTxs = TransactionPoolConfiguration .DEFAULT_DISABLE_LOCAL_TXS ;
1225-
1226- @ CommandLine .Option (
1227- names = {"--tx-pool-enable-save-restore" },
1228- paramLabel = "<Boolean>" ,
1229- description =
1230- "Set to true to enable saving the txpool content to file on shutdown and reloading it on startup (default: ${DEFAULT-VALUE})" ,
1231- fallbackValue = "true" ,
1232- arity = "0..1" )
1233- private Boolean saveRestoreEnabled = TransactionPoolConfiguration .DEFAULT_ENABLE_SAVE_RESTORE ;
1234-
1235- @ CommandLine .Option (
1236- names = {"--tx-pool-limit-by-account-percentage" },
1237- paramLabel = "<DOUBLE>" ,
1238- converter = FractionConverter .class ,
1239- description =
1240- "Maximum portion of the transaction pool which a single account may occupy with future transactions (default: ${DEFAULT-VALUE})" ,
1241- arity = "1" )
1242- private Float txPoolLimitByAccountPercentage =
1243- TransactionPoolConfiguration .DEFAULT_LIMIT_TX_POOL_BY_ACCOUNT_PERCENTAGE ;
1244-
1245- @ CommandLine .Option (
1246- names = {"--tx-pool-save-file" },
1247- paramLabel = "<STRING>" ,
1248- description =
1249- "If saving the txpool content is enabled, define a custom path for the save file (default: ${DEFAULT-VALUE} in the data-dir)" ,
1250- arity = "1" )
1251- private File saveFile = TransactionPoolConfiguration .DEFAULT_SAVE_FILE ;
1252-
1253- @ Option (
1254- names = {"--tx-pool-max-size" },
1255- paramLabel = MANDATORY_INTEGER_FORMAT_HELP ,
1256- description =
1257- "Maximum number of pending transactions that will be kept in the transaction pool (default: ${DEFAULT-VALUE})" ,
1258- arity = "1" )
1259- private final Integer txPoolMaxSize =
1260- TransactionPoolConfiguration .DEFAULT_MAX_PENDING_TRANSACTIONS ;
1261-
1262- @ Option (
1263- names = {"--tx-pool-retention-hours" },
1264- paramLabel = MANDATORY_INTEGER_FORMAT_HELP ,
1265- description =
1266- "Maximum retention period of pending transactions in hours (default: ${DEFAULT-VALUE})" ,
1267- arity = "1" )
1268- private final Integer pendingTxRetentionPeriod =
1269- TransactionPoolConfiguration .DEFAULT_TX_RETENTION_HOURS ;
1270-
1271- @ Option (
1272- names = {"--tx-pool-price-bump" },
1273- paramLabel = MANDATORY_INTEGER_FORMAT_HELP ,
1274- converter = PercentageConverter .class ,
1275- description =
1276- "Price bump percentage to replace an already existing transaction (default: ${DEFAULT-VALUE})" ,
1277- arity = "1" )
1278- private final Integer priceBump = TransactionPoolConfiguration .DEFAULT_PRICE_BUMP .getValue ();
1279- }
1280-
12811209 @ SuppressWarnings ({"FieldCanBeFinal" , "FieldMayBeFinal" }) // PicoCLI requires non-final Strings.
12821210 @ Option (
12831211 names = {"--key-value-storage" },
@@ -1906,10 +1834,15 @@ private void validateOptions() {
19061834 validateRpcOptionsParams ();
19071835 validateChainDataPruningParams ();
19081836 validatePostMergeCheckpointBlockRequirements ();
1837+ validateTransactionPoolOptions ();
19091838 p2pTLSConfigOptions .checkP2PTLSOptionsDependencies (logger , commandLine );
19101839 pkiBlockCreationOptions .checkPkiBlockCreationOptionsDependencies (logger , commandLine );
19111840 }
19121841
1842+ private void validateTransactionPoolOptions () {
1843+ stableTransactionPoolOptions .validate (commandLine );
1844+ }
1845+
19131846 private void validateRequiredOptions () {
19141847 commandLine
19151848 .getCommandSpec ()
@@ -2987,28 +2920,14 @@ private SynchronizerConfiguration buildSyncConfig() {
29872920 }
29882921
29892922 private TransactionPoolConfiguration buildTransactionPoolConfiguration () {
2990- return unstableTransactionPoolOptions
2991- .toDomainObject ()
2992- .enableSaveRestore (txPoolOptionGroup .saveRestoreEnabled )
2993- .disableLocalTransactions (txPoolOptionGroup .disableLocalTxs )
2994- .txPoolLimitByAccountPercentage (txPoolOptionGroup .txPoolLimitByAccountPercentage )
2995- .txPoolMaxSize (txPoolOptionGroup .txPoolMaxSize )
2996- .pendingTxRetentionPeriod (txPoolOptionGroup .pendingTxRetentionPeriod )
2997- .priceBump (Percentage .fromInt (txPoolOptionGroup .priceBump ))
2998- .txFeeCap (txFeeCap )
2999- .saveFile (dataPath .resolve (txPoolOptionGroup .saveFile .getPath ()).toFile ())
2923+ final var stableTxPoolOption = stableTransactionPoolOptions .toDomainObject ();
2924+ return ImmutableTransactionPoolConfiguration .builder ()
2925+ .from (stableTxPoolOption )
2926+ .unstable (unstableTransactionPoolOptions .toDomainObject ())
2927+ .saveFile ((dataPath .resolve (stableTxPoolOption .getSaveFile ().getPath ()).toFile ()))
30002928 .build ();
30012929 }
30022930
3003- /**
3004- * Return the file where to save txpool content if the relative option is enabled.
3005- *
3006- * @return the save file
3007- */
3008- public File getSaveFile () {
3009- return txPoolOptionGroup .saveFile ;
3010- }
3011-
30122931 private boolean isPruningEnabled () {
30132932 return pruningEnabled ;
30142933 }
@@ -3613,9 +3532,7 @@ private String generateConfigurationOverview() {
36133532 builder .setHighSpecEnabled ();
36143533 }
36153534
3616- if (buildTransactionPoolConfiguration ().getLayeredTxPoolEnabled ()) {
3617- builder .setLayeredTxPoolEnabled ();
3618- }
3535+ builder .setTxPoolImplementation (buildTransactionPoolConfiguration ().getTxPoolImplementation ());
36193536
36203537 return builder .build ();
36213538 }
0 commit comments