Merge branch 'main' into feature/worldstate-refactor

pull/6209/head
Karim TAAM 11 months ago committed by GitHub
commit 61e985b77d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .circleci/config.yml
  2. 51
      CHANGELOG.md
  3. 2
      acceptance-tests/dsl/build.gradle
  4. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java
  5. 40
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/SyncingStatusCondition.java
  6. 15
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
  7. 14
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
  8. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  9. 7
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java
  10. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
  11. 11
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
  12. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java
  13. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java
  14. 40
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthSyncingTransaction.java
  15. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java
  16. 2
      acceptance-tests/tests/build.gradle
  17. 5
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java
  18. 5
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java
  19. 2
      acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json
  20. 2
      acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json
  21. 2
      besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java
  22. 91
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java
  23. 66
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/TransactionEvaluationContext.java
  24. 10
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java
  25. 9
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java
  26. 11
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java
  27. 13
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java
  28. 11
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java
  29. 29
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java
  30. 10
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java
  31. 39
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java
  32. 33
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java
  33. 2
      evm/src/main/java/org/hyperledger/besu/evm/fluent/EVMExecutor.java
  34. 2
      gradle.properties
  35. 4
      gradle/allowed-licenses.json
  36. 2
      gradle/license-normalizer-bundle.json
  37. 2928
      gradle/verification-metadata.xml
  38. 111
      gradle/versions.gradle
  39. 2
      nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java
  40. 25
      pki/src/test/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreFileWrapperTest.java
  41. 2
      plugin-api/build.gradle
  42. 17
      plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java
  43. 57
      plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionEvaluationContext.java
  44. 9
      testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java

@ -269,7 +269,7 @@ jobs:
- capture_test_logs - capture_test_logs
acceptanceTestsPermissioning: acceptanceTestsPermissioning:
executor: besu_executor_xl executor: besu_executor_med
steps: steps:
- prepare - prepare
- attach_workspace: - attach_workspace:
@ -278,7 +278,7 @@ jobs:
name: AcceptanceTests (Non-Mainnet) name: AcceptanceTests (Non-Mainnet)
no_output_timeout: 20m no_output_timeout: 20m
command: | command: |
./gradlew --no-daemon acceptanceTestPermissioning ./gradlew --no-daemon --max-workers=1 acceptanceTestPermissioning
- capture_test_results - capture_test_results
- capture_test_logs - capture_test_logs
@ -428,12 +428,12 @@ workflows:
- acceptanceTestsPermissioning: - acceptanceTestsPermissioning:
requires: requires:
- assemble - assemble
- acceptanceTestsCliqueBft
- buildDocker: - buildDocker:
requires: requires:
- assemble - assemble
- buildArm64Docker: - buildArm64Docker:
requires: requires:
- buildDocker
- assemble - assemble
- publish: - publish:
filters: filters:

