From ef020865eb2c78c5c0e8a0a68c64cb16d6e1bf84 Mon Sep 17 00:00:00 2001 From: Nischal Sharma Date: Mon, 24 Jul 2023 23:16:03 +0530 Subject: [PATCH] Removed GoQuorum permissioning interop (#5607) * removed quorum permissioning * removed isQuorum Signed-off-by: Nischal Sharma --------- Signed-off-by: Nischal Sharma --- CHANGELOG.md | 9 ++ .../node/configuration/BesuNodeFactory.java | 2 +- .../PermissionedNodeBuilder.java | 2 +- ...PermissioningIbft2StallAcceptanceTest.java | 4 +- .../org/hyperledger/besu/RunnerBuilder.java | 13 +-- .../org/hyperledger/besu/cli/BesuCommand.java | 74 +----------- .../hyperledger/besu/cli/BesuCommandTest.java | 56 +-------- .../besu/config/GenesisConfigOptions.java | 15 --- .../besu/config/JsonGenesisConfigOptions.java | 15 --- .../besu/config/StubGenesisConfigOptions.java | 10 -- .../besu/config/GenesisConfigOptionsTest.java | 17 --- .../valid_config_with_quorum_config.json | 33 ------ .../besu/ethereum/core/Transaction.java | 13 --- .../GoQuorumPermissioningConfiguration.java | 44 ------- .../permissioning/GoQuorumQip714Gate.java | 72 ------------ .../NodePermissioningControllerFactory.java | 17 +-- .../PermissioningConfiguration.java | 11 +- .../AccountPermissioningController.java | 13 +-- ...AccountPermissioningControllerFactory.java | 21 +--- .../node/NodePermissioningController.java | 13 +-- .../permissioning/GoQuorumQip714GateTest.java | 109 ------------------ ...untPermissioningControllerFactoryTest.java | 35 +++--- .../AccountPermissioningControllerTest.java | 51 +------- ...odePermissioningControllerFactoryTest.java | 23 ++-- .../node/NodePermissioningControllerTest.java | 64 +--------- 25 files changed, 56 insertions(+), 680 deletions(-) delete mode 100644 config/src/test/resources/valid_config_with_quorum_config.json delete mode 100644 ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumPermissioningConfiguration.java delete mode 100644 ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumQip714Gate.java delete mode 100644 ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumQip714GateTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index ac3eceb02cd..50840e1b872 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Changelog +## 23.7.0 + +### Breaking Changes +- Removed deprecated GoQuorum permissioning interop [#5607](https://github.com/hyperledger/besu/pull/5607) + +### Additions and Improvements + +### Bug Fixes + ## 23.4.5 ### Breaking Changes 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 fb6ac5f1014..e3cdaefe089 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 @@ -398,7 +398,7 @@ public BesuNode createIbft2NodeWithLocalAccountPermissioning( config.setAccountAllowlist(accountAllowList); config.setAccountPermissioningConfigFilePath(configFile.getAbsolutePath()); final PermissioningConfiguration permissioningConfiguration = - new PermissioningConfiguration(Optional.of(config), Optional.empty(), Optional.empty()); + new PermissioningConfiguration(Optional.of(config), Optional.empty()); return create( new BesuNodeConfigurationBuilder() .name(name) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/permissioning/PermissionedNodeBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/permissioning/PermissionedNodeBuilder.java index 8dafc14d77f..ab15f63a30e 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/permissioning/PermissionedNodeBuilder.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/permissioning/PermissionedNodeBuilder.java @@ -186,7 +186,7 @@ public BesuNode build() { } final PermissioningConfiguration permissioningConfiguration = - new PermissioningConfiguration(localPermConfig, smartContractPermConfig, Optional.empty()); + new PermissioningConfiguration(localPermConfig, smartContractPermConfig); final BesuNodeConfigurationBuilder builder = new BesuNodeConfigurationBuilder(); builder 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 fc64ee13862..e9da331a9e3 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 @@ -61,9 +61,7 @@ public void restartedIbftClusterShouldNotStall() throws IOException { Address.fromHexString(CONTRACT_ADDRESS)); final PermissioningConfiguration permissioningConfiguration = new PermissioningConfiguration( - Optional.empty(), - Optional.of(smartContractPermissioningConfiguration), - Optional.empty()); + Optional.empty(), Optional.of(smartContractPermissioningConfiguration)); // Set permissioning configurations on nodes bootnode.setPermissioningConfiguration(permissioningConfiguration); diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index d54a9149429..782fb3c46ca 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -783,10 +783,7 @@ public Runner build() { final Optional accountPermissioningController = buildAccountPermissioningController( - permissioningConfiguration, - besuController, - transactionSimulator, - context.getBlockchain()); + permissioningConfiguration, besuController, transactionSimulator); final Optional accountLocalConfigPermissioningController = @@ -1110,8 +1107,7 @@ private Optional buildNodePermissioningController( final NodePermissioningController nodePermissioningController = new NodePermissioningControllerFactory() .create( - new PermissioningConfiguration( - Optional.empty(), Optional.empty(), Optional.empty()), + new PermissioningConfiguration(Optional.empty(), Optional.empty()), synchronizer, fixedNodes, localNodeId, @@ -1129,13 +1125,12 @@ private Optional buildNodePermissioningController( private Optional buildAccountPermissioningController( final Optional permissioningConfiguration, final BesuController besuController, - final TransactionSimulator transactionSimulator, - final Blockchain blockchain) { + final TransactionSimulator transactionSimulator) { if (permissioningConfiguration.isPresent()) { final Optional accountPermissioningController = AccountPermissioningControllerFactory.create( - permissioningConfiguration.get(), transactionSimulator, metricsSystem, blockchain); + permissioningConfiguration.get(), transactionSimulator, metricsSystem); accountPermissioningController.ifPresent( permissioningController -> 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 831c52a74f4..182b8f762aa 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -31,7 +31,6 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.VALID_APIS; import static org.hyperledger.besu.ethereum.api.jsonrpc.authentication.EngineAuthService.EPHEMERAL_JWT_FILE; import static org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration.DEFAULT_WEBSOCKET_PORT; -import static org.hyperledger.besu.ethereum.permissioning.GoQuorumPermissioningConfiguration.QIP714_DEFAULT_BLOCK; import static org.hyperledger.besu.metrics.BesuMetricCategory.DEFAULT_METRIC_CATEGORIES; import static org.hyperledger.besu.metrics.MetricsProtocol.PROMETHEUS; import static org.hyperledger.besu.metrics.prometheus.MetricsConfiguration.DEFAULT_METRICS_PORT; @@ -134,7 +133,6 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; import org.hyperledger.besu.ethereum.p2p.peers.StaticNodesParser; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; -import org.hyperledger.besu.ethereum.permissioning.GoQuorumPermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfigurationBuilder; @@ -219,7 +217,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.OptionalLong; import java.util.Set; import java.util.TreeMap; import java.util.function.Function; @@ -1387,8 +1384,6 @@ static class TxPoolOptionGroup { private Vertx vertx; private EnodeDnsConfiguration enodeDnsConfiguration; private KeyValueStorageProvider keyValueStorageProvider; - /** Sets GoQuorum compatibility mode. */ - protected Boolean isGoQuorumCompatibilityMode = false; /** * Besu command constructor. @@ -1531,13 +1526,9 @@ public void run() { try { configureLogging(true); - // Set the goquorum compatibility mode based on the genesis file + if (genesisFile != null) { genesisConfigOptions = readGenesisConfigOptions(); - - if (genesisConfigOptions.isQuorum()) { - enableGoQuorumCompatibilityMode(); - } } // set merge config on the basis of genesis config @@ -2200,8 +2191,6 @@ private void configure() throws Exception { ethNetworkConfig = updateNetworkConfig(network); - checkGoQuorumCompatibilityConfig(ethNetworkConfig); - jsonRpcConfiguration = jsonRpcConfiguration( jsonRPCHttpOptionGroup.rpcHttpPort, jsonRPCHttpOptionGroup.rpcHttpApis, hostsAllowlist); @@ -2811,27 +2800,11 @@ private Optional permissioningConfiguration() throws final PermissioningConfiguration permissioningConfiguration = new PermissioningConfiguration( localPermissioningConfigurationOptional, - Optional.of(smartContractPermissioningConfiguration), - quorumPermissioningConfig()); + Optional.of(smartContractPermissioningConfiguration)); return Optional.of(permissioningConfiguration); } - private Optional quorumPermissioningConfig() { - if (!isGoQuorumCompatibilityMode) { - return Optional.empty(); - } - - try { - final OptionalLong qip714BlockNumber = genesisConfigOptions.getQip714BlockNumber(); - return Optional.of( - GoQuorumPermissioningConfiguration.enabled( - qip714BlockNumber.orElse(QIP714_DEFAULT_BLOCK))); - } catch (final Exception e) { - throw new IllegalStateException("Error reading GoQuorum permissioning options", e); - } - } - private boolean localPermissionsEnabled() { return permissionsOptionGroup.permissionsAccountsEnabled || permissionsOptionGroup.permissionsNodesEnabled; @@ -2854,8 +2827,8 @@ private PrivacyParameters privacyParameters() { CommandLineUtils.checkMultiOptionDependencies( logger, commandLine, - "--privacy-url and/or --privacy-public-key-file ignored because none of --privacy-enabled or isQuorum (in genesis file) was defined.", - List.of(!privacyOptionGroup.isPrivacyEnabled, !isGoQuorumCompatibilityMode), + "--privacy-url and/or --privacy-public-key-file ignored because none of --privacy-enabled was defined.", + List.of(!privacyOptionGroup.isPrivacyEnabled), List.of("--privacy-url", "--privacy-public-key-file")); checkPrivacyTlsOptionsDependencies(); @@ -2869,10 +2842,6 @@ private PrivacyParameters privacyParameters() { if (isPruningEnabled()) { throw new ParameterException(commandLine, String.format("%s %s", "Pruning", errorSuffix)); } - if (isGoQuorumCompatibilityMode) { - throw new ParameterException( - commandLine, String.format("GoQuorum privacy is no longer supported in Besu")); - } if (Boolean.TRUE.equals(privacyOptionGroup.isPrivacyMultiTenancyEnabled) && Boolean.FALSE.equals(jsonRpcConfiguration.isAuthenticationEnabled()) @@ -3451,34 +3420,6 @@ private void addPortIfEnabled( } } - private void checkGoQuorumCompatibilityConfig(final EthNetworkConfig ethNetworkConfig) { - if (isGoQuorumCompatibilityMode) { - - logger.warn( - DEPRECATION_WARNING_MSG, - "isQuorum mode in genesis file (GoQuorum-compatible privacy mode)", - "--privacy-enabled"); - if (!minTransactionGasPrice.isZero()) { - throw new ParameterException( - this.commandLine, - "--min-gas-price must be set to zero if isQuorum mode is enabled in the genesis file."); - } - - if (ensureGoQuorumCompatibilityModeNotUsedOnMainnet(genesisConfigOptions, ethNetworkConfig)) { - throw new ParameterException(this.commandLine, "isQuorum mode cannot be used on Mainnet."); - } - } - } - - private static boolean ensureGoQuorumCompatibilityModeNotUsedOnMainnet( - final GenesisConfigOptions genesisConfigOptions, final EthNetworkConfig ethNetworkConfig) { - return ethNetworkConfig.getNetworkId().equals(MAINNET.getNetworkId()) - || genesisConfigOptions - .getChainId() - .map(chainId -> chainId.equals(MAINNET.getNetworkId())) - .orElse(false); - } - @VisibleForTesting String getLogLevel() { return loggingLevelOption.getLogLevel(); @@ -3532,13 +3473,6 @@ private Optional getEcCurveFromGenesisFile() { return genesisConfigOptions.getEcCurve(); } - /** Enables Go Quorum Compatibility mode. Visible for testing. */ - @VisibleForTesting - protected void enableGoQuorumCompatibilityMode() { - // this static flag is still used for GoQuorum permissioning compatibility - isGoQuorumCompatibilityMode = true; - } - private GenesisConfigOptions getActualGenesisConfigOptions() { return Optional.ofNullable(genesisConfigOptions) .orElseGet( diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index 7e634282260..7f78c5d85b3 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -155,13 +155,6 @@ public class BesuCommandTest extends CommandTestAbstract { .put("config", (new JsonObject()).put("chainId", GENESIS_CONFIG_TEST_CHAINID)); private static final JsonObject GENESIS_INVALID_DATA = (new JsonObject()).put("config", new JsonObject()); - private static final JsonObject VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID = - (new JsonObject()) - .put( - "config", - new JsonObject().put("isQuorum", true).put("chainId", GENESIS_CONFIG_TEST_CHAINID)); - private static final JsonObject INVALID_GENESIS_QUORUM_INTEROP_ENABLED_MAINNET = - (new JsonObject()).put("config", new JsonObject().put("isQuorum", true)); private static final JsonObject INVALID_GENESIS_EC_CURVE = (new JsonObject()).put("config", new JsonObject().put("ecCurve", "abcd")); private static final JsonObject VALID_GENESIS_EC_CURVE = @@ -4229,7 +4222,7 @@ public void privacyOptionsRequiresServiceToBeEnabled() { parseCommand("--privacy-url", ENCLAVE_URI, "--privacy-public-key-file", file.toString()); verifyMultiOptionsConstraintLoggerCall( - "--privacy-url and/or --privacy-public-key-file ignored because none of --privacy-enabled or isQuorum (in genesis file) was defined."); + "--privacy-url and/or --privacy-public-key-file ignored because none of --privacy-enabled was defined."); assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); @@ -4557,17 +4550,6 @@ public void privacyWithPruningMustError() { assertThat(commandOutput.toString(UTF_8)).isEmpty(); } - @Test - public void privacyWithGoQuorumModeMustError() throws IOException { - final Path genesisFile = - createFakeGenesisFile(VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID); - parseCommand( - "--privacy-enabled", "--genesis-file", genesisFile.toString(), "--min-gas-price", "0"); - - assertThat(commandErrorOutput.toString(UTF_8)) - .contains("GoQuorum privacy is no longer supported in Besu"); - } - @Rule public TemporaryFolder testFolder = new TemporaryFolder(); @Test @@ -5241,42 +5223,6 @@ public void assertThatCompatibilityEth64ForkIdIsPresentInHelpMessage() { assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); } - @Test - public void quorumInteropNotDefinedInGenesisDoesNotEnforceZeroGasPrice() throws IOException { - final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON); - parseCommand("--genesis-file", genesisFile.toString()); - assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); - } - - @Test - public void quorumInteropEnabledFailsWithoutGasPriceSet() throws IOException { - final Path genesisFile = - createFakeGenesisFile(VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID); - parseCommand("--genesis-file", genesisFile.toString()); - assertThat(commandErrorOutput.toString(UTF_8)) - .contains( - "--min-gas-price must be set to zero if isQuorum mode is enabled in the genesis file."); - } - - @Test - public void quorumInteropEnabledFailsWithoutGasPriceSetToZero() throws IOException { - final Path genesisFile = - createFakeGenesisFile(VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID); - parseCommand("--genesis-file", genesisFile.toString(), "--min-gas-price", "1"); - assertThat(commandErrorOutput.toString(UTF_8)) - .contains( - "--min-gas-price must be set to zero if isQuorum mode is enabled in the genesis file."); - } - - @Test - public void quorumInteropEnabledFailsWithMainnetChainId() throws IOException { - final Path genesisFile = - createFakeGenesisFile(INVALID_GENESIS_QUORUM_INTEROP_ENABLED_MAINNET.put("chainId", "1")); - parseCommand("--genesis-file", genesisFile.toString(), "--min-gas-price", "0"); - assertThat(commandErrorOutput.toString(UTF_8)) - .contains("isQuorum mode cannot be used on Mainnet."); - } - @Test public void assertThatCheckPortClashAcceptsAsExpected() throws Exception { // use WS port for HTTP diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java index ba1f52769e8..f60bffec96f 100644 --- a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java @@ -466,21 +466,6 @@ default boolean isConsensusMigration() { */ TransitionsConfigOptions getTransitions(); - /** - * Set Besu in Quorum-compatibility mode - * - * @return true, if Besu is running on Quorum-compatibility mode, false, otherwise. - */ - boolean isQuorum(); - - /** - * Block number to activate Quorum Permissioning. This option is used on Quorum-compatibility - * mode. - * - * @return block number to activate Quorum Permissioning - */ - OptionalLong getQip714BlockNumber(); - /** * The PoW algorithm associated with the genesis file. * diff --git a/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java index ab269142ba2..3c8776cac40 100644 --- a/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java @@ -400,16 +400,6 @@ public OptionalLong getEcip1017EraRounds() { return getOptionalLong("ecip1017erarounds"); } - @Override - public boolean isQuorum() { - return getOptionalBoolean("isquorum").orElse(false); - } - - @Override - public OptionalLong getQip714BlockNumber() { - return getOptionalLong("qip714block"); - } - @Override public PowAlgorithm getPowAlgorithm() { return isEthHash() ? PowAlgorithm.ETHASH : PowAlgorithm.UNSUPPORTED; @@ -490,11 +480,6 @@ public Map asMap() { builder.put("qbft", getQbftConfigOptions().asMap()); } - if (isQuorum()) { - builder.put("isQuorum", true); - getQip714BlockNumber().ifPresent(blockNumber -> builder.put("qip714block", blockNumber)); - } - if (isZeroBaseFee()) { builder.put("zeroBaseFee", true); } diff --git a/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java index a0eac55cd8a..0d1648f13d2 100644 --- a/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java @@ -395,16 +395,6 @@ public TransitionsConfigOptions getTransitions() { return transitions; } - @Override - public boolean isQuorum() { - return false; - } - - @Override - public OptionalLong getQip714BlockNumber() { - return OptionalLong.empty(); - } - @Override public PowAlgorithm getPowAlgorithm() { return isEthHash() ? PowAlgorithm.ETHASH : PowAlgorithm.UNSUPPORTED; diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java index d04027dcc10..7dcc21a2c7c 100644 --- a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java @@ -266,23 +266,6 @@ public void shouldNotReturnTerminalTotalDifficultyWhenNotSpecified() { assertThat(new StubGenesisConfigOptions().getTerminalTotalDifficulty()).isNotPresent(); } - @Test - public void isQuorumShouldDefaultToFalse() { - final GenesisConfigOptions config = GenesisConfigFile.fromConfig("{}").getConfigOptions(); - - assertThat(config.isQuorum()).isFalse(); - assertThat(config.getQip714BlockNumber()).isEmpty(); - } - - @Test - public void isQuorumConfigParsedCorrectly() { - final GenesisConfigOptions config = - fromConfigOptions(Map.of("isQuorum", true, "qip714block", 99999L)); - - assertThat(config.isQuorum()).isTrue(); - assertThat(config.getQip714BlockNumber()).hasValue(99999L); - } - @Test public void isZeroBaseFeeShouldDefaultToFalse() { final GenesisConfigOptions config = GenesisConfigFile.fromConfig("{}").getConfigOptions(); diff --git a/config/src/test/resources/valid_config_with_quorum_config.json b/config/src/test/resources/valid_config_with_quorum_config.json deleted file mode 100644 index 2c1db33dfc6..00000000000 --- a/config/src/test/resources/valid_config_with_quorum_config.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "chainId": 4, - "homesteadBlock": 1, - "eip150Block": 2, - "eip158Block": 3, - "byzantiumBlock": 1035301, - "isQuorum": true, - "qip714block": 99999, - "ibft2": { - "blockperiodseconds": 2, - "epochlength": 30000, - "requesttimeoutseconds": 10, - "blockreward": "0x15", - "miningbeneficiary": "0x1234567890123456789012345678901234567890" - }, - "transitions": { - "ibft2": [ - { - "block": 20, - "validators": [ - "0x1234567890123456789012345678901234567890", - "0x9876543210987654321098765432109876543210" - ] - }, - { - "block": 25, - "validators": [ - "0x1234567890123456789012345678901234567890" - ] - } - ] - } -} \ No newline at end of file diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java index bb86c9491a5..3d381ae62b0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java @@ -735,19 +735,6 @@ public Optional> getVersionedHashes() { return this.versionedHashes; } - /** - * Returns whether or not the transaction is a GoQuorum private transaction.
- *
- * A GoQuorum private transaction has its v value equal to 37 or 38, and does not contain a - * chainId. - * - * @param goQuorumCompatibilityMode true if GoQuorum compatbility mode is set - * @return true if GoQuorum private transaction, false otherwise - */ - public boolean isGoQuorumPrivateTransaction(final boolean goQuorumCompatibilityMode) { - return false; - } - /** * Return the list of transaction hashes extracted from the collection of Transaction passed as * argument diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumPermissioningConfiguration.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumPermissioningConfiguration.java deleted file mode 100644 index 4e66a6c0723..00000000000 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumPermissioningConfiguration.java +++ /dev/null @@ -1,44 +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.ethereum.permissioning; - -public class GoQuorumPermissioningConfiguration { - - public static final long QIP714_DEFAULT_BLOCK = 0; - - private final long qip714Block; - private final boolean enabled; - - public GoQuorumPermissioningConfiguration(final long qip714Block, final boolean enabled) { - this.qip714Block = qip714Block; - this.enabled = enabled; - } - - public static GoQuorumPermissioningConfiguration enabled(final long qip714Block) { - return new GoQuorumPermissioningConfiguration(qip714Block, true); - } - - public static GoQuorumPermissioningConfiguration disabled() { - return new GoQuorumPermissioningConfiguration(QIP714_DEFAULT_BLOCK, false); - } - - public long getQip714Block() { - return qip714Block; - } - - public boolean isEnabled() { - return enabled; - } -} diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumQip714Gate.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumQip714Gate.java deleted file mode 100644 index 7958cf3b5aa..00000000000 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumQip714Gate.java +++ /dev/null @@ -1,72 +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.ethereum.permissioning; - -import org.hyperledger.besu.ethereum.chain.BlockAddedEvent; -import org.hyperledger.besu.ethereum.chain.Blockchain; - -import java.util.concurrent.atomic.AtomicLong; - -import com.google.common.annotations.VisibleForTesting; - -public class GoQuorumQip714Gate { - - private static GoQuorumQip714Gate SINGLE_INSTANCE = null; - - private final long qip714Block; - private final AtomicLong latestBlock = new AtomicLong(0L); - - @VisibleForTesting - GoQuorumQip714Gate(final long qip714Block, final Blockchain blockchain) { - this.qip714Block = qip714Block; - - blockchain.observeBlockAdded(this::checkChainHeight); - } - - // this is only called during start-up, synchronized access won't hurt performance - public static synchronized GoQuorumQip714Gate getInstance( - final long qip714Block, final Blockchain blockchain) { - if (SINGLE_INSTANCE == null) { - SINGLE_INSTANCE = new GoQuorumQip714Gate(qip714Block, blockchain); - } else { - if (SINGLE_INSTANCE.qip714Block != qip714Block) { - throw new IllegalStateException( - "Tried to create Quorum QIP-714 gate with different block config from already instantiated gate block config"); - } - } - - return SINGLE_INSTANCE; - } - - public boolean shouldCheckPermissions() { - if (qip714Block == 0) { - return true; - } else { - return latestBlock.get() >= qip714Block; - } - } - - @VisibleForTesting - void checkChainHeight(final BlockAddedEvent event) { - if (event.isNewCanonicalHead()) { - latestBlock.set(event.getBlock().getHeader().getNumber()); - } - } - - @VisibleForTesting - long getLatestBlock() { - return latestBlock.get(); - } -} diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java index 7bca3ef8dfb..be1eb703dcf 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java @@ -88,21 +88,8 @@ public NodePermissioningController create( syncStatusProviderOptional = Optional.empty(); } - final Optional goQuorumQip714Gate = - permissioningConfiguration - .getQuorumPermissioningConfig() - .flatMap( - config -> { - if (config.isEnabled()) { - return Optional.of( - GoQuorumQip714Gate.getInstance(config.getQip714Block(), blockchain)); - } else { - return Optional.empty(); - } - }); - final NodePermissioningController nodePermissioningController = - new NodePermissioningController(syncStatusProviderOptional, providers, goQuorumQip714Gate); + new NodePermissioningController(syncStatusProviderOptional, providers); permissioningConfiguration .getSmartContractConfig() @@ -159,7 +146,7 @@ private void validatePermissioningContract( // eliminate the sync status and other checks, so we can just check the smart contract function final NodePermissioningController tempControllerCheckingSmartContractOnly = new NodePermissioningController( - Optional.empty(), nodePermissioningController.getProviders(), Optional.empty()); + Optional.empty(), nodePermissioningController.getProviders()); try { // the enodeURLs don't matter. We just want to check if a call to the smart contract succeeds diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfiguration.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfiguration.java index 402239243f6..857060a02ec 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfiguration.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfiguration.java @@ -20,15 +20,12 @@ public class PermissioningConfiguration { private final Optional localConfig; private final Optional smartContractConfig; - private final Optional quorumPermissioningConfig; public PermissioningConfiguration( final Optional localConfig, - final Optional smartContractConfig, - final Optional quorumPermissioningConfig) { + final Optional smartContractConfig) { this.localConfig = localConfig; this.smartContractConfig = smartContractConfig; - this.quorumPermissioningConfig = quorumPermissioningConfig; } public Optional getLocalConfig() { @@ -39,11 +36,7 @@ public Optional getSmartContractConfig( return smartContractConfig; } - public Optional getQuorumPermissioningConfig() { - return quorumPermissioningConfig; - } - public static PermissioningConfiguration createDefault() { - return new PermissioningConfiguration(Optional.empty(), Optional.empty(), Optional.empty()); + return new PermissioningConfiguration(Optional.empty(), Optional.empty()); } } diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningController.java index cc8f3236394..7bd691d024c 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningController.java @@ -18,7 +18,6 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; -import org.hyperledger.besu.ethereum.permissioning.GoQuorumQip714Gate; import org.hyperledger.besu.ethereum.permissioning.TransactionSmartContractPermissioningController; import java.util.Optional; @@ -35,31 +34,21 @@ public class AccountPermissioningController { accountLocalConfigPermissioningController; private final Optional transactionSmartContractPermissioningController; - private final Optional goQuorumQip714Gate; public AccountPermissioningController( final Optional accountLocalConfigPermissioningController, final Optional - transactionSmartContractPermissioningController, - final Optional goQuorumQip714Gate) { + transactionSmartContractPermissioningController) { this.accountLocalConfigPermissioningController = accountLocalConfigPermissioningController; this.transactionSmartContractPermissioningController = transactionSmartContractPermissioningController; - this.goQuorumQip714Gate = goQuorumQip714Gate; } public boolean isPermitted( final Transaction transaction, final boolean includeLocalCheck, final boolean includeOnchainCheck) { - final boolean checkPermissions = - goQuorumQip714Gate.map(GoQuorumQip714Gate::shouldCheckPermissions).orElse(true); - if (!checkPermissions) { - LOG.trace("Skipping account permissioning check due to qip714block config"); - - return true; - } final Hash transactionHash = transaction.getHash(); final Address sender = transaction.getSender(); diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java index 2de2b846657..29e513ea5cf 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java @@ -20,10 +20,8 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; -import org.hyperledger.besu.ethereum.permissioning.GoQuorumQip714Gate; import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration; @@ -45,8 +43,7 @@ public class AccountPermissioningControllerFactory { public static Optional create( final PermissioningConfiguration permissioningConfiguration, final TransactionSimulator transactionSimulator, - final MetricsSystem metricsSystem, - final Blockchain blockchain) { + final MetricsSystem metricsSystem) { if (permissioningConfiguration == null) { return Optional.empty(); @@ -64,24 +61,10 @@ public static Optional create( if (accountLocalConfigPermissioningController.isPresent() || transactionSmartContractPermissioningController.isPresent()) { - final Optional goQuorumQip714Gate = - permissioningConfiguration - .getQuorumPermissioningConfig() - .flatMap( - config -> { - if (config.isEnabled()) { - return Optional.of( - GoQuorumQip714Gate.getInstance(config.getQip714Block(), blockchain)); - } else { - return Optional.empty(); - } - }); - final AccountPermissioningController controller = new AccountPermissioningController( accountLocalConfigPermissioningController, - transactionSmartContractPermissioningController, - goQuorumQip714Gate); + transactionSmartContractPermissioningController); return Optional.of(controller); } else { diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningController.java index 2ca141e54dd..2ccb0e47c28 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningController.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.permissioning.node; -import org.hyperledger.besu.ethereum.permissioning.GoQuorumQip714Gate; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.node.provider.SyncStatusNodePermissioningProvider; import org.hyperledger.besu.plugin.data.EnodeURL; @@ -35,26 +34,16 @@ public class NodePermissioningController { private Optional insufficientPeersPermissioningProvider = Optional.empty(); private final List providers; - private final Optional goQuorumQip714Gate; private final Subscribers permissioningUpdateSubscribers = Subscribers.create(); public NodePermissioningController( final Optional syncStatusNodePermissioningProvider, - final List providers, - final Optional goQuorumQip714Gate) { + final List providers) { this.providers = providers; this.syncStatusNodePermissioningProvider = syncStatusNodePermissioningProvider; - this.goQuorumQip714Gate = goQuorumQip714Gate; } public boolean isPermitted(final EnodeURL sourceEnode, final EnodeURL destinationEnode) { - final boolean checkPermissions = - goQuorumQip714Gate.map(GoQuorumQip714Gate::shouldCheckPermissions).orElse(true); - if (!checkPermissions) { - LOG.trace("Skipping node permissioning check due to qip714block config"); - - return true; - } LOG.trace("Node permissioning: Checking {} -> {}", sourceEnode, destinationEnode); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumQip714GateTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumQip714GateTest.java deleted file mode 100644 index b280e181b38..00000000000 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/GoQuorumQip714GateTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.hyperledger.besu.ethereum.permissioning; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.hyperledger.besu.ethereum.chain.BlockAddedEvent; -import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; - -import java.util.Collections; - -import org.junit.Before; -import org.junit.Test; - -/* - * 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 - */ -public class GoQuorumQip714GateTest { - - private Blockchain blockchain; - private GoQuorumQip714Gate gate; - - @Before - public void before() { - blockchain = mock(Blockchain.class); - } - - @Test - public void gateShouldSubscribeAsBlockAddedObserver() { - gate = new GoQuorumQip714Gate(100, blockchain); - - verify(blockchain).observeBlockAdded(any()); - } - - @Test - public void whenTargetBlockIsZeroCheckPermissionsReturnTrue() { - gate = new GoQuorumQip714Gate(0, blockchain); - - assertThat(gate.shouldCheckPermissions()).isTrue(); - } - - @Test - public void whenBelowTargetBlockCheckPermissionsReturnFalse() { - gate = new GoQuorumQip714Gate(99, blockchain); - - updateChainHead(55); - - assertThat(gate.shouldCheckPermissions()).isFalse(); - } - - @Test - public void whenAboveTargetBlockCheckPermissionsReturnTrue() { - gate = new GoQuorumQip714Gate(99, blockchain); - - updateChainHead(100); - - assertThat(gate.shouldCheckPermissions()).isTrue(); - } - - @Test - public void latestBlockCheckShouldKeepUpToChainHeight() { - gate = new GoQuorumQip714Gate(0, blockchain); - assertThat(gate.getLatestBlock()).isEqualTo(0); - - updateChainHead(1); - assertThat(gate.getLatestBlock()).isEqualTo(1); - - updateChainHead(3); - assertThat(gate.getLatestBlock()).isEqualTo(3); - - updateChainHead(2); - assertThat(gate.getLatestBlock()).isEqualTo(2); - } - - @Test - public void getInstanceForbidInstancesWithDifferentQip714BlockNumber() { - // creating singleton with qip714block = 1 - GoQuorumQip714Gate.getInstance(1L, blockchain); - - // creating new instance with qip714block != 1 should fail - assertThatThrownBy(() -> GoQuorumQip714Gate.getInstance(2L, blockchain)) - .isInstanceOf(IllegalStateException.class) - .hasMessage( - "Tried to create Quorum QIP-714 gate with different block config from already instantiated gate block config"); - } - - private void updateChainHead(final int height) { - final Block block = new BlockDataGenerator().block(new BlockOptions().setBlockNumber(height)); - gate.checkChainHeight( - BlockAddedEvent.createForHeadAdvancement( - block, Collections.emptyList(), Collections.emptyList())); - } -} diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactoryTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactoryTest.java index 2c19f3cd37b..85ad5596fe7 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactoryTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactoryTest.java @@ -21,7 +21,6 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration; @@ -44,15 +43,13 @@ public class AccountPermissioningControllerFactoryTest { @Mock private TransactionSimulator transactionSimulator; - @Mock private Blockchain blockchain; private final MetricsSystem metricsSystem = new NoOpMetricsSystem(); @Test public void createWithNullPermissioningConfigShouldReturnEmpty() { Optional controller = - AccountPermissioningControllerFactory.create( - null, transactionSimulator, metricsSystem, blockchain); + AccountPermissioningControllerFactory.create(null, transactionSimulator, metricsSystem); Assertions.assertThat(controller).isEmpty(); } @@ -63,12 +60,11 @@ public void createLocalConfigWithAccountPermissioningDisabledShouldReturnEmpty() assertThat(localConfig.isAccountAllowlistEnabled()).isFalse(); PermissioningConfiguration permissioningConfiguration = - new PermissioningConfiguration( - Optional.of(localConfig), Optional.empty(), Optional.empty()); + new PermissioningConfiguration(Optional.of(localConfig), Optional.empty()); Optional controller = AccountPermissioningControllerFactory.create( - permissioningConfiguration, transactionSimulator, metricsSystem, blockchain); + permissioningConfiguration, transactionSimulator, metricsSystem); Assertions.assertThat(controller).isEmpty(); } @@ -79,12 +75,11 @@ public void createLocalConfigOnlyControllerShouldReturnExpectedController() { assertThat(localConfig.isAccountAllowlistEnabled()).isTrue(); PermissioningConfiguration permissioningConfiguration = - new PermissioningConfiguration( - Optional.of(localConfig), Optional.empty(), Optional.empty()); + new PermissioningConfiguration(Optional.of(localConfig), Optional.empty()); Optional controller = AccountPermissioningControllerFactory.create( - permissioningConfiguration, transactionSimulator, metricsSystem, blockchain); + permissioningConfiguration, transactionSimulator, metricsSystem); Assertions.assertThat(controller).isNotEmpty(); assertThat(controller.get().getAccountLocalConfigPermissioningController()).isNotEmpty(); @@ -98,12 +93,11 @@ public void createOnchainConfigWithAccountPermissioningDisabledShouldReturnEmpty assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isFalse(); PermissioningConfiguration permissioningConfiguration = - new PermissioningConfiguration( - Optional.empty(), Optional.of(onchainConfig), Optional.empty()); + new PermissioningConfiguration(Optional.empty(), Optional.of(onchainConfig)); Optional controller = AccountPermissioningControllerFactory.create( - permissioningConfiguration, transactionSimulator, metricsSystem, blockchain); + permissioningConfiguration, transactionSimulator, metricsSystem); Assertions.assertThat(controller).isEmpty(); } @@ -114,12 +108,11 @@ public void createOnchainConfigOnlyControllerShouldReturnExpectedController() { assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isTrue(); PermissioningConfiguration permissioningConfiguration = - new PermissioningConfiguration( - Optional.empty(), Optional.of(onchainConfig), Optional.empty()); + new PermissioningConfiguration(Optional.empty(), Optional.of(onchainConfig)); Optional controller = AccountPermissioningControllerFactory.create( - permissioningConfiguration, transactionSimulator, metricsSystem, blockchain); + permissioningConfiguration, transactionSimulator, metricsSystem); Assertions.assertThat(controller).isNotEmpty(); assertThat(controller.get().getAccountLocalConfigPermissioningController()).isEmpty(); @@ -132,8 +125,7 @@ public void createOnchainShouldFailIfValidationFails() { assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isTrue(); PermissioningConfiguration permissioningConfiguration = - new PermissioningConfiguration( - Optional.empty(), Optional.of(onchainConfig), Optional.empty()); + new PermissioningConfiguration(Optional.empty(), Optional.of(onchainConfig)); when(transactionSimulator.processAtHead(any())).thenThrow(new RuntimeException()); @@ -141,7 +133,7 @@ public void createOnchainShouldFailIfValidationFails() { catchThrowable( () -> AccountPermissioningControllerFactory.create( - permissioningConfiguration, transactionSimulator, metricsSystem, blockchain)); + permissioningConfiguration, transactionSimulator, metricsSystem)); assertThat(thrown) .isInstanceOf(IllegalStateException.class) @@ -157,12 +149,11 @@ public void createLocalAndOnchainControllerShouldReturnExpectedControllers() { assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isTrue(); PermissioningConfiguration permissioningConfiguration = - new PermissioningConfiguration( - Optional.of(localConfig), Optional.of(onchainConfig), Optional.empty()); + new PermissioningConfiguration(Optional.of(localConfig), Optional.of(onchainConfig)); Optional controller = AccountPermissioningControllerFactory.create( - permissioningConfiguration, transactionSimulator, metricsSystem, blockchain); + permissioningConfiguration, transactionSimulator, metricsSystem); Assertions.assertThat(controller).isNotEmpty(); assertThat(controller.get().getAccountLocalConfigPermissioningController()).isNotEmpty(); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerTest.java index b125138a18b..5ed0d1e66c7 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerTest.java @@ -23,7 +23,6 @@ import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; -import org.hyperledger.besu.ethereum.permissioning.GoQuorumQip714Gate; import org.hyperledger.besu.ethereum.permissioning.TransactionSmartContractPermissioningController; import java.util.Optional; @@ -41,15 +40,12 @@ public class AccountPermissioningControllerTest { @Mock private AccountLocalConfigPermissioningController localConfigController; @Mock private TransactionSmartContractPermissioningController smartContractController; - @Mock private GoQuorumQip714Gate goQuorumQip714Gate; @Before public void before() { permissioningController = new AccountPermissioningController( - Optional.of(localConfigController), - Optional.of(smartContractController), - Optional.empty()); + Optional.of(localConfigController), Optional.of(smartContractController)); } @Test @@ -89,49 +85,4 @@ public void shouldReturnFalseIfOneControllerPermitsAndTheOtherDoesNot() { verify(localConfigController).isPermitted(any()); verify(smartContractController).isPermitted(any()); } - - @Test - public void whenQuorumQip714GateIsEmptyShouldDelegateToProviders() { - this.permissioningController = - new AccountPermissioningController( - Optional.of(localConfigController), - Optional.of(smartContractController), - Optional.empty()); - - permissioningController.isPermitted(mock(Transaction.class), true, false); - - verify(localConfigController).isPermitted(any()); - } - - @Test - public void whenQuorumQip714GateIsNotActiveShouldBypassProviders() { - this.permissioningController = - new AccountPermissioningController( - Optional.of(localConfigController), - Optional.of(smartContractController), - Optional.of(goQuorumQip714Gate)); - - when(goQuorumQip714Gate.shouldCheckPermissions()).thenReturn(false); - - boolean isPermitted = permissioningController.isPermitted(mock(Transaction.class), true, false); - assertThat(isPermitted).isTrue(); - - verifyNoInteractions(localConfigController); - verifyNoInteractions(smartContractController); - } - - @Test - public void whenQuorumQip714GateIsActiveActiveShouldDelegateToProviders() { - this.permissioningController = - new AccountPermissioningController( - Optional.of(localConfigController), - Optional.of(smartContractController), - Optional.of(goQuorumQip714Gate)); - - when(goQuorumQip714Gate.shouldCheckPermissions()).thenReturn(true); - - permissioningController.isPermitted(mock(Transaction.class), true, false); - - verify(localConfigController).isPermitted(any()); - } } diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java index a313c4a60ed..afba9bb18fb 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java @@ -67,7 +67,7 @@ public void before() { @Test public void testCreateWithNeitherPermissioningEnabled() { - config = new PermissioningConfiguration(Optional.empty(), Optional.empty(), Optional.empty()); + config = new PermissioningConfiguration(Optional.empty(), Optional.empty()); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = factory.create( @@ -93,9 +93,7 @@ public void testCreateWithSmartContractNodePermissioningEnabledOnly() { smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true); config = new PermissioningConfiguration( - Optional.empty(), - Optional.of(smartContractPermissioningConfiguration), - Optional.empty()); + Optional.empty(), Optional.of(smartContractPermissioningConfiguration)); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = @@ -123,8 +121,7 @@ public void testCreateWithLocalNodePermissioningEnabledOnly() { localPermissioningConfig.setNodeAllowlist(Collections.emptyList()); localPermissioningConfig.setNodePermissioningConfigFilePath("fake-file-path"); config = - new PermissioningConfiguration( - Optional.of(localPermissioningConfig), Optional.empty(), Optional.empty()); + new PermissioningConfiguration(Optional.of(localPermissioningConfig), Optional.empty()); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = @@ -160,8 +157,7 @@ public void testCreateWithLocalNodePermissioningEnabledOnly() { config = new PermissioningConfiguration( Optional.of(localPermissioningConfig), - Optional.of(smartContractPermissioningConfiguration), - Optional.empty()); + Optional.of(smartContractPermissioningConfiguration)); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = @@ -196,8 +192,7 @@ public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() { config = new PermissioningConfiguration( Optional.of(localPermissioningConfig), - Optional.of(smartContractPermissioningConfiguration), - Optional.empty()); + Optional.of(smartContractPermissioningConfiguration)); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = @@ -235,9 +230,7 @@ public void testCreateWithSmartContractNodePermissioningEnabledOnlyAndBootnode() smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true); config = new PermissioningConfiguration( - Optional.empty(), - Optional.of(smartContractPermissioningConfiguration), - Optional.empty()); + Optional.empty(), Optional.of(smartContractPermissioningConfiguration)); NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); NodePermissioningController controller = @@ -262,9 +255,7 @@ public void createOnchainShouldFailIfValidationFails() { smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true); config = new PermissioningConfiguration( - Optional.empty(), - Optional.of(smartContractPermissioningConfiguration), - Optional.empty()); + Optional.empty(), Optional.of(smartContractPermissioningConfiguration)); when(transactionSimulator.processAtHead(any())).thenThrow(new RuntimeException()); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerTest.java index 77743814d9b..512b752895b 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerTest.java @@ -21,18 +21,15 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; -import org.hyperledger.besu.ethereum.permissioning.GoQuorumQip714Gate; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.node.provider.SyncStatusNodePermissioningProvider; import org.hyperledger.besu.plugin.data.EnodeURL; import org.hyperledger.besu.plugin.services.permissioning.NodeConnectionPermissioningProvider; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Optional; @@ -56,7 +53,6 @@ public class NodePermissioningControllerTest { Optional syncStatusNodePermissioningProviderOptional; @Mock private NodeLocalConfigPermissioningController localConfigNodePermissioningProvider; @Mock private NodeConnectionPermissioningProvider otherPermissioningProvider; - @Mock private GoQuorumQip714Gate goQuorumQip714Gate; private NodePermissioningController controller; @@ -66,7 +62,7 @@ public void before() { List emptyProviders = new ArrayList<>(); this.controller = new NodePermissioningController( - syncStatusNodePermissioningProviderOptional, emptyProviders, Optional.empty()); + syncStatusNodePermissioningProviderOptional, emptyProviders); } @Test @@ -81,8 +77,7 @@ public void isPermittedShouldDelegateToSyncStatusProvider() { public void whenNoSyncStatusProviderWeShouldDelegateToLocalConfigNodePermissioningProvider() { List providers = new ArrayList<>(); providers.add(localConfigNodePermissioningProvider); - this.controller = - new NodePermissioningController(Optional.empty(), providers, Optional.empty()); + this.controller = new NodePermissioningController(Optional.empty(), providers); controller.isPermitted(enode1, enode2); @@ -94,8 +89,7 @@ public void whenNoSyncStatusProviderWeShouldDelegateToLocalConfigNodePermissioni whenInSyncWeShouldDelegateToAnyOtherNodePermissioningProviderAndIsPermittedIfAllPermitted() { List providers = getNodePermissioningProviders(); this.controller = - new NodePermissioningController( - syncStatusNodePermissioningProviderOptional, providers, Optional.empty()); + new NodePermissioningController(syncStatusNodePermissioningProviderOptional, providers); when(syncStatusNodePermissioningProvider.isConnectionPermitted(eq(enode1), eq(enode2))) .thenReturn(true); @@ -124,8 +118,7 @@ private List getNodePermissioningProviders( List providers = getNodePermissioningProviders(); this.controller = - new NodePermissioningController( - syncStatusNodePermissioningProviderOptional, providers, Optional.empty()); + new NodePermissioningController(syncStatusNodePermissioningProviderOptional, providers); when(syncStatusNodePermissioningProvider.isConnectionPermitted(eq(enode1), eq(enode2))) .thenReturn(true); @@ -147,8 +140,7 @@ public void shouldStopAtInsufficientPeersWhenInsufficientAndBootnode() { final List providers = getNodePermissioningProviders(); this.controller = - new NodePermissioningController( - syncStatusNodePermissioningProviderOptional, providers, Optional.empty()); + new NodePermissioningController(syncStatusNodePermissioningProviderOptional, providers); final ContextualNodePermissioningProvider insufficientPeersPermissioningProvider = mock(ContextualNodePermissioningProvider.class); @@ -170,8 +162,7 @@ public void doesntStopAtInsufficientPeersWhenNoAnswer() { final List providers = getNodePermissioningProviders(); this.controller = - new NodePermissioningController( - syncStatusNodePermissioningProviderOptional, providers, Optional.empty()); + new NodePermissioningController(syncStatusNodePermissioningProviderOptional, providers); final ContextualNodePermissioningProvider insufficientPeersPermissioningProvider = mock(ContextualNodePermissioningProvider.class); @@ -191,47 +182,4 @@ public void doesntStopAtInsufficientPeersWhenNoAnswer() { verify(insufficientPeersPermissioningProvider, times(1)).isPermitted(any(), any()); providers.forEach(p -> verify(p, times(1)).isConnectionPermitted(any(), any())); } - - @Test - public void whenQuorumQip714GateIsEmptyShouldDelegateToProviders() { - this.controller = - new NodePermissioningController( - syncStatusNodePermissioningProviderOptional, Collections.emptyList(), Optional.empty()); - - controller.isPermitted(enode1, enode2); - - verify(syncStatusNodePermissioningProvider, atLeast(1)) - .isConnectionPermitted(eq(enode1), eq(enode2)); - } - - @Test - public void whenQuorumQip714GateIsNotActiveShouldBypassProviders() { - this.controller = - new NodePermissioningController( - syncStatusNodePermissioningProviderOptional, - Collections.emptyList(), - Optional.of(goQuorumQip714Gate)); - - when(goQuorumQip714Gate.shouldCheckPermissions()).thenReturn(false); - - assertThat(controller.isPermitted(enode1, enode2)).isTrue(); - - verifyNoInteractions(syncStatusNodePermissioningProvider); - } - - @Test - public void whenQuorumQip714GateIsActiveShouldDelegateToProviders() { - this.controller = - new NodePermissioningController( - syncStatusNodePermissioningProviderOptional, - Collections.emptyList(), - Optional.of(goQuorumQip714Gate)); - - when(goQuorumQip714Gate.shouldCheckPermissions()).thenReturn(true); - - controller.isPermitted(enode1, enode2); - - verify(syncStatusNodePermissioningProvider, atLeast(1)) - .isConnectionPermitted(eq(enode1), eq(enode2)); - } }