diff --git a/.circleci/config.yml b/.circleci/config.yml index bcd81e45cb..2f008df257 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -269,7 +269,7 @@ jobs: - capture_test_logs acceptanceTestsPermissioning: - executor: besu_executor_xl + executor: besu_executor_med steps: - prepare - attach_workspace: @@ -278,7 +278,7 @@ jobs: name: AcceptanceTests (Non-Mainnet) no_output_timeout: 20m command: | - ./gradlew --no-daemon acceptanceTestPermissioning + ./gradlew --no-daemon --max-workers=1 acceptanceTestPermissioning - capture_test_results - capture_test_logs @@ -428,12 +428,12 @@ workflows: - acceptanceTestsPermissioning: requires: - assemble - - acceptanceTestsCliqueBft - buildDocker: requires: - assemble - buildArm64Docker: requires: + - buildDocker - assemble - publish: filters: diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f51e8b4c2..abcc2ab3c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,26 +1,64 @@ # Changelog -## 24.1.0-SNAPSHOT +## 24.1.1-SNAPSHOT ### 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) - 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 - 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 - 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) - 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) -- 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 -- 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) +- Hotfix for selfdestruct preimages on bonsai [#6359]((https://github.com/hyperledger/besu/pull/6359) +- 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 @@ -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) - 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) +- Optimization: Delete leftPad when capturing the stack before and after a frame execution [#6102](https://github.com/hyperledger/besu/pull/6102) ### Bug fixes - Upgrade netty to address CVE-2023-44487, CVE-2023-34462 [#6100](https://github.com/hyperledger/besu/pull/6100) diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle index 96a6a1c1bc..6c9090fe9b 100644 --- a/acceptance-tests/dsl/build.gradle +++ b/acceptance-tests/dsl/build.gradle @@ -26,7 +26,6 @@ dependencies { implementation project(':testutil') implementation project(':util') - implementation 'com.github.tomakehurst:wiremock-jre8' implementation 'com.google.guava:guava' implementation 'com.google.dagger:dagger' annotationProcessor 'com.google.dagger:dagger-compiler' @@ -45,6 +44,7 @@ dependencies { implementation 'org.web3j:abi' implementation 'org.web3j:besu' implementation 'org.web3j:crypto' + implementation 'org.wiremock:wiremock' implementation 'org.testcontainers:testcontainers' implementation 'org.junit.jupiter:junit-jupiter' diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java index c4ee134727..d3a86bafa8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java @@ -77,6 +77,10 @@ public class EthConditions { return new MiningStatusCondition(transactions.mining(), isMining); } + public Condition syncingStatus(final boolean isSyncing) { + return new SyncingStatusCondition(transactions.syncing(), isSyncing); + } + public Condition expectNewPendingTransactions( final BigInteger filterId, final List transactionHashes) { return new NewPendingTransactionFilterChangesCondition( diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/SyncingStatusCondition.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/SyncingStatusCondition.java new file mode 100644 index 0000000000..5e01a0d4a9 --- /dev/null +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/SyncingStatusCondition.java @@ -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)); + } +} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java index c8613e9a4b..ba00ac8f22 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java @@ -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.PrivacyParameters; 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.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -100,6 +101,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable private final String name; private MiningParameters miningParameters; + private TransactionPoolConfiguration txPoolConfiguration; private final List runCommand; private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT; private final JsonRpcConfiguration jsonRpcConfiguration; @@ -135,6 +137,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable final String name, final Optional dataPath, final MiningParameters miningParameters, + final TransactionPoolConfiguration txPoolConfiguration, final JsonRpcConfiguration jsonRpcConfiguration, final Optional engineRpcConfiguration, final WebSocketConfiguration webSocketConfiguration, @@ -184,6 +187,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable () -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory)); this.name = name; this.miningParameters = miningParameters; + this.txPoolConfiguration = txPoolConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration; this.webSocketConfiguration = webSocketConfiguration; @@ -661,7 +665,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable this.bootnodes.addAll(bootnodes); } - MiningParameters getMiningParameters() { + public MiningParameters getMiningParameters() { return miningParameters; } @@ -669,6 +673,15 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable this.miningParameters = miningParameters; } + public TransactionPoolConfiguration getTransactionPoolConfiguration() { + return txPoolConfiguration; + } + + public void setTransactionPoolConfiguration( + final TransactionPoolConfiguration txPoolConfiguration) { + this.txPoolConfiguration = txPoolConfiguration; + } + public PrivacyParameters getPrivacyParameters() { return privacyParameters; } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java index f01c58549b..538cb89e12 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java @@ -17,8 +17,10 @@ package org.hyperledger.besu.tests.acceptance.dsl.node; import static com.google.common.base.Preconditions.checkState; 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.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.permissioning.PermissioningConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; @@ -98,6 +100,15 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner { params.add("--p2p-port"); params.add(node.getP2pPort()); + params.addAll( + TransactionPoolOptions.fromConfig( + ImmutableTransactionPoolConfiguration.builder() + .from(node.getTransactionPoolConfiguration()) + .strictTransactionReplayProtectionEnabled( + node.isStrictTxReplayProtectionEnabled()) + .build()) + .getCLIOptions()); + if (node.getMiningParameters().isMiningEnabled()) { params.add("--miner-enabled"); params.add("--miner-coinbase"); @@ -391,9 +402,6 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner { params.add("--auto-log-bloom-caching-enabled"); params.add("false"); - params.add("--strict-tx-replay-protection-enabled"); - params.add(Boolean.toString(node.isStrictTxReplayProtectionEnabled())); - final String level = System.getProperty("root.log.level"); if (level != null) { params.add("--logging=" + level); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java index 501674ea38..429c91d2b9 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java @@ -182,6 +182,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { final TransactionPoolConfiguration txPoolConfig = ImmutableTransactionPoolConfiguration.builder() + .from(node.getTransactionPoolConfiguration()) .strictTransactionReplayProtectionEnabled(node.isStrictTxReplayProtectionEnabled()) .build(); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java index 16a0287426..b454894e06 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java @@ -86,11 +86,8 @@ public class Cluster implements AutoCloseable { final Optional bootnode = selectAndStartBootnode(nodes); nodes.parallelStream() - .filter( - node -> { - LOG.info("starting non-bootnode {}", node.getName()); - return bootnode.map(boot -> boot != node).orElse(true); - }) + .filter(node -> bootnode.map(boot -> boot != node).orElse(true)) + .peek(node -> LOG.info("starting non-bootnode {}", node.getName())) .forEach(this::startNode); if (clusterConfiguration.isAwaitPeerDiscovery()) { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java index 3a61749881..0c0d66be6a 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java @@ -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.core.MiningParameters; 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.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -39,6 +40,7 @@ public class BesuNodeConfiguration { private final String name; private final Optional dataPath; private final MiningParameters miningParameters; + private final TransactionPoolConfiguration transactionPoolConfiguration; private final JsonRpcConfiguration jsonRpcConfiguration; private final Optional engineRpcConfiguration; private final WebSocketConfiguration webSocketConfiguration; @@ -74,6 +76,7 @@ public class BesuNodeConfiguration { final String name, final Optional dataPath, final MiningParameters miningParameters, + final TransactionPoolConfiguration transactionPoolConfiguration, final JsonRpcConfiguration jsonRpcConfiguration, final Optional engineRpcConfiguration, final WebSocketConfiguration webSocketConfiguration, @@ -106,6 +109,7 @@ public class BesuNodeConfiguration { final Map environment) { this.name = name; this.miningParameters = miningParameters; + this.transactionPoolConfiguration = transactionPoolConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration; this.webSocketConfiguration = webSocketConfiguration; @@ -147,6 +151,10 @@ public class BesuNodeConfiguration { return miningParameters; } + public TransactionPoolConfiguration getTransactionPoolConfiguration() { + return transactionPoolConfiguration; + } + public JsonRpcConfiguration getJsonRpcConfiguration() { return jsonRpcConfiguration; } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java index 2a7f16d24f..c20e7ec6d1 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java @@ -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.MiningParameters; 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.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -63,7 +64,8 @@ public class BesuNodeConfigurationBuilder { .mutableInitValues( MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build()) .build(); - + private TransactionPoolConfiguration transactionPoolConfiguration = + TransactionPoolConfiguration.DEFAULT; private JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); private JsonRpcConfiguration engineRpcConfiguration = JsonRpcConfiguration.createEngineDefault(); private WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); @@ -128,6 +130,12 @@ public class BesuNodeConfigurationBuilder { return this; } + public BesuNodeConfigurationBuilder transactionPoolConfiguration( + final TransactionPoolConfiguration transactionPoolConfiguration) { + this.transactionPoolConfiguration = transactionPoolConfiguration; + return this; + } + public BesuNodeConfigurationBuilder jsonRpcConfiguration( final JsonRpcConfiguration jsonRpcConfiguration) { this.jsonRpcConfiguration = jsonRpcConfiguration; @@ -503,6 +511,7 @@ public class BesuNodeConfigurationBuilder { name, dataPath, miningParameters, + transactionPoolConfiguration, jsonRpcConfiguration, Optional.of(engineRpcConfiguration), webSocketConfiguration, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java index 4b24071ab3..ed26587812 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java @@ -64,6 +64,7 @@ public class BesuNodeFactory { config.getName(), config.getDataPath(), config.getMiningParameters(), + config.getTransactionPoolConfiguration(), config.getJsonRpcConfiguration(), config.getEngineRpcConfiguration(), config.getWebSocketConfiguration(), diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java index 3d397e24e2..4ec4396d6b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java @@ -100,6 +100,7 @@ public class PrivacyNode implements AutoCloseable { besuConfig.getName(), besuConfig.getDataPath(), besuConfig.getMiningParameters(), + besuConfig.getTransactionPoolConfiguration(), besuConfig.getJsonRpcConfiguration(), besuConfig.getEngineRpcConfiguration(), besuConfig.getWebSocketConfiguration(), diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthSyncingTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthSyncingTransaction.java new file mode 100644 index 0000000000..21b628abef --- /dev/null +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthSyncingTransaction.java @@ -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 { + + 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); + } + } +} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java index 84882b822d..b8b72052d0 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java @@ -73,6 +73,10 @@ public class EthTransactions { return new EthMiningTransaction(); } + public EthSyncingTransaction syncing() { + return new EthSyncingTransaction(); + } + public EthNewPendingTransactionFilterTransaction newPendingTransactionsFilter() { return new EthNewPendingTransactionFilterTransaction(); } diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index 464805779c..b20b96b273 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -55,7 +55,6 @@ dependencies { testImplementation project(':testutil') testImplementation project(':util') - testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone' testImplementation 'commons-io:commons-io' testImplementation 'io.grpc:grpc-all' testImplementation 'io.grpc:grpc-core' @@ -84,6 +83,7 @@ dependencies { testImplementation 'org.web3j:abi' testImplementation 'org.web3j:besu' testImplementation 'org.web3j:core' + testImplementation 'org.wiremock:wiremock' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java index c5fbb69304..e9442bc007 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java @@ -49,6 +49,11 @@ public class NodeSmartContractPermissioningAcceptanceTest permissionedNode.verify(admin.addPeer(bootnode)); 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java index 72aab9cb7e..b04bad5644 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java @@ -46,6 +46,11 @@ public class NodeSmartContractPermissioningV2AcceptanceTest permissionedNode.execute(allowNode(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 diff --git a/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json b/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json index 04ee1a4882..5e8bc92a46 100644 --- a/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json +++ b/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json @@ -4,7 +4,7 @@ "londonBlock": 0, "zeroBaseFee": true, "ethash": { - "fixeddifficulty": 100 + "fixeddifficulty": 500 } }, "nonce": "0x42", diff --git a/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json b/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json index b7ec620f31..aab9a35cdd 100644 --- a/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json +++ b/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json @@ -4,7 +4,7 @@ "londonBlock": 0, "zeroBaseFee": true, "ethash": { - "fixeddifficulty": 100 + "fixeddifficulty": 500 } }, "nonce": "0x42", diff --git a/besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java index 3ab2961734..43af4e3866 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java @@ -216,7 +216,7 @@ public class TraceServiceImpl implements TraceService { worldUpdater, header, transaction, - header.getCoinbase(), + protocolSpec.getMiningBeneficiaryCalculator().calculateBeneficiary(header), tracer, new CachingBlockHashLookup(header, blockchain), false, diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java index 4a0707e76f..944cf426d7 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java @@ -228,26 +228,42 @@ public class BlockTransactionSelector { final PendingTransaction pendingTransaction) { checkCancellation(); - final Stopwatch evaluationTimer = Stopwatch.createStarted(); + final TransactionEvaluationContext evaluationContext = + createTransactionEvaluationContext(pendingTransaction); - TransactionSelectionResult selectionResult = evaluatePreProcessing(pendingTransaction); + TransactionSelectionResult selectionResult = evaluatePreProcessing(evaluationContext); if (!selectionResult.selected()) { - return handleTransactionNotSelected(pendingTransaction, selectionResult, evaluationTimer); + return handleTransactionNotSelected(evaluationContext, selectionResult); } final WorldUpdater txWorldStateUpdater = blockWorldStateUpdater.updater(); final TransactionProcessingResult processingResult = processTransaction(pendingTransaction, txWorldStateUpdater); - var postProcessingSelectionResult = - evaluatePostProcessing(pendingTransaction, processingResult); + var postProcessingSelectionResult = evaluatePostProcessing(evaluationContext, processingResult); if (postProcessingSelectionResult.selected()) { - return handleTransactionSelected( - pendingTransaction, processingResult, txWorldStateUpdater, evaluationTimer); + return handleTransactionSelected(evaluationContext, processingResult, txWorldStateUpdater); } 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 * 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. */ private TransactionSelectionResult evaluatePreProcessing( - final PendingTransaction pendingTransaction) { + final TransactionEvaluationContext evaluationContext) { for (var selector : transactionSelectors) { TransactionSelectionResult result = - selector.evaluateTransactionPreProcessing( - pendingTransaction, transactionSelectionResults); + selector.evaluateTransactionPreProcessing(evaluationContext, transactionSelectionResults); if (!result.equals(SELECTED)) { 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 * 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. * @return The result of the transaction selection process. */ private TransactionSelectionResult evaluatePostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionProcessingResult processingResult) { for (var selector : transactionSelectors) { TransactionSelectionResult result = selector.evaluateTransactionPostProcessing( - pendingTransaction, transactionSelectionResults, processingResult); + evaluationContext, transactionSelectionResults, processingResult); if (!result.equals(SELECTED)) { return result; } } return pluginTransactionSelector.evaluateTransactionPostProcessing( - pendingTransaction, processingResult); + evaluationContext, processingResult); } /** @@ -328,18 +343,16 @@ public class BlockTransactionSelector { * receipt, updating the TransactionSelectionResults with the selected transaction, and notifying * 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 txWorldStateUpdater The world state updater. - * @param evaluationTimer tracks the evaluation elapsed time * @return The result of the transaction selection process. */ private TransactionSelectionResult handleTransactionSelected( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionProcessingResult processingResult, - final WorldUpdater txWorldStateUpdater, - final Stopwatch evaluationTimer) { - final Transaction transaction = pendingTransaction.getTransaction(); + final WorldUpdater txWorldStateUpdater) { + final Transaction transaction = evaluationContext.getTransaction(); final long gasUsedByTransaction = transaction.getGasLimit() - processingResult.getGasRemaining(); @@ -363,13 +376,14 @@ public class BlockTransactionSelector { transaction.getType(), processingResult, worldState, cumulativeGasUsed); transactionSelectionResults.updateSelected( - pendingTransaction.getTransaction(), receipt, gasUsedByTransaction, blobGasUsed); + transaction, receipt, gasUsedByTransaction, blobGasUsed); } } if (tooLate) { // 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 + final var evaluationTimer = evaluationContext.getEvaluationTimer(); // check if this tx took too much to evaluate, and in case remove it from the pool 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 // reading it could have been already executed by another thread return handleTransactionNotSelected( - pendingTransaction, timeoutSelectionResult, txWorldStateUpdater, evaluationTimer); + evaluationContext, timeoutSelectionResult, txWorldStateUpdater); } - pluginTransactionSelector.onTransactionSelected(pendingTransaction, processingResult); + pluginTransactionSelector.onTransactionSelected(evaluationContext, processingResult); blockWorldStateUpdater = worldState.updater(); LOG.atTrace() .setMessage("Selected {} for block creation, evaluated in {}") .addArgument(transaction::toTraceLog) - .addArgument(evaluationTimer) + .addArgument(evaluationContext.getPendingTransaction()) .log(); return SELECTED; } @@ -413,36 +427,35 @@ public class BlockTransactionSelector { * TransactionSelectionResults with the unselected transaction, and notifies the external * 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 evaluationTimer tracks the evaluation elapsed time * @return The result of the transaction selection process. */ private TransactionSelectionResult handleTransactionNotSelected( - final PendingTransaction pendingTransaction, - final TransactionSelectionResult selectionResult, - final Stopwatch evaluationTimer) { + final TransactionEvaluationContext evaluationContext, + final TransactionSelectionResult selectionResult) { + + final var pendingTransaction = evaluationContext.getPendingTransaction(); transactionSelectionResults.updateNotSelected( - pendingTransaction.getTransaction(), selectionResult); - pluginTransactionSelector.onTransactionNotSelected(pendingTransaction, selectionResult); + evaluationContext.getTransaction(), selectionResult); + pluginTransactionSelector.onTransactionNotSelected(evaluationContext, selectionResult); LOG.atTrace() .setMessage("Not selected {} for block creation with result {}, evaluated in {}") .addArgument(pendingTransaction::toTraceLog) .addArgument(selectionResult) - .addArgument(evaluationTimer) + .addArgument(evaluationContext.getEvaluationTimer()) .log(); return selectionResult; } private TransactionSelectionResult handleTransactionNotSelected( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResult selectionResult, - final WorldUpdater txWorldStateUpdater, - final Stopwatch evaluationTimer) { + final WorldUpdater txWorldStateUpdater) { txWorldStateUpdater.revert(); - return handleTransactionNotSelected(pendingTransaction, selectionResult, evaluationTimer); + return handleTransactionNotSelected(evaluationContext, selectionResult); } private void checkCancellation() { diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/TransactionEvaluationContext.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/TransactionEvaluationContext.java new file mode 100644 index 0000000000..20609ebdc8 --- /dev/null +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/TransactionEvaluationContext.java @@ -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; + } +} diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java index 205e803e82..0e7f610a1f 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java @@ -15,8 +15,8 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; 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.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; 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. * - * @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. * @return The result of the transaction evaluation */ public abstract TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults); /** * Evaluates a transaction considering other transactions in the same block and a transaction * 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 processingResult The result of transaction processing. * @return The result of the transaction evaluation */ public abstract TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult); } diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java index 9032ddca57..a2b8d57ff2 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java @@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.PendingTransaction; import org.hyperledger.besu.plugin.data.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; +import org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext; /** A TransactionSelector that unconditionally selects all transactions. */ public class AllAcceptingTransactionSelector implements PluginTransactionSelector { @@ -29,25 +30,25 @@ public class AllAcceptingTransactionSelector implements PluginTransactionSelecto /** * 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. */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction) { + final TransactionEvaluationContext evaluationContext) { return TransactionSelectionResult.SELECTED; } /** * 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. * @return Always SELECTED. */ @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionProcessingResult processingResult) { return TransactionSelectionResult.SELECTED; } diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java index 56a17c2843..96135bea21 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; 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.core.Transaction; -import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; @@ -39,14 +39,15 @@ public class BlobPriceTransactionSelector extends AbstractTransactionSelector { /** * 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. * @return The result of the transaction selection. */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, final TransactionSelectionResults ignored) { - if (transactionBlobPriceBelowMin(pendingTransaction.getTransaction())) { + final TransactionEvaluationContext evaluationContext, + final TransactionSelectionResults ignored) { + if (transactionBlobPriceBelowMin(evaluationContext.getTransaction())) { return TransactionSelectionResult.BLOB_PRICE_BELOW_CURRENT_MIN; } return TransactionSelectionResult.SELECTED; @@ -54,7 +55,7 @@ public class BlobPriceTransactionSelector extends AbstractTransactionSelector { @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { // All necessary checks were done in the pre-processing method, so nothing to do here. diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java index 96f357546f..168107f595 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; 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.core.Transaction; -import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; 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 * 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 * block. * @return The result of the transaction selection. */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults transactionSelectionResults) { + if (transactionTooLargeForBlock( - pendingTransaction.getTransaction(), transactionSelectionResults)) { + evaluationContext.getTransaction(), transactionSelectionResults)) { LOG.atTrace() .setMessage("Transaction {} too large to select for block creation") - .addArgument(pendingTransaction::toTraceLog) + .addArgument(evaluationContext.getPendingTransaction()::toTraceLog) .log(); if (blockOccupancyAboveThreshold(transactionSelectionResults)) { LOG.trace("Block occupancy above threshold, completing operation"); @@ -70,7 +71,7 @@ public class BlockSizeTransactionSelector extends AbstractTransactionSelector { @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { // All necessary checks were done in the pre-processing method, so nothing to do here. diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java index 91085f4f02..1a46242ffe 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java @@ -16,6 +16,7 @@ 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.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; @@ -36,7 +37,7 @@ public class MinPriorityFeePerGasTransactionSelector extends AbstractTransaction /** * 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 * block. * @return TransactionSelectionResult. If the priority fee is below the minimum, it returns an @@ -44,9 +45,9 @@ public class MinPriorityFeePerGasTransactionSelector extends AbstractTransaction */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults transactionSelectionResults) { - if (isPriorityFeePriceBelowMinimum(pendingTransaction)) { + if (isPriorityFeePriceBelowMinimum(evaluationContext.getPendingTransaction())) { return TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN; } return TransactionSelectionResult.SELECTED; @@ -74,13 +75,13 @@ public class MinPriorityFeePerGasTransactionSelector extends AbstractTransaction /** * 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. * @return Always returns SELECTED. */ @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { return TransactionSelectionResult.SELECTED; diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java index defd75cb77..d677ea9358 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java @@ -14,10 +14,9 @@ */ 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.TransactionEvaluationContext; 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.processing.TransactionProcessingResult; 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 * 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. * @return The result of the transaction selection. */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, final TransactionSelectionResults ignored) { - if (transactionCurrentPriceBelowMin(pendingTransaction)) { + final TransactionEvaluationContext evaluationContext, + final TransactionSelectionResults ignored) { + if (transactionCurrentPriceBelowMin(evaluationContext)) { return TransactionSelectionResult.CURRENT_TX_PRICE_BELOW_MIN; } return TransactionSelectionResult.SELECTED; @@ -56,7 +56,7 @@ public class PriceTransactionSelector extends AbstractTransactionSelector { @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { // 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. * - * @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. */ - private boolean transactionCurrentPriceBelowMin(final PendingTransaction pendingTransaction) { - final Transaction transaction = pendingTransaction.getTransaction(); + private boolean transactionCurrentPriceBelowMin( + final TransactionEvaluationContext evaluationContext) { + final PendingTransaction pendingTransaction = evaluationContext.getPendingTransaction(); // Priority txs are exempt from this check 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 .miningParameters() .getMinTransactionGasPrice() - .compareTo(transactionGasPriceInBlock) + .compareTo(evaluationContext.getTransactionGasPrice()) > 0) { LOG.atTrace() .setMessage( "Current gas price of {} is {} and lower than the configured minimum {}, skipping") .addArgument(pendingTransaction::toTraceLog) - .addArgument(transactionGasPriceInBlock::toHumanReadableString) + .addArgument(evaluationContext.getTransactionGasPrice()::toHumanReadableString) .addArgument( context.miningParameters().getMinTransactionGasPrice()::toHumanReadableString) .log(); diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java index 8a2778eda0..bb89b965a3 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; 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.core.Transaction; -import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; @@ -41,7 +41,7 @@ public class ProcessingResultTransactionSelector extends AbstractTransactionSele @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults) { // All checks depend on processingResult and will be done in the post-processing method, so // 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. * - * @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 processingResult The processing result of the transaction. * @return The result of the transaction selection. */ @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { if (processingResult.isInvalid()) { return transactionSelectionResultForInvalidResult( - pendingTransaction.getTransaction(), processingResult.getValidationResult()); + evaluationContext.getTransaction(), processingResult.getValidationResult()); } return TransactionSelectionResult.SELECTED; } diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java index 4e7b3eae5e..0b0b2cd783 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java @@ -83,6 +83,7 @@ import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; 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.util.number.Percentage; @@ -581,17 +582,25 @@ public abstract class AbstractBlockTransactionSelectorTest { new PluginTransactionSelector() { @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction) { - if (pendingTransaction.getTransaction().equals(notSelectedTransient)) + final TransactionEvaluationContext + evaluationContext) { + if (evaluationContext + .getPendingTransaction() + .getTransaction() + .equals(notSelectedTransient)) return PluginTransactionSelectionResult.GENERIC_PLUGIN_INVALID_TRANSIENT; - if (pendingTransaction.getTransaction().equals(notSelectedInvalid)) + if (evaluationContext + .getPendingTransaction() + .getTransaction() + .equals(notSelectedInvalid)) return PluginTransactionSelectionResult.GENERIC_PLUGIN_INVALID; return SELECTED; } @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext + evaluationContext, final org.hyperledger.besu.plugin.data.TransactionProcessingResult processingResult) { return SELECTED; @@ -645,13 +654,15 @@ public abstract class AbstractBlockTransactionSelectorTest { new PluginTransactionSelector() { @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction) { + final TransactionEvaluationContext + evaluationContext) { return SELECTED; } @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext + evaluationContext, final org.hyperledger.besu.plugin.data.TransactionProcessingResult processingResult) { // the transaction with max gas +1 should fail @@ -711,13 +722,14 @@ public abstract class AbstractBlockTransactionSelectorTest { selector.buildTransactionListForBlock(); - ArgumentCaptor argumentCaptor = - ArgumentCaptor.forClass(PendingTransaction.class); + @SuppressWarnings("unchecked") + ArgumentCaptor> argumentCaptor = + ArgumentCaptor.forClass(TransactionEvaluationContext.class); // selected transaction must be notified to the selector verify(transactionSelector) .onTransactionSelected(argumentCaptor.capture(), any(TransactionProcessingResult.class)); - PendingTransaction selected = argumentCaptor.getValue(); + PendingTransaction selected = argumentCaptor.getValue().getPendingTransaction(); assertThat(selected.getTransaction()).isEqualTo(transaction); // unselected transaction must be notified to the selector with correct reason @@ -725,7 +737,7 @@ public abstract class AbstractBlockTransactionSelectorTest { .onTransactionNotSelected( argumentCaptor.capture(), eq(TransactionSelectionResult.invalid(invalidReason.toString()))); - PendingTransaction rejectedTransaction = argumentCaptor.getValue(); + PendingTransaction rejectedTransaction = argumentCaptor.getValue().getPendingTransaction(); assertThat(rejectedTransaction.getTransaction()).isEqualTo(invalidTransaction); } @@ -931,9 +943,10 @@ public abstract class AbstractBlockTransactionSelectorTest { final BiFunction> tooLate = (p, t) -> invocation -> { - final org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction ptx = - invocation.getArgument(0); - if (ptx.getTransaction().equals(p)) { + final org.hyperledger.besu.ethereum.blockcreation.txselection + .TransactionEvaluationContext + ctx = invocation.getArgument(0); + if (ctx.getTransaction().equals(p)) { Thread.sleep(t); } else { Thread.sleep(fastProcessingTxTime); diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java index a86dc73ee4..94d3abb105 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java @@ -21,6 +21,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.datatypes.Wei; 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.MinPriorityFeePerGasTransactionSelector; 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.plugin.data.TransactionSelectionResult; +import com.google.common.base.Stopwatch; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -56,44 +58,47 @@ public class MinPriorityFeePerGasTransactionSelectorTest { @Test public void shouldNotSelectWhen_PriorityFeePerGas_IsLessThan_MinPriorityFeePerGas() { - var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter - 1); + var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter - 1); assertSelectionResult( transaction, TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN); } @Test public void shouldSelectWhen_PriorityFeePerGas_IsEqual_MinPriorityFeePerGas() { - var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter); + var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter); assertSelectionResult(transaction, TransactionSelectionResult.SELECTED); } @Test public void shouldSelectWhen_PriorityFeePerGas_IsGreaterThan_MinPriorityFeePerGas() { - var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter + 1); + var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter + 1); assertSelectionResult(transaction, TransactionSelectionResult.SELECTED); } @Test public void shouldSelectWhenPrioritySender() { - var prioritySenderTransaction = mockTransactionWithPriorityFee(minPriorityFeeParameter - 1); + final var evaluationContext = mockTransactionEvaluationContext(minPriorityFeeParameter - 1); assertSelectionResult( - prioritySenderTransaction, - TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN); - when(prioritySenderTransaction.hasPriority()).thenReturn(true); - assertSelectionResult(prioritySenderTransaction, TransactionSelectionResult.SELECTED); + evaluationContext, TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN); + when(evaluationContext.getPendingTransaction().hasPriority()).thenReturn(true); + assertSelectionResult(evaluationContext, TransactionSelectionResult.SELECTED); } private void assertSelectionResult( - final PendingTransaction transaction, final TransactionSelectionResult expectedResult) { - var actualResult = transactionSelector.evaluateTransactionPreProcessing(transaction, null); + final TransactionEvaluationContext evaluationContext, + final TransactionSelectionResult expectedResult) { + var actualResult = + transactionSelector.evaluateTransactionPreProcessing(evaluationContext, null); assertThat(actualResult).isEqualTo(expectedResult); } - private PendingTransaction mockTransactionWithPriorityFee(final int priorityFeePerGas) { - PendingTransaction mockTransaction = mock(PendingTransaction.class); + private TransactionEvaluationContext mockTransactionEvaluationContext( + final int priorityFeePerGas) { + PendingTransaction pendingTransaction = mock(PendingTransaction.class); Transaction transaction = mock(Transaction.class); - when(mockTransaction.getTransaction()).thenReturn(transaction); + when(pendingTransaction.getTransaction()).thenReturn(transaction); when(transaction.getEffectivePriorityFeePerGas(any())).thenReturn(Wei.of(priorityFeePerGas)); - return mockTransaction; + return new TransactionEvaluationContext( + pendingTransaction, Stopwatch.createStarted(), Wei.ONE, Wei.ONE); } } diff --git a/evm/src/main/java/org/hyperledger/besu/evm/fluent/EVMExecutor.java b/evm/src/main/java/org/hyperledger/besu/evm/fluent/EVMExecutor.java index 9946b6f57a..0a43a6d359 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/fluent/EVMExecutor.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/fluent/EVMExecutor.java @@ -221,7 +221,7 @@ public class EVMExecutor { final EVMExecutor executor = new EVMExecutor(MainnetEVMs.tangerineWhistle(evmConfiguration)); executor.precompileContractRegistry = MainnetPrecompiledContracts.frontier(executor.evm.getGasCalculator()); - executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000)); + executor.contractValidationRules = List.of(); executor.initialNonce = 0; return executor; } diff --git a/gradle.properties b/gradle.properties index 206d0b7c70..75ee1d04ee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=24.1.0-SNAPSHOT +version=24.1.1-SNAPSHOT org.gradle.welcome=never # Set exports/opens flags required by Google Java Format and ErrorProne plugins. (JEP-396) diff --git a/gradle/allowed-licenses.json b/gradle/allowed-licenses.json index a5d4048b22..2527019080 100644 --- a/gradle/allowed-licenses.json +++ b/gradle/allowed-licenses.json @@ -60,6 +60,10 @@ "moduleLicense": "Eclipse Public License - v 1.0", "moduleVersion": "4.13.2", "moduleName": "junit:junit" + }, + { + "moduleName": "org.jetbrains.kotlin:kotlin-stdlib-common", + "moduleVersion": "1.9.22" } ] } \ No newline at end of file diff --git a/gradle/license-normalizer-bundle.json b/gradle/license-normalizer-bundle.json index 341b7ab5f6..8c0af450fd 100644 --- a/gradle/license-normalizer-bundle.json +++ b/gradle/license-normalizer-bundle.json @@ -50,9 +50,9 @@ { "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\\.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-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", "licenseUrlPattern" : ".*(www\\.)?creativecommons\\.org/publicdomain/zero/1\\.0/" }, { "bundleName" : "CDDL-1.0", "licenseFileContentPattern" : ".*CDDL.*1\\.0" }, diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 8265a2810c..30d55eb684 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -78,9 +78,12 @@ - - - + + + + + + @@ -128,14 +131,9 @@ - - - - - - - - + + + @@ -153,11 +151,6 @@ - - - - - @@ -183,9 +176,9 @@ - - - + + + @@ -208,11 +201,6 @@ - - - - - @@ -229,11 +217,6 @@ - - - - - @@ -242,12 +225,12 @@ - - - + + + - - + + @@ -282,12 +265,12 @@ - - - + + + - - + + @@ -319,75 +302,55 @@ - - - - - - - - - - - + + + - - + + - - - + + + - - + + - - - - - - - - - - - - + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - + + - - - - + + - - - + + + @@ -414,33 +377,33 @@ - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + @@ -523,11 +486,6 @@ - - - - - @@ -584,27 +542,17 @@ - - - - - - - - - - - + + + - - - - + + - - - + + + @@ -615,35 +563,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -689,14 +608,6 @@ - - - - - - - - @@ -705,15 +616,10 @@ - - - - - - - - + + + @@ -736,6 +642,14 @@ + + + + + + + + @@ -806,54 +720,36 @@ - - - - - - - - - - - - - - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -864,11 +760,6 @@ - - - - - @@ -909,11 +800,6 @@ - - - - - @@ -922,11 +808,6 @@ - - - - - @@ -947,11 +828,6 @@ - - - - - @@ -960,11 +836,6 @@ - - - - - @@ -1072,9 +943,6 @@ - - - @@ -1281,31 +1149,23 @@ - - - - - - - - - - - + + + - - + + - - - + + + - - + + - - + + @@ -1316,12 +1176,15 @@ - - - + + + + + + - - + + @@ -1329,49 +1192,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - + + + + + @@ -1446,17 +1278,6 @@ - - - - - - - - - - - @@ -1465,6 +1286,17 @@ + + + + + + + + + + + @@ -1473,19 +1305,6 @@ - - - - - - - - - - - - - @@ -1494,25 +1313,19 @@ - - - - - - - - - - - + + + - - + + + + @@ -1523,12 +1336,15 @@ - - - + + + + + + - - + + @@ -1539,12 +1355,12 @@ - - - + + + - - + + @@ -1556,6 +1372,9 @@ + + + @@ -1584,15 +1403,10 @@ - - - - - - - - + + + @@ -1610,35 +1424,36 @@ - - - - - - - - + + + - - - - - - - - + + + - - - + + + + + + + + + + + + + + @@ -1649,41 +1464,36 @@ - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -1694,155 +1504,140 @@ - - - + + + - - + + - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -1853,61 +1648,46 @@ - - - - - - + + + - - - - + + - - - - - - + + + - - - - + + - - - + + + - - - + + + - - + + - - - - - - + + + - - - - + + - - - + + + @@ -1920,12 +1700,12 @@ - - - + + + - - + + @@ -1933,12 +1713,12 @@ - - - + + + - - + + @@ -1949,12 +1729,12 @@ - - - + + + - - + + @@ -1965,20 +1745,20 @@ - - - + + + - - + + - - - + + + - - + + @@ -1990,13 +1770,18 @@ - - - + + + + + + + + @@ -2005,49 +1790,44 @@ - - - - - - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2058,28 +1838,28 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2087,12 +1867,12 @@ - - - + + + - - + + @@ -2104,13 +1884,18 @@ - - - + + + + + + + + @@ -2119,17 +1904,12 @@ - - - - - - - - + + + - - + + @@ -2137,9 +1917,9 @@ - - - + + + @@ -2147,22 +1927,12 @@ - - - - - - - - - - - - - + + + - - + + @@ -2170,12 +1940,12 @@ - - - + + + - - + + @@ -2186,23 +1956,23 @@ - - - + + + - - + + - - - + + + - - + + - - + + @@ -2226,12 +1996,12 @@ - - - + + + - - + + @@ -2239,95 +2009,83 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - - + + - - - + + + - - + + - - + + - - - - - - - + + - - - + + + - - + + - - - + + + - - - - - - - + + - - - + + + - - + + - - - + + + - - + + @@ -2365,14 +2123,6 @@ - - - - - - - - @@ -2428,14 +2178,6 @@ - - - - - - - - @@ -2458,14 +2200,6 @@ - - - - - - - - @@ -2477,14 +2211,6 @@ - - - - - - - - @@ -2507,14 +2233,6 @@ - - - - - - - - @@ -2548,14 +2266,6 @@ - - - - - - - - @@ -2567,14 +2277,6 @@ - - - - - - - - @@ -2586,14 +2288,6 @@ - - - - - - - - @@ -2618,14 +2312,6 @@ - - - - - - - - @@ -2634,14 +2320,6 @@ - - - - - - - - @@ -2750,11 +2428,6 @@ - - - - - @@ -2763,11 +2436,6 @@ - - - - - @@ -2784,11 +2452,6 @@ - - - - - @@ -2805,11 +2468,6 @@ - - - - - @@ -2836,9 +2494,7 @@ - - - + @@ -3003,16 +2659,6 @@ - - - - - - - - - - @@ -3029,11 +2675,6 @@ - - - - - @@ -3042,11 +2683,6 @@ - - - - - @@ -3057,11 +2693,6 @@ - - - - - @@ -3080,11 +2711,6 @@ - - - - - @@ -3119,11 +2745,6 @@ - - - - - @@ -3140,11 +2761,6 @@ - - - - - @@ -3153,11 +2769,6 @@ - - - - - @@ -3171,19 +2782,14 @@ - - - - - - - - + + + - - - + + + @@ -3210,14 +2816,6 @@ - - - - - - - - @@ -3268,12 +2866,12 @@ - - - + + + - - + + @@ -3289,9 +2887,9 @@ - - - + + + @@ -3304,38 +2902,33 @@ - - - - - - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -3343,11 +2936,6 @@ - - - - - @@ -3364,36 +2952,20 @@ - - - - - - - - - - - + + + - - + + - - - + + + - - - - - - - - - - + + @@ -3446,11 +3018,6 @@ - - - - - @@ -3459,16 +3026,6 @@ - - - - - - - - - - @@ -3479,11 +3036,6 @@ - - - - - @@ -3532,14 +3084,6 @@ - - - - - - - - @@ -3549,6 +3093,9 @@ + + + @@ -3570,6 +3117,9 @@ + + + @@ -3600,11 +3150,6 @@ - - - - - @@ -3615,11 +3160,6 @@ - - - - - @@ -3660,35 +3200,14 @@ - - - - - - - - - - - - - - - - + + + - - - - - - - - @@ -3730,9 +3249,9 @@ - - - + + + @@ -3751,38 +3270,38 @@ - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -3793,112 +3312,51 @@ - - - - - - - - + + + - - - + + + - - - + + + - - - - - - - + + - - - + + + - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -3957,22 +3415,12 @@ - - - - - - - - + + + - - - - - - - + + @@ -3996,15 +3444,10 @@ - - - - - - - - + + + @@ -4025,25 +3468,20 @@ - - - - - - - - + + + - - - + + + - - + + @@ -4097,9 +3535,9 @@ - - - + + + @@ -4120,55 +3558,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4198,9 +3587,9 @@ - - - + + + @@ -4259,205 +3648,186 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - + + + - - + + - - - + + + - - - - - - + + + - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - + + + - - - - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - + + + - - + + - - - + + + - - - - + + - - + + + + @@ -5195,15 +4565,10 @@ - - - - - - - - + + + @@ -5237,14 +4602,6 @@ - - - - - - - - @@ -5266,11 +4623,6 @@ - - - - - @@ -5323,9 +4675,6 @@ - - - @@ -5334,9 +4683,6 @@ - - - @@ -5345,9 +4691,6 @@ - - - @@ -5356,9 +4699,6 @@ - - - @@ -5367,9 +4707,6 @@ - - - @@ -5378,54 +4715,36 @@ - - - - - - - - + + + - - - - - - - - + + + - - - - - - - - - - - + + + - - - + + + @@ -5473,17 +4792,12 @@ - - - - - - + + + - - - - + + @@ -5539,14 +4853,6 @@ - - - - - - - - @@ -5555,12 +4861,15 @@ - - - + + + + + + - - + + @@ -5581,14 +4890,6 @@ - - - - - - - - @@ -5597,6 +4898,16 @@ + + + + + + + + + + @@ -5605,36 +4916,28 @@ - - - - - - - - - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -5650,36 +4953,28 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - - - - - - - - - + + @@ -5714,14 +5009,6 @@ - - - - - - - - @@ -5851,6 +5138,9 @@ + + + @@ -5858,18 +5148,10 @@ - - - - - - - - - - - + + + @@ -5885,18 +5167,10 @@ - - - - - - - - - - - + + + @@ -5912,18 +5186,10 @@ - - - - - - - - - - - + + + @@ -5931,15 +5197,15 @@ - - - + + + - - + + - - + + @@ -5950,23 +5216,12 @@ - - - + + + - - - - - - - - - - - - - + + @@ -5974,12 +5229,15 @@ - - - + + + - - + + + + + @@ -5990,23 +5248,12 @@ - - - - - - - - - - - - - - + + + - - + + @@ -6022,34 +5269,21 @@ - - - - - - - - - - - + + + - - - - - - - + + + + + - - - @@ -6059,55 +5293,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - + + + - - - - - @@ -6126,11 +5332,6 @@ - - - - - @@ -6139,11 +5340,6 @@ - - - - - @@ -6181,11 +5377,6 @@ - - - - - @@ -6202,11 +5393,6 @@ - - - - - @@ -6246,6 +5432,17 @@ + + + + + + + + + + + @@ -6280,12 +5477,12 @@ - - - + + + - - + + @@ -6296,6 +5493,11 @@ + + + + + @@ -6365,17 +5567,12 @@ - - - - - - + + + - - - - + + @@ -6394,35 +5591,25 @@ - - - - - - + + + - - - - + + - - - + + + - - - - - - + + + - - - - + + @@ -6435,14 +5622,9 @@ - - - - - - - - + + + @@ -6476,11 +5658,6 @@ - - - - - @@ -6496,99 +5673,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + - - - - - - - - - - - - - - - - - - + + + + + - - - + + + @@ -6599,6 +5705,17 @@ + + + + + + + + + + + @@ -6607,30 +5724,15 @@ - - - - - - - - - - - - - - - - + + + - - + + - - - - + + @@ -6641,6 +5743,17 @@ + + + + + + + + + + + @@ -6657,17 +5770,15 @@ - - - + + + - - + + - - - - + + @@ -6678,30 +5789,15 @@ - - - + + + - - - - - - - - - - - - + + - - - - - - - + + @@ -6709,6 +5805,17 @@ + + + + + + + + + + + @@ -6717,12 +5824,15 @@ - - - + + + - - + + + + + @@ -6741,12 +5851,15 @@ - - - + + + + + + - - + + @@ -6757,14 +5870,6 @@ - - - - - - - - @@ -6786,11 +5891,6 @@ - - - - - @@ -6799,46 +5899,52 @@ - - - + + + + + + + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + @@ -6860,14 +5966,6 @@ - - - - - - - - diff --git a/gradle/versions.gradle b/gradle/versions.gradle index f239370ab7..b497109d78 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -22,7 +22,7 @@ dependencyManagement { 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-datatype' entry 'jackson-datatype-jdk8' @@ -30,14 +30,11 @@ dependencyManagement { dependency 'com.github.ben-manes.caffeine:caffeine:3.1.8' - dependencySet(group: 'com.github.tomakehurst', version: '2.35.0') { - entry'wiremock-jre8-standalone' - entry'wiremock-jre8' - } + dependency 'com.github.oshi:oshi-core:6.4.10' - 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' } @@ -51,37 +48,37 @@ dependencyManagement { 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-codegen' } - dependencySet(group: 'io.grpc', version: '1.59.0') { + dependencySet(group: 'io.grpc', version: '1.60.1') { entry 'grpc-all' entry 'grpc-core' entry 'grpc-netty' 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 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-kqueue', version:'4.1.100.Final', classifier: 'osx-x86_64' - dependency 'io.netty:netty-transport-native-unix-common:4.1.100.Final' + 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.104.Final', classifier: 'osx-x86_64' + dependency 'io.netty:netty-transport-native-unix-common:4.1.104.Final' dependency 'io.opentelemetry:opentelemetry-api: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' + 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') { entry 'vertx-auth-jwt' entry 'vertx-codegen' @@ -121,43 +132,29 @@ dependencyManagement { 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-lang3:3.12.0' - dependency 'org.apache.commons:commons-text:1.10.0' + dependency 'org.apache.commons:commons-compress:1.25.0' + dependency 'org.apache.commons:commons-lang3:3.14.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-core' entry 'log4j-jul' entry 'log4j-slf4j2-impl' } - 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' - } - - dependency 'org.assertj:assertj-core:3.24.2' + dependency 'org.assertj:assertj-core:3.25.1' 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'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 'tech.pegasys:jc-kzg-4844:0.8.0' @@ -170,16 +167,16 @@ dependencyManagement { entry 'blake2bf' } - dependencySet(group: 'org.immutables', version: '2.9.3') { + dependencySet(group: 'org.immutables', version: '2.10.0') { entry 'value-annotations' 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-api' entry 'junit-jupiter-engine' @@ -188,9 +185,9 @@ dependencyManagement { 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' } @@ -207,31 +204,33 @@ dependencyManagement { 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-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' - dependencySet(group: 'org.web3j', version: '4.9.7') { + dependencySet(group: 'org.web3j', version: '4.10.3') { entry 'abi' entry 'besu' entry 'core' 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 'tech.pegasys.discovery:discovery:22.2.0' - - dependency 'com.github.oshi:oshi-core:6.4.1' } } diff --git a/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java b/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java index 5504def9c8..e7f1cf2328 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java @@ -33,6 +33,8 @@ public class DockerDetector implements NatMethodDetector { return stream .filter(line -> line.contains("/docker")) .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); } catch (IOException e) { return Optional.empty(); diff --git a/pki/src/test/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreFileWrapperTest.java b/pki/src/test/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreFileWrapperTest.java index 0dde591cf5..31eb03126c 100644 --- a/pki/src/test/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreFileWrapperTest.java +++ b/pki/src/test/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreFileWrapperTest.java @@ -22,11 +22,13 @@ import org.hyperledger.besu.pki.PkiException; import java.nio.file.Path; import java.security.Provider; import java.security.Security; -import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.Optional; 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.Test; 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 configName = "NSScrypto-partner1client1"; private static final String validKeystorePassword = "test123"; + private static KeyStoreWrapperTestParameter keyStoreWrapperTestParameter; - public static Collection data() { - return Arrays.asList( + @BeforeAll + public static void setup() { + keyStoreWrapperTestParameter = new KeyStoreWrapperTestParameter( "HardwareKeyStoreWrapper[PKCS11 keystore/truststore]", true, - CryptoTestUtil.isNSSLibInstalled() ? getHardwareKeyStoreWrapper(configName) : null)); + CryptoTestUtil.isNSSLibInstalled() ? getHardwareKeyStoreWrapper(configName) : null); + } + + public static Collection data() { + return List.of(keyStoreWrapperTestParameter); } private static KeyStoreWrapper getHardwareKeyStoreWrapper(final String cfgName) { @@ -58,11 +66,10 @@ public class HardwareKeyStoreFileWrapperTest extends BaseKeyStoreFileWrapperTest .map(provider -> new HardwareKeyStoreWrapper(validKeystorePassword, provider, crlPath)) .orElseGet(() -> new HardwareKeyStoreWrapper(validKeystorePassword, path, crlPath)); } catch (final Exception e) { - if (OS.MAC.isCurrentOs()) { - // nss3 is difficult to setup on mac correctly, don't let it break unit tests for dev - // machines. - System.out.println("Failed to initialize hardware keystore " + e.getLocalizedMessage()); - } + // nss3 is difficult to setup on mac, don't let it break unit tests for dev machines. + Assumptions.assumeFalse( + OS.MAC.isCurrentOs(), + "Failed to initialize hardware keystore: " + e.getLocalizedMessage()); // Not a mac, probably a production build. Full failure. throw new PkiException("Failed to initialize hardware keystore", e); } diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index d271094604..1dcfd00f7e 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -69,7 +69,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = 'N583pqJipDs4kJkgL0cPq9PBsYdsLzvUlu2I8Kk+w7g=' + knownHash = 'IGq+V3KaStHCRFkeK3KwPxJYKO4RX9YM1O4JYITk8S8=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java index 716a05e7d8..3d152c370c 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java @@ -39,39 +39,40 @@ public interface PluginTransactionSelector { * 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. * - * @param pendingTransaction candidate transaction + * @param evaluationContext The current selection context * @return TransactionSelectionResult that indicates whether to include the transaction */ TransactionSelectionResult evaluateTransactionPreProcessing( - PendingTransaction pendingTransaction); + TransactionEvaluationContext evaluationContext); /** * 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. * - * @param pendingTransaction candidate transaction + * @param evaluationContext The current selection context * @param processingResult the transaction processing result * @return TransactionSelectionResult that indicates whether to include the transaction */ TransactionSelectionResult evaluateTransactionPostProcessing( - PendingTransaction pendingTransaction, TransactionProcessingResult processingResult); + TransactionEvaluationContext evaluationContext, + TransactionProcessingResult processingResult); /** * 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. */ default void onTransactionSelected( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionProcessingResult processingResult) {} /** * 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 */ default void onTransactionNotSelected( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResult transactionSelectionResult) {} } diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionEvaluationContext.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionEvaluationContext.java new file mode 100644 index 0000000000..83aa7b91e7 --- /dev/null +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionEvaluationContext.java @@ -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 the type of the pending transaction + */ +public interface TransactionEvaluationContext { + + /** + * 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(); +} diff --git a/testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java b/testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java index f4fc7c49a3..69b21b37c8 100644 --- a/testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java +++ b/testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java @@ -37,6 +37,8 @@ import javax.annotation.Nullable; import com.fasterxml.jackson.annotation.JsonCreator; 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.ObjectMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; @@ -121,7 +123,12 @@ public class JsonTestParameters { } 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 private final Class jsonFileMappedType;