@ -1,26 +1,64 @@
# Changelog # Changelog
## 24.1.0-SNAPSHOT ## 24.1.1-SNAPSHOT
### Breaking Changes ### Breaking Changes
- New `EXECUTION_HALTED` error returned if there is an error executing or simulating a transaction, with the reason for execution being halted. Replaces the generic `INTERNAL_ERROR` return code in certain cases which some applications may be checking for [#6343](https://github.com/hyperledger/besu/pull/6343) - New `EXECUTION_HALTED` error returned if there is an error executing or simulating a transaction, with the reason for execution being halted. Replaces the generic `INTERNAL_ERROR` return code in certain cases which some applications may be checking for [#6343](https://github.com/hyperledger/besu/pull/6343)
- The Besu Docker images with `openjdk-latest` tags since 23.10.3 were incorrectly using UID 1001 instead of 1000 for the container's `besu` user. The user now uses 1000 again. Containers created from or migrated to images using UID 1001 will need to chown their persistent database files to UID 1000 [#6360](https://github.com/hyperledger/besu/pull/6360) - The Besu Docker images with `openjdk-latest` tags since 23.10.3 were incorrectly using UID 1001 instead of 1000 for the container's `besu` user. The user now uses 1000 again. Containers created from or migrated to images using UID 1001 will need to chown their persistent database files to UID 1000 [#6360](https://github.com/hyperledger/besu/pull/6360)
### Deprecations
### Additions and Improvements
- Optimize RocksDB WAL files, allows for faster restart and a more linear disk space utilization [#6328](https://github.com/hyperledger/besu/pull/6328)
- Disable transaction handling when the node is not in sync, to avoid unnecessary transaction validation work [#6302](https://github.com/hyperledger/besu/pull/6302)
- Introduce TransactionEvaluationContext to pass data between transaction selectors and plugin, during block creation [#6381](https://github.com/hyperledger/besu/pull/6381)
- Upgrade dependencies [#6377](https://github.com/hyperledger/besu/pull/6377)
- Upgrade `com.fasterxml.jackson` dependencies [#6378](https://github.com/hyperledger/besu/pull/6378)
### Bug fixes
- INTERNAL_ERROR from `eth_estimateGas` JSON/RPC calls [#6344](https://github.com/hyperledger/besu/issues/6344)
- Fix Besu Docker images with `openjdk-latest` tags since 23.10.3 using UID 1001 instead of 1000 for the `besu` user [#6360](https://github.com/hyperledger/besu/pull/6360)
- Fluent EVM API definition for Tangerine Whistle had incorrect code size validation configured [#6382](https://github.com/hyperledger/besu/pull/6382)
- Correct mining beneficiary for Clique networks in TraceServiceImpl [#6390](https://github.com/hyperledger/besu/pull/6390)
### Download Links
## 24.1.0
### Breaking Changes
### Deprecations ### Deprecations
- Forest pruning (`pruning-enabled` options) is deprecated and will be removed soon. To save disk space consider switching to Bonsai data storage format [#6230](https://github.com/hyperledger/besu/pull/6230) - Forest pruning (`pruning-enabled` options) is deprecated and will be removed soon. To save disk space consider switching to Bonsai data storage format [#6230](https://github.com/hyperledger/besu/pull/6230)
### Additions and Improvements ### Additions and Improvements
- Add error messages on authentication failures with username and password [#6212](https://github.com/hyperledger/besu/pull/6212) - Add error messages on authentication failures with username and password [#6212](https://github.com/hyperledger/besu/pull/6212)
- New `Sequenced` transaction pool. The pool is an evolution of the `legacy` pool and is likely to be more suitable to enterprise or permissioned chains than the `layered` transaction pool. Select to use this pool with `--tx-pool=sequenced`. Supports the same options as the `legacy` pool [#6211](https://github.com/hyperledger/besu/issues/6211) - New `Sequenced` transaction pool. The pool is an evolution of the `legacy` pool and is likely to be more suitable to enterprise or permissioned chains than the `layered` transaction pool. Select to use this pool with `--tx-pool=sequenced`. Supports the same options as the `legacy` pool [#6274](https://github.com/hyperledger/besu/issues/6274)
- Set Ethereum Classic mainnet activation block for Spiral network upgrade [#6267](https://github.com/hyperledger/besu/pull/6267) - Set Ethereum Classic mainnet activation block for Spiral network upgrade [#6267](https://github.com/hyperledger/besu/pull/6267)
- Add custom genesis file name to config overview if specified [#6297](https://github.com/hyperledger/besu/pull/6297) - Add custom genesis file name to config overview if specified [#6297](https://github.com/hyperledger/besu/pull/6297)
- Update Gradle plugins and replace unmaintained License Gradle Plugin with the actively maintained Gradle License Report [#6275](https://github.com/hyperledger/besu/pull/6275) - Update Gradle plugins and replace unmaintained License Gradle Plugin with the actively maintained Gradle License Report [#6275](https://github.com/hyperledger/besu/pull/6275)
- Disable transaction handling when the node is not in sync, to avoid unnecessary transaction validation work [#6302](https://github.com/hyperledger/besu/pull/6302)
- Optimize RocksDB WAL files, allows for faster restart and a more linear disk space utilization [#6328](https://github.com/hyperledger/besu/pull/6328)
### Bug fixes ### Bug fixes
- INTERNAL_ERROR from `eth_estimateGas` JSON/RPC calls [#6344](https://github.com/hyperledger/besu/issues/6344) - Hotfix for selfdestruct preimages on bonsai [#6359]((https://github.com/hyperledger/besu/pull/6359)
- Fix Besu Docker images with `openjdk-latest` tags since 23.10.3 using UID 1001 instead of 1000 for the `besu` user [#6360](https://github.com/hyperledger/besu/pull/6360) - Fix trielog shipping issue during self destruct [#6340]((https://github.com/hyperledger/besu/pull/6340)
- mitigation for trielog failure [#6315]((https://github.com/hyperledger/besu/pull/6315)
### Download Links
https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/24.1.0/besu-24.1.0.zip / sha256 TBA
https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/24.1.0/besu-24.1.0.tar.gz / sha256 TBA
## 23.10.3-hotfix
This is a hotfix for a selfdestruct defect that occurred on mainnet at block [18947893](https://etherscan.io/block/18947893)
### Bug fixes
- Hotfix for selfdestruct preimages on bonsai [#6359]((https://github.com/hyperledger/besu/pull/6359)
- mitigation for trielog failure [#6315]((https://github.com/hyperledger/besu/pull/6315)
### Download Links
https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/23.10.3-hotfix/besu-23.10.3-hotfix.zip / sha256 1c37762909858a40eca749fb85b77fb4d1e918f247aff56d518144828bd85378
https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/23.10.3-hotfix/besu-23.10.3-hotfix.tar.gz / sha256 8e38e9fd0c16e049aa324effc96f9ec31dc06e82ea4995e9dd75d571394667af
## 23.10.3 ## 23.10.3
@ -68,6 +106,7 @@ https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/23.10.3/besu-23.10.3
- Force tx replacement price bump to zero when zero base fee market is configured or `--min-gas-price` is set to 0. This allows for easier tx replacement in networks where there is not gas price. [#6079](https://github.com/hyperledger/besu/pull/6079) - Force tx replacement price bump to zero when zero base fee market is configured or `--min-gas-price` is set to 0. This allows for easier tx replacement in networks where there is not gas price. [#6079](https://github.com/hyperledger/besu/pull/6079)
- Introduce the possibility to limit the time spent selecting pending transactions during block creation, using the new experimental option `Xblock-txs-selection-max-time` on PoS and PoW networks (by default set to 5000ms) or `Xpoa-block-txs-selection-max-time` on PoA networks (by default 75% of the min block time) [#6044](https://github.com/hyperledger/besu/pull/6044) - Introduce the possibility to limit the time spent selecting pending transactions during block creation, using the new experimental option `Xblock-txs-selection-max-time` on PoS and PoW networks (by default set to 5000ms) or `Xpoa-block-txs-selection-max-time` on PoA networks (by default 75% of the min block time) [#6044](https://github.com/hyperledger/besu/pull/6044)
- Remove LowestInvalidNonceCache from `legacy` transaction pool to make it more private networks friendly [#6148](https://github.com/hyperledger/besu/pull/6148) - Remove LowestInvalidNonceCache from `legacy` transaction pool to make it more private networks friendly [#6148](https://github.com/hyperledger/besu/pull/6148)
- Optimization: Delete leftPad when capturing the stack before and after a frame execution [#6102](https://github.com/hyperledger/besu/pull/6102)
### Bug fixes ### Bug fixes
- Upgrade netty to address CVE-2023-44487, CVE-2023-34462 [#6100](https://github.com/hyperledger/besu/pull/6100) - Upgrade netty to address CVE-2023-44487, CVE-2023-34462 [#6100](https://github.com/hyperledger/besu/pull/6100)

@ -26,7 +26,6 @@ dependencies {
implementation project(':testutil') implementation project(':testutil')
implementation project(':util') implementation project(':util')
implementation 'com.github.tomakehurst:wiremock-jre8'
implementation 'com.google.guava:guava' implementation 'com.google.guava:guava'
implementation 'com.google.dagger:dagger' implementation 'com.google.dagger:dagger'
annotationProcessor 'com.google.dagger:dagger-compiler' annotationProcessor 'com.google.dagger:dagger-compiler'
@ -45,6 +44,7 @@ dependencies {
implementation 'org.web3j:abi' implementation 'org.web3j:abi'
implementation 'org.web3j:besu' implementation 'org.web3j:besu'
implementation 'org.web3j:crypto' implementation 'org.web3j:crypto'
implementation 'org.wiremock:wiremock'
implementation 'org.testcontainers:testcontainers' implementation 'org.testcontainers:testcontainers'
implementation 'org.junit.jupiter:junit-jupiter' implementation 'org.junit.jupiter:junit-jupiter'

@ -77,6 +77,10 @@ public class EthConditions {
return new MiningStatusCondition(transactions.mining(), isMining); return new MiningStatusCondition(transactions.mining(), isMining);
} }
public Condition syncingStatus(final boolean isSyncing) {
return new SyncingStatusCondition(transactions.syncing(), isSyncing);
}
public Condition expectNewPendingTransactions( public Condition expectNewPendingTransactions(
final BigInteger filterId, final List<String> transactionHashes) { final BigInteger filterId, final List<String> transactionHashes) {
return new NewPendingTransactionFilterChangesCondition( return new NewPendingTransactionFilterChangesCondition(

@ -0,0 +1,40 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.eth;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.tests.acceptance.dsl.WaitUtils;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.eth.EthSyncingTransaction;
public class SyncingStatusCondition implements Condition {
private final EthSyncingTransaction transaction;
private final boolean syncingMiningStatus;
public SyncingStatusCondition(
final EthSyncingTransaction transaction, final boolean syncingStatus) {
this.transaction = transaction;
this.syncingMiningStatus = syncingStatus;
}
@Override
public void verify(final Node node) {
WaitUtils.waitFor(
10, () -> assertThat(node.execute(transaction)).isEqualTo(syncingMiningStatus));
}
}

@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguratio
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
@ -100,6 +101,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private final String name; private final String name;
private MiningParameters miningParameters; private MiningParameters miningParameters;
private TransactionPoolConfiguration txPoolConfiguration;
private final List<String> runCommand; private final List<String> runCommand;
private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT; private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT;
private final JsonRpcConfiguration jsonRpcConfiguration; private final JsonRpcConfiguration jsonRpcConfiguration;
@ -135,6 +137,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
final String name, final String name,
final Optional<Path> dataPath, final Optional<Path> dataPath,
final MiningParameters miningParameters, final MiningParameters miningParameters,
final TransactionPoolConfiguration txPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration, final JsonRpcConfiguration jsonRpcConfiguration,
final Optional<JsonRpcConfiguration> engineRpcConfiguration, final Optional<JsonRpcConfiguration> engineRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration, final WebSocketConfiguration webSocketConfiguration,
@ -184,6 +187,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
() -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory)); () -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory));
this.name = name; this.name = name;
this.miningParameters = miningParameters; this.miningParameters = miningParameters;
this.txPoolConfiguration = txPoolConfiguration;
this.jsonRpcConfiguration = jsonRpcConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration;
this.engineRpcConfiguration = engineRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration;
this.webSocketConfiguration = webSocketConfiguration; this.webSocketConfiguration = webSocketConfiguration;
@ -661,7 +665,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.bootnodes.addAll(bootnodes); this.bootnodes.addAll(bootnodes);
} }
MiningParameters getMiningParameters() { public MiningParameters getMiningParameters() {
return miningParameters; return miningParameters;
} }
@ -669,6 +673,15 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.miningParameters = miningParameters; this.miningParameters = miningParameters;
} }
public TransactionPoolConfiguration getTransactionPoolConfiguration() {
return txPoolConfiguration;
}
public void setTransactionPoolConfiguration(
final TransactionPoolConfiguration txPoolConfiguration) {
this.txPoolConfiguration = txPoolConfiguration;
}
public PrivacyParameters getPrivacyParameters() { public PrivacyParameters getPrivacyParameters() {
return privacyParameters; return privacyParameters;
} }

@ -17,8 +17,10 @@ package org.hyperledger.besu.tests.acceptance.dsl.node;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
import org.hyperledger.besu.cli.options.unstable.NetworkingOptions; import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
@ -98,6 +100,15 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
params.add("--p2p-port"); params.add("--p2p-port");
params.add(node.getP2pPort()); params.add(node.getP2pPort());
params.addAll(
TransactionPoolOptions.fromConfig(
ImmutableTransactionPoolConfiguration.builder()
.from(node.getTransactionPoolConfiguration())
.strictTransactionReplayProtectionEnabled(
node.isStrictTxReplayProtectionEnabled())
.build())
.getCLIOptions());
if (node.getMiningParameters().isMiningEnabled()) { if (node.getMiningParameters().isMiningEnabled()) {
params.add("--miner-enabled"); params.add("--miner-enabled");
params.add("--miner-coinbase"); params.add("--miner-coinbase");
@ -391,9 +402,6 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
params.add("--auto-log-bloom-caching-enabled"); params.add("--auto-log-bloom-caching-enabled");
params.add("false"); params.add("false");
params.add("--strict-tx-replay-protection-enabled");
params.add(Boolean.toString(node.isStrictTxReplayProtectionEnabled()));
final String level = System.getProperty("root.log.level"); final String level = System.getProperty("root.log.level");
if (level != null) { if (level != null) {
params.add("--logging=" + level); params.add("--logging=" + level);

@ -182,6 +182,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final TransactionPoolConfiguration txPoolConfig = final TransactionPoolConfiguration txPoolConfig =
ImmutableTransactionPoolConfiguration.builder() ImmutableTransactionPoolConfiguration.builder()
.from(node.getTransactionPoolConfiguration())
.strictTransactionReplayProtectionEnabled(node.isStrictTxReplayProtectionEnabled()) .strictTransactionReplayProtectionEnabled(node.isStrictTxReplayProtectionEnabled())
.build(); .build();

@ -86,11 +86,8 @@ public class Cluster implements AutoCloseable {
final Optional<? extends RunnableNode> bootnode = selectAndStartBootnode(nodes); final Optional<? extends RunnableNode> bootnode = selectAndStartBootnode(nodes);
nodes.parallelStream() nodes.parallelStream()
.filter( .filter(node -> bootnode.map(boot -> boot != node).orElse(true))
node -> { .peek(node -> LOG.info("starting non-bootnode {}", node.getName()))
LOG.info("starting non-bootnode {}", node.getName());
return bootnode.map(boot -> boot != node).orElse(true);
})
.forEach(this::startNode); .forEach(this::startNode);
if (clusterConfiguration.isAwaitPeerDiscovery()) { if (clusterConfiguration.isAwaitPeerDiscovery()) {

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
@ -39,6 +40,7 @@ public class BesuNodeConfiguration {
private final String name; private final String name;
private final Optional<Path> dataPath; private final Optional<Path> dataPath;
private final MiningParameters miningParameters; private final MiningParameters miningParameters;
private final TransactionPoolConfiguration transactionPoolConfiguration;
private final JsonRpcConfiguration jsonRpcConfiguration; private final JsonRpcConfiguration jsonRpcConfiguration;
private final Optional<JsonRpcConfiguration> engineRpcConfiguration; private final Optional<JsonRpcConfiguration> engineRpcConfiguration;
private final WebSocketConfiguration webSocketConfiguration; private final WebSocketConfiguration webSocketConfiguration;
@ -74,6 +76,7 @@ public class BesuNodeConfiguration {
final String name, final String name,
final Optional<Path> dataPath, final Optional<Path> dataPath,
final MiningParameters miningParameters, final MiningParameters miningParameters,
final TransactionPoolConfiguration transactionPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration, final JsonRpcConfiguration jsonRpcConfiguration,
final Optional<JsonRpcConfiguration> engineRpcConfiguration, final Optional<JsonRpcConfiguration> engineRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration, final WebSocketConfiguration webSocketConfiguration,
@ -106,6 +109,7 @@ public class BesuNodeConfiguration {
final Map<String, String> environment) { final Map<String, String> environment) {
this.name = name; this.name = name;
this.miningParameters = miningParameters; this.miningParameters = miningParameters;
this.transactionPoolConfiguration = transactionPoolConfiguration;
this.jsonRpcConfiguration = jsonRpcConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration;
this.engineRpcConfiguration = engineRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration;
this.webSocketConfiguration = webSocketConfiguration; this.webSocketConfiguration = webSocketConfiguration;
@ -147,6 +151,10 @@ public class BesuNodeConfiguration {
return miningParameters; return miningParameters;
} }
public TransactionPoolConfiguration getTransactionPoolConfiguration() {
return transactionPoolConfiguration;
}
public JsonRpcConfiguration getJsonRpcConfiguration() { public JsonRpcConfiguration getJsonRpcConfiguration() {
return jsonRpcConfiguration; return jsonRpcConfiguration;
} }

@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
@ -63,7 +64,8 @@ public class BesuNodeConfigurationBuilder {
.mutableInitValues( .mutableInitValues(
MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build()) MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build())
.build(); .build();
private TransactionPoolConfiguration transactionPoolConfiguration =
TransactionPoolConfiguration.DEFAULT;
private JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); private JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
private JsonRpcConfiguration engineRpcConfiguration = JsonRpcConfiguration.createEngineDefault(); private JsonRpcConfiguration engineRpcConfiguration = JsonRpcConfiguration.createEngineDefault();
private WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); private WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
@ -128,6 +130,12 @@ public class BesuNodeConfigurationBuilder {
return this; return this;
} }
public BesuNodeConfigurationBuilder transactionPoolConfiguration(
final TransactionPoolConfiguration transactionPoolConfiguration) {
this.transactionPoolConfiguration = transactionPoolConfiguration;
return this;
}
public BesuNodeConfigurationBuilder jsonRpcConfiguration( public BesuNodeConfigurationBuilder jsonRpcConfiguration(
final JsonRpcConfiguration jsonRpcConfiguration) { final JsonRpcConfiguration jsonRpcConfiguration) {
this.jsonRpcConfiguration = jsonRpcConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration;
@ -503,6 +511,7 @@ public class BesuNodeConfigurationBuilder {
name, name,
dataPath, dataPath,
miningParameters, miningParameters,
transactionPoolConfiguration,
jsonRpcConfiguration, jsonRpcConfiguration,
Optional.of(engineRpcConfiguration), Optional.of(engineRpcConfiguration),
webSocketConfiguration, webSocketConfiguration,

@ -64,6 +64,7 @@ public class BesuNodeFactory {
config.getName(), config.getName(),
config.getDataPath(), config.getDataPath(),
config.getMiningParameters(), config.getMiningParameters(),
config.getTransactionPoolConfiguration(),
config.getJsonRpcConfiguration(), config.getJsonRpcConfiguration(),
config.getEngineRpcConfiguration(), config.getEngineRpcConfiguration(),
config.getWebSocketConfiguration(), config.getWebSocketConfiguration(),

@ -100,6 +100,7 @@ public class PrivacyNode implements AutoCloseable {
besuConfig.getName(), besuConfig.getName(),
besuConfig.getDataPath(), besuConfig.getDataPath(),
besuConfig.getMiningParameters(), besuConfig.getMiningParameters(),
besuConfig.getTransactionPoolConfiguration(),
besuConfig.getJsonRpcConfiguration(), besuConfig.getJsonRpcConfiguration(),
besuConfig.getEngineRpcConfiguration(), besuConfig.getEngineRpcConfiguration(),
besuConfig.getWebSocketConfiguration(), besuConfig.getWebSocketConfiguration(),

@ -0,0 +1,40 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.transaction.eth;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException;
import org.web3j.protocol.core.methods.response.EthSyncing;
public class EthSyncingTransaction implements Transaction<Boolean> {
EthSyncingTransaction() {}
@Override
public Boolean execute(final NodeRequests node) {
try {
EthSyncing response = node.eth().ethSyncing().send();
assertThat(response).isNotNull();
return response.isSyncing();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -73,6 +73,10 @@ public class EthTransactions {
return new EthMiningTransaction(); return new EthMiningTransaction();
} }
public EthSyncingTransaction syncing() {
return new EthSyncingTransaction();
}
public EthNewPendingTransactionFilterTransaction newPendingTransactionsFilter() { public EthNewPendingTransactionFilterTransaction newPendingTransactionsFilter() {
return new EthNewPendingTransactionFilterTransaction(); return new EthNewPendingTransactionFilterTransaction();
} }

@ -55,7 +55,6 @@ dependencies {
testImplementation project(':testutil') testImplementation project(':testutil')
testImplementation project(':util') testImplementation project(':util')
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone'
testImplementation 'commons-io:commons-io' testImplementation 'commons-io:commons-io'
testImplementation 'io.grpc:grpc-all' testImplementation 'io.grpc:grpc-all'
testImplementation 'io.grpc:grpc-core' testImplementation 'io.grpc:grpc-core'
@ -84,6 +83,7 @@ dependencies {
testImplementation 'org.web3j:abi' testImplementation 'org.web3j:abi'
testImplementation 'org.web3j:besu' testImplementation 'org.web3j:besu'
testImplementation 'org.web3j:core' testImplementation 'org.web3j:core'
testImplementation 'org.wiremock:wiremock'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
} }

@ -49,6 +49,11 @@ public class NodeSmartContractPermissioningAcceptanceTest
permissionedNode.verify(admin.addPeer(bootnode)); permissionedNode.verify(admin.addPeer(bootnode));
permissionedNode.verify(admin.addPeer(allowedNode)); permissionedNode.verify(admin.addPeer(allowedNode));
allowedNode.verify(eth.syncingStatus(false));
bootnode.verify(eth.syncingStatus(false));
permissionedNode.verify(eth.syncingStatus(false));
forbiddenNode.verify(eth.syncingStatus(false));
} }
@Test @Test

@ -46,6 +46,11 @@ public class NodeSmartContractPermissioningV2AcceptanceTest
permissionedNode.execute(allowNode(permissionedNode)); permissionedNode.execute(allowNode(permissionedNode));
permissionedNode.verify(connectionIsAllowed(permissionedNode)); permissionedNode.verify(connectionIsAllowed(permissionedNode));
allowedNode.verify(eth.syncingStatus(false));
bootnode.verify(eth.syncingStatus(false));
permissionedNode.verify(eth.syncingStatus(false));
forbiddenNode.verify(eth.syncingStatus(false));
} }
@Test @Test

@ -4,7 +4,7 @@
"londonBlock": 0, "londonBlock": 0,
"zeroBaseFee": true, "zeroBaseFee": true,
"ethash": { "ethash": {
"fixeddifficulty": 100 "fixeddifficulty": 500
} }
}, },
"nonce": "0x42", "nonce": "0x42",

@ -4,7 +4,7 @@
"londonBlock": 0, "londonBlock": 0,
"zeroBaseFee": true, "zeroBaseFee": true,
"ethash": { "ethash": {
"fixeddifficulty": 100 "fixeddifficulty": 500
} }
}, },
"nonce": "0x42", "nonce": "0x42",

@ -216,7 +216,7 @@ public class TraceServiceImpl implements TraceService {
worldUpdater, worldUpdater,
header, header,
transaction, transaction,
header.getCoinbase(), protocolSpec.getMiningBeneficiaryCalculator().calculateBeneficiary(header),
tracer, tracer,
new CachingBlockHashLookup(header, blockchain), new CachingBlockHashLookup(header, blockchain),
false, false,

@ -228,26 +228,42 @@ public class BlockTransactionSelector {
final PendingTransaction pendingTransaction) { final PendingTransaction pendingTransaction) {
checkCancellation(); checkCancellation();
final Stopwatch evaluationTimer = Stopwatch.createStarted(); final TransactionEvaluationContext evaluationContext =
createTransactionEvaluationContext(pendingTransaction);
TransactionSelectionResult selectionResult = evaluatePreProcessing(pendingTransaction); TransactionSelectionResult selectionResult = evaluatePreProcessing(evaluationContext);
if (!selectionResult.selected()) { if (!selectionResult.selected()) {
return handleTransactionNotSelected(pendingTransaction, selectionResult, evaluationTimer); return handleTransactionNotSelected(evaluationContext, selectionResult);
} }
final WorldUpdater txWorldStateUpdater = blockWorldStateUpdater.updater(); final WorldUpdater txWorldStateUpdater = blockWorldStateUpdater.updater();
final TransactionProcessingResult processingResult = final TransactionProcessingResult processingResult =
processTransaction(pendingTransaction, txWorldStateUpdater); processTransaction(pendingTransaction, txWorldStateUpdater);
var postProcessingSelectionResult = var postProcessingSelectionResult = evaluatePostProcessing(evaluationContext, processingResult);
evaluatePostProcessing(pendingTransaction, processingResult);
if (postProcessingSelectionResult.selected()) { if (postProcessingSelectionResult.selected()) {
return handleTransactionSelected( return handleTransactionSelected(evaluationContext, processingResult, txWorldStateUpdater);
pendingTransaction, processingResult, txWorldStateUpdater, evaluationTimer);
} }
return handleTransactionNotSelected( return handleTransactionNotSelected(
pendingTransaction, postProcessingSelectionResult, txWorldStateUpdater, evaluationTimer); evaluationContext, postProcessingSelectionResult, txWorldStateUpdater);
}
private TransactionEvaluationContext createTransactionEvaluationContext(
final PendingTransaction pendingTransaction) {
final Wei transactionGasPriceInBlock =
blockSelectionContext
.feeMarket()
.getTransactionPriceCalculator()
.price(
pendingTransaction.getTransaction(),
blockSelectionContext.processableBlockHeader().getBaseFee());
return new TransactionEvaluationContext(
pendingTransaction,
Stopwatch.createStarted(),
transactionGasPriceInBlock,
blockSelectionContext.miningParameters().getMinTransactionGasPrice());
} }
/** /**
@ -256,21 +272,20 @@ public class BlockTransactionSelector {
* it then processes it through external selectors. If the transaction is selected by all * it then processes it through external selectors. If the transaction is selected by all
* selectors, it returns SELECTED. * selectors, it returns SELECTED.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection session data.
* @return The result of the transaction selection process. * @return The result of the transaction selection process.
*/ */
private TransactionSelectionResult evaluatePreProcessing( private TransactionSelectionResult evaluatePreProcessing(
final PendingTransaction pendingTransaction) { final TransactionEvaluationContext evaluationContext) {
for (var selector : transactionSelectors) { for (var selector : transactionSelectors) {
TransactionSelectionResult result = TransactionSelectionResult result =
selector.evaluateTransactionPreProcessing( selector.evaluateTransactionPreProcessing(evaluationContext, transactionSelectionResults);
pendingTransaction, transactionSelectionResults);
if (!result.equals(SELECTED)) { if (!result.equals(SELECTED)) {
return result; return result;
} }
} }
return pluginTransactionSelector.evaluateTransactionPreProcessing(pendingTransaction); return pluginTransactionSelector.evaluateTransactionPreProcessing(evaluationContext);
} }
/** /**
@ -279,24 +294,24 @@ public class BlockTransactionSelector {
* whether the transaction should be included in a block. If the transaction is selected by all * whether the transaction should be included in a block. If the transaction is selected by all
* selectors, it returns SELECTED. * selectors, it returns SELECTED.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection session data.
* @param processingResult The result of the transaction processing. * @param processingResult The result of the transaction processing.
* @return The result of the transaction selection process. * @return The result of the transaction selection process.
*/ */
private TransactionSelectionResult evaluatePostProcessing( private TransactionSelectionResult evaluatePostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionProcessingResult processingResult) { final TransactionProcessingResult processingResult) {
for (var selector : transactionSelectors) { for (var selector : transactionSelectors) {
TransactionSelectionResult result = TransactionSelectionResult result =
selector.evaluateTransactionPostProcessing( selector.evaluateTransactionPostProcessing(
pendingTransaction, transactionSelectionResults, processingResult); evaluationContext, transactionSelectionResults, processingResult);
if (!result.equals(SELECTED)) { if (!result.equals(SELECTED)) {
return result; return result;
} }
} }
return pluginTransactionSelector.evaluateTransactionPostProcessing( return pluginTransactionSelector.evaluateTransactionPostProcessing(
pendingTransaction, processingResult); evaluationContext, processingResult);
} }
/** /**
@ -328,18 +343,16 @@ public class BlockTransactionSelector {
* receipt, updating the TransactionSelectionResults with the selected transaction, and notifying * receipt, updating the TransactionSelectionResults with the selected transaction, and notifying
* the external transaction selector. * the external transaction selector.
* *
* @param pendingTransaction The pending transaction. * @param evaluationContext The current selection session data.
* @param processingResult The result of the transaction processing. * @param processingResult The result of the transaction processing.
* @param txWorldStateUpdater The world state updater. * @param txWorldStateUpdater The world state updater.
* @param evaluationTimer tracks the evaluation elapsed time
* @return The result of the transaction selection process. * @return The result of the transaction selection process.
*/ */
private TransactionSelectionResult handleTransactionSelected( private TransactionSelectionResult handleTransactionSelected(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionProcessingResult processingResult, final TransactionProcessingResult processingResult,
final WorldUpdater txWorldStateUpdater, final WorldUpdater txWorldStateUpdater) {
final Stopwatch evaluationTimer) { final Transaction transaction = evaluationContext.getTransaction();
final Transaction transaction = pendingTransaction.getTransaction();
final long gasUsedByTransaction = final long gasUsedByTransaction =
transaction.getGasLimit() - processingResult.getGasRemaining(); transaction.getGasLimit() - processingResult.getGasRemaining();
@ -363,13 +376,14 @@ public class BlockTransactionSelector {
transaction.getType(), processingResult, worldState, cumulativeGasUsed); transaction.getType(), processingResult, worldState, cumulativeGasUsed);
transactionSelectionResults.updateSelected( transactionSelectionResults.updateSelected(
pendingTransaction.getTransaction(), receipt, gasUsedByTransaction, blobGasUsed); transaction, receipt, gasUsedByTransaction, blobGasUsed);
} }
} }
if (tooLate) { if (tooLate) {
// even if this tx passed all the checks, it is too late to include it in this block, // even if this tx passed all the checks, it is too late to include it in this block,
// so we need to treat it as not selected // so we need to treat it as not selected
final var evaluationTimer = evaluationContext.getEvaluationTimer();
// check if this tx took too much to evaluate, and in case remove it from the pool // check if this tx took too much to evaluate, and in case remove it from the pool
final TransactionSelectionResult timeoutSelectionResult; final TransactionSelectionResult timeoutSelectionResult;
@ -395,15 +409,15 @@ public class BlockTransactionSelector {
// do not rely on the presence of this result, since by the time it is added, the code // do not rely on the presence of this result, since by the time it is added, the code
// reading it could have been already executed by another thread // reading it could have been already executed by another thread
return handleTransactionNotSelected( return handleTransactionNotSelected(
pendingTransaction, timeoutSelectionResult, txWorldStateUpdater, evaluationTimer); evaluationContext, timeoutSelectionResult, txWorldStateUpdater);
} }
pluginTransactionSelector.onTransactionSelected(pendingTransaction, processingResult); pluginTransactionSelector.onTransactionSelected(evaluationContext, processingResult);
blockWorldStateUpdater = worldState.updater(); blockWorldStateUpdater = worldState.updater();
LOG.atTrace() LOG.atTrace()
.setMessage("Selected {} for block creation, evaluated in {}") .setMessage("Selected {} for block creation, evaluated in {}")
.addArgument(transaction::toTraceLog) .addArgument(transaction::toTraceLog)
.addArgument(evaluationTimer) .addArgument(evaluationContext.getPendingTransaction())
.log(); .log();
return SELECTED; return SELECTED;
} }
@ -413,36 +427,35 @@ public class BlockTransactionSelector {
* TransactionSelectionResults with the unselected transaction, and notifies the external * TransactionSelectionResults with the unselected transaction, and notifies the external
* transaction selector. * transaction selector.
* *
* @param pendingTransaction The unselected pending transaction. * @param evaluationContext The current selection session data.
* @param selectionResult The result of the transaction selection process. * @param selectionResult The result of the transaction selection process.
* @param evaluationTimer tracks the evaluation elapsed time
* @return The result of the transaction selection process. * @return The result of the transaction selection process.
*/ */
private TransactionSelectionResult handleTransactionNotSelected( private TransactionSelectionResult handleTransactionNotSelected(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResult selectionResult, final TransactionSelectionResult selectionResult) {
final Stopwatch evaluationTimer) {
final var pendingTransaction = evaluationContext.getPendingTransaction();
transactionSelectionResults.updateNotSelected( transactionSelectionResults.updateNotSelected(
pendingTransaction.getTransaction(), selectionResult); evaluationContext.getTransaction(), selectionResult);
pluginTransactionSelector.onTransactionNotSelected(pendingTransaction, selectionResult); pluginTransactionSelector.onTransactionNotSelected(evaluationContext, selectionResult);
LOG.atTrace() LOG.atTrace()
.setMessage("Not selected {} for block creation with result {}, evaluated in {}") .setMessage("Not selected {} for block creation with result {}, evaluated in {}")
.addArgument(pendingTransaction::toTraceLog) .addArgument(pendingTransaction::toTraceLog)
.addArgument(selectionResult) .addArgument(selectionResult)
.addArgument(evaluationTimer) .addArgument(evaluationContext.getEvaluationTimer())
.log(); .log();
return selectionResult; return selectionResult;
} }
private TransactionSelectionResult handleTransactionNotSelected( private TransactionSelectionResult handleTransactionNotSelected(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResult selectionResult, final TransactionSelectionResult selectionResult,
final WorldUpdater txWorldStateUpdater, final WorldUpdater txWorldStateUpdater) {
final Stopwatch evaluationTimer) {
txWorldStateUpdater.revert(); txWorldStateUpdater.revert();
return handleTransactionNotSelected(pendingTransaction, selectionResult, evaluationTimer); return handleTransactionNotSelected(evaluationContext, selectionResult);
} }
private void checkCancellation() { private void checkCancellation() {

@ -0,0 +1,66 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.blockcreation.txselection;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import com.google.common.base.Stopwatch;
public class TransactionEvaluationContext
implements org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext<
PendingTransaction> {
private final org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction
pendingTransaction;
private final Stopwatch evaluationTimer;
private final Wei transactionGasPrice;
private final Wei minGasPrice;
public TransactionEvaluationContext(
final PendingTransaction pendingTransaction,
final Stopwatch evaluationTimer,
final Wei transactionGasPrice,
final Wei minGasPrice) {
this.pendingTransaction = pendingTransaction;
this.evaluationTimer = evaluationTimer;
this.transactionGasPrice = transactionGasPrice;
this.minGasPrice = minGasPrice;
}
public Transaction getTransaction() {
return pendingTransaction.getTransaction();
}
@Override
public PendingTransaction getPendingTransaction() {
return pendingTransaction;
}
@Override
public Stopwatch getEvaluationTimer() {
return evaluationTimer;
}
@Override
public Wei getTransactionGasPrice() {
return transactionGasPrice;
}
@Override
public Wei getMinGasPrice() {
return minGasPrice;
}
}

@ -15,8 +15,8 @@
package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors;
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
@ -34,25 +34,25 @@ public abstract class AbstractTransactionSelector {
/** /**
* Evaluates a transaction in the context of other transactions in the same block. * Evaluates a transaction in the context of other transactions in the same block.
* *
* @param pendingTransaction The transaction to be evaluated within a block. * @param evaluationContext The current selection session data.
* @param blockTransactionResults The results of other transaction evaluations in the same block. * @param blockTransactionResults The results of other transaction evaluations in the same block.
* @return The result of the transaction evaluation * @return The result of the transaction evaluation
*/ */
public abstract TransactionSelectionResult evaluateTransactionPreProcessing( public abstract TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults blockTransactionResults); final TransactionSelectionResults blockTransactionResults);
/** /**
* Evaluates a transaction considering other transactions in the same block and a transaction * Evaluates a transaction considering other transactions in the same block and a transaction
* processing result. * processing result.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection session data.
* @param blockTransactionResults The results of other transaction evaluations in the same block. * @param blockTransactionResults The results of other transaction evaluations in the same block.
* @param processingResult The result of transaction processing. * @param processingResult The result of transaction processing.
* @return The result of the transaction evaluation * @return The result of the transaction evaluation
*/ */
public abstract TransactionSelectionResult evaluateTransactionPostProcessing( public abstract TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults blockTransactionResults, final TransactionSelectionResults blockTransactionResults,
final TransactionProcessingResult processingResult); final TransactionProcessingResult processingResult);
} }

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.PendingTransaction;
import org.hyperledger.besu.plugin.data.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionProcessingResult;
import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector;
import org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext;
/** A TransactionSelector that unconditionally selects all transactions. */ /** A TransactionSelector that unconditionally selects all transactions. */
public class AllAcceptingTransactionSelector implements PluginTransactionSelector { public class AllAcceptingTransactionSelector implements PluginTransactionSelector {
@ -29,25 +30,25 @@ public class AllAcceptingTransactionSelector implements PluginTransactionSelecto
/** /**
* Always selects the transaction in the pre-processing stage. * Always selects the transaction in the pre-processing stage.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection context.
* @return Always SELECTED. * @return Always SELECTED.
*/ */
@Override @Override
public TransactionSelectionResult evaluateTransactionPreProcessing( public TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction) { final TransactionEvaluationContext<? extends PendingTransaction> evaluationContext) {
return TransactionSelectionResult.SELECTED; return TransactionSelectionResult.SELECTED;
} }
/** /**
* Always selects the transaction in the post-processing stage. * Always selects the transaction in the post-processing stage.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection context.
* @param processingResult The result of the transaction processing. * @param processingResult The result of the transaction processing.
* @return Always SELECTED. * @return Always SELECTED.
*/ */
@Override @Override
public TransactionSelectionResult evaluateTransactionPostProcessing( public TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext<? extends PendingTransaction> evaluationContext,
final TransactionProcessingResult processingResult) { final TransactionProcessingResult processingResult) {
return TransactionSelectionResult.SELECTED; return TransactionSelectionResult.SELECTED;
} }

@ -15,9 +15,9 @@
package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors;
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
@ -39,14 +39,15 @@ public class BlobPriceTransactionSelector extends AbstractTransactionSelector {
/** /**
* Evaluates a transaction considering its blob price. * Evaluates a transaction considering its blob price.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection session data.
* @param ignored The results of other transaction evaluations in the same block. * @param ignored The results of other transaction evaluations in the same block.
* @return The result of the transaction selection. * @return The result of the transaction selection.
*/ */
@Override @Override
public TransactionSelectionResult evaluateTransactionPreProcessing( public TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction, final TransactionSelectionResults ignored) { final TransactionEvaluationContext evaluationContext,
if (transactionBlobPriceBelowMin(pendingTransaction.getTransaction())) { final TransactionSelectionResults ignored) {
if (transactionBlobPriceBelowMin(evaluationContext.getTransaction())) {
return TransactionSelectionResult.BLOB_PRICE_BELOW_CURRENT_MIN; return TransactionSelectionResult.BLOB_PRICE_BELOW_CURRENT_MIN;
} }
return TransactionSelectionResult.SELECTED; return TransactionSelectionResult.SELECTED;
@ -54,7 +55,7 @@ public class BlobPriceTransactionSelector extends AbstractTransactionSelector {
@Override @Override
public TransactionSelectionResult evaluateTransactionPostProcessing( public TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults blockTransactionResults, final TransactionSelectionResults blockTransactionResults,
final TransactionProcessingResult processingResult) { final TransactionProcessingResult processingResult) {
// All necessary checks were done in the pre-processing method, so nothing to do here. // All necessary checks were done in the pre-processing method, so nothing to do here.

@ -15,9 +15,9 @@
package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors;
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
@ -40,20 +40,21 @@ public class BlockSizeTransactionSelector extends AbstractTransactionSelector {
* Evaluates a transaction considering other transactions in the same block. If the transaction is * Evaluates a transaction considering other transactions in the same block. If the transaction is
* too large for the block returns a selection result based on block occupancy. * too large for the block returns a selection result based on block occupancy.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection session data.
* @param transactionSelectionResults The results of other transaction evaluations in the same * @param transactionSelectionResults The results of other transaction evaluations in the same
* block. * block.
* @return The result of the transaction selection. * @return The result of the transaction selection.
*/ */
@Override @Override
public TransactionSelectionResult evaluateTransactionPreProcessing( public TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults transactionSelectionResults) { final TransactionSelectionResults transactionSelectionResults) {
if (transactionTooLargeForBlock( if (transactionTooLargeForBlock(
pendingTransaction.getTransaction(), transactionSelectionResults)) { evaluationContext.getTransaction(), transactionSelectionResults)) {
LOG.atTrace() LOG.atTrace()
.setMessage("Transaction {} too large to select for block creation") .setMessage("Transaction {} too large to select for block creation")
.addArgument(pendingTransaction::toTraceLog) .addArgument(evaluationContext.getPendingTransaction()::toTraceLog)
.log(); .log();
if (blockOccupancyAboveThreshold(transactionSelectionResults)) { if (blockOccupancyAboveThreshold(transactionSelectionResults)) {
LOG.trace("Block occupancy above threshold, completing operation"); LOG.trace("Block occupancy above threshold, completing operation");
@ -70,7 +71,7 @@ public class BlockSizeTransactionSelector extends AbstractTransactionSelector {
@Override @Override
public TransactionSelectionResult evaluateTransactionPostProcessing( public TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults blockTransactionResults, final TransactionSelectionResults blockTransactionResults,
final TransactionProcessingResult processingResult) { final TransactionProcessingResult processingResult) {
// All necessary checks were done in the pre-processing method, so nothing to do here. // All necessary checks were done in the pre-processing method, so nothing to do here.

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
@ -36,7 +37,7 @@ public class MinPriorityFeePerGasTransactionSelector extends AbstractTransaction
/** /**
* Evaluates a transaction before processing. * Evaluates a transaction before processing.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection session data.
* @param transactionSelectionResults The results of other transaction evaluations in the same * @param transactionSelectionResults The results of other transaction evaluations in the same
* block. * block.
* @return TransactionSelectionResult. If the priority fee is below the minimum, it returns an * @return TransactionSelectionResult. If the priority fee is below the minimum, it returns an
@ -44,9 +45,9 @@ public class MinPriorityFeePerGasTransactionSelector extends AbstractTransaction
*/ */
@Override @Override
public TransactionSelectionResult evaluateTransactionPreProcessing( public TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults transactionSelectionResults) { final TransactionSelectionResults transactionSelectionResults) {
if (isPriorityFeePriceBelowMinimum(pendingTransaction)) { if (isPriorityFeePriceBelowMinimum(evaluationContext.getPendingTransaction())) {
return TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN; return TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN;
} }
return TransactionSelectionResult.SELECTED; return TransactionSelectionResult.SELECTED;
@ -74,13 +75,13 @@ public class MinPriorityFeePerGasTransactionSelector extends AbstractTransaction
/** /**
* No evaluation is performed post-processing. * No evaluation is performed post-processing.
* *
* @param pendingTransaction The processed transaction. * @param evaluationContext The current selection session data.
* @param processingResult The result of the transaction processing. * @param processingResult The result of the transaction processing.
* @return Always returns SELECTED. * @return Always returns SELECTED.
*/ */
@Override @Override
public TransactionSelectionResult evaluateTransactionPostProcessing( public TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults blockTransactionResults, final TransactionSelectionResults blockTransactionResults,
final TransactionProcessingResult processingResult) { final TransactionProcessingResult processingResult) {
return TransactionSelectionResult.SELECTED; return TransactionSelectionResult.SELECTED;

@ -14,10 +14,9 @@
*/ */
package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
@ -41,14 +40,15 @@ public class PriceTransactionSelector extends AbstractTransactionSelector {
* Evaluates a transaction considering its price. If the transaction's current price is below the * Evaluates a transaction considering its price. If the transaction's current price is below the
* minimum, it returns a selection result indicating the reason. * minimum, it returns a selection result indicating the reason.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection session data.
* @param ignored The results of other transaction evaluations in the same block. * @param ignored The results of other transaction evaluations in the same block.
* @return The result of the transaction selection. * @return The result of the transaction selection.
*/ */
@Override @Override
public TransactionSelectionResult evaluateTransactionPreProcessing( public TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction, final TransactionSelectionResults ignored) { final TransactionEvaluationContext evaluationContext,
if (transactionCurrentPriceBelowMin(pendingTransaction)) { final TransactionSelectionResults ignored) {
if (transactionCurrentPriceBelowMin(evaluationContext)) {
return TransactionSelectionResult.CURRENT_TX_PRICE_BELOW_MIN; return TransactionSelectionResult.CURRENT_TX_PRICE_BELOW_MIN;
} }
return TransactionSelectionResult.SELECTED; return TransactionSelectionResult.SELECTED;
@ -56,7 +56,7 @@ public class PriceTransactionSelector extends AbstractTransactionSelector {
@Override @Override
public TransactionSelectionResult evaluateTransactionPostProcessing( public TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults blockTransactionResults, final TransactionSelectionResults blockTransactionResults,
final TransactionProcessingResult processingResult) { final TransactionProcessingResult processingResult) {
// All necessary checks were done in the pre-processing method, so nothing to do here. // All necessary checks were done in the pre-processing method, so nothing to do here.
@ -66,30 +66,25 @@ public class PriceTransactionSelector extends AbstractTransactionSelector {
/** /**
* Checks if the transaction's current price is below the minimum. * Checks if the transaction's current price is below the minimum.
* *
* @param pendingTransaction The transaction to be checked. * @param evaluationContext The current selection session data.
* @return True if the transaction's current price is below the minimum, false otherwise. * @return True if the transaction's current price is below the minimum, false otherwise.
*/ */
private boolean transactionCurrentPriceBelowMin(final PendingTransaction pendingTransaction) { private boolean transactionCurrentPriceBelowMin(
final Transaction transaction = pendingTransaction.getTransaction(); final TransactionEvaluationContext evaluationContext) {
final PendingTransaction pendingTransaction = evaluationContext.getPendingTransaction();
// Priority txs are exempt from this check // Priority txs are exempt from this check
if (!pendingTransaction.hasPriority()) { if (!pendingTransaction.hasPriority()) {
// since the minGasPrice can change at runtime, we need to recheck it everytime
final Wei transactionGasPriceInBlock =
context
.feeMarket()
.getTransactionPriceCalculator()
.price(transaction, context.processableBlockHeader().getBaseFee());
if (context if (context
.miningParameters() .miningParameters()
.getMinTransactionGasPrice() .getMinTransactionGasPrice()
.compareTo(transactionGasPriceInBlock) .compareTo(evaluationContext.getTransactionGasPrice())
> 0) { > 0) {
LOG.atTrace() LOG.atTrace()
.setMessage( .setMessage(
"Current gas price of {} is {} and lower than the configured minimum {}, skipping") "Current gas price of {} is {} and lower than the configured minimum {}, skipping")
.addArgument(pendingTransaction::toTraceLog) .addArgument(pendingTransaction::toTraceLog)
.addArgument(transactionGasPriceInBlock::toHumanReadableString) .addArgument(evaluationContext.getTransactionGasPrice()::toHumanReadableString)
.addArgument( .addArgument(
context.miningParameters().getMinTransactionGasPrice()::toHumanReadableString) context.miningParameters().getMinTransactionGasPrice()::toHumanReadableString)
.log(); .log();

@ -15,9 +15,9 @@
package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors;
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
@ -41,7 +41,7 @@ public class ProcessingResultTransactionSelector extends AbstractTransactionSele
@Override @Override
public TransactionSelectionResult evaluateTransactionPreProcessing( public TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults blockTransactionResults) { final TransactionSelectionResults blockTransactionResults) {
// All checks depend on processingResult and will be done in the post-processing method, so // All checks depend on processingResult and will be done in the post-processing method, so
// nothing to do here. // nothing to do here.
@ -53,20 +53,20 @@ public class ProcessingResultTransactionSelector extends AbstractTransactionSele
* result. If the processing result is invalid, it determines the selection result for the invalid * result. If the processing result is invalid, it determines the selection result for the invalid
* result. * result.
* *
* @param pendingTransaction The transaction to be evaluated. * @param evaluationContext The current selection session data.
* @param blockTransactionResults The results of other transaction evaluations in the same block. * @param blockTransactionResults The results of other transaction evaluations in the same block.
* @param processingResult The processing result of the transaction. * @param processingResult The processing result of the transaction.
* @return The result of the transaction selection. * @return The result of the transaction selection.
*/ */
@Override @Override
public TransactionSelectionResult evaluateTransactionPostProcessing( public TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResults blockTransactionResults, final TransactionSelectionResults blockTransactionResults,
final TransactionProcessingResult processingResult) { final TransactionProcessingResult processingResult) {
if (processingResult.isInvalid()) { if (processingResult.isInvalid()) {
return transactionSelectionResultForInvalidResult( return transactionSelectionResultForInvalidResult(
pendingTransaction.getTransaction(), processingResult.getValidationResult()); evaluationContext.getTransaction(), processingResult.getValidationResult());
} }
return TransactionSelectionResult.SELECTED; return TransactionSelectionResult.SELECTED;
} }

@ -83,6 +83,7 @@ import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector;
import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelectorFactory; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelectorFactory;
import org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
import org.hyperledger.besu.util.number.Percentage; import org.hyperledger.besu.util.number.Percentage;
@ -581,17 +582,25 @@ public abstract class AbstractBlockTransactionSelectorTest {
new PluginTransactionSelector() { new PluginTransactionSelector() {
@Override @Override
public TransactionSelectionResult evaluateTransactionPreProcessing( public TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction) { final TransactionEvaluationContext<? extends PendingTransaction>
if (pendingTransaction.getTransaction().equals(notSelectedTransient)) evaluationContext) {
if (evaluationContext
.getPendingTransaction()
.getTransaction()
.equals(notSelectedTransient))
return PluginTransactionSelectionResult.GENERIC_PLUGIN_INVALID_TRANSIENT; return PluginTransactionSelectionResult.GENERIC_PLUGIN_INVALID_TRANSIENT;
if (pendingTransaction.getTransaction().equals(notSelectedInvalid)) if (evaluationContext
.getPendingTransaction()
.getTransaction()
.equals(notSelectedInvalid))
return PluginTransactionSelectionResult.GENERIC_PLUGIN_INVALID; return PluginTransactionSelectionResult.GENERIC_PLUGIN_INVALID;
return SELECTED; return SELECTED;
} }
@Override @Override
public TransactionSelectionResult evaluateTransactionPostProcessing( public TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext<? extends PendingTransaction>
evaluationContext,
final org.hyperledger.besu.plugin.data.TransactionProcessingResult final org.hyperledger.besu.plugin.data.TransactionProcessingResult
processingResult) { processingResult) {
return SELECTED; return SELECTED;
@ -645,13 +654,15 @@ public abstract class AbstractBlockTransactionSelectorTest {
new PluginTransactionSelector() { new PluginTransactionSelector() {
@Override @Override
public TransactionSelectionResult evaluateTransactionPreProcessing( public TransactionSelectionResult evaluateTransactionPreProcessing(
final PendingTransaction pendingTransaction) { final TransactionEvaluationContext<? extends PendingTransaction>
evaluationContext) {
return SELECTED; return SELECTED;
} }
@Override @Override
public TransactionSelectionResult evaluateTransactionPostProcessing( public TransactionSelectionResult evaluateTransactionPostProcessing(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext<? extends PendingTransaction>
evaluationContext,
final org.hyperledger.besu.plugin.data.TransactionProcessingResult final org.hyperledger.besu.plugin.data.TransactionProcessingResult
processingResult) { processingResult) {
// the transaction with max gas +1 should fail // the transaction with max gas +1 should fail
@ -711,13 +722,14 @@ public abstract class AbstractBlockTransactionSelectorTest {
selector.buildTransactionListForBlock(); selector.buildTransactionListForBlock();
ArgumentCaptor<PendingTransaction> argumentCaptor = @SuppressWarnings("unchecked")
ArgumentCaptor.forClass(PendingTransaction.class); ArgumentCaptor<TransactionEvaluationContext<PendingTransaction>> argumentCaptor =
ArgumentCaptor.forClass(TransactionEvaluationContext.class);
// selected transaction must be notified to the selector // selected transaction must be notified to the selector
verify(transactionSelector) verify(transactionSelector)
.onTransactionSelected(argumentCaptor.capture(), any(TransactionProcessingResult.class)); .onTransactionSelected(argumentCaptor.capture(), any(TransactionProcessingResult.class));
PendingTransaction selected = argumentCaptor.getValue(); PendingTransaction selected = argumentCaptor.getValue().getPendingTransaction();
assertThat(selected.getTransaction()).isEqualTo(transaction); assertThat(selected.getTransaction()).isEqualTo(transaction);
// unselected transaction must be notified to the selector with correct reason // unselected transaction must be notified to the selector with correct reason
@ -725,7 +737,7 @@ public abstract class AbstractBlockTransactionSelectorTest {
.onTransactionNotSelected( .onTransactionNotSelected(
argumentCaptor.capture(), argumentCaptor.capture(),
eq(TransactionSelectionResult.invalid(invalidReason.toString()))); eq(TransactionSelectionResult.invalid(invalidReason.toString())));
PendingTransaction rejectedTransaction = argumentCaptor.getValue(); PendingTransaction rejectedTransaction = argumentCaptor.getValue().getPendingTransaction();
assertThat(rejectedTransaction.getTransaction()).isEqualTo(invalidTransaction); assertThat(rejectedTransaction.getTransaction()).isEqualTo(invalidTransaction);
} }
@ -931,9 +943,10 @@ public abstract class AbstractBlockTransactionSelectorTest {
final BiFunction<Transaction, Long, Answer<TransactionSelectionResult>> tooLate = final BiFunction<Transaction, Long, Answer<TransactionSelectionResult>> tooLate =
(p, t) -> (p, t) ->
invocation -> { invocation -> {
final org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction ptx = final org.hyperledger.besu.ethereum.blockcreation.txselection
invocation.getArgument(0); .TransactionEvaluationContext
if (ptx.getTransaction().equals(p)) { ctx = invocation.getArgument(0);
if (ctx.getTransaction().equals(p)) {
Thread.sleep(t); Thread.sleep(t);
} else { } else {
Thread.sleep(fastProcessingTxTime); Thread.sleep(fastProcessingTxTime);

@ -21,6 +21,7 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.AbstractTransactionSelector; import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.AbstractTransactionSelector;
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.MinPriorityFeePerGasTransactionSelector; import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.MinPriorityFeePerGasTransactionSelector;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningParameters;
@ -29,6 +30,7 @@ import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
import com.google.common.base.Stopwatch;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -56,44 +58,47 @@ public class MinPriorityFeePerGasTransactionSelectorTest {
@Test @Test
public void shouldNotSelectWhen_PriorityFeePerGas_IsLessThan_MinPriorityFeePerGas() { public void shouldNotSelectWhen_PriorityFeePerGas_IsLessThan_MinPriorityFeePerGas() {
var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter - 1); var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter - 1);
assertSelectionResult( assertSelectionResult(
transaction, TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN); transaction, TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN);
} }
@Test @Test
public void shouldSelectWhen_PriorityFeePerGas_IsEqual_MinPriorityFeePerGas() { public void shouldSelectWhen_PriorityFeePerGas_IsEqual_MinPriorityFeePerGas() {
var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter); var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter);
assertSelectionResult(transaction, TransactionSelectionResult.SELECTED); assertSelectionResult(transaction, TransactionSelectionResult.SELECTED);
} }
@Test @Test
public void shouldSelectWhen_PriorityFeePerGas_IsGreaterThan_MinPriorityFeePerGas() { public void shouldSelectWhen_PriorityFeePerGas_IsGreaterThan_MinPriorityFeePerGas() {
var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter + 1); var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter + 1);
assertSelectionResult(transaction, TransactionSelectionResult.SELECTED); assertSelectionResult(transaction, TransactionSelectionResult.SELECTED);
} }
@Test @Test
public void shouldSelectWhenPrioritySender() { public void shouldSelectWhenPrioritySender() {
var prioritySenderTransaction = mockTransactionWithPriorityFee(minPriorityFeeParameter - 1); final var evaluationContext = mockTransactionEvaluationContext(minPriorityFeeParameter - 1);
assertSelectionResult( assertSelectionResult(
prioritySenderTransaction, evaluationContext, TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN);
TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN); when(evaluationContext.getPendingTransaction().hasPriority()).thenReturn(true);
when(prioritySenderTransaction.hasPriority()).thenReturn(true); assertSelectionResult(evaluationContext, TransactionSelectionResult.SELECTED);
assertSelectionResult(prioritySenderTransaction, TransactionSelectionResult.SELECTED);
} }
private void assertSelectionResult( private void assertSelectionResult(
final PendingTransaction transaction, final TransactionSelectionResult expectedResult) { final TransactionEvaluationContext evaluationContext,
var actualResult = transactionSelector.evaluateTransactionPreProcessing(transaction, null); final TransactionSelectionResult expectedResult) {
var actualResult =
transactionSelector.evaluateTransactionPreProcessing(evaluationContext, null);
assertThat(actualResult).isEqualTo(expectedResult); assertThat(actualResult).isEqualTo(expectedResult);
} }
private PendingTransaction mockTransactionWithPriorityFee(final int priorityFeePerGas) { private TransactionEvaluationContext mockTransactionEvaluationContext(
PendingTransaction mockTransaction = mock(PendingTransaction.class); final int priorityFeePerGas) {
PendingTransaction pendingTransaction = mock(PendingTransaction.class);
Transaction transaction = mock(Transaction.class); Transaction transaction = mock(Transaction.class);
when(mockTransaction.getTransaction()).thenReturn(transaction); when(pendingTransaction.getTransaction()).thenReturn(transaction);
when(transaction.getEffectivePriorityFeePerGas(any())).thenReturn(Wei.of(priorityFeePerGas)); when(transaction.getEffectivePriorityFeePerGas(any())).thenReturn(Wei.of(priorityFeePerGas));
return mockTransaction; return new TransactionEvaluationContext(
pendingTransaction, Stopwatch.createStarted(), Wei.ONE, Wei.ONE);
} }
} }

@ -221,7 +221,7 @@ public class EVMExecutor {
final EVMExecutor executor = new EVMExecutor(MainnetEVMs.tangerineWhistle(evmConfiguration)); final EVMExecutor executor = new EVMExecutor(MainnetEVMs.tangerineWhistle(evmConfiguration));
executor.precompileContractRegistry = executor.precompileContractRegistry =
MainnetPrecompiledContracts.frontier(executor.evm.getGasCalculator()); MainnetPrecompiledContracts.frontier(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000)); executor.contractValidationRules = List.of();
executor.initialNonce = 0; executor.initialNonce = 0;
return executor; return executor;
} }

@ -1,4 +1,4 @@
version=24.1.0-SNAPSHOT version=24.1.1-SNAPSHOT
org.gradle.welcome=never org.gradle.welcome=never
# Set exports/opens flags required by Google Java Format and ErrorProne plugins. (JEP-396) # Set exports/opens flags required by Google Java Format and ErrorProne plugins. (JEP-396)

@ -60,6 +60,10 @@
"moduleLicense": "Eclipse Public License - v 1.0", "moduleLicense": "Eclipse Public License - v 1.0",
"moduleVersion": "4.13.2", "moduleVersion": "4.13.2",
"moduleName": "junit:junit" "moduleName": "junit:junit"
},
{
"moduleName": "org.jetbrains.kotlin:kotlin-stdlib-common",
"moduleVersion": "1.9.22"
} }
] ]
} }

@ -50,9 +50,9 @@
{ "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*Apache License,?( Version)? 2.*" }, { "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*Apache License,?( Version)? 2.*" },
{ "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/Apache-2\\.0.*" }, { "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/Apache-2\\.0.*" },
{ "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*www\\.apache\\.org/licenses/LICENSE-2\\.0.*" }, { "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*www\\.apache\\.org/licenses/LICENSE-2\\.0.*" },
{ "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*www\\.gnu\\.org/licenses/old-licenses/lgpl-2\\.1\\.html" },
{ "bundleName" : "Apache-2.0", "licenseFileContentPattern" : ".*Apache License,?( Version)? 2.*" }, { "bundleName" : "Apache-2.0", "licenseFileContentPattern" : ".*Apache License,?( Version)? 2.*" },
{ "bundleName" : "Apache-1.1", "licenseFileContentPattern" : ".*Apache Software License, Version 1\\.1.*" }, { "bundleName" : "Apache-1.1", "licenseFileContentPattern" : ".*Apache Software License, Version 1\\.1.*" },
{ "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*www\\.gnu\\.org/licenses/old-licenses/lgpl-2\\.1\\.html" },
{ "bundleName" : "CC0-1.0", "licenseNamePattern" : "CC0(( |-)1(\\.0)?)?" }, { "bundleName" : "CC0-1.0", "licenseNamePattern" : "CC0(( |-)1(\\.0)?)?" },
{ "bundleName" : "CC0-1.0", "licenseUrlPattern" : ".*(www\\.)?creativecommons\\.org/publicdomain/zero/1\\.0/" }, { "bundleName" : "CC0-1.0", "licenseUrlPattern" : ".*(www\\.)?creativecommons\\.org/publicdomain/zero/1\\.0/" },
{ "bundleName" : "CDDL-1.0", "licenseFileContentPattern" : ".*CDDL.*1\\.0" }, { "bundleName" : "CDDL-1.0", "licenseFileContentPattern" : ".*CDDL.*1\\.0" },

File diff suppressed because it is too large Load Diff

@ -22,7 +22,7 @@ dependencyManagement {
entry 'antlr4-runtime' entry 'antlr4-runtime'
} }
dependencySet(group:'com.fasterxml.jackson.core', version:'2.14.2') { dependencySet(group:'com.fasterxml.jackson.core', version:'2.16.1') {
entry 'jackson-databind' entry 'jackson-databind'
entry 'jackson-datatype' entry 'jackson-datatype'
entry 'jackson-datatype-jdk8' entry 'jackson-datatype-jdk8'
@ -30,14 +30,11 @@ dependencyManagement {
dependency 'com.github.ben-manes.caffeine:caffeine:3.1.8' dependency 'com.github.ben-manes.caffeine:caffeine:3.1.8'
dependencySet(group: 'com.github.tomakehurst', version: '2.35.0') { dependency 'com.github.oshi:oshi-core:6.4.10'
entry'wiremock-jre8-standalone'
entry'wiremock-jre8'
}
dependency 'com.google.auto.service:auto-service:1.0.1' dependency 'com.google.auto.service:auto-service:1.1.1'
dependencySet(group: 'com.google.dagger', version: '2.45') { dependencySet(group: 'com.google.dagger', version: '2.50') {
entry'dagger-compiler' entry'dagger-compiler'
entry'dagger' entry'dagger'
} }
@ -51,37 +48,37 @@ dependencyManagement {
dependency 'com.google.guava:guava:31.1-jre' dependency 'com.google.guava:guava:31.1-jre'
dependency 'com.graphql-java:graphql-java:20.1' dependency 'com.graphql-java:graphql-java:21.3'
dependency 'com.splunk.logging:splunk-library-javalogging:1.11.5' dependency 'com.splunk.logging:splunk-library-javalogging:1.11.8'
dependency 'com.squareup.okhttp3:okhttp:4.10.0' dependency 'com.squareup.okhttp3:okhttp:4.12.0'
dependency 'commons-codec:commons-codec:1.15' dependency 'commons-codec:commons-codec:1.16.0'
dependency 'commons-io:commons-io:2.11.0' dependency 'commons-io:commons-io:2.15.1'
dependency 'dnsjava:dnsjava:3.5.2' dependency 'dnsjava:dnsjava:3.5.3'
dependencySet(group: 'info.picocli', version: '4.7.1') { dependencySet(group: 'info.picocli', version: '4.7.5') {
entry 'picocli' entry 'picocli'
entry 'picocli-codegen' entry 'picocli-codegen'
} }
dependencySet(group: 'io.grpc', version: '1.59.0') { dependencySet(group: 'io.grpc', version: '1.60.1') {
entry 'grpc-all' entry 'grpc-all'
entry 'grpc-core' entry 'grpc-core'
entry 'grpc-netty' entry 'grpc-netty'
entry 'grpc-stub' entry 'grpc-stub'
} }
dependency 'io.kubernetes:client-java:18.0.0' dependency 'io.kubernetes:client-java:18.0.1'
dependency 'io.netty:netty-all:4.1.100.Final' dependency 'io.netty:netty-all:4.1.104.Final'
dependency 'io.netty:netty-tcnative-boringssl-static:2.0.62.Final' dependency 'io.netty:netty-tcnative-boringssl-static:2.0.62.Final'
dependency group: 'io.netty', name: 'netty-transport-native-epoll', version:'4.1.100.Final', classifier: 'linux-x86_64' dependency group: 'io.netty', name: 'netty-transport-native-epoll', version:'4.1.104.Final', classifier: 'linux-x86_64'
dependency group: 'io.netty', name: 'netty-transport-native-kqueue', version:'4.1.100.Final', classifier: 'osx-x86_64' dependency group: 'io.netty', name: 'netty-transport-native-kqueue', version:'4.1.104.Final', classifier: 'osx-x86_64'
dependency 'io.netty:netty-transport-native-unix-common:4.1.100.Final' dependency 'io.netty:netty-transport-native-unix-common:4.1.104.Final'
dependency 'io.opentelemetry:opentelemetry-api:1.24.0' dependency 'io.opentelemetry:opentelemetry-api:1.24.0'
dependency 'io.opentelemetry:opentelemetry-exporter-otlp:1.24.0' dependency 'io.opentelemetry:opentelemetry-exporter-otlp:1.24.0'
@ -108,6 +105,20 @@ dependencyManagement {
dependency 'io.reactivex.rxjava2:rxjava:2.2.21' dependency 'io.reactivex.rxjava2:rxjava:2.2.21'
dependencySet(group: 'io.tmio', version: '2.4.2') {
entry 'tuweni-bytes'
entry 'tuweni-config'
entry 'tuweni-concurrent'
entry 'tuweni-crypto'
entry 'tuweni-devp2p'
entry 'tuweni-dns-discovery'
entry 'tuweni-io'
entry 'tuweni-net'
entry 'tuweni-rlp'
entry 'tuweni-toml'
entry 'tuweni-units'
}
dependencySet(group: 'io.vertx', version: '4.3.5') { dependencySet(group: 'io.vertx', version: '4.3.5') {
entry 'vertx-auth-jwt' entry 'vertx-auth-jwt'
entry 'vertx-codegen' entry 'vertx-codegen'
@ -121,43 +132,29 @@ dependencyManagement {
dependency 'junit:junit:4.13.2' dependency 'junit:junit:4.13.2'
dependency 'net.java.dev.jna:jna:5.13.0' dependency 'net.java.dev.jna:jna:5.14.0'
dependency 'org.apache.commons:commons-compress:1.23.0' dependency 'org.apache.commons:commons-compress:1.25.0'
dependency 'org.apache.commons:commons-lang3:3.12.0' dependency 'org.apache.commons:commons-lang3:3.14.0'
dependency 'org.apache.commons:commons-text:1.10.0' dependency 'org.apache.commons:commons-text:1.11.0'
dependencySet(group: 'org.apache.logging.log4j', version: '2.20.0') { dependencySet(group: 'org.apache.logging.log4j', version: '2.22.1') {
entry 'log4j-api' entry 'log4j-api'
entry 'log4j-core' entry 'log4j-core'
entry 'log4j-jul' entry 'log4j-jul'
entry 'log4j-slf4j2-impl' entry 'log4j-slf4j2-impl'
} }
dependencySet(group: 'io.tmio', version: '2.4.2') { dependency 'org.assertj:assertj-core:3.25.1'
entry 'tuweni-bytes'
entry 'tuweni-config'
entry 'tuweni-concurrent'
entry 'tuweni-crypto'
entry 'tuweni-devp2p'
entry 'tuweni-dns-discovery'
entry 'tuweni-io'
entry 'tuweni-net'
entry 'tuweni-rlp'
entry 'tuweni-toml'
entry 'tuweni-units'
}
dependency 'org.assertj:assertj-core:3.24.2'
dependency 'org.awaitility:awaitility:4.2.0' dependency 'org.awaitility:awaitility:4.2.0'
dependencySet(group: 'org.bouncycastle', version: '1.76') { dependencySet(group: 'org.bouncycastle', version: '1.77') {
entry'bcpkix-jdk18on' entry'bcpkix-jdk18on'
entry'bcprov-jdk18on' entry'bcprov-jdk18on'
} }
dependency 'org.fusesource.jansi:jansi:2.4.0' dependency 'org.fusesource.jansi:jansi:2.4.1'
dependency 'org.openjdk.jol:jol-core:0.17' dependency 'org.openjdk.jol:jol-core:0.17'
dependency 'tech.pegasys:jc-kzg-4844:0.8.0' dependency 'tech.pegasys:jc-kzg-4844:0.8.0'
@ -170,16 +167,16 @@ dependencyManagement {
entry 'blake2bf' entry 'blake2bf'
} }
dependencySet(group: 'org.immutables', version: '2.9.3') { dependencySet(group: 'org.immutables', version: '2.10.0') {
entry 'value-annotations' entry 'value-annotations'
entry 'value' entry 'value'
} }
dependency 'org.java-websocket:Java-WebSocket:1.5.3' dependency 'org.java-websocket:Java-WebSocket:1.5.5'
dependency 'org.jetbrains.kotlin:kotlin-stdlib:1.8.10' dependency 'org.jetbrains.kotlin:kotlin-stdlib:1.9.22'
dependencySet(group: 'org.junit.jupiter', version: '5.8.2') { dependencySet(group: 'org.junit.jupiter', version: '5.10.1') {
entry 'junit-jupiter' entry 'junit-jupiter'
entry 'junit-jupiter-api' entry 'junit-jupiter-api'
entry 'junit-jupiter-engine' entry 'junit-jupiter-engine'
@ -188,9 +185,9 @@ dependencyManagement {
dependency 'org.junit.platform:junit-platform-runner:1.9.2' dependency 'org.junit.platform:junit-platform-runner:1.9.2'
dependency 'org.junit.vintage:junit-vintage-engine:5.9.2' dependency 'org.junit.vintage:junit-vintage-engine:5.10.1'
dependencySet(group: 'org.jupnp', version:'2.7.0') { dependencySet(group: 'org.jupnp', version:'2.7.1') {
entry 'org.jupnp.support' entry 'org.jupnp.support'
entry 'org.jupnp' entry 'org.jupnp'
} }
@ -207,31 +204,33 @@ dependencyManagement {
dependency 'org.owasp.encoder:encoder:1.2.3' dependency 'org.owasp.encoder:encoder:1.2.3'
dependency 'org.rocksdb:rocksdbjni:8.3.2' dependency 'org.rocksdb:rocksdbjni:8.9.1'
dependencySet(group: 'org.slf4j', version:'2.0.7') { dependencySet(group: 'org.slf4j', version:'2.0.10') {
entry 'slf4j-api' entry 'slf4j-api'
entry 'slf4j-nop' entry 'slf4j-nop'
} }
dependency 'org.springframework.security:spring-security-crypto:6.0.2' dependency 'org.springframework.security:spring-security-crypto:6.2.1'
dependency 'org.testcontainers:testcontainers:1.17.6' dependency 'org.testcontainers:testcontainers:1.19.3'
dependency 'org.web3j:quorum:4.9.5' dependency 'org.web3j:quorum:4.9.5'
dependencySet(group: 'org.web3j', version: '4.9.7') { dependencySet(group: 'org.web3j', version: '4.10.3') {
entry 'abi' entry 'abi'
entry 'besu' entry 'besu'
entry 'core' entry 'core'
entry 'crypto' entry 'crypto'
} }
dependency 'org.xerial.snappy:snappy-java:1.1.9.1' dependencySet(group: 'org.wiremock', version: '3.3.1') {
entry 'wiremock'
}
dependency 'org.xerial.snappy:snappy-java:1.1.10.5'
dependency 'org.yaml:snakeyaml:2.0' dependency 'org.yaml:snakeyaml:2.0'
dependency 'tech.pegasys.discovery:discovery:22.2.0' dependency 'tech.pegasys.discovery:discovery:22.2.0'
dependency 'com.github.oshi:oshi-core:6.4.1'
} }
} }

@ -33,6 +33,8 @@ public class DockerDetector implements NatMethodDetector {
return stream return stream
.filter(line -> line.contains("/docker")) .filter(line -> line.contains("/docker"))
.findFirst() .findFirst()
// fallback to looking for /.dockerenv in case we are running on Docker for Mac
.or(() -> Optional.ofNullable(Files.exists(Paths.get("/.dockerenv")) ? "docker" : null))
.map(__ -> NatMethod.DOCKER); .map(__ -> NatMethod.DOCKER);
} catch (IOException e) { } catch (IOException e) {
return Optional.empty(); return Optional.empty();

@ -22,11 +22,13 @@ import org.hyperledger.besu.pki.PkiException;
import java.nio.file.Path; import java.nio.file.Path;
import java.security.Provider; import java.security.Provider;
import java.security.Security; import java.security.Security;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.condition.OS;
@ -37,13 +39,19 @@ public class HardwareKeyStoreFileWrapperTest extends BaseKeyStoreFileWrapperTest
private static final String crl = "/keystore/partner1client1/crl.pem"; private static final String crl = "/keystore/partner1client1/crl.pem";
private static final String configName = "NSScrypto-partner1client1"; private static final String configName = "NSScrypto-partner1client1";
private static final String validKeystorePassword = "test123"; private static final String validKeystorePassword = "test123";
private static KeyStoreWrapperTestParameter keyStoreWrapperTestParameter;
public static Collection<KeyStoreWrapperTestParameter> data() { @BeforeAll
return Arrays.asList( public static void setup() {
keyStoreWrapperTestParameter =
new KeyStoreWrapperTestParameter( new KeyStoreWrapperTestParameter(
"HardwareKeyStoreWrapper[PKCS11 keystore/truststore]", "HardwareKeyStoreWrapper[PKCS11 keystore/truststore]",
true, true,
CryptoTestUtil.isNSSLibInstalled() ? getHardwareKeyStoreWrapper(configName) : null)); CryptoTestUtil.isNSSLibInstalled() ? getHardwareKeyStoreWrapper(configName) : null);
}
public static Collection<KeyStoreWrapperTestParameter> data() {
return List.of(keyStoreWrapperTestParameter);
} }
private static KeyStoreWrapper getHardwareKeyStoreWrapper(final String cfgName) { private static KeyStoreWrapper getHardwareKeyStoreWrapper(final String cfgName) {
@ -58,11 +66,10 @@ public class HardwareKeyStoreFileWrapperTest extends BaseKeyStoreFileWrapperTest
.map(provider -> new HardwareKeyStoreWrapper(validKeystorePassword, provider, crlPath)) .map(provider -> new HardwareKeyStoreWrapper(validKeystorePassword, provider, crlPath))
.orElseGet(() -> new HardwareKeyStoreWrapper(validKeystorePassword, path, crlPath)); .orElseGet(() -> new HardwareKeyStoreWrapper(validKeystorePassword, path, crlPath));
} catch (final Exception e) { } catch (final Exception e) {
if (OS.MAC.isCurrentOs()) { // nss3 is difficult to setup on mac, don't let it break unit tests for dev machines.
// nss3 is difficult to setup on mac correctly, don't let it break unit tests for dev Assumptions.assumeFalse(
// machines. OS.MAC.isCurrentOs(),
System.out.println("Failed to initialize hardware keystore " + e.getLocalizedMessage()); "Failed to initialize hardware keystore: " + e.getLocalizedMessage());
}
// Not a mac, probably a production build. Full failure. // Not a mac, probably a production build. Full failure.
throw new PkiException("Failed to initialize hardware keystore", e); throw new PkiException("Failed to initialize hardware keystore", e);
} }

@ -69,7 +69,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) { tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought" description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files files = sourceSets.main.allJava.files
knownHash = 'N583pqJipDs4kJkgL0cPq9PBsYdsLzvUlu2I8Kk+w7g=' knownHash = 'IGq+V3KaStHCRFkeK3KwPxJYKO4RX9YM1O4JYITk8S8='
} }
check.dependsOn('checkAPIChanges') check.dependsOn('checkAPIChanges')

@ -39,39 +39,40 @@ public interface PluginTransactionSelector {
* Method called to decide whether a transaction is added to a block. The result can also indicate * Method called to decide whether a transaction is added to a block. The result can also indicate
* that no further transactions can be added to the block. * that no further transactions can be added to the block.
* *
* @param pendingTransaction candidate transaction * @param evaluationContext The current selection context
* @return TransactionSelectionResult that indicates whether to include the transaction * @return TransactionSelectionResult that indicates whether to include the transaction
*/ */
TransactionSelectionResult evaluateTransactionPreProcessing( TransactionSelectionResult evaluateTransactionPreProcessing(
PendingTransaction pendingTransaction); TransactionEvaluationContext<? extends PendingTransaction> evaluationContext);
/** /**
* Method called to decide whether a processed transaction is added to a block. The result can * Method called to decide whether a processed transaction is added to a block. The result can
* also indicate that no further transactions can be added to the block. * also indicate that no further transactions can be added to the block.
* *
* @param pendingTransaction candidate transaction * @param evaluationContext The current selection context
* @param processingResult the transaction processing result * @param processingResult the transaction processing result
* @return TransactionSelectionResult that indicates whether to include the transaction * @return TransactionSelectionResult that indicates whether to include the transaction
*/ */
TransactionSelectionResult evaluateTransactionPostProcessing( TransactionSelectionResult evaluateTransactionPostProcessing(
PendingTransaction pendingTransaction, TransactionProcessingResult processingResult); TransactionEvaluationContext<? extends PendingTransaction> evaluationContext,
TransactionProcessingResult processingResult);
/** /**
* Method called when a transaction is selected to be added to a block. * Method called when a transaction is selected to be added to a block.
* *
* @param pendingTransaction The transaction that has been selected. * @param evaluationContext The current selection context
* @param processingResult The result of processing the selected transaction. * @param processingResult The result of processing the selected transaction.
*/ */
default void onTransactionSelected( default void onTransactionSelected(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext<? extends PendingTransaction> evaluationContext,
final TransactionProcessingResult processingResult) {} final TransactionProcessingResult processingResult) {}
/** /**
* Method called when a transaction is not selected to be added to a block. * Method called when a transaction is not selected to be added to a block.
* *
* @param pendingTransaction The transaction that has not been selected. * @param evaluationContext The current selection context
* @param transactionSelectionResult The transaction selection result * @param transactionSelectionResult The transaction selection result
*/ */
default void onTransactionNotSelected( default void onTransactionNotSelected(
final PendingTransaction pendingTransaction, final TransactionEvaluationContext<? extends PendingTransaction> evaluationContext,
final TransactionSelectionResult transactionSelectionResult) {} final TransactionSelectionResult transactionSelectionResult) {}
} }

@ -0,0 +1,57 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.plugin.services.txselection;
import org.hyperledger.besu.datatypes.PendingTransaction;
import org.hyperledger.besu.datatypes.Wei;
import com.google.common.base.Stopwatch;
/**
* This interface defines the context for evaluating a transaction. It provides methods to get the
* pending transaction, the evaluation timer, and the transaction gas price.
*
* @param <PT> the type of the pending transaction
*/
public interface TransactionEvaluationContext<PT extends PendingTransaction> {
/**
* Gets the pending transaction.
*
* @return the pending transaction
*/
PT getPendingTransaction();
/**
* Gets the stopwatch used for timing the evaluation.
*
* @return the evaluation timer
*/
Stopwatch getEvaluationTimer();
/**
* Gets the gas price of the transaction.
*
* @return the transaction gas price
*/
Wei getTransactionGasPrice();
/**
* Gets the min gas price for block inclusion
*
* @return the min gas price
*/
Wei getMinGasPrice();
}

@ -37,6 +37,8 @@ import javax.annotation.Nullable;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonFactoryBuilder;
import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
@ -121,7 +123,12 @@ public class JsonTestParameters<S, T> {
} }
private static final ObjectMapper objectMapper = private static final ObjectMapper objectMapper =
new ObjectMapper().registerModule(new Jdk8Module()); new ObjectMapper(
new JsonFactoryBuilder()
.streamReadConstraints(
StreamReadConstraints.builder().maxStringLength(Integer.MAX_VALUE).build())
.build())
.registerModule(new Jdk8Module());
// The type to which the json file is directly mapped // The type to which the json file is directly mapped
private final Class<S> jsonFileMappedType; private final Class<S> jsonFileMappedType;

Loading…
Cancel
Save