Skip to content

Commit

Permalink
Removed GoQuorum permissioning interop (#5607)
Browse files Browse the repository at this point in the history
* removed quorum permissioning

* removed isQuorum

Signed-off-by: Nischal Sharma <nischal@web3labs.com>

---------

Signed-off-by: Nischal Sharma <nischal@web3labs.com>
  • Loading branch information
NickSneo authored Jul 24, 2023
1 parent 47a61dd commit ef02086
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 680 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 4 additions & 9 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,7 @@ public Runner build() {

final Optional<AccountPermissioningController> accountPermissioningController =
buildAccountPermissioningController(
permissioningConfiguration,
besuController,
transactionSimulator,
context.getBlockchain());
permissioningConfiguration, besuController, transactionSimulator);

final Optional<AccountLocalConfigPermissioningController>
accountLocalConfigPermissioningController =
Expand Down Expand Up @@ -1110,8 +1107,7 @@ private Optional<NodePermissioningController> buildNodePermissioningController(
final NodePermissioningController nodePermissioningController =
new NodePermissioningControllerFactory()
.create(
new PermissioningConfiguration(
Optional.empty(), Optional.empty(), Optional.empty()),
new PermissioningConfiguration(Optional.empty(), Optional.empty()),
synchronizer,
fixedNodes,
localNodeId,
Expand All @@ -1129,13 +1125,12 @@ private Optional<NodePermissioningController> buildNodePermissioningController(
private Optional<AccountPermissioningController> buildAccountPermissioningController(
final Optional<PermissioningConfiguration> permissioningConfiguration,
final BesuController besuController,
final TransactionSimulator transactionSimulator,
final Blockchain blockchain) {
final TransactionSimulator transactionSimulator) {

if (permissioningConfiguration.isPresent()) {
final Optional<AccountPermissioningController> accountPermissioningController =
AccountPermissioningControllerFactory.create(
permissioningConfiguration.get(), transactionSimulator, metricsSystem, blockchain);
permissioningConfiguration.get(), transactionSimulator, metricsSystem);

accountPermissioningController.ifPresent(
permissioningController ->
Expand Down
74 changes: 4 additions & 70 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2200,8 +2191,6 @@ private void configure() throws Exception {

ethNetworkConfig = updateNetworkConfig(network);

checkGoQuorumCompatibilityConfig(ethNetworkConfig);

jsonRpcConfiguration =
jsonRpcConfiguration(
jsonRPCHttpOptionGroup.rpcHttpPort, jsonRPCHttpOptionGroup.rpcHttpApis, hostsAllowlist);
Expand Down Expand Up @@ -2811,27 +2800,11 @@ private Optional<PermissioningConfiguration> permissioningConfiguration() throws
final PermissioningConfiguration permissioningConfiguration =
new PermissioningConfiguration(
localPermissioningConfigurationOptional,
Optional.of(smartContractPermissioningConfiguration),
quorumPermissioningConfig());
Optional.of(smartContractPermissioningConfiguration));

return Optional.of(permissioningConfiguration);
}

private Optional<GoQuorumPermissioningConfiguration> 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;
Expand All @@ -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();
Expand All @@ -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())
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -3532,13 +3473,6 @@ private Optional<String> 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(
Expand Down
56 changes: 1 addition & 55 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -490,11 +480,6 @@ public Map<String, Object> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit ef02086

Please sign in to comment.