diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml new file mode 100644 index 00000000000..a5447473147 --- /dev/null +++ b/.github/workflows/develop.yml @@ -0,0 +1,121 @@ +name: docker develop + +on: + push: + branches: + - main +env: + registry: docker.io + +jobs: + hadolint: + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: Set up Java + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 + with: + distribution: temurin + java-version: 17 + - name: setup gradle + uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1 + with: + cache-disabled: true + + - name: hadoLint + run: docker run --rm -i hadolint/hadolint < docker/Dockerfile + buildDocker: + needs: hadolint + permissions: + contents: read + packages: write + + strategy: + fail-fast: false + matrix: + platform: + - ubuntu-22.04 + - [self-hosted, ARM64] + runs-on: ${{ matrix.platform }} + steps: + - name: Prepare + id: prep + run: | + platform=${{ matrix.platform }} + if [ "$platform" = 'ubuntu-22.04' ]; then + echo "PLATFORM_PAIR=linux-amd64" >> $GITHUB_OUTPUT + echo "ARCH=amd64" >> $GITHUB_OUTPUT + else + echo "PLATFORM_PAIR=linux-arm64" >> $GITHUB_OUTPUT + echo "ARCH=arm64" >> $GITHUB_OUTPUT + fi + + # Get the current date and time in the format YY.MM + DATE_TIME=$(date +"%y.%-m") + # Get the short SHA of the merge commit + SHORT_SHA=${GITHUB_SHA::7} + # Construct the build target name + BUILD_TARGET_NAME="${DATE_TIME}-develop-${SHORT_SHA}" + echo "Build Target Name: $BUILD_TARGET_NAME" + # Set the build target name as an environment variable + echo "BUILD_TARGET_NAME=${BUILD_TARGET_NAME}" >> $GITHUB_ENV + + - name: Checkout Repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: Set up Java + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 + with: + distribution: temurin + java-version: 17 + - name: setup gradle + uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1 + with: + cache-disabled: true + - name: install goss + run: | + mkdir -p docker/reports + curl -L https://github.com/aelsabbahy/goss/releases/download/v0.4.4/goss-${{ steps.prep.outputs.PLATFORM_PAIR }} -o ./docker/tests/goss-${{ steps.prep.outputs.PLATFORM_PAIR }} + - name: login to ${{ env.registry }} + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d + with: + registry: ${{ env.registry }} + username: ${{ secrets.DOCKER_USER_RW }} + password: ${{ secrets.DOCKER_PASSWORD_RW }} + - name: build and test docker + uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1 + env: + architecture: ${{ steps.prep.outputs.ARCH }} + with: + cache-disabled: true + arguments: testDocker -PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }} -Pversion=${{ env.BUILD_TARGET_NAME}} -Prelease.releaseVersion=develop + - name: publish + env: + architecture: ${{ steps.prep.outputs.ARCH }} + run: ./gradlew --no-daemon dockerUpload -PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }} -Pversion=${{ env.BUILD_TARGET_NAME }} -Prelease.releaseVersion=develop + multiArch: + needs: buildDocker + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + steps: + - name: Checkout Repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: Set up Java + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 + with: + distribution: temurin + java-version: 17 + - name: setup gradle + uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1 + with: + cache-disabled: true + - name: login to ${{ env.registry }} + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d + with: + registry: ${{ env.registry }} + username: ${{ secrets.DOCKER_USER_RW }} + password: ${{ secrets.DOCKER_PASSWORD_RW }} + - name: multi-arch docker + run: ./gradlew manifestDocker -PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }} -Pversion=${{ env.BUILD_TARGET_NAME }} -Prelease.releaseVersion=develop diff --git a/.github/workflows/splitTestsByTime.sh b/.github/workflows/splitTestsByTime.sh new file mode 100755 index 00000000000..2b9893819b2 --- /dev/null +++ b/.github/workflows/splitTestsByTime.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +REPORTS_DIR="$1" +SPLIT_COUNT=$2 +SPLIT_INDEX=$3 + +# extract tests time from Junit XML reports +find "$REPORTS_DIR" -type f -name TEST-*.xml | xargs -I{} bash -c "xmlstarlet sel -t -v 'sum(//testcase/@time)' '{}'; echo '{}' | sed 's/.*TEST\-\(.*\)\.xml/ \1/'" > tmp/timing.tsv + +# Sort times in descending order +IFS=$'\n' sorted=($(sort -nr tmp/timing.tsv)) +unset IFS + +sums=() +tests=() + +# Initialize sums +for ((i=0; i> tmp/processedTests.list + fi +done + +# Any new test? +grep -F --line-regexp -v -f tmp/processedTests.list tmp/currentTests.list > tmp/newTests.list +idx_new_test=0 +while read -r new_test_name +do + idx_group=$(( idx_new_test % SPLIT_COUNT )) + group=${tests[$idx_group]} + tests[$idx_group]="${group}${new_test_name}," + idx_new_test=$(( idx_new_test + 1 )) +done < tmp/newTests.list + + +# return the requests index, without quotes to drop the last trailing space +echo ${tests[$SPLIT_INDEX]//,/ } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d7fdc02931..1f64e16851d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Upcoming Breaking Changes - Receipt compaction will be enabled by default in a future version of Besu. After this change it will not be possible to downgrade to the previous Besu version. +- PKI-backed QBFT will be removed in a future version of Besu. Other forms of QBFT will remain unchanged. ### Deprecations @@ -40,6 +41,10 @@ - Expose transaction count by type metrics for the layered txpool [#6903](https://github.com/hyperledger/besu/pull/6903) - Expose bad block events via the BesuEvents plugin API [#6848](https://github.com/hyperledger/besu/pull/6848) - Add RPC errors metric [#6919](https://github.com/hyperledger/besu/pull/6919/) +- Add `rlp decode` subcommand to decode IBFT/QBFT extraData to validator list [#6895](https://github.com/hyperledger/besu/pull/6895) +- Allow users to specify which plugins are registered [#6700](https://github.com/hyperledger/besu/pull/6700) +- Layered txpool tuning for blob transactions [#6940](https://github.com/hyperledger/besu/pull/6940) +- Update Gradle to 7.6.4 [#7030](https://github.com/hyperledger/besu/pull/7030) ### Bug fixes - Fix txpool dump/restore race condition [#6665](https://github.com/hyperledger/besu/pull/6665) @@ -50,6 +55,8 @@ - Fix to avoid broadcasting full blob txs, instead of only the tx announcement, to a subset of nodes [#6835](https://github.com/hyperledger/besu/pull/6835) - Snap client fixes discovered during snap server testing [#6847](https://github.com/hyperledger/besu/pull/6847) - Correctly initialize the txpool as disabled on creation [#6890](https://github.com/hyperledger/besu/pull/6890) +- Fix worldstate download halt when using snap sync during initial sync [#6981](https://github.com/hyperledger/besu/pull/6981) +- Fix chain halt due to peers only partially responding with headers. And worldstate halts caused by a halt in the chain sync [#7027](https://github.com/hyperledger/besu/pull/7027) ### Download Links diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java index 0e1f6d65d5f..cac4deb9d9b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java @@ -56,12 +56,15 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.junit.jupiter.api.AfterEach; +import org.junit.After; import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Superclass for acceptance tests. */ +/** + * Superclass for acceptance tests. For now (transition to junit5 is ongoing) this class supports + * junit4 format. + */ @ExtendWith(AcceptanceTestBaseTestWatcher.class) public class AcceptanceTestBase { @@ -128,7 +131,7 @@ protected AcceptanceTestBase() { exitedSuccessfully = new ExitedWithCode(0); } - @AfterEach + @After public void tearDownAcceptanceTestBase() { reportMemory(); cluster.close(); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java index 39b45d6e327..92d9273e8f8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.dsl; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseTestWatcher.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseTestWatcher.java index ec50920403c..5a75413bd00 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseTestWatcher.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseTestWatcher.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.dsl; import java.io.File; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/admin/ExpectHasPeer.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/admin/ExpectHasPeer.java index 58f91c8e0a3..6632f16b855 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/admin/ExpectHasPeer.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/admin/ExpectHasPeer.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.dsl.condition.admin; import static org.assertj.core.api.Assertions.assertThat; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/admin/ExpectNotHavePeer.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/admin/ExpectNotHavePeer.java index 64f06bec4c1..2b6189b6bfe 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/admin/ExpectNotHavePeer.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/admin/ExpectNotHavePeer.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.dsl.condition.admin; import static org.assertj.core.api.Assertions.assertThat; 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 index 5e01a0d4a90..47cd39fb922 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivateSyncingStatusCondition.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivateSyncingStatusCondition.java index c80683e2c5f..067cba268d2 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivateSyncingStatusCondition.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivateSyncingStatusCondition.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 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 b2f9bc0abf7..5f30941f232 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 @@ -35,7 +35,6 @@ import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; -import org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration; import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition; import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.NodeConfiguration; import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationProvider; @@ -132,7 +131,6 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable private final List staticNodes; private boolean isDnsEnabled = false; private Optional exitCode = Optional.empty(); - private Optional pkiKeyStoreConfiguration = Optional.empty(); private final boolean isStrictTxReplayProtectionEnabled; private final Map environment; @@ -169,7 +167,6 @@ public BesuNode( final Optional privacyParameters, final List runCommand, final Optional keyPair, - final Optional pkiKeyStoreConfiguration, final boolean isStrictTxReplayProtectionEnabled, final Map environment) throws IOException { @@ -230,7 +227,6 @@ public BesuNode( this.staticNodes = staticNodes; this.isDnsEnabled = isDnsEnabled; privacyParameters.ifPresent(this::setPrivacyParameters); - this.pkiKeyStoreConfiguration = pkiKeyStoreConfiguration; this.environment = environment; LOG.info("Created BesuNode {}", this); } @@ -763,10 +759,6 @@ public List getRunCommand() { return runCommand; } - public Optional getPkiKeyStoreConfiguration() { - return pkiKeyStoreConfiguration; - } - public boolean isStrictTxReplayProtectionEnabled() { return isStrictTxReplayProtectionEnabled; } @@ -789,21 +781,6 @@ public void stop() { nodeRequests.shutdown(); nodeRequests = null; } - - deleteRuntimeFiles(); - } - - private void deleteRuntimeFiles() { - try { - Files.deleteIfExists(homeDirectory.resolve("besu.networks")); - } catch (IOException e) { - LOG.error("Failed to clean up besu.networks file in {}", homeDirectory, e); - } - try { - Files.deleteIfExists(homeDirectory.resolve("besu.ports")); - } catch (IOException e) { - LOG.error("Failed to clean up besu.ports file in {}", homeDirectory, e); - } } @Override 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 adf872e19cc..583992718aa 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 @@ -52,7 +52,6 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.apache.commons.lang3.SystemUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -78,15 +77,8 @@ public void startNode(final BesuNode node) { final Path dataDir = node.homeDirectory(); - final var workingDir = - new File(System.getProperty("user.dir")).getParentFile().getParentFile().toPath(); - final List params = new ArrayList<>(); - if (SystemUtils.IS_OS_WINDOWS) { - params.add(workingDir.resolve("build\\install\\besu\\bin\\besu.bat").toString()); - } else { - params.add("build/install/besu/bin/besu"); - } + params.add("build/install/besu/bin/besu"); params.add("--data-path"); params.add(dataDir.toAbsolutePath().toString()); @@ -385,33 +377,6 @@ public void startNode(final BesuNode node) { permissioningConfiguration.getNodeSmartContractInterfaceVersion())); }); - node.getPkiKeyStoreConfiguration() - .ifPresent( - pkiConfig -> { - params.add("--Xpki-block-creation-enabled"); - - params.add("--Xpki-block-creation-keystore-certificate-alias"); - params.add(pkiConfig.getCertificateAlias()); - - params.add("--Xpki-block-creation-keystore-type"); - params.add(pkiConfig.getKeyStoreType()); - - params.add("--Xpki-block-creation-keystore-file"); - params.add(pkiConfig.getKeyStorePath().toAbsolutePath().toString()); - - params.add("--Xpki-block-creation-keystore-password-file"); - params.add(pkiConfig.getKeyStorePasswordPath().toAbsolutePath().toString()); - - params.add("--Xpki-block-creation-truststore-type"); - params.add(pkiConfig.getTrustStoreType()); - - params.add("--Xpki-block-creation-truststore-file"); - params.add(pkiConfig.getTrustStorePath().toAbsolutePath().toString()); - - params.add("--Xpki-block-creation-truststore-password-file"); - params.add(pkiConfig.getTrustStorePasswordPath().toAbsolutePath().toString()); - }); - params.addAll(node.getExtraCLIOptions()); params.add("--key-value-storage"); @@ -430,13 +395,15 @@ public void startNode(final BesuNode node) { LOG.info("Creating besu process with params {}", params); final ProcessBuilder processBuilder = new ProcessBuilder(params) - .directory(workingDir.toFile()) + .directory(new File(System.getProperty("user.dir")).getParentFile().getParentFile()) .redirectErrorStream(true) .redirectInput(Redirect.INHERIT); if (!node.getPlugins().isEmpty()) { processBuilder .environment() - .put("BESU_OPTS", "-Dbesu.plugins.dir=" + dataDir.resolve("plugins").toAbsolutePath()); + .put( + "BESU_OPTS", + "-Dbesu.plugins.dir=" + dataDir.resolve("plugins").toAbsolutePath().toString()); } // Use non-blocking randomness for acceptance tests processBuilder @@ -578,7 +545,7 @@ private void killBesuProcess(final String name) { LOG.info("Killing {} process, pid {}", name, process.pid()); - process.descendants().forEach(ProcessHandle::destroy); + process.destroy(); try { process.waitFor(30, TimeUnit.SECONDS); } catch (final InterruptedException e) { 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 5ab01326d70..073e0bd1d1b 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 @@ -21,7 +21,6 @@ import org.hyperledger.besu.cli.config.EthNetworkConfig; import org.hyperledger.besu.cli.config.NetworkName; import org.hyperledger.besu.config.GenesisConfigFile; -import org.hyperledger.besu.consensus.qbft.pki.PkiBlockCreationConfigurationProvider; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.controller.BesuControllerBuilder; import org.hyperledger.besu.crypto.KeyPairUtil; @@ -31,6 +30,7 @@ import org.hyperledger.besu.ethereum.api.ApiConfiguration; import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; +import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; @@ -74,7 +74,6 @@ import java.io.File; import java.nio.file.Path; import java.time.Clock; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -141,7 +140,8 @@ private BesuPluginContextImpl buildPluginContext( besuPluginContext.addService(PermissioningService.class, permissioningService); besuPluginContext.addService(PrivacyPluginService.class, new PrivacyPluginServiceImpl()); - besuPluginContext.registerPlugins(pluginsPath); + besuPluginContext.registerPlugins(new PluginConfiguration(pluginsPath)); + commandLine.parseArgs(node.getConfiguration().getExtraCLIOptions().toArray(new String[0])); // register built-in plugins @@ -212,14 +212,16 @@ public void startNode(final BesuNode node) { final EthNetworkConfig.Builder networkConfigBuilder = new EthNetworkConfig.Builder(EthNetworkConfig.getNetworkConfig(network)) .setBootNodes(bootnodes); - node.getConfiguration().getGenesisConfig().ifPresent(networkConfigBuilder::setGenesisConfig); + node.getConfiguration() + .getGenesisConfig() + .map(GenesisConfigFile::fromConfig) + .ifPresent(networkConfigBuilder::setGenesisConfigFile); final EthNetworkConfig ethNetworkConfig = networkConfigBuilder.build(); final SynchronizerConfiguration synchronizerConfiguration = new SynchronizerConfiguration.Builder().build(); final BesuControllerBuilder builder = new BesuController.Builder() - .fromEthNetworkConfig( - ethNetworkConfig, Collections.emptyMap(), synchronizerConfiguration.getSyncMode()); + .fromEthNetworkConfig(ethNetworkConfig, synchronizerConfiguration.getSyncMode()); final KeyValueStorageProvider storageProvider = new KeyValueStorageProviderBuilder() @@ -251,9 +253,6 @@ public void startNode(final BesuNode node) { .isRevertReasonEnabled(node.isRevertReasonEnabled()) .storageProvider(storageProvider) .gasLimitCalculator(GasLimitCalculator.constant()) - .pkiBlockCreationConfiguration( - node.getPkiKeyStoreConfiguration() - .map(pkiConfig -> new PkiBlockCreationConfigurationProvider().load(pkiConfig))) .evmConfiguration(EvmConfiguration.DEFAULT) .maxPeers(maxPeers) .maxRemotelyInitiatedPeers(15) 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 ff6dc2ac9b1..6ed5ee55f33 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 @@ -1,16 +1,13 @@ /* * Copyright ConsenSys AG. * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file - * except in compliance with + * 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 + * 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 @@ -39,7 +36,6 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.RunnableNode; import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationFactory; import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationFactory.CliqueOptions; -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.pki.PkiKeystoreConfigurationFactory; import java.io.File; import java.io.IOException; @@ -57,8 +53,6 @@ public class BesuNodeFactory { private final NodeConfigurationFactory node = new NodeConfigurationFactory(); - private final PkiKeystoreConfigurationFactory pkiKeystoreConfigurationFactory = - new PkiKeystoreConfigurationFactory(); public BesuNode create(final BesuNodeConfiguration config) throws IOException { return new BesuNode( @@ -94,7 +88,6 @@ public BesuNode create(final BesuNodeConfiguration config) throws IOException { config.getPrivacyParameters(), config.getRunCommand(), config.getKeyPair(), - config.getPkiKeyStoreConfiguration(), config.isStrictTxReplayProtectionEnabled(), config.getEnvironment()); } @@ -517,31 +510,6 @@ public BesuNode createQbftNode(final String name) throws IOException { .build()); } - public BesuNode createPkiQbftJKSNode(final String name) throws IOException { - return createPkiQbftNode(KeyStoreWrapper.KEYSTORE_TYPE_JKS, name); - } - - public BesuNode createPkiQbftPKCS11Node(final String name) throws IOException { - return createPkiQbftNode(KeyStoreWrapper.KEYSTORE_TYPE_PKCS11, name); - } - - public BesuNode createPkiQbftPKCS12Node(final String name) throws IOException { - return createPkiQbftNode(KeyStoreWrapper.KEYSTORE_TYPE_PKCS12, name); - } - - public BesuNode createPkiQbftNode(final String type, final String name) throws IOException { - return create( - new BesuNodeConfigurationBuilder() - .name(name) - .miningEnabled() - .jsonRpcConfiguration(node.createJsonRpcWithQbftEnabledConfig(false)) - .webSocketConfiguration(node.createWebSocketEnabledConfig()) - .devMode(false) - .genesisConfigProvider(GenesisConfigurationFactory::createQbftGenesisConfig) - .pkiBlockCreationEnabled(pkiKeystoreConfigurationFactory.createPkiConfig(type, name)) - .build()); - } - public BesuNode createCustomGenesisNode( final String name, final String genesisPath, final boolean canBeBootnode) throws IOException { return createCustomGenesisNode(name, genesisPath, canBeBootnode, false); @@ -699,41 +667,6 @@ public BesuNode createQbftNodeWithContractBasedValidators( .build()); } - public BesuNode createPkiQbftJKSNodeWithValidators(final String name, final String... validators) - throws IOException { - return createPkiQbftNodeWithValidators(KeyStoreWrapper.KEYSTORE_TYPE_JKS, name, validators); - } - - public BesuNode createPkiQbftPKCS11NodeWithValidators( - final String name, final String... validators) throws IOException { - return createPkiQbftNodeWithValidators(KeyStoreWrapper.KEYSTORE_TYPE_PKCS11, name, validators); - } - - public BesuNode createPkiQbftPKCS12NodeWithValidators( - final String name, final String... validators) throws IOException { - return createPkiQbftNodeWithValidators(KeyStoreWrapper.KEYSTORE_TYPE_PKCS12, name, validators); - } - - public BesuNode createPkiQbftNodeWithValidators( - final String type, final String name, final String... validators) throws IOException { - - return create( - new BesuNodeConfigurationBuilder() - .name(name) - .miningEnabled() - .jsonRpcConfiguration(node.createJsonRpcWithQbftEnabledConfig(false)) - .webSocketConfiguration(node.createWebSocketEnabledConfig()) - .devMode(false) - .pkiBlockCreationEnabled(pkiKeystoreConfigurationFactory.createPkiConfig(type, name)) - .genesisConfigProvider( - nodes -> - node.createGenesisConfigForValidators( - asList(validators), - nodes, - GenesisConfigurationFactory::createQbftGenesisConfig)) - .build()); - } - public BesuNode createNodeWithStaticNodes(final String name, final List staticNodes) throws IOException { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/genesis/QbftValidatorContractConfigFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/genesis/QbftValidatorContractConfigFactory.java index 1afdae90ffc..7bf9e2f31af 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/genesis/QbftValidatorContractConfigFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/genesis/QbftValidatorContractConfigFactory.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/pki/PKCS11Utils.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/pki/PKCS11Utils.java index 7c77722c8b2..76799d12e87 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/pki/PKCS11Utils.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/pki/PKCS11Utils.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.dsl.node.configuration.pki; import java.io.File; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/pki/PkiKeystoreConfigurationFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/pki/PkiKeystoreConfigurationFactory.java deleted file mode 100644 index ac7f814d433..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/pki/PkiKeystoreConfigurationFactory.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * 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.node.configuration.pki; - -import static org.hyperledger.besu.pki.util.TestCertificateUtils.createKeyPair; -import static org.hyperledger.besu.pki.util.TestCertificateUtils.createSelfSignedCertificate; -import static org.hyperledger.besu.pki.util.TestCertificateUtils.issueCertificate; - -import org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration; -import org.hyperledger.besu.pki.keystore.KeyStoreWrapper; -import org.hyperledger.besu.pki.util.TestCertificateUtils; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.KeyPair; -import java.security.KeyStore; -import java.security.cert.Certificate; -import java.security.cert.X509Certificate; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Objects; -import java.util.UUID; - -public class PkiKeystoreConfigurationFactory { - - /* - PKCS11 config files - */ - final String NSSCONFIG_PATH_STRING = "/pki-certs/%s/nss.cfg"; - final String NSSPIN_PATH_STRING = "/pki-certs/%s/nsspin.txt"; - final String TRUSTSTORE_PATH_STRING = "/pki-certs/%s/truststore.p12"; - final String CRL_PATH_STRING = "/pki-certs/crl/crl.pem"; - - /* - Software keystore config - */ - public static final String KEYSTORE_DEFAULT_PASSWORD = "password"; - - private KeyPair caKeyPair; - private X509Certificate caCertificate; - private Path trustStoreFile; - private Path passwordFile; - - public PkiKeyStoreConfiguration createPkiConfig(final String type, final String name) { - if (KeyStoreWrapper.KEYSTORE_TYPE_PKCS11.equals(type)) { - return createPKCS11PkiConfig(name); - } else { - return createSoftwareKeyStorePkiConfig(type, name); - } - } - - private PkiKeyStoreConfiguration createPKCS11PkiConfig(final String name) { - final PkiKeyStoreConfiguration.Builder pkiKeyStoreConfigBuilder = - new PkiKeyStoreConfiguration.Builder(); - - try { - pkiKeyStoreConfigBuilder - .withKeyStoreType(KeyStoreWrapper.KEYSTORE_TYPE_PKCS11) - .withKeyStorePath( - PKCS11Utils.initNSSConfigFile( - readResourceAsPath(String.format(NSSCONFIG_PATH_STRING, name)))) - .withKeyStorePasswordPath(readResourceAsPath(String.format(NSSPIN_PATH_STRING, name))) - .withTrustStoreType(KeyStoreWrapper.KEYSTORE_TYPE_PKCS12) - .withTrustStorePath(readResourceAsPath(String.format(TRUSTSTORE_PATH_STRING, name))) - .withTrustStorePasswordPath(readResourceAsPath(String.format(NSSPIN_PATH_STRING, name))) - .withCrlFilePath(readResourceAsPath(CRL_PATH_STRING)) - .withCertificateAlias(name); - - } catch (Exception e) { - throw new RuntimeException(e); - } - - return pkiKeyStoreConfigBuilder.build(); - } - - private PkiKeyStoreConfiguration createSoftwareKeyStorePkiConfig( - final String type, final String name) { - PkiKeyStoreConfiguration.Builder pkiKeyStoreConfigBuilder = - new PkiKeyStoreConfiguration.Builder(); - - pkiKeyStoreConfigBuilder.withTrustStoreType(type); - pkiKeyStoreConfigBuilder.withTrustStorePath(createTrustStore(type)); - pkiKeyStoreConfigBuilder.withTrustStorePasswordPath(passwordFile); - - pkiKeyStoreConfigBuilder.withKeyStoreType(type); - pkiKeyStoreConfigBuilder.withKeyStorePath(createKeyStore(type, name)); - pkiKeyStoreConfigBuilder.withKeyStorePasswordPath(passwordFile); - - pkiKeyStoreConfigBuilder.withCertificateAlias(name); - - return pkiKeyStoreConfigBuilder.build(); - } - - private Path createTrustStore(final String type) { - // Only create the truststore if this is the first time this method is being called - if (caKeyPair == null) { - try { - caKeyPair = createKeyPair(TestCertificateUtils.Algorithm.RSA); - caCertificate = createSelfSignedCertificate("ca", notBefore(), notAfter(), caKeyPair); - - final KeyStore truststore = KeyStore.getInstance(type); - truststore.load(null, null); - truststore.setCertificateEntry("ca", caCertificate); - - final String uniqueId = UUID.randomUUID().toString(); - trustStoreFile = writeKeyStoreFile(truststore, "truststore", uniqueId); - passwordFile = writePasswordFile(KEYSTORE_DEFAULT_PASSWORD, "password", uniqueId); - } catch (final Exception e) { - throw new RuntimeException("Error creating truststore for Acceptance Test", e); - } - } - - return trustStoreFile; - } - - private Path createKeyStore(final String type, final String alias) { - if (caKeyPair == null) { - createTrustStore(type); - } - - final KeyPair kp = createKeyPair(TestCertificateUtils.Algorithm.RSA); - final X509Certificate certificate = - issueCertificate(caCertificate, caKeyPair, "validator", notBefore(), notAfter(), kp, false); - - try { - final KeyStore keyStore = KeyStore.getInstance(type); - keyStore.load(null, null); - keyStore.setKeyEntry( - alias, - kp.getPrivate(), - KEYSTORE_DEFAULT_PASSWORD.toCharArray(), - new Certificate[] {certificate, caCertificate}); - - final String id = UUID.randomUUID().toString(); - return writeKeyStoreFile(keyStore, "keystore", id); - } catch (final Exception e) { - throw new RuntimeException("Error creating keystore for Acceptance Test", e); - } - } - - private Path writeKeyStoreFile( - final KeyStore keyStore, final String prefix, final String suffix) { - try { - final Path file = Files.createTempFile(prefix, suffix != null ? suffix : ""); - file.toFile().deleteOnExit(); - final FileOutputStream keyStoreFOS = new FileOutputStream(file.toFile()); - keyStore.store(keyStoreFOS, KEYSTORE_DEFAULT_PASSWORD.toCharArray()); - - return file; - } catch (final Exception e) { - throw new RuntimeException("Error creating keystore file", e); - } - } - - private Path writePasswordFile(final String password, final String prefix, final String suffix) { - try { - final Path file = Files.createTempFile(prefix, suffix); - file.toFile().deleteOnExit(); - Files.write(file, password.getBytes(StandardCharsets.UTF_8)); - return file; - } catch (final IOException e) { - throw new RuntimeException("Error creating password file", e); - } - } - - private Instant notBefore() { - return Instant.now().minus(1, ChronoUnit.DAYS); - } - - private Instant notAfter() { - return Instant.now().plus(10, ChronoUnit.DAYS); - } - - private Path readResourceAsPath(final String path) throws Exception { - return Path.of(Objects.requireNonNull(this.getClass().getResource(path)).toURI()); - } -} 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 1c0df5ace6d..c9487ebcd67 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 @@ -130,7 +130,6 @@ public PrivacyNode( besuConfig.getPrivacyParameters(), List.of(), Optional.empty(), - Optional.empty(), besuConfig.isStrictTxReplayProtectionEnabled(), besuConfig.getEnvironment()); } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/rpc/JsonRpcTestCase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/rpc/JsonRpcTestCase.java index cc133703495..662e49a1f7b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/rpc/JsonRpcTestCase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/rpc/JsonRpcTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/admin/AdminPeersTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/admin/AdminPeersTransaction.java index dffd700b93b..d2a5364dab4 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/admin/AdminPeersTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/admin/AdminPeersTransaction.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.dsl.transaction.admin; import static org.assertj.core.api.Assertions.assertThat; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthCallTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthCallTransaction.java index 28ea6a0206a..8749a4083a8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthCallTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthCallTransaction.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthEstimateGasTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthEstimateGasTransaction.java index f89bf75c7d7..31e0c518200 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthEstimateGasTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthEstimateGasTransaction.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 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 index 21b628abef2..0d3d9a7d824 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivSyncingTransactions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivSyncingTransactions.java index dc36a8dca56..361d2c556a0 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivSyncingTransactions.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivSyncingTransactions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java index a3fe06c572c..d9bde19b1ea 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java @@ -11,7 +11,6 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ package org.hyperledger.besu.tests.acceptance.plugins; diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java index 2964e76229f..44afeeadaa5 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.plugins; import org.hyperledger.besu.plugin.BesuContext; diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java index fee061f5449..67980373ea2 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyGroupGenesisProvider.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyGroupGenesisProvider.java index d763683ba7f..24d32e759a3 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyGroupGenesisProvider.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyGroupGenesisProvider.java @@ -11,7 +11,6 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ package org.hyperledger.besu.tests.acceptance.plugins.privacy; diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java index 2a26218a6b8..c375946c98b 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java @@ -11,7 +11,6 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ package org.hyperledger.besu.tests.acceptance.plugins.privacy; diff --git a/acceptance-tests/test-plugins/src/test/java/org/hyperledger/besu/services/BesuPluginContextImplTest.java b/acceptance-tests/test-plugins/src/test/java/org/hyperledger/besu/services/BesuPluginContextImplTest.java index 57797462739..c266eaf66a1 100644 --- a/acceptance-tests/test-plugins/src/test/java/org/hyperledger/besu/services/BesuPluginContextImplTest.java +++ b/acceptance-tests/test-plugins/src/test/java/org/hyperledger/besu/services/BesuPluginContextImplTest.java @@ -16,24 +16,31 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; +import org.hyperledger.besu.ethereum.core.plugins.PluginInfo; import org.hyperledger.besu.plugin.BesuPlugin; +import org.hyperledger.besu.tests.acceptance.plugins.TestBesuEventsPlugin; import org.hyperledger.besu.tests.acceptance.plugins.TestPicoCLIPlugin; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; +import java.util.NoSuchElementException; import java.util.Optional; -import org.assertj.core.api.Assertions; import org.assertj.core.api.ThrowableAssert; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class BesuPluginContextImplTest { + private static final Path DEFAULT_PLUGIN_DIRECTORY = Paths.get("."); + private BesuPluginContextImpl contextImpl; @BeforeAll public static void createFakePluginDir() throws IOException { @@ -49,16 +56,20 @@ public void clearTestPluginState() { System.clearProperty("testPicoCLIPlugin.testOption"); } + @BeforeEach + void setup() { + contextImpl = new BesuPluginContextImpl(); + } + @Test public void verifyEverythingGoesSmoothly() { - final BesuPluginContextImpl contextImpl = new BesuPluginContextImpl(); + assertThat(contextImpl.getRegisteredPlugins()).isEmpty(); + contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY)); + assertThat(contextImpl.getRegisteredPlugins()).isNotEmpty(); - assertThat(contextImpl.getPlugins()).isEmpty(); - contextImpl.registerPlugins(new File(".").toPath()); - assertThat(contextImpl.getPlugins()).isNotEmpty(); - - final Optional testPluginOptional = findTestPlugin(contextImpl.getPlugins()); - Assertions.assertThat(testPluginOptional).isPresent(); + final Optional testPluginOptional = + findTestPlugin(contextImpl.getRegisteredPlugins(), TestPicoCLIPlugin.class); + assertThat(testPluginOptional).isPresent(); final TestPicoCLIPlugin testPicoCLIPlugin = testPluginOptional.get(); assertThat(testPicoCLIPlugin.getState()).isEqualTo("registered"); @@ -72,33 +83,34 @@ public void verifyEverythingGoesSmoothly() { @Test public void registrationErrorsHandledSmoothly() { - final BesuPluginContextImpl contextImpl = new BesuPluginContextImpl(); System.setProperty("testPicoCLIPlugin.testOption", "FAILREGISTER"); - assertThat(contextImpl.getPlugins()).isEmpty(); - contextImpl.registerPlugins(new File(".").toPath()); - assertThat(contextImpl.getPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); + assertThat(contextImpl.getRegisteredPlugins()).isEmpty(); + contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY)); + assertThat(contextImpl.getRegisteredPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); contextImpl.beforeExternalServices(); - assertThat(contextImpl.getPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); + assertThat(contextImpl.getRegisteredPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); contextImpl.startPlugins(); - assertThat(contextImpl.getPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); + assertThat(contextImpl.getRegisteredPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); contextImpl.stopPlugins(); - assertThat(contextImpl.getPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); + assertThat(contextImpl.getRegisteredPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); } @Test public void startErrorsHandledSmoothly() { - final BesuPluginContextImpl contextImpl = new BesuPluginContextImpl(); System.setProperty("testPicoCLIPlugin.testOption", "FAILSTART"); - assertThat(contextImpl.getPlugins()).isEmpty(); - contextImpl.registerPlugins(new File(".").toPath()); - assertThat(contextImpl.getPlugins()).extracting("class").contains(TestPicoCLIPlugin.class); + assertThat(contextImpl.getRegisteredPlugins()).isEmpty(); + contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY)); + assertThat(contextImpl.getRegisteredPlugins()) + .extracting("class") + .contains(TestPicoCLIPlugin.class); - final Optional testPluginOptional = findTestPlugin(contextImpl.getPlugins()); + final Optional testPluginOptional = + findTestPlugin(contextImpl.getRegisteredPlugins(), TestPicoCLIPlugin.class); assertThat(testPluginOptional).isPresent(); final TestPicoCLIPlugin testPicoCLIPlugin = testPluginOptional.get(); assertThat(testPicoCLIPlugin.getState()).isEqualTo("registered"); @@ -106,22 +118,24 @@ public void startErrorsHandledSmoothly() { contextImpl.beforeExternalServices(); contextImpl.startPlugins(); assertThat(testPicoCLIPlugin.getState()).isEqualTo("failstart"); - assertThat(contextImpl.getPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); + assertThat(contextImpl.getRegisteredPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); contextImpl.stopPlugins(); - assertThat(contextImpl.getPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); + assertThat(contextImpl.getRegisteredPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class); } @Test public void stopErrorsHandledSmoothly() { - final BesuPluginContextImpl contextImpl = new BesuPluginContextImpl(); System.setProperty("testPicoCLIPlugin.testOption", "FAILSTOP"); - assertThat(contextImpl.getPlugins()).isEmpty(); - contextImpl.registerPlugins(new File(".").toPath()); - assertThat(contextImpl.getPlugins()).extracting("class").contains(TestPicoCLIPlugin.class); + assertThat(contextImpl.getRegisteredPlugins()).isEmpty(); + contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY)); + assertThat(contextImpl.getRegisteredPlugins()) + .extracting("class") + .contains(TestPicoCLIPlugin.class); - final Optional testPluginOptional = findTestPlugin(contextImpl.getPlugins()); + final Optional testPluginOptional = + findTestPlugin(contextImpl.getRegisteredPlugins(), TestPicoCLIPlugin.class); assertThat(testPluginOptional).isPresent(); final TestPicoCLIPlugin testPicoCLIPlugin = testPluginOptional.get(); assertThat(testPicoCLIPlugin.getState()).isEqualTo("registered"); @@ -136,9 +150,8 @@ public void stopErrorsHandledSmoothly() { @Test public void lifecycleExceptions() throws Throwable { - final BesuPluginContextImpl contextImpl = new BesuPluginContextImpl(); final ThrowableAssert.ThrowingCallable registerPlugins = - () -> contextImpl.registerPlugins(new File(".").toPath()); + () -> contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY)); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::startPlugins); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::stopPlugins); @@ -158,9 +171,74 @@ public void lifecycleExceptions() throws Throwable { assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::stopPlugins); } - private Optional findTestPlugin(final List plugins) { + @Test + public void shouldRegisterAllPluginsWhenNoPluginsOption() { + final PluginConfiguration config = createConfigurationForAllPlugins(); + + assertThat(contextImpl.getRegisteredPlugins()).isEmpty(); + contextImpl.registerPlugins(config); + final Optional testPluginOptional = + findTestPlugin(contextImpl.getRegisteredPlugins(), TestPicoCLIPlugin.class); + assertThat(testPluginOptional).isPresent(); + final TestPicoCLIPlugin testPicoCLIPlugin = testPluginOptional.get(); + assertThat(testPicoCLIPlugin.getState()).isEqualTo("registered"); + } + + @Test + public void shouldRegisterOnlySpecifiedPluginWhenPluginsOptionIsSet() { + final PluginConfiguration config = createConfigurationForSpecificPlugin("TestPicoCLIPlugin"); + + assertThat(contextImpl.getRegisteredPlugins()).isEmpty(); + contextImpl.registerPlugins(config); + + final Optional requestedPlugin = + findTestPlugin(contextImpl.getRegisteredPlugins(), TestPicoCLIPlugin.class); + + assertThat(requestedPlugin).isPresent(); + assertThat(requestedPlugin.get().getState()).isEqualTo("registered"); + + final Optional nonRequestedPlugin = + findTestPlugin(contextImpl.getRegisteredPlugins(), TestBesuEventsPlugin.class); + + assertThat(nonRequestedPlugin).isEmpty(); + } + + @Test + public void shouldNotRegisterUnspecifiedPluginsWhenPluginsOptionIsSet() { + final PluginConfiguration config = createConfigurationForSpecificPlugin("TestPicoCLIPlugin"); + assertThat(contextImpl.getRegisteredPlugins()).isEmpty(); + contextImpl.registerPlugins(config); + + final Optional nonRequestedPlugin = + findTestPlugin(contextImpl.getRegisteredPlugins(), TestBesuEventsPlugin.class); + assertThat(nonRequestedPlugin).isEmpty(); + } + + @Test + void shouldThrowExceptionIfExplicitlySpecifiedPluginNotFound() { + PluginConfiguration config = createConfigurationForSpecificPlugin("NonExistentPlugin"); + + String exceptionMessage = + assertThrows(NoSuchElementException.class, () -> contextImpl.registerPlugins(config)) + .getMessage(); + final String expectedMessage = + "The following requested plugins were not found: NonExistentPlugin"; + assertThat(exceptionMessage).isEqualTo(expectedMessage); + assertThat(contextImpl.getRegisteredPlugins()).isEmpty(); + } + + private PluginConfiguration createConfigurationForAllPlugins() { + return new PluginConfiguration(null, DEFAULT_PLUGIN_DIRECTORY); + } + + private PluginConfiguration createConfigurationForSpecificPlugin(final String pluginName) { + return new PluginConfiguration(List.of(new PluginInfo(pluginName)), DEFAULT_PLUGIN_DIRECTORY); + } + + private Optional findTestPlugin( + final List plugins, final Class type) { return plugins.stream() - .filter(p -> p instanceof TestPicoCLIPlugin) + .filter(p -> type.equals(p.getClass())) .map(p -> (TestPicoCLIPlugin) p) .findFirst(); } diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index 10b3138384a..74f4a1164a8 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -13,7 +13,7 @@ plugins { id 'org.web3j' version '4.11.1' - id 'org.web3j.solidity' version '0.4.0' + id 'org.web3j.solidity' version '0.4.1' } web3j { generatedPackageName = 'org.hyperledger.besu.tests.web3j.generated' } @@ -258,3 +258,32 @@ task acceptanceTestPermissioning(type: Test) { doFirst { mkdir "${buildDir}/jvmErrorLogs" } } + +// temporary solution to get a list of tests +// Gradle >8.3 has a supported test dry-run option to achieve the same result +task listAcceptanceTestNotPrivacy { + doLast { + def testExecutionSpec = tasks.getByName("acceptanceTestNotPrivacy") as Test + + def processor = new org.gradle.api.internal.tasks.testing.TestClassProcessor() { + void startProcessing(org.gradle.api.internal.tasks.testing.TestResultProcessor processor) {} + void stop() {} + void stopNow() {} + + void processTestClass(org.gradle.api.internal.tasks.testing.TestClassRunInfo info) { + def splitName = info.getTestClassName().split("\\."); + def testClassName = splitName[splitName.length-1]; + if(testClassName.endsWith("Test") && !testClassName.startsWith("Abstract")) { + println(info.getTestClassName()) + } + } + } + + def detector = new org.gradle.api.internal.tasks.testing.detection.DefaultTestClassScanner(testExecutionSpec.getCandidateClassFiles(), testExecutionSpec.getTestFramework().getDetector()?.tap { + setTestClasses(testExecutionSpec.getTestClassesDirs().getFiles()) + setTestClasspath(Collections.unmodifiableSet(testExecutionSpec.getClasspath().getFiles())) + }, processor) + + detector.run() + } +} diff --git a/acceptance-tests/tests/contracts/CrossContractReader.sol b/acceptance-tests/tests/contracts/CrossContractReader.sol index e54e4c712eb..f43ce8b621e 100644 --- a/acceptance-tests/tests/contracts/CrossContractReader.sol +++ b/acceptance-tests/tests/contracts/CrossContractReader.sol @@ -59,4 +59,4 @@ contract CrossContractReader { CrossContractReader cross = CrossContractReader(crossAddress); cross.destroy(); } -} \ No newline at end of file +} diff --git a/acceptance-tests/tests/contracts/EventEmitter.sol b/acceptance-tests/tests/contracts/EventEmitter.sol index 22afa7a0868..2e6e29e59d6 100644 --- a/acceptance-tests/tests/contracts/EventEmitter.sol +++ b/acceptance-tests/tests/contracts/EventEmitter.sol @@ -41,4 +41,4 @@ contract EventEmitter { function sender() view public returns (address) { return _sender; } -} \ No newline at end of file +} diff --git a/acceptance-tests/tests/contracts/RemoteSimpleStorage.sol b/acceptance-tests/tests/contracts/RemoteSimpleStorage.sol index 072948e035b..03c95dc2bd1 100644 --- a/acceptance-tests/tests/contracts/RemoteSimpleStorage.sol +++ b/acceptance-tests/tests/contracts/RemoteSimpleStorage.sol @@ -1,5 +1,5 @@ /* - * Copyright contributors to Hyperledger Besu + * Copyright contributors to Hyperledger Besu. * * 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 @@ -34,4 +34,4 @@ contract RemoteSimpleStorage { function get() public view returns (uint) { return simpleStorage.get(); } -} \ No newline at end of file +} diff --git a/acceptance-tests/tests/contracts/RevertReason.sol b/acceptance-tests/tests/contracts/RevertReason.sol index d632910662c..b1270fe4ccd 100644 --- a/acceptance-tests/tests/contracts/RevertReason.sol +++ b/acceptance-tests/tests/contracts/RevertReason.sol @@ -27,4 +27,4 @@ contract RevertReason { function revertWithoutRevertReason() public pure returns (bool) { revert(); } -} \ No newline at end of file +} diff --git a/acceptance-tests/tests/contracts/SimpleStorage.sol b/acceptance-tests/tests/contracts/SimpleStorage.sol index 0b4838f1c26..9303def9e05 100644 --- a/acceptance-tests/tests/contracts/SimpleStorage.sol +++ b/acceptance-tests/tests/contracts/SimpleStorage.sol @@ -28,4 +28,4 @@ contract SimpleStorage { function get() public view returns (uint) { return data; } -} \ No newline at end of file +} diff --git a/acceptance-tests/tests/contracts/TestDepth.sol b/acceptance-tests/tests/contracts/TestDepth.sol index ec49a1ad8bf..3b4e17904c3 100644 --- a/acceptance-tests/tests/contracts/TestDepth.sol +++ b/acceptance-tests/tests/contracts/TestDepth.sol @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 @@ -29,4 +29,4 @@ contract TestDepth { x = gasleft(); } } -} \ No newline at end of file +} diff --git a/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/Migrations.sol b/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/Migrations.sol index f47e9cea31c..e0e4dd0959d 100644 --- a/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/Migrations.sol +++ b/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/Migrations.sol @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - pragma solidity ^0.5.0; contract Migrations { diff --git a/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleAccountPermissioning.sol b/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleAccountPermissioning.sol index 04542a50551..72215b4a9cd 100644 --- a/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleAccountPermissioning.sol +++ b/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleAccountPermissioning.sol @@ -1,3 +1,17 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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 + */ pragma solidity >=0.4.0 <0.6.0; // THIS CONTRACT IS FOR TESTING PURPOSES ONLY // DO NOT USE THIS CONTRACT IN PRODUCTION APPLICATIONS @@ -43,4 +57,4 @@ contract SimpleAccountPermissioning { function getSize() public view returns(uint256) { return size; } -} \ No newline at end of file +} diff --git a/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleNodePermissioning.sol b/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleNodePermissioning.sol index 334cf959c50..57c72370b82 100644 --- a/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleNodePermissioning.sol +++ b/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleNodePermissioning.sol @@ -1,3 +1,17 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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 + */ pragma solidity >=0.4.0 <0.6.0; // THIS CONTRACT IS FOR TESTING PURPOSES ONLY // DO NOT USE THIS CONTRACT IN PRODUCTION APPLICATIONS diff --git a/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleNodePermissioningV2.sol b/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleNodePermissioningV2.sol index 9458f0619bf..a3b7ffa47b5 100644 --- a/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleNodePermissioningV2.sol +++ b/acceptance-tests/tests/simple-permissioning-smart-contract/contracts/SimpleNodePermissioningV2.sol @@ -1,3 +1,17 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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 + */ pragma solidity >=0.4.0 <0.6.0; // THIS CONTRACT IS FOR TESTING PURPOSES ONLY // DO NOT USE THIS CONTRACT IN PRODUCTION APPLICATIONS diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/AbstractPreexistingNodeTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/AbstractPreexistingNodeTest.java index a407b389e44..fe148921002 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/AbstractPreexistingNodeTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/AbstractPreexistingNodeTest.java @@ -11,9 +11,7 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ - package org.hyperledger.besu.tests.acceptance; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java index 1c1f0c33b68..aab428eee75 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright contributors to Hyperledger Besu + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java index aa58ffb2fdf..56560247435 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java @@ -11,9 +11,7 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ - package org.hyperledger.besu.tests.acceptance.backup; import static java.util.Collections.singletonList; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTest.java deleted file mode 100644 index 12ae887a510..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * 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.bft.pki; - -import org.hyperledger.besu.tests.acceptance.dsl.account.Account; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; - -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -public class PkiQbftAcceptanceTest extends ParameterizedPkiQbftTestBase { - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("factoryFunctions") - public void shouldMineOnSingleNode( - final String testName, final PkiQbftAcceptanceTestParameterization nodeFactory) - throws Exception { - final BesuNode minerNode = nodeFactory.createNode(besu, "miner1"); - cluster.start(minerNode); - - cluster.verify(blockchain.reachesHeight(minerNode, 1)); - - final Account sender = accounts.createAccount("account1"); - final Account receiver = accounts.createAccount("account2"); - - minerNode.execute(accountTransactions.createTransfer(sender, 50)); - cluster.verify(sender.balanceEquals(50)); - - minerNode.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 1)); - cluster.verify(receiver.balanceEquals(1)); - - minerNode.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 2)); - cluster.verify(receiver.balanceEquals(3)); - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("factoryFunctions") - public void shouldMineOnMultipleNodes( - final String testName, final PkiQbftAcceptanceTestParameterization nodeFactory) - throws Exception { - final BesuNode minerNode1 = nodeFactory.createNode(besu, "miner1"); - final BesuNode minerNode2 = nodeFactory.createNode(besu, "miner2"); - final BesuNode minerNode3 = nodeFactory.createNode(besu, "miner3"); - final BesuNode minerNode4 = nodeFactory.createNode(besu, "miner4"); - cluster.start(minerNode1, minerNode2, minerNode3, minerNode4); - - cluster.verify(blockchain.reachesHeight(minerNode1, 1, 85)); - - final Account sender = accounts.createAccount("account1"); - final Account receiver = accounts.createAccount("account2"); - - minerNode1.execute(accountTransactions.createTransfer(sender, 50)); - cluster.verify(sender.balanceEquals(50)); - - minerNode2.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 1)); - cluster.verify(receiver.balanceEquals(1)); - - minerNode3.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 2)); - cluster.verify(receiver.balanceEquals(3)); - - minerNode4.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 3)); - cluster.verify(receiver.balanceEquals(6)); - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("factoryFunctions") - public void shouldMineWithIgnoringANodeInCRL( - final String testName, final PkiQbftAcceptanceTestParameterization nodeFactory) - throws Exception { - final BesuNode minerNode1 = nodeFactory.createNode(besu, "miner1"); - final BesuNode minerNode2 = nodeFactory.createNode(besu, "miner2"); - final BesuNode minerNode3 = nodeFactory.createNode(besu, "miner3"); - final BesuNode minerNode4 = nodeFactory.createNode(besu, "miner4"); - final BesuNode minerNode5 = nodeFactory.createNode(besu, "miner5"); - final BesuNode minerNode6 = nodeFactory.createNode(besu, "miner6"); - try { - cluster.start(minerNode1, minerNode2, minerNode3, minerNode4); - - cluster.startNode(minerNode5); - cluster.startNode(minerNode6); - - cluster.verify(blockchain.reachesHeight(minerNode1, 1, 85)); - - final Account sender = accounts.createAccount("account1"); - final Account receiver = accounts.createAccount("account2"); - - minerNode1.execute(accountTransactions.createTransfer(sender, 50)); - cluster.verify(sender.balanceEquals(50)); - - minerNode2.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 1)); - cluster.verify(receiver.balanceEquals(1)); - - minerNode3.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 2)); - cluster.verify(receiver.balanceEquals(3)); - - minerNode4.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 3)); - cluster.verify(receiver.balanceEquals(6)); - - if (minerNode1.getTLSConfiguration().isEmpty()) { - minerNode1.verify(net.awaitPeerCount(5)); - minerNode5.verify(net.awaitPeerCount(5)); - minerNode6.verify(net.awaitPeerCount(5)); - } else { - minerNode1.verify(net.awaitPeerCount(3)); - minerNode5.verify(net.awaitPeerCount(0)); - minerNode6.verify(net.awaitPeerCount(0)); - } - } finally { - cluster.stopNode(minerNode5); - cluster.stopNode(minerNode6); - minerNode5.close(); - minerNode6.close(); - } - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTestParameterization.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTestParameterization.java deleted file mode 100644 index 7bcf09afd38..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTestParameterization.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2020 ConsenSys AG. - * - * 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.bft.pki; - -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import org.junit.jupiter.params.provider.Arguments; - -public class PkiQbftAcceptanceTestParameterization { - - public static Stream getFactories() { - List args = new ArrayList<>(); - - /* - BLOCK CREATION - */ - - args.add( - Arguments.of( - "qbft-pki-jks", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createPkiQbftJKSNode, - BesuNodeFactory::createPkiQbftJKSNodeWithValidators))); - - args.add( - Arguments.of( - "qbft-pki-pkcs12", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createPkiQbftPKCS12Node, - BesuNodeFactory::createPkiQbftPKCS12NodeWithValidators))); - - if (Boolean.getBoolean("acctests.runBesuAsProcess")) { - args.add( - Arguments.of( - "qbft-pki-pkcs11", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createPkiQbftPKCS11Node, - BesuNodeFactory::createPkiQbftPKCS11NodeWithValidators))); - } - - /* - TLS - */ - - args.add( - Arguments.of( - "qbft-tls-jks", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createQbftNodeWithTLSJKS, - BesuNodeFactory::createQbftTLSJKSNodeWithValidators))); - - args.add( - Arguments.of( - "qbft-tls-pkcs12", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createQbftNodeWithTLSPKCS12, - BesuNodeFactory::createQbftTLSPKCS12NodeWithValidators))); - - if (Boolean.getBoolean("acctests.runBesuAsProcess")) { - args.add( - Arguments.of( - "qbft-tls-pkcs11", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createQbftNodeWithTLSPKCS11, - BesuNodeFactory::createQbftTLSPKCS11NodeWithValidators))); - } - - return args.stream(); - } - - @FunctionalInterface - public interface NodeCreator { - - BesuNode create(BesuNodeFactory factory, String name) throws Exception; - } - - @FunctionalInterface - public interface NodeWithValidatorsCreator { - - BesuNode create(BesuNodeFactory factory, String name, String[] validators) throws Exception; - } - - private final NodeCreator creatorFn; - private final NodeWithValidatorsCreator createorWithValidatorFn; - - public PkiQbftAcceptanceTestParameterization( - final NodeCreator creatorFn, final NodeWithValidatorsCreator createorWithValidatorFn) { - this.creatorFn = creatorFn; - this.createorWithValidatorFn = createorWithValidatorFn; - } - - public BesuNode createNode(BesuNodeFactory factory, String name) throws Exception { - return creatorFn.create(factory, name); - } - - public BesuNode createNodeWithValidators( - BesuNodeFactory factory, String name, String[] validators) throws Exception { - return createorWithValidatorFn.create(factory, name, validators); - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java index 51500bb1490..b62eb96e195 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java index 50c58f8b34b..f6718b4ded1 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java @@ -86,7 +86,7 @@ public void shouldMineTransactionsOnMultipleNodes() throws IOException { final BesuNode minerNode1 = besu.createCliqueNode("miner1"); final BesuNode minerNode2 = besu.createCliqueNode("miner2"); final BesuNode minerNode3 = besu.createCliqueNode("miner3"); - cluster.start(minerNode1, minerNode2, minerNode3); + startClusterAndVerifyProducingBlocks(minerNode1, minerNode2, minerNode3); final Account sender = accounts.createAccount("account1"); final Account receiver = accounts.createAccount("account2"); @@ -106,7 +106,7 @@ public void shouldStallMiningWhenInsufficientValidators() throws IOException { final BesuNode minerNode1 = besu.createCliqueNode("miner1"); final BesuNode minerNode2 = besu.createCliqueNode("miner2"); final BesuNode minerNode3 = besu.createCliqueNode("miner3"); - cluster.start(minerNode1, minerNode2, minerNode3); + startClusterAndVerifyProducingBlocks(minerNode1, minerNode2, minerNode3); cluster.stopNode(minerNode2); cluster.stopNode(minerNode3); @@ -116,12 +116,23 @@ public void shouldStallMiningWhenInsufficientValidators() throws IOException { minerNode1.verify(clique.noNewBlockCreated(minerNode1)); } + private void startClusterAndVerifyProducingBlocks( + final BesuNode minerNode1, final BesuNode minerNode2, final BesuNode minerNode3) { + cluster.start(minerNode1, minerNode2, minerNode3); + + // verify that we have started producing blocks + waitForBlockHeight(minerNode1, 1); + final var minerChainHead = minerNode1.execute(ethTransactions.block()); + minerNode2.verify(blockchain.minimumHeight(minerChainHead.getNumber().longValue())); + minerNode3.verify(blockchain.minimumHeight(minerChainHead.getNumber().longValue())); + } + @Test public void shouldStillMineWhenANodeFailsAndHasSufficientValidators() throws IOException { final BesuNode minerNode1 = besu.createCliqueNode("miner1"); final BesuNode minerNode2 = besu.createCliqueNode("miner2"); final BesuNode minerNode3 = besu.createCliqueNode("miner3"); - cluster.start(minerNode1, minerNode2, minerNode3); + startClusterAndVerifyProducingBlocks(minerNode1, minerNode2, minerNode3); cluster.verifyOnActiveNodes(blockchain.reachesHeight(minerNode1, 1, 85)); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java index 7164de0b7aa..7488b0603e8 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java @@ -11,7 +11,6 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ package org.hyperledger.besu.tests.acceptance.crypto; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/database/DatabaseMigrationAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/database/DatabaseMigrationAcceptanceTest.java index b2166a1cc58..428803544ce 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/database/DatabaseMigrationAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/database/DatabaseMigrationAcceptanceTest.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.database; import static java.util.Collections.singletonList; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/AbstractJsonRpcTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/AbstractJsonRpcTest.java index e8f83c29998..d88b1ed8b55 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/AbstractJsonRpcTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/AbstractJsonRpcTest.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugReplayBlockAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugReplayBlockAcceptanceTest.java index aa8547d83bb..9fafeac3a77 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugReplayBlockAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugReplayBlockAcceptanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugSetHeadAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugSetHeadAcceptanceTest.java index 4a2b956efcd..d6f6740d2b5 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugSetHeadAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugSetHeadAcceptanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthEstimateGasAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthEstimateGasAcceptanceTest.java index 5326c5763cb..a09f44093ea 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthEstimateGasAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthEstimateGasAcceptanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthGetBlockByNumberAndHashShanghaiAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthGetBlockByNumberAndHashShanghaiAcceptanceTest.java index e795ee27abc..e3dab61ba6b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthGetBlockByNumberAndHashShanghaiAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthGetBlockByNumberAndHashShanghaiAcceptanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineParisAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineParisAcceptanceTest.java index e7cb8a9150e..a0fdc9c3026 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineParisAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineParisAcceptanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalAndOnchainPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalAndOnchainPermissioningAcceptanceTest.java index 4b6401303be..1d38f7e6c7c 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalAndOnchainPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalAndOnchainPermissioningAcceptanceTest.java @@ -21,15 +21,15 @@ import java.math.BigInteger; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AccountLocalAndOnchainPermissioningAcceptanceTest extends AccountSmartContractPermissioningAcceptanceTestBase { private Account senderC; - @Before + @BeforeEach public void setUp() { senderC = accounts.createAccount("Account-C"); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java index 78a9fee0413..4b163a4efc9 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java @@ -22,8 +22,8 @@ import java.math.BigInteger; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AccountLocalConfigPermissioningAcceptanceTest extends AcceptanceTestBase { @@ -31,7 +31,7 @@ public class AccountLocalConfigPermissioningAcceptanceTest extends AcceptanceTes private Account senderA; private Account senderB; - @Before + @BeforeEach public void setUp() throws Exception { senderA = accounts.getPrimaryBenefactor(); senderB = accounts.getSecondaryBenefactor(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningImportAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningImportAcceptanceTest.java index 4415a03f807..c3a2ab6e11a 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningImportAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningImportAcceptanceTest.java @@ -21,20 +21,19 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster; import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; -import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class AccountLocalConfigPermissioningImportAcceptanceTest extends AcceptanceTestBase { - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir Path folder; private static final String GENESIS_FILE = "/ibft/ibft.json"; @@ -45,20 +44,20 @@ public class AccountLocalConfigPermissioningImportAcceptanceTest extends Accepta private BesuNode nodeB; private Cluster permissionedCluster; - @Before + @BeforeEach public void setUp() throws IOException { sender = accounts.getPrimaryBenefactor(); beneficiary = accounts.createAccount("beneficiary"); final List allowList = List.of(sender.getAddress(), beneficiary.getAddress()); - final File sharedFile = folder.newFile(); - persistAllowList(allowList, sharedFile.toPath()); + final Path sharedFile = Files.createFile(folder.resolve("sharedFile")); + persistAllowList(allowList, sharedFile); bootnode = besu.createIbft2NonValidatorBootnode("bootnode", GENESIS_FILE); nodeA = besu.createIbft2NodeWithLocalAccountPermissioning( - "nodeA", GENESIS_FILE, allowList, sharedFile); + "nodeA", GENESIS_FILE, allowList, sharedFile.toFile()); nodeB = besu.createIbft2NodeWithLocalAccountPermissioning( - "nodeB", GENESIS_FILE, allowList, sharedFile); + "nodeB", GENESIS_FILE, allowList, sharedFile.toFile()); permissionedCluster = new Cluster(new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(), net); @@ -67,12 +66,12 @@ public void setUp() throws IOException { @Test public void transactionFromDeniedAccountShouldNotBreakBlockImport() throws IOException { - final File newPermissionsFile = folder.newFile(); + final Path newPermissionsFile = Files.createFile(folder.resolve("newPermissionsFile")); final List allowList = List.of(beneficiary.getAddress()); - persistAllowList(allowList, newPermissionsFile.toPath()); + persistAllowList(allowList, newPermissionsFile); final BesuNode nodeC = besu.createIbft2NodeWithLocalAccountPermissioning( - "nodeC", GENESIS_FILE, allowList, newPermissionsFile); + "nodeC", GENESIS_FILE, allowList, newPermissionsFile.toFile()); waitForBlockHeight(bootnode, 2); @@ -91,7 +90,7 @@ private void persistAllowList(final List allowList, final Path path) thr AllowlistPersistor.ALLOWLIST_TYPE.ACCOUNTS, allowList, path); } - @After + @AfterEach public void tearDown() { permissionedCluster.stop(); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountSmartContractPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountSmartContractPermissioningAcceptanceTest.java index 6d9e74e04a6..9009721d94d 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountSmartContractPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountSmartContractPermissioningAcceptanceTest.java @@ -21,8 +21,8 @@ import java.math.BigInteger; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AccountSmartContractPermissioningAcceptanceTest extends AccountSmartContractPermissioningAcceptanceTestBase { @@ -31,7 +31,7 @@ public class AccountSmartContractPermissioningAcceptanceTest private Account allowedSender; private Account otherAccount; - @Before + @BeforeEach public void setUp() { node = permissionedNode("node1", Collections.emptyList()); permissionedCluster.start(node); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java index 5a563cc5264..71258222d78 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java @@ -26,8 +26,8 @@ import java.util.Collections; import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AllowlistPersistorAcceptanceTest extends AcceptanceTestBase { @@ -45,7 +45,7 @@ public class AllowlistPersistorAcceptanceTest extends AcceptanceTestBase { private Account senderB; private Path tempFile; - @Before + @BeforeEach public void setUp() throws Exception { senderA = accounts.getPrimaryBenefactor(); senderB = accounts.getSecondaryBenefactor(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java index 88c7e783777..08761ef6e07 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java @@ -31,8 +31,8 @@ import java.util.ArrayList; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AllowlistWithDnsPersistorAcceptanceTest extends AcceptanceTestBase { @@ -48,7 +48,7 @@ public class AllowlistWithDnsPersistorAcceptanceTest extends AcceptanceTestBase private Account senderA; private Path tempFile; - @Before + @BeforeEach public void setUp() throws Exception { ENODE_LOCALHOST_DNS = ENODE_PREFIX + InetAddress.getLocalHost().getHostName() + PORT_SUFFIX; ENODE_LOCALHOST_IP = ENODE_PREFIX + "127.0.0.1" + PORT_SUFFIX; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnchainPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnchainPermissioningAcceptanceTest.java index 6a7b8e9b35f..3dfdae528a8 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnchainPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnchainPermissioningAcceptanceTest.java @@ -16,8 +16,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeLocalAndOnchainPermissioningAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { @@ -27,7 +27,7 @@ public class NodeLocalAndOnchainPermissioningAcceptanceTest private Node allowedNode; private Node forbiddenNode; - @Before + @BeforeEach public void setUp() { bootnode = bootnode("bootnode"); forbiddenNode = node("forbidden-node"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java index 7d8128d66c7..d889abb9fbb 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java @@ -20,8 +20,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration; import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeLocalConfigPermissioningAcceptanceTest extends AcceptanceTestBase { @@ -31,7 +31,7 @@ public class NodeLocalConfigPermissioningAcceptanceTest extends AcceptanceTestBa private Node allowedNode; private Node permissionedNode; - @Before + @BeforeEach public void setUp() throws Exception { final ClusterConfiguration clusterConfiguration = new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); 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 e9442bc0077..8f17c78adde 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 @@ -16,8 +16,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { @@ -27,7 +27,7 @@ public class NodeSmartContractPermissioningAcceptanceTest private Node allowedNode; private Node forbiddenNode; - @Before + @BeforeEach public void setUp() { bootnode = bootnode("bootnode"); forbiddenNode = node("forbidden-node"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbft2StallAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbft2StallAcceptanceTest.java index e9da331a9e3..ed48ad9db97 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbft2StallAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbft2StallAcceptanceTest.java @@ -22,7 +22,7 @@ import java.io.IOException; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningIbft2StallAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningOutOfSyncAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningOutOfSyncAcceptanceTest.java index 2f8adf43867..935db106ca5 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningOutOfSyncAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningOutOfSyncAcceptanceTest.java @@ -16,8 +16,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningOutOfSyncAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { @@ -25,7 +25,7 @@ public class NodeSmartContractPermissioningOutOfSyncAcceptanceTest private Node permissionedNodeA; private Node permissionedNodeB; - @Before + @BeforeEach public void setUp() throws InterruptedException { bootnode = bootnode("bootnode"); permissionedNodeA = permissionedNode("permissioned-node-A"); @@ -46,14 +46,18 @@ public void addNodeToClusterAndVerifyNonBootNodePeerConnectionWorksAfterSync() { final long blockchainHeight = 25L; waitForBlockHeight(permissionedNodeA, blockchainHeight); - // Add Node B + // verify Node A is in sync with bootnode + final var minerChainHead = bootnode.execute(ethTransactions.block()); + permissionedNodeA.verify(blockchain.minimumHeight(minerChainHead.getNumber().longValue())); + + // check that connection is forbidden (before node b is permitted) permissionedCluster.addNode(permissionedNodeB); + permissionedNodeB.verify(connectionIsForbidden(permissionedNodeA, permissionedNodeB)); + + // Permit Node B permissionedNodeA.execute(allowNode(permissionedNodeB)); permissionedNodeA.verify(admin.addPeer(permissionedNodeB)); - // check that connection is forbidden (while node b is syncing) - permissionedNodeB.verify(connectionIsForbidden(permissionedNodeA, permissionedNodeB)); - // connection should be allowed after node B syncs waitForBlockHeight(permissionedNodeB, blockchainHeight); permissionedNodeB.verify(connectionIsAllowed(permissionedNodeA, permissionedNodeB)); 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 396b2b4c73c..843d14004fc 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 @@ -16,8 +16,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningV2AcceptanceTest extends NodeSmartContractPermissioningV2AcceptanceTestBase { @@ -27,7 +27,7 @@ public class NodeSmartContractPermissioningV2AcceptanceTest private Node allowedNode; private Node forbiddenNode; - @Before + @BeforeEach public void setUp() { bootnode = bootnode("bootnode"); forbiddenNode = node("forbidden-node"); @@ -116,6 +116,8 @@ public void onchainPermissioningAllowlistShouldPersistAcrossRestarts() { permissionedCluster.stop(); permissionedCluster.start(bootnode, forbiddenNode, allowedNode, permissionedNode); + verifyAllNodesAreInSyncWithMiner(); + permissionedNode.verify(connectionIsAllowed(allowedNode)); permissionedNode.verify(connectionIsAllowed(bootnode)); permissionedNode.verify(connectionIsAllowed(permissionedNode)); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2DNSAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2DNSAcceptanceTest.java index b2ed27d7c5d..7a55283e4f4 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2DNSAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2DNSAcceptanceTest.java @@ -24,8 +24,8 @@ import java.net.UnknownHostException; import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningV2DNSAcceptanceTest extends NodeSmartContractPermissioningV2AcceptanceTestBase { @@ -38,7 +38,7 @@ public class NodeSmartContractPermissioningV2DNSAcceptanceTest final ImmutableEnodeDnsConfiguration enodeDnsConfiguration = ImmutableEnodeDnsConfiguration.builder().dnsEnabled(true).updateEnabled(true).build(); - @Before + @BeforeEach public void setUp() { bootnode = bootnode("bootnode"); forbiddenNode = node("forbidden-node"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java index 57253d474c2..4f516d1cda5 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java @@ -24,8 +24,8 @@ import java.util.List; import javax.annotation.Nonnull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodesSmartContractPermissioningStaticNodesAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { @@ -33,7 +33,7 @@ public class NodesSmartContractPermissioningStaticNodesAcceptanceTest private Node miner; private Node permissionedNode; - @Before + @BeforeEach public void setUp() { miner = miner("miner"); permissionedCluster.start(miner); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java index 733fdc6a7c2..fb35aaacf54 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java @@ -11,7 +11,6 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ package org.hyperledger.besu.tests.acceptance.plugins; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java index 60047c16579..86756a42082 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.tests.acceptance.plugins; import org.hyperledger.besu.datatypes.Hash; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/RpcEndpointServicePluginTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/RpcEndpointServicePluginTest.java index 09da91663af..5ad125719cf 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/RpcEndpointServicePluginTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/RpcEndpointServicePluginTest.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json index 98d388cc0f7..8c6a3d41d5a 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json @@ -32,6 +32,24 @@ "0xa4664C40AACeBD82A2Db79f0ea36C06Bc6A19Adb": { "balance": "1000000000000000000000000000" }, + "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f": { + "comment": "This is the account used to sign the transaction that creates a validator exit", + "balance": "1000000000000000000000000000" + }, + "0xEd8EA01d70Cb49726175BCf2778B9C982912e017": { + "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the deployment transaction in EIP-7002 (https://eips.ethereum.org/EIPS/eip-7002#deployment)", + "balance": "0", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b36603814156101215760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012157600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f5460015460028282011161010f5750505f610115565b01600290035b5f555f600155604c025ff35b5f5ffd", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000001": "0000000000000000000000000000000000000000000000000000000000000001", + "0x0000000000000000000000000000000000000000000000000000000000000002": "0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000003": "0000000000000000000000000000000000000000000000000000000000000001", + "0x0000000000000000000000000000000000000000000000000000000000000004": "000000000000000000000000a4664C40AACeBD82A2Db79f0ea36C06Bc6A19Adb", + "0x0000000000000000000000000000000000000000000000000000000000000005": "b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee9922355", + "0x0000000000000000000000000000000000000000000000000000000000000006": "5d8601f0cb3bcc4ce1af9864779a416e00000000000000000000000000000000" + } + }, "0x4242424242424242424242424242424242424242": { "balance": "0", "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json index 47063a25e4b..e810b1cad33 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json @@ -4,8 +4,8 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x78a301e0d846bd169889c9755c9aa4ce2972dfc4bd63de61f3303887d3e81f98", - "safeBlockHash": "0x78a301e0d846bd169889c9755c9aa4ce2972dfc4bd63de61f3303887d3e81f98", + "headBlockHash": "0x292042b10484fc182be8aba2a4c1863f6712cc7f0c74489c226792138134248f", + "safeBlockHash": "0x292042b10484fc182be8aba2a4c1863f6712cc7f0c74489c226792138134248f", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x78a301e0d846bd169889c9755c9aa4ce2972dfc4bd63de61f3303887d3e81f98", + "latestValidHash": "0x292042b10484fc182be8aba2a4c1863f6712cc7f0c74489c226792138134248f", "validationError": null }, - "payloadId": "0x282643d459a6f711" + "payloadId": "0x282643efdc841a11" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json index c6180edaad3..8c7d4177c45 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV3", "params": [ - "0x282643d459a6f711" + "0x282643efdc841a11" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x78a301e0d846bd169889c9755c9aa4ce2972dfc4bd63de61f3303887d3e81f98", + "parentHash": "0x292042b10484fc182be8aba2a4c1863f6712cc7f0c74489c226792138134248f", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", + "stateRoot": "0xf4e9cba3bdb0cf3aa214612d87f2a1ab18cdc604a0af18f71110754a85de5d15", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -29,7 +29,7 @@ "blockNumber": "0x1", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed": "0x0", - "blockHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315" + "blockHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a" }, "blockValue": "0x0", "blobsBundle": { diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json index b8ae8dbd89a..3145cd5439f 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV3", "params": [ { - "parentHash": "0x78a301e0d846bd169889c9755c9aa4ce2972dfc4bd63de61f3303887d3e81f98", + "parentHash": "0x292042b10484fc182be8aba2a4c1863f6712cc7f0c74489c226792138134248f", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", + "stateRoot": "0xf4e9cba3bdb0cf3aa214612d87f2a1ab18cdc604a0af18f71110754a85de5d15", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -17,7 +17,7 @@ "transactions": [], "withdrawals": [], "blockNumber": "0x1", - "blockHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", + "blockHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "excessBlobGas": "0x0", "blobGasUsed": "0x0" @@ -32,7 +32,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", + "latestValidHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json index 3e7d9adcb42..b578116448d 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", - "safeBlockHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", - "finalizedBlockHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315" + "headBlockHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", + "safeBlockHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", + "finalizedBlockHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a" }, null ], @@ -18,7 +18,7 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", + "latestValidHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", "validationError": null }, "payloadId": null diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json index 30317597867..3e7d4b38595 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", - "safeBlockHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", - "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + "headBlockHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", + "safeBlockHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", + "finalizedBlockHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a" }, { "timestamp": "0x20", @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", + "latestValidHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", "validationError": null }, - "payloadId": "0x282643b909febddf" + "payloadId": "0x282643882dfdc121" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json index 7405dbae026..2608c920829 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV4", "params": [ - "0x282643b909febddf" + "0x282643882dfdc121" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", + "parentHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", + "stateRoot": "0x9d7467981e875b5b81ec6b9ab44300fa390d253b5d83da24fe58700f66a3925e", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -27,9 +27,15 @@ "transactions": [], "withdrawals": [], "depositReceipts": [], - "exits": [], + "withdrawalRequests": [ + { + "sourceAddress": "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adb", + "amount" : "0x0", + "validatorPubKey": "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e" + } + ], "blockNumber": "0x2", - "blockHash": "0x194d190af2a85c418947fecca405eb168c832481f33f618b0c36326ba65d4767", + "blockHash": "0xb4be7cd1193f86d725c93275f9f9fe902c5fc34e1758b9ebcac371de370a1bdd", "blobGasUsed": "0x0", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json index 1f63502a891..c3ef237f912 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV4", "params": [ { - "parentHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315", + "parentHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x14208ac0e218167936e220b72d5d5887a963cb858ea2f2d268518f014a3da3fa", + "stateRoot": "0xdcd8284a4904f95448a522e4c47d9c2f1b4541c5f6f711b42692fb26e1e0d986", "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -19,12 +19,24 @@ "0x02f9021c8217de808459682f008459682f0e830271009442424242424242424242424242424242424242428901bc16d674ec800000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120749715de5d1226545c6b3790f515d551a5cc5bf1d49c87a696860554d2fc4f14000000000000000000000000000000000000000000000000000000000000003096a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef20000000000000000000000000000000000000000000000000000000000000060b1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9c080a09f597089338d7f44f5c59f8230bb38f243849228a8d4e9d2e2956e6050f5b2c7a076486996c7e62802b8f95eee114783e4b403fd11093ba96286ff42c595f24452" ], "withdrawals": [], - "depositReceipts" : [ - {"amount":"0x773594000","index":"0x0","pubkey":"0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9","signature":"0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9","withdrawalCredentials":"0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2"} + "depositReceipts": [ + { + "amount": "0x773594000", + "index": "0x0", + "pubkey": "0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9", + "signature": "0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9", + "withdrawalCredentials": "0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2" + } + ], + "withdrawalRequests": [ + { + "sourceAddress": "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adb", + "amount" : "0x0", + "validatorPubKey": "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e" + } ], - "exits": [], "blockNumber": "0x2", - "blockHash": "0x84e13dc50074ba4be5841bd7e453a87b6f77261a8907518a78f3de8c9d877ee7", + "blockHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c", "receiptsRoot": "0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9", "blobGasUsed": "0x0" }, @@ -38,7 +50,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0x84e13dc50074ba4be5841bd7e453a87b6f77261a8907518a78f3de8c9d877ee7", + "latestValidHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json index cf4554ddfdc..a337f15a655 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x84e13dc50074ba4be5841bd7e453a87b6f77261a8907518a78f3de8c9d877ee7", - "safeBlockHash": "0x84e13dc50074ba4be5841bd7e453a87b6f77261a8907518a78f3de8c9d877ee7", - "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + "headBlockHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c", + "safeBlockHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c", + "finalizedBlockHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c" }, { "timestamp": "0x30", @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x84e13dc50074ba4be5841bd7e453a87b6f77261a8907518a78f3de8c9d877ee7", + "latestValidHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c", "validationError": null }, - "payloadId": "0x282643f559414ecf" + "payloadId": "0x282643832633dccf" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json index 7f2a1884518..4031b1c5694 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV4", "params": [ - "0x282643f559414ecf" + "0x282643832633dccf" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x84e13dc50074ba4be5841bd7e453a87b6f77261a8907518a78f3de8c9d877ee7", + "parentHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x14208ac0e218167936e220b72d5d5887a963cb858ea2f2d268518f014a3da3fa", + "stateRoot": "0xdcd8284a4904f95448a522e4c47d9c2f1b4541c5f6f711b42692fb26e1e0d986", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -27,9 +27,9 @@ "transactions": [], "withdrawals": [], "depositReceipts": [], - "exits": [], + "withdrawalRequests": [], "blockNumber": "0x3", - "blockHash": "0xec4741580be2d83cde0dcd6346a67a71636d915f5da592f39d4470aecef72020", + "blockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed": "0x0" }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV4.json new file mode 100644 index 00000000000..96a019ca7ae --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV4.json @@ -0,0 +1,42 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "engine_newPayloadV3", + "params": [ + { + "parentHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c", + "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "stateRoot": "0xdcd8284a4904f95448a522e4c47d9c2f1b4541c5f6f711b42692fb26e1e0d986", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", + "gasLimit": "0x1c9c380", + "gasUsed": "0x0", + "timestamp": "0x30", + "extraData": "0x", + "baseFeePerGas": "0x7", + "transactions": [], + "withdrawals": [], + "depositReceipts": [], + "withdrawalRequests": [], + "blockNumber": "0x3", + "blockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "excessBlobGas": "0x0", + "blobGasUsed": "0x0" + }, + [], + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": { + "status": "VALID", + "latestValidHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b", + "validationError": null + } + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/13_prague_send_raw_transaction_create_exit.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/13_prague_send_raw_transaction_create_exit.json new file mode 100644 index 00000000000..c9facbcc663 --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/13_prague_send_raw_transaction_create_exit.json @@ -0,0 +1,14 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "eth_sendRawTransaction", + "params": ["0xf8a08085e8d4a51000832dc6c094ed8ea01d70cb49726175bcf2778b9c982912e01702b8388706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf2430000000000000000822fe0a008135b1be1734b1b446de871eba10dbc317437eff377a7444f2ff6c06b5e5345a01bc61e0d4dd6d8e0b1f41d843fd9e07260c8be8c664ec2fa8c364477fa021176"], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": "0x764bfa879d0df4ff3962e32dfd45dc39ea18a35ccbd0dadf0bb58672537b1db2" + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/14_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/14_prague_forkchoiceUpdatedV3.json new file mode 100644 index 00000000000..fdcb24d1dc8 --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/14_prague_forkchoiceUpdatedV3.json @@ -0,0 +1,34 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "engine_forkchoiceUpdatedV3", + "params": [ + { + "headBlockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b", + "safeBlockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b", + "finalizedBlockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b" + }, + { + "timestamp": "0x40", + "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", + "suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "withdrawals": [], + "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + ], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": { + "payloadStatus": { + "status": "VALID", + "latestValidHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b", + "validationError": null + }, + "payloadId": "0x282643f22efc45bf" + } + }, + "statusCode" : 200 +} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_getPayloadV4.json new file mode 100644 index 00000000000..df041bc8308 --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_getPayloadV4.json @@ -0,0 +1,55 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "engine_getPayloadV4", + "params": [ + "0x282643f22efc45bf" + ], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": { + "executionPayload": { + "parentHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b", + "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "stateRoot": "0x4a387af05417b5767993052457ca85b2a5a172b3f809eb5cbcf17f070f398c3f", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", + "gasLimit": "0x1c9c380", + "gasUsed": "0x145d3", + "timestamp": "0x40", + "extraData": "0x", + "baseFeePerGas": "0x7", + "excessBlobGas": "0x0", + "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transactions": [ + "0xf8a08085e8d4a51000832dc6c094ed8ea01d70cb49726175bcf2778b9c982912e01702b8388706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf2430000000000000000822fe0a008135b1be1734b1b446de871eba10dbc317437eff377a7444f2ff6c06b5e5345a01bc61e0d4dd6d8e0b1f41d843fd9e07260c8be8c664ec2fa8c364477fa021176" + ], + "withdrawals": [], + "depositReceipts": [], + "withdrawalRequests": [ + { + "sourceAddress": "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f", + "amount": "0x0", + "validatorPubKey": "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243" + } + ], + "receiptsRoot": "0x765bd9d63cc10fa47117d6cc0958f15e55a3bde540d4ed15d220f573fbb82cba", + "blobGasUsed": "0x0", + "blockHash": "0xe589c7673025f6844ffbaeddcf38d77d652669c60412e8506a2ae62ac80e9de4", + "blockNumber": "0x4" + }, + "blockValue": "0x12855dcd153473b", + "blobsBundle": { + "commitments": [], + "proofs": [], + "blobs": [] + }, + "shouldOverrideBuilder": false + } + }, + "statusCode": 200, + "waitTime": 1500 +} \ No newline at end of file diff --git a/besu/src/main/java/org/hyperledger/besu/Besu.java b/besu/src/main/java/org/hyperledger/besu/Besu.java index 6bdd87d0cff..14c95cc867c 100644 --- a/besu/src/main/java/org/hyperledger/besu/Besu.java +++ b/besu/src/main/java/org/hyperledger/besu/Besu.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index 6379e2c1a64..f38d362fde2 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -603,15 +603,15 @@ public Runner build() { .setAdvertisedHost(p2pAdvertisedHost); if (discovery) { final List bootstrap; - if (ethNetworkConfig.getBootNodes() == null) { - bootstrap = EthNetworkConfig.getNetworkConfig(NetworkName.MAINNET).getBootNodes(); + if (ethNetworkConfig.bootNodes() == null) { + bootstrap = EthNetworkConfig.getNetworkConfig(NetworkName.MAINNET).bootNodes(); } else { - bootstrap = ethNetworkConfig.getBootNodes(); + bootstrap = ethNetworkConfig.bootNodes(); } discoveryConfiguration.setBootnodes(bootstrap); LOG.info("Resolved {} bootnodes.", bootstrap.size()); LOG.debug("Bootnodes = {}", bootstrap); - discoveryConfiguration.setDnsDiscoveryURL(ethNetworkConfig.getDnsDiscoveryUrl()); + discoveryConfiguration.setDnsDiscoveryURL(ethNetworkConfig.dnsDiscoveryUrl()); discoveryConfiguration.setDiscoveryV5Enabled( networkingConfiguration.getDiscovery().isDiscoveryV5Enabled()); discoveryConfiguration.setFilterOnEnrForkId( @@ -1209,7 +1209,7 @@ private Map jsonRpcMethods( new JsonRpcMethodsFactory() .methods( BesuInfo.nodeName(identityString), - ethNetworkConfig.getNetworkId(), + ethNetworkConfig.networkId(), besuController.getGenesisConfigOptions(), network, blockchainQueries, diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 4c504c4e33b..e3419f594c4 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -16,7 +16,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.hyperledger.besu.cli.DefaultCommandValues.getDefaultBesuDataPath; @@ -58,6 +57,7 @@ import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption; import org.hyperledger.besu.cli.options.stable.P2PTLSConfigOptions; import org.hyperledger.besu.cli.options.stable.PermissionsOptions; +import org.hyperledger.besu.cli.options.stable.PluginsConfigurationOptions; import org.hyperledger.besu.cli.options.stable.RpcWebsocketOptions; import org.hyperledger.besu.cli.options.unstable.ChainPruningOptions; import org.hyperledger.besu.cli.options.unstable.DnsOptions; @@ -85,7 +85,7 @@ import org.hyperledger.besu.cli.subcommands.storage.StorageSubCommand; import org.hyperledger.besu.cli.util.BesuCommandCustomFactory; import org.hyperledger.besu.cli.util.CommandLineUtils; -import org.hyperledger.besu.cli.util.ConfigOptionSearchAndRunHandler; +import org.hyperledger.besu.cli.util.ConfigDefaultValueProviderStrategy; import org.hyperledger.besu.cli.util.VersionProvider; import org.hyperledger.besu.components.BesuComponent; import org.hyperledger.besu.config.CheckpointConfigOptions; @@ -121,6 +121,7 @@ import org.hyperledger.besu.ethereum.core.MiningParametersMetrics; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.VersionMetadata; +import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; @@ -205,6 +206,7 @@ import java.net.InetAddress; import java.net.SocketException; import java.net.URI; +import java.net.URL; import java.net.UnknownHostException; import java.nio.file.Path; import java.time.Clock; @@ -229,7 +231,6 @@ import com.google.common.base.Strings; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableMap; -import com.google.common.io.Resources; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.core.json.DecodeException; @@ -322,7 +323,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable { private final Set allocatedPorts = new HashSet<>(); private final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider; - private GenesisConfigOptions genesisConfigOptions; + private final Supplier genesisConfigFileSupplier = + Suppliers.memoize(this::readGenesisConfigFile); + private final Supplier genesisConfigOptionsSupplier = + Suppliers.memoize(this::readGenesisConfigOptions); private RocksDBPlugin rocksDBPlugin; @@ -876,6 +880,10 @@ static class MetricsOptionGroup { @Mixin private PkiBlockCreationOptions pkiBlockCreationOptions; + // Plugins Configuration Option Group + @CommandLine.ArgGroup(validate = false) + PluginsConfigurationOptions pluginsConfigurationOptions = new PluginsConfigurationOptions(); + private EthNetworkConfig ethNetworkConfig; private JsonRpcConfiguration jsonRpcConfiguration; private JsonRpcConfiguration engineJsonRpcConfiguration; @@ -1020,6 +1028,16 @@ protected BesuCommand( * @param args arguments to Besu command * @return success or failure exit code. */ + /** + * Parses command line arguments and configures the application accordingly. + * + * @param resultHandler The strategy to handle the execution result. + * @param parameterExceptionHandler Handler for exceptions related to command line parameters. + * @param executionExceptionHandler Handler for exceptions during command execution. + * @param in The input stream for commands. + * @param args The command line arguments. + * @return The execution result status code. + */ public int parse( final IExecutionStrategy resultHandler, final BesuParameterExceptionHandler parameterExceptionHandler, @@ -1027,9 +1045,24 @@ public int parse( final InputStream in, final String... args) { - toCommandLine(); + initializeCommandLineSettings(in); - // use terminal width for usage message + // Create the execution strategy chain. + final IExecutionStrategy executeTask = createExecuteTask(resultHandler); + final IExecutionStrategy pluginRegistrationTask = createPluginRegistrationTask(executeTask); + final IExecutionStrategy setDefaultValueProviderTask = + createDefaultValueProviderTask(pluginRegistrationTask); + + // 1- Config default value provider + // 2- Register plugins + // 3- Execute command + return executeCommandLine( + setDefaultValueProviderTask, parameterExceptionHandler, executionExceptionHandler, args); + } + + private void initializeCommandLineSettings(final InputStream in) { + toCommandLine(); + // Automatically adjust the width of usage messages to the terminal width. commandLine.getCommandSpec().usageMessage().autoWidth(true); handleStableOptions(); @@ -1037,11 +1070,51 @@ public int parse( registerConverters(); handleUnstableOptions(); preparePlugins(); + } - final int exitCode = - parse(resultHandler, executionExceptionHandler, parameterExceptionHandler, args); + private IExecutionStrategy createExecuteTask(final IExecutionStrategy nextStep) { + return parseResult -> { + commandLine.setExecutionStrategy(nextStep); + // At this point we don't allow unmatched options since plugins were already registered + commandLine.setUnmatchedArgumentsAllowed(false); + return commandLine.execute(parseResult.originalArgs().toArray(new String[0])); + }; + } + + private IExecutionStrategy createPluginRegistrationTask(final IExecutionStrategy nextStep) { + return parseResult -> { + PluginConfiguration configuration = + PluginsConfigurationOptions.fromCommandLine(parseResult.commandSpec().commandLine()); + besuPluginContext.registerPlugins(configuration); + commandLine.setExecutionStrategy(nextStep); + return commandLine.execute(parseResult.originalArgs().toArray(new String[0])); + }; + } + + private IExecutionStrategy createDefaultValueProviderTask(final IExecutionStrategy nextStep) { + return new ConfigDefaultValueProviderStrategy(nextStep, environment); + } - return exitCode; + /** + * Executes the command line with the provided execution strategy and exception handlers. + * + * @param executionStrategy The execution strategy to use. + * @param args The command line arguments. + * @return The execution result status code. + */ + private int executeCommandLine( + final IExecutionStrategy executionStrategy, + final BesuParameterExceptionHandler parameterExceptionHandler, + final BesuExecutionExceptionHandler executionExceptionHandler, + final String... args) { + return commandLine + .setExecutionStrategy(executionStrategy) + .setParameterExceptionHandler(parameterExceptionHandler) + .setExecutionExceptionHandler(executionExceptionHandler) + // As this happens before the plugins registration and plugins can add options, we must + // allow unmatched options + .setUnmatchedArgumentsAllowed(true) + .execute(args); } /** Used by Dagger to parse all options into a commandline instance. */ @@ -1059,10 +1132,6 @@ public void run() { try { configureLogging(true); - if (genesisFile != null) { - genesisConfigOptions = readGenesisConfigOptions(); - } - // set merge config on the basis of genesis config setMergeConfigOptions(); @@ -1208,8 +1277,6 @@ private void preparePlugins() { rocksDBPlugin.register(besuPluginContext); new InMemoryStoragePlugin().register(besuPluginContext); - besuPluginContext.registerPlugins(pluginsDir()); - metricCategoryRegistry .getMetricCategories() .forEach(metricCategoryConverter::addRegistryCategory); @@ -1223,8 +1290,6 @@ private SecurityModule defaultSecurityModule() { return new KeyPairSecurityModule(loadKeyPair(nodePrivateKeyFileOption.getNodePrivateKeyFile())); } - // loadKeyPair() is public because it is accessed by subcommands - /** * Load key pair from private key. Visible to be accessed by subcommands. * @@ -1235,26 +1300,6 @@ public KeyPair loadKeyPair(final File nodePrivateKeyFile) { return KeyPairUtil.loadKeyPair(resolveNodePrivateKeyFile(nodePrivateKeyFile)); } - private int parse( - final CommandLine.IExecutionStrategy resultHandler, - final BesuExecutionExceptionHandler besuExecutionExceptionHandler, - final BesuParameterExceptionHandler besuParameterExceptionHandler, - final String... args) { - // Create a handler that will search for a config file option and use it for - // default values - // and eventually it will run regular parsing of the remaining options. - - final ConfigOptionSearchAndRunHandler configParsingHandler = - new ConfigOptionSearchAndRunHandler( - resultHandler, besuParameterExceptionHandler, environment); - - return commandLine - .setExecutionStrategy(configParsingHandler) - .setParameterExceptionHandler(besuParameterExceptionHandler) - .setExecutionExceptionHandler(besuExecutionExceptionHandler) - .execute(args); - } - private void preSynchronization() { preSynchronizationTaskRunner.runTasks(besuController); } @@ -1424,8 +1469,8 @@ private void configureNativeLibs() { logger.info("Using the Java implementation of the blake2bf algorithm"); } - if (getActualGenesisConfigOptions().getCancunTime().isPresent() - || getActualGenesisConfigOptions().getPragueTime().isPresent()) { + if (genesisConfigOptionsSupplier.get().getCancunTime().isPresent() + || genesisConfigOptionsSupplier.get().getPragueTime().isPresent()) { if (kzgTrustedSetupFile != null) { KZGPointEvalPrecompiledContract.init(kzgTrustedSetupFile); } else { @@ -1455,16 +1500,33 @@ private void validateOptions() { validateDataStorageOptions(); validateGraphQlOptions(); validateApiOptions(); + validateConsensusSyncCompatibilityOptions(); p2pTLSConfigOptions.checkP2PTLSOptionsDependencies(logger, commandLine); pkiBlockCreationOptions.checkPkiBlockCreationOptionsDependencies(logger, commandLine); } + private void validateConsensusSyncCompatibilityOptions() { + // snap and checkpoint can't be used with BFT but can for clique + if (genesisConfigOptionsSupplier.get().isIbftLegacy() + || genesisConfigOptionsSupplier.get().isIbft2() + || genesisConfigOptionsSupplier.get().isQbft()) { + final String errorSuffix = "can't be used with BFT networks"; + if (SyncMode.CHECKPOINT.equals(syncMode) || SyncMode.X_CHECKPOINT.equals(syncMode)) { + throw new ParameterException( + commandLine, String.format("%s %s", "Checkpoint sync", errorSuffix)); + } + if (syncMode == SyncMode.SNAP || syncMode == SyncMode.X_SNAP) { + throw new ParameterException(commandLine, String.format("%s %s", "Snap sync", errorSuffix)); + } + } + } + private void validateApiOptions() { apiConfigurationOptions.validate(commandLine, logger); } private void validateTransactionPoolOptions() { - transactionPoolOptions.validate(commandLine, getActualGenesisConfigOptions()); + transactionPoolOptions.validate(commandLine, genesisConfigOptionsSupplier.get()); } private void validateDataStorageOptions() { @@ -1485,7 +1547,8 @@ private void validateRequiredOptions() { } private void validateMiningParams() { - miningOptions.validate(commandLine, getActualGenesisConfigOptions(), isMergeEnabled(), logger); + miningOptions.validate( + commandLine, genesisConfigOptionsSupplier.get(), isMergeEnabled(), logger); } /** @@ -1595,29 +1658,20 @@ private void validateChainDataPruningParams() { } } - private GenesisConfigOptions readGenesisConfigOptions() { + private GenesisConfigFile readGenesisConfigFile() { + return genesisFile != null + ? GenesisConfigFile.fromSource(genesisConfigSource(genesisFile)) + : GenesisConfigFile.fromResource( + Optional.ofNullable(network).orElse(MAINNET).getGenesisFile()); + } + private GenesisConfigOptions readGenesisConfigOptions() { try { - final GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromConfig(genesisConfig()); - genesisConfigOptions = genesisConfigFile.getConfigOptions(genesisConfigOverrides); + return genesisConfigFileSupplier.get().getConfigOptions(genesisConfigOverrides); } catch (final Exception e) { throw new ParameterException( this.commandLine, "Unable to load genesis file. " + e.getCause()); } - // snap and checkpoint can't be used with BFT but can for clique - if (genesisConfigOptions.isIbftLegacy() - || genesisConfigOptions.isIbft2() - || genesisConfigOptions.isQbft()) { - final String errorSuffix = "can't be used with BFT networks"; - if (SyncMode.CHECKPOINT.equals(syncMode) || SyncMode.X_CHECKPOINT.equals(syncMode)) { - throw new ParameterException( - commandLine, String.format("%s %s", "Checkpoint sync", errorSuffix)); - } - if (syncMode == SyncMode.SNAP || syncMode == SyncMode.X_SNAP) { - throw new ParameterException(commandLine, String.format("%s %s", "Snap sync", errorSuffix)); - } - } - return genesisConfigOptions; } private void issueOptionWarnings() { @@ -1716,7 +1770,7 @@ private void configure() throws Exception { permissioningConfiguration = permissioningConfiguration(); staticNodes = loadStaticNodes(); - final List enodeURIs = ethNetworkConfig.getBootNodes(); + final List enodeURIs = ethNetworkConfig.bootNodes(); permissioningConfiguration .flatMap(PermissioningConfiguration::getLocalConfig) .ifPresent(p -> ensureAllNodesAreInAllowlist(enodeURIs, p)); @@ -1793,8 +1847,7 @@ public BesuControllerBuilder getControllerBuilder() { getMiningParameters()); final KeyValueStorageProvider storageProvider = keyValueStorageProvider(keyValueStorageName); return controllerBuilderFactory - .fromEthNetworkConfig( - updateNetworkConfig(network), genesisConfigOverrides, getDefaultSyncModeIfNotSet()) + .fromEthNetworkConfig(updateNetworkConfig(network), getDefaultSyncModeIfNotSet()) .synchronizerConfiguration(buildSyncConfig()) .ethProtocolConfiguration(unstableEthProtocolOptions.toDomainObject()) .networkConfiguration(unstableNetworkingOptions.toDomainObject()) @@ -1810,7 +1863,6 @@ public BesuControllerBuilder getControllerBuilder() { .clock(Clock.systemUTC()) .isRevertReasonEnabled(isRevertReasonEnabled) .storageProvider(storageProvider) - .genesisConfigOverrides(genesisConfigOverrides) .gasLimitCalculator( getMiningParameters().getTargetGasLimit().isPresent() ? new FrontierTargetingGasLimitCalculator() @@ -2099,7 +2151,7 @@ private TransactionPoolConfiguration buildTransactionPoolConfiguration() { .from(txPoolConf) .saveFile((dataPath.resolve(txPoolConf.getSaveFile().getPath()).toFile())); - if (getActualGenesisConfigOptions().isZeroBaseFee()) { + if (genesisConfigOptionsSupplier.get().isZeroBaseFee()) { logger.info( "Forcing price bump for transaction replacement to 0, since we are on a zero basefee network"); txPoolConfBuilder.priceBump(Percentage.ZERO); @@ -2136,7 +2188,7 @@ private MiningParameters getMiningParameters() { if (miningParameters == null) { miningOptions.setTransactionSelectionService(transactionSelectionServiceImpl); miningParameters = miningOptions.toDomainObject(); - getGenesisBlockPeriodSeconds(getActualGenesisConfigOptions()) + getGenesisBlockPeriodSeconds(genesisConfigOptionsSupplier.get()) .ifPresent(miningParameters::setBlockPeriodSeconds); initMiningParametersMetrics(miningParameters); } @@ -2288,16 +2340,14 @@ private EthNetworkConfig updateNetworkConfig(final NetworkName network) { + "refer to CLI reference for more details about this constraint."); } - builder.setGenesisConfig(genesisConfig()); - if (networkId == null) { // If no chain id is found in the genesis, use mainnet network id try { builder.setNetworkId( - getGenesisConfigFile() - .getConfigOptions(genesisConfigOverrides) + genesisConfigOptionsSupplier + .get() .getChainId() - .orElse(EthNetworkConfig.getNetworkConfig(MAINNET).getNetworkId())); + .orElse(EthNetworkConfig.getNetworkConfig(MAINNET).networkId())); } catch (final DecodeException e) { throw new ParameterException( this.commandLine, String.format("Unable to parse genesis file %s.", genesisFile), e); @@ -2315,18 +2365,20 @@ private EthNetworkConfig updateNetworkConfig(final NetworkName network) { builder.setDnsDiscoveryUrl(null); } + builder.setGenesisConfigFile(genesisConfigFileSupplier.get()); + + if (networkId != null) { + builder.setNetworkId(networkId); + } + if (p2PDiscoveryOptionGroup.discoveryDnsUrl != null) { builder.setDnsDiscoveryUrl(p2PDiscoveryOptionGroup.discoveryDnsUrl); - } else if (genesisConfigOptions != null) { + } else { final Optional discoveryDnsUrlFromGenesis = - genesisConfigOptions.getDiscoveryOptions().getDiscoveryDnsUrl(); + genesisConfigOptionsSupplier.get().getDiscoveryOptions().getDiscoveryDnsUrl(); discoveryDnsUrlFromGenesis.ifPresent(builder::setDnsDiscoveryUrl); } - if (networkId != null) { - builder.setNetworkId(networkId); - } - List listBootNodes = null; if (p2PDiscoveryOptionGroup.bootNodes != null) { try { @@ -2334,9 +2386,9 @@ private EthNetworkConfig updateNetworkConfig(final NetworkName network) { } catch (final IllegalArgumentException e) { throw new ParameterException(commandLine, e.getMessage()); } - } else if (genesisConfigOptions != null) { + } else { final Optional> bootNodesFromGenesis = - genesisConfigOptions.getDiscoveryOptions().getBootNodes(); + genesisConfigOptionsSupplier.get().getDiscoveryOptions().getBootNodes(); if (bootNodesFromGenesis.isPresent()) { listBootNodes = buildEnodes(bootNodesFromGenesis.get(), getEnodeDnsConfiguration()); } @@ -2351,28 +2403,15 @@ private EthNetworkConfig updateNetworkConfig(final NetworkName network) { return builder.build(); } - private GenesisConfigFile getGenesisConfigFile() { - return GenesisConfigFile.fromConfig(genesisConfig()); - } - - private String genesisConfig() { + private URL genesisConfigSource(final File genesisFile) { try { - return Resources.toString(genesisFile.toURI().toURL(), UTF_8); + return genesisFile.toURI().toURL(); } catch (final IOException e) { throw new ParameterException( this.commandLine, String.format("Unable to load genesis URL %s.", genesisFile), e); } } - private static String genesisConfig(final NetworkName networkName) { - try (final InputStream genesisFileInputStream = - EthNetworkConfig.class.getResourceAsStream(networkName.getGenesisFile())) { - return new String(genesisFileInputStream.readAllBytes(), UTF_8); - } catch (final IOException | NullPointerException e) { - throw new IllegalStateException(e); - } - } - /** * Returns data directory used by Besu. Visible as it is accessed by other subcommands. * @@ -2382,15 +2421,6 @@ public Path dataDir() { return dataPath.toAbsolutePath(); } - private Path pluginsDir() { - final String pluginsDir = System.getProperty("besu.plugins.dir"); - if (pluginsDir == null) { - return new File(System.getProperty("besu.home", "."), "plugins").toPath(); - } else { - return new File(pluginsDir).toPath(); - } - } - private SecurityModule securityModule() { return securityModuleService .getByName(securityModuleName) @@ -2595,26 +2625,21 @@ private Optional getEcCurveFromGenesisFile() { if (genesisFile == null) { return Optional.empty(); } - return genesisConfigOptions.getEcCurve(); + return genesisConfigOptionsSupplier.get().getEcCurve(); } /** - * Return the genesis config options after applying any specified config overrides + * Return the genesis config options * - * @return the genesis config options after applying any specified config overrides + * @return the genesis config options */ - protected GenesisConfigOptions getActualGenesisConfigOptions() { - return Optional.ofNullable(genesisConfigOptions) - .orElseGet( - () -> - GenesisConfigFile.fromConfig( - genesisConfig(Optional.ofNullable(network).orElse(MAINNET))) - .getConfigOptions(genesisConfigOverrides)); + protected GenesisConfigOptions getGenesisConfigOptions() { + return genesisConfigOptionsSupplier.get(); } private void setMergeConfigOptions() { MergeConfigOptions.setMergeEnabled( - getActualGenesisConfigOptions().getTerminalTotalDifficulty().isPresent()); + genesisConfigOptionsSupplier.get().getTerminalTotalDifficulty().isPresent()); } /** Set ignorable segments in RocksDB Storage Provider plugin. */ @@ -2625,11 +2650,12 @@ public void setIgnorableStorageSegments() { } private void validatePostMergeCheckpointBlockRequirements() { - final GenesisConfigOptions genesisOptions = getActualGenesisConfigOptions(); final SynchronizerConfiguration synchronizerConfiguration = unstableSynchronizerOptions.toDomainObject().build(); - final Optional terminalTotalDifficulty = genesisOptions.getTerminalTotalDifficulty(); - final CheckpointConfigOptions checkpointConfigOptions = genesisOptions.getCheckpointOptions(); + final Optional terminalTotalDifficulty = + genesisConfigOptionsSupplier.get().getTerminalTotalDifficulty(); + final CheckpointConfigOptions checkpointConfigOptions = + genesisConfigOptionsSupplier.get().getCheckpointOptions(); if (synchronizerConfiguration.isCheckpointPostMergeEnabled()) { if (!checkpointConfigOptions.isValid()) { throw new InvalidConfigurationException( @@ -2637,15 +2663,13 @@ private void validatePostMergeCheckpointBlockRequirements() { } terminalTotalDifficulty.ifPresentOrElse( ttd -> { - if (UInt256.fromHexString( - genesisOptions.getCheckpointOptions().getTotalDifficulty().get()) + if (UInt256.fromHexString(checkpointConfigOptions.getTotalDifficulty().get()) .equals(UInt256.ZERO) && ttd.equals(UInt256.ZERO)) { throw new InvalidConfigurationException( "PoS checkpoint sync can't be used with TTD = 0 and checkpoint totalDifficulty = 0"); } - if (UInt256.fromHexString( - genesisOptions.getCheckpointOptions().getTotalDifficulty().get()) + if (UInt256.fromHexString(checkpointConfigOptions.getTotalDifficulty().get()) .lessThan(ttd)) { throw new InvalidConfigurationException( "PoS checkpoint sync requires a block with total difficulty greater or equal than the TTD"); @@ -2679,7 +2703,8 @@ private SyncMode getDefaultSyncModeIfNotSet() { private Boolean getDefaultVersionCompatibilityProtectionIfNotSet() { // Version compatibility protection is enabled by default for non-named networks return Optional.ofNullable(versionCompatibilityProtection) - .orElse(commandLine.getParseResult().hasMatchedOption("network") ? false : true); + // if we have a specific genesis file or custom network id, we are not using a named network + .orElse(genesisFile != null || networkId != null); } private String generateConfigurationOverview() { @@ -2701,7 +2726,7 @@ private String generateConfigurationOverview() { if (genesisFile != null) { builder.setCustomGenesis(genesisFile.getAbsolutePath()); } - builder.setNetworkId(ethNetworkConfig.getNetworkId()); + builder.setNetworkId(ethNetworkConfig.networkId()); builder .setDataStorage(dataStorageOptions.normalizeDataStorageFormat()) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index 2b3dfd7dd51..119bdf9fd1f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java b/besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java index 62de356e5f2..84055db663c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java @@ -125,6 +125,9 @@ public interface DefaultCommandValues { /** The Default tls protocols. */ List DEFAULT_TLS_PROTOCOLS = List.of("TLSv1.3", "TLSv1.2"); + /** The constant DEFAULT_PLUGINS_OPTION_NAME. */ + String DEFAULT_PLUGINS_OPTION_NAME = "--plugins"; + /** * Gets default besu data path. * diff --git a/besu/src/main/java/org/hyperledger/besu/cli/NetworkDeprecationMessage.java b/besu/src/main/java/org/hyperledger/besu/cli/NetworkDeprecationMessage.java index 10c97d6a5ad..6f8060ec5a1 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/NetworkDeprecationMessage.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/NetworkDeprecationMessage.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java b/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java index 3af85016c8c..d591637e33b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.cli.config; -import static java.nio.charset.StandardCharsets.UTF_8; - import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; @@ -24,6 +22,8 @@ import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; +import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -31,102 +31,25 @@ import java.util.stream.Collectors; /** The Eth network config. */ -public class EthNetworkConfig { - - private final String genesisConfig; - private final BigInteger networkId; - private final List bootNodes; - private final String dnsDiscoveryUrl; +public record EthNetworkConfig( + GenesisConfigFile genesisConfigFile, + BigInteger networkId, + List bootNodes, + String dnsDiscoveryUrl) { /** - * Instantiates a new Eth network config. + * Validate parameters on new record creation * - * @param genesisConfig the genesis config + * @param genesisConfigFile the genesis config * @param networkId the network id * @param bootNodes the boot nodes * @param dnsDiscoveryUrl the dns discovery url */ - public EthNetworkConfig( - final String genesisConfig, - final BigInteger networkId, - final List bootNodes, - final String dnsDiscoveryUrl) { - Objects.requireNonNull(genesisConfig); + @SuppressWarnings( + "MethodInputParametersMustBeFinal") // needed since record constructors are not yet supported + public EthNetworkConfig { + Objects.requireNonNull(genesisConfigFile); Objects.requireNonNull(bootNodes); - this.genesisConfig = genesisConfig; - this.networkId = networkId; - this.bootNodes = bootNodes; - this.dnsDiscoveryUrl = dnsDiscoveryUrl; - } - - /** - * Gets genesis config. - * - * @return the genesis config - */ - public String getGenesisConfig() { - return genesisConfig; - } - - /** - * Gets network id. - * - * @return the network id - */ - public BigInteger getNetworkId() { - return networkId; - } - - /** - * Gets boot nodes. - * - * @return the boot nodes - */ - public List getBootNodes() { - return bootNodes; - } - - /** - * Gets dns discovery url. - * - * @return the dns discovery url - */ - public String getDnsDiscoveryUrl() { - return dnsDiscoveryUrl; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final EthNetworkConfig that = (EthNetworkConfig) o; - return networkId.equals(that.networkId) - && Objects.equals(genesisConfig, that.genesisConfig) - && Objects.equals(bootNodes, that.bootNodes) - && Objects.equals(dnsDiscoveryUrl, that.dnsDiscoveryUrl); - } - - @Override - public int hashCode() { - return Objects.hash(genesisConfig, networkId, bootNodes, dnsDiscoveryUrl); - } - - @Override - public String toString() { - return "EthNetworkConfig{" - + "genesisConfig=" - + genesisConfig - + ", networkId=" - + networkId - + ", bootNodes=" - + bootNodes - + ", dnsDiscoveryUrl=" - + dnsDiscoveryUrl - + '}'; } /** @@ -136,9 +59,9 @@ public String toString() { * @return the network config */ public static EthNetworkConfig getNetworkConfig(final NetworkName networkName) { - final String genesisContent = jsonConfig(networkName.getGenesisFile()); - final GenesisConfigOptions genesisConfigOptions = - GenesisConfigFile.fromConfig(genesisContent).getConfigOptions(); + final URL genesisSource = jsonConfigSource(networkName.getGenesisFile()); + final GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromSource(genesisSource); + final GenesisConfigOptions genesisConfigOptions = genesisConfigFile.getConfigOptions(); final Optional> rawBootNodes = genesisConfigOptions.getDiscoveryOptions().getBootNodes(); final List bootNodes = @@ -148,36 +71,36 @@ public static EthNetworkConfig getNetworkConfig(final NetworkName networkName) { strings.stream().map(EnodeURLImpl::fromString).collect(Collectors.toList())) .orElse(Collections.emptyList()); return new EthNetworkConfig( - genesisContent, + genesisConfigFile, networkName.getNetworkId(), bootNodes, genesisConfigOptions.getDiscoveryOptions().getDiscoveryDnsUrl().orElse(null)); } - private static String jsonConfig(final String resourceName) { - try (final InputStream genesisFileInputStream = - EthNetworkConfig.class.getResourceAsStream(resourceName)) { - return new String(genesisFileInputStream.readAllBytes(), UTF_8); - } catch (IOException | NullPointerException e) { - throw new IllegalStateException(e); - } + private static URL jsonConfigSource(final String resourceName) { + return EthNetworkConfig.class.getResource(resourceName); } /** * Json config string. * - * @param network the network - * @return the string + * @param network the named network + * @return the json string */ public static String jsonConfig(final NetworkName network) { - return jsonConfig(network.getGenesisFile()); + try (final InputStream genesisFileInputStream = + EthNetworkConfig.class.getResourceAsStream(network.getGenesisFile())) { + return new String(genesisFileInputStream.readAllBytes(), StandardCharsets.UTF_8); + } catch (IOException | NullPointerException e) { + throw new IllegalStateException(e); + } } /** The type Builder. */ public static class Builder { private String dnsDiscoveryUrl; - private String genesisConfig; + private GenesisConfigFile genesisConfigFile; private BigInteger networkId; private List bootNodes; @@ -187,20 +110,20 @@ public static class Builder { * @param ethNetworkConfig the eth network config */ public Builder(final EthNetworkConfig ethNetworkConfig) { - this.genesisConfig = ethNetworkConfig.genesisConfig; + this.genesisConfigFile = ethNetworkConfig.genesisConfigFile; this.networkId = ethNetworkConfig.networkId; this.bootNodes = ethNetworkConfig.bootNodes; this.dnsDiscoveryUrl = ethNetworkConfig.dnsDiscoveryUrl; } /** - * Sets genesis config. + * Sets genesis config file. * - * @param genesisConfig the genesis config - * @return the genesis config + * @param genesisConfigFile the genesis config + * @return this builder */ - public Builder setGenesisConfig(final String genesisConfig) { - this.genesisConfig = genesisConfig; + public Builder setGenesisConfigFile(final GenesisConfigFile genesisConfigFile) { + this.genesisConfigFile = genesisConfigFile; return this; } @@ -208,7 +131,7 @@ public Builder setGenesisConfig(final String genesisConfig) { * Sets network id. * * @param networkId the network id - * @return the network id + * @return this builder */ public Builder setNetworkId(final BigInteger networkId) { this.networkId = networkId; @@ -219,7 +142,7 @@ public Builder setNetworkId(final BigInteger networkId) { * Sets boot nodes. * * @param bootNodes the boot nodes - * @return the boot nodes + * @return this builder */ public Builder setBootNodes(final List bootNodes) { this.bootNodes = bootNodes; @@ -230,7 +153,7 @@ public Builder setBootNodes(final List bootNodes) { * Sets dns discovery url. * * @param dnsDiscoveryUrl the dns discovery url - * @return the dns discovery url + * @return this builder */ public Builder setDnsDiscoveryUrl(final String dnsDiscoveryUrl) { this.dnsDiscoveryUrl = dnsDiscoveryUrl; @@ -243,7 +166,7 @@ public Builder setDnsDiscoveryUrl(final String dnsDiscoveryUrl) { * @return the eth network config */ public EthNetworkConfig build() { - return new EthNetworkConfig(genesisConfig, networkId, bootNodes, dnsDiscoveryUrl); + return new EthNetworkConfig(genesisConfigFile, networkId, bootNodes, dnsDiscoveryUrl); } } } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/config/ProfileName.java b/besu/src/main/java/org/hyperledger/besu/cli/config/ProfileName.java index 111261d5c80..37e96bca78b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/config/ProfileName.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/config/ProfileName.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/DurationMillisConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/DurationMillisConverter.java index bfaffa8826a..46a2066d80a 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/DurationMillisConverter.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/DurationMillisConverter.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/PluginInfoConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/PluginInfoConverter.java new file mode 100644 index 00000000000..9264ce365be --- /dev/null +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/PluginInfoConverter.java @@ -0,0 +1,53 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.cli.converter; + +import org.hyperledger.besu.ethereum.core.plugins.PluginInfo; + +import java.util.List; +import java.util.stream.Stream; + +import picocli.CommandLine; + +/** + * Converts a comma-separated string into a list of {@link PluginInfo} objects. This converter is + * intended for use with PicoCLI to process command line arguments that specify plugin information. + */ +public class PluginInfoConverter implements CommandLine.ITypeConverter> { + + /** + * Converts a comma-separated string into a list of {@link PluginInfo}. + * + * @param value The comma-separated string representing plugin names. + * @return A list of {@link PluginInfo} objects created from the provided string. + */ + @Override + public List convert(final String value) { + if (value == null || value.isBlank()) { + return List.of(); + } + return Stream.of(value.split(",")).map(String::trim).map(this::toPluginInfo).toList(); + } + + /** + * Creates a {@link PluginInfo} object from a plugin name. + * + * @param pluginName The name of the plugin. + * @return A {@link PluginInfo} object representing the plugin. + */ + private PluginInfo toPluginInfo(final String pluginName) { + return new PluginInfo(pluginName); + } +} diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/PositiveNumberConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/PositiveNumberConverter.java index 2b45f35ffe5..283af9f02ab 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/PositiveNumberConverter.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/PositiveNumberConverter.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/TypeFormatter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/TypeFormatter.java index 59658d135ac..965cac9b6cf 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/TypeFormatter.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/TypeFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/DurationConversionException.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/DurationConversionException.java index cd56d06188c..a2000c5d65b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/DurationConversionException.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/DurationConversionException.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/PositiveNumberConversionException.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/PositiveNumberConversionException.java index c9f0d9e934b..26689aba8e3 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/PositiveNumberConversionException.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/PositiveNumberConversionException.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/error/BesuExecutionExceptionHandler.java b/besu/src/main/java/org/hyperledger/besu/cli/error/BesuExecutionExceptionHandler.java index 77b458eb78c..55d60efec82 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/error/BesuExecutionExceptionHandler.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/error/BesuExecutionExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright contributors to Hyperledger Besu + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java index d4b383f8f9b..93d7db8c011 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java index b2013a4ab06..6f5381a968f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 @@ -27,6 +27,7 @@ import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; @@ -37,6 +38,7 @@ import java.io.File; import java.time.Duration; import java.util.List; +import java.util.Map; import java.util.Set; import picocli.CommandLine; @@ -155,6 +157,8 @@ public class TransactionPoolOptions implements CLIOptions txPoolMaxPrioritizedByType = + TransactionPoolConfiguration.DEFAULT_MAX_PRIORITIZED_TRANSACTIONS_BY_TYPE; + @CommandLine.Option( names = {TX_POOL_MAX_FUTURE_BY_SENDER}, paramLabel = MANDATORY_INTEGER_FORMAT_HELP, @@ -297,6 +311,8 @@ public static TransactionPoolOptions fromConfig(final TransactionPoolConfigurati options.layeredOptions.txPoolLayerMaxCapacity = config.getPendingTransactionsLayerMaxCapacityBytes(); options.layeredOptions.txPoolMaxPrioritized = config.getMaxPrioritizedTransactions(); + options.layeredOptions.txPoolMaxPrioritizedByType = + config.getMaxPrioritizedTransactionsByType(); options.layeredOptions.txPoolMaxFutureBySender = config.getMaxFutureBySender(); options.sequencedOptions.txPoolLimitByAccountPercentage = config.getTxPoolLimitByAccountPercentage(); @@ -354,6 +370,7 @@ public TransactionPoolConfiguration toDomainObject() { .minGasPrice(minGasPrice) .pendingTransactionsLayerMaxCapacityBytes(layeredOptions.txPoolLayerMaxCapacity) .maxPrioritizedTransactions(layeredOptions.txPoolMaxPrioritized) + .maxPrioritizedTransactionsByType(layeredOptions.txPoolMaxPrioritizedByType) .maxFutureBySender(layeredOptions.txPoolMaxFutureBySender) .txPoolLimitByAccountPercentage(sequencedOptions.txPoolLimitByAccountPercentage) .txPoolMaxSize(sequencedOptions.txPoolMaxSize) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java index 269e1424f20..632c7bad442 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java index 3d9bb759d73..c380fb6c2cf 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java @@ -11,9 +11,7 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ - package org.hyperledger.besu.cli.options.stable; import static org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration.DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java index c384ad2cff0..5fe31ad0a7c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java index 51b6a59f1cb..65e4458fb2e 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java index 3f16432750e..fd6cfd9eb0d 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java new file mode 100644 index 00000000000..84d5387f469 --- /dev/null +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java @@ -0,0 +1,63 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.cli.options.stable; + +import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_OPTION_NAME; + +import org.hyperledger.besu.cli.converter.PluginInfoConverter; +import org.hyperledger.besu.cli.options.CLIOptions; +import org.hyperledger.besu.cli.util.CommandLineUtils; +import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; +import org.hyperledger.besu.ethereum.core.plugins.PluginInfo; + +import java.util.List; + +import picocli.CommandLine; + +/** The Plugins Options options. */ +public class PluginsConfigurationOptions implements CLIOptions { + @CommandLine.Option( + names = {DEFAULT_PLUGINS_OPTION_NAME}, + description = "Comma-separated list of plugin names", + split = ",", + hidden = true, + converter = PluginInfoConverter.class, + arity = "1..*") + private List plugins; + + @Override + public PluginConfiguration toDomainObject() { + return new PluginConfiguration(plugins); + } + + @Override + public List getCLIOptions() { + return CommandLineUtils.getCLIOptions(this, new PluginsConfigurationOptions()); + } + + /** + * Constructs a {@link PluginConfiguration} instance based on the command line options. + * + * @param commandLine The command line instance containing parsed options. + * @return A new {@link PluginConfiguration} instance. + */ + public static PluginConfiguration fromCommandLine(final CommandLine commandLine) { + List plugins = + CommandLineUtils.getOptionValueOrDefault( + commandLine, DEFAULT_PLUGINS_OPTION_NAME, new PluginInfoConverter()); + + return new PluginConfiguration(plugins); + } +} diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java index cdc77a3f655..dccbeee72e5 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java index 66d6b15f22f..46dd7922ab1 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java @@ -1,5 +1,5 @@ /* - * Copyright Hyperledger Besu Contributors. + * Copyright contributors to Hyperledger Besu. * * 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 @@ -11,7 +11,6 @@ * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - * */ package org.hyperledger.besu.cli.options.unstable; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java index 4e61b82fef8..8b14b1bad81 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.cli.options.unstable; import org.hyperledger.besu.cli.options.CLIOptions; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PkiBlockCreationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PkiBlockCreationOptions.java index e3673a1ab8e..b73597c1033 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PkiBlockCreationOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PkiBlockCreationOptions.java @@ -12,7 +12,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - package org.hyperledger.besu.cli.options.unstable; import static java.util.Arrays.asList; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java index da5199f85dc..1adf7080582 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java @@ -39,6 +39,8 @@ public class SynchronizerOptions implements CLIOptions