Skip to content

Commit

Permalink
[23.4] Remove GoQuorum privacy (hyperledger#5303)
Browse files Browse the repository at this point in the history
* removed separate decoding logic

* run non-mainnet ATs to make sure

* remove goQuorum flag from everywhere

* remove GOQUORUM api group

* remove GoQuorum enclave, privacy params, RPCs and other related config

* removed Goquorum related error codes, rpcMethod codes, privateBloom

* removed v from transaction

* removed private GoQuorum storage provider

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
macfarla authored and eum602 committed Nov 3, 2023
1 parent 3ebb0d5 commit 044aff1
Show file tree
Hide file tree
Showing 107 changed files with 150 additions and 4,341 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## 23.4-RC

### Breaking Changes
- Removed IBFT1 feature [#5302](https://github.com/hyperledger/besu/pull/5302)
- Remove IBFT 1.0 feature (deprecated in 23.1.0-beta) [#5302](https://github.com/hyperledger/besu/pull/5302)
- Remove GoQuorum-compatible privacy feature (deprecated in 23.1.0-beta) [#5303](https://github.com/hyperledger/besu/pull/5303)

### Additions and Improvements
- Update most dependencies to latest version [#5269](https://github.com/hyperledger/besu/pull/5269)
Expand Down
4 changes: 1 addition & 3 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -936,9 +936,7 @@ public Runner build() {

Optional<GraphQLHttpService> graphQLHttpService = Optional.empty();
if (graphQLConfiguration.isEnabled()) {
final GraphQLDataFetchers fetchers =
new GraphQLDataFetchers(
supportedCapabilities, privacyParameters.getGoQuorumPrivacyParameters());
final GraphQLDataFetchers fetchers = new GraphQLDataFetchers(supportedCapabilities);
final Map<GraphQLContextType, Object> graphQlContextMap = new ConcurrentHashMap<>();
graphQlContextMap.putIfAbsent(GraphQLContextType.BLOCKCHAIN_QUERIES, blockchainQueries);
graphQlContextMap.putIfAbsent(GraphQLContextType.PROTOCOL_SCHEDULE, protocolSchedule);
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 @@ -89,7 +89,6 @@
import org.hyperledger.besu.config.CheckpointConfigOptions;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.GoQuorumOptions;
import org.hyperledger.besu.config.MergeConfigOptions;
import org.hyperledger.besu.consensus.qbft.pki.PkiBlockCreationConfiguration;
import org.hyperledger.besu.consensus.qbft.pki.PkiBlockCreationConfigurationProvider;
Expand All @@ -106,7 +105,6 @@
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.enclave.EnclaveFactory;
import org.hyperledger.besu.enclave.GoQuorumEnclave;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
Expand All @@ -122,7 +120,6 @@
import org.hyperledger.besu.ethereum.api.tls.TlsClientAuthConfiguration;
import org.hyperledger.besu.ethereum.api.tls.TlsConfiguration;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.GoQuorumPrivacyParameters;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
Expand All @@ -141,15 +138,10 @@
import org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration;
import org.hyperledger.besu.ethereum.privacy.storage.keyvalue.PrivacyKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.keyvalue.PrivacyKeyValueStorageProviderBuilder;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract;
import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract;
import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract;
Expand Down Expand Up @@ -213,7 +205,6 @@
import java.time.Clock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -235,7 +226,6 @@
import com.google.common.base.Strings;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import com.google.common.io.Resources;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
Expand Down Expand Up @@ -2211,44 +2201,6 @@ private JsonRpcIpcConfiguration jsonRpcIpcConfiguration(
vertx.isNativeTransportEnabled() && enabled, actualPath, rpcIpcApis);
}

private GoQuorumPrivacyParameters configureGoQuorumPrivacy(
final KeyValueStorageProvider storageProvider) {
return new GoQuorumPrivacyParameters(
createGoQuorumEnclave(),
readEnclaveKey(),
storageProvider.createGoQuorumPrivateStorage(),
createPrivateWorldStateArchive(storageProvider));
}

private GoQuorumEnclave createGoQuorumEnclave() {
final EnclaveFactory enclaveFactory = new EnclaveFactory(Vertx.vertx());
if (privacyOptionGroup.privacyKeyStoreFile != null) {
return enclaveFactory.createGoQuorumEnclave(
privacyOptionGroup.privacyUrl,
privacyOptionGroup.privacyKeyStoreFile,
privacyOptionGroup.privacyKeyStorePasswordFile,
privacyOptionGroup.privacyTlsKnownEnclaveFile);
} else {
return enclaveFactory.createGoQuorumEnclave(privacyOptionGroup.privacyUrl);
}
}

private String readEnclaveKey() {
final String key;
try {
key = Files.asCharSource(privacyOptionGroup.privacyPublicKeyFile, UTF_8).read();
} catch (final Exception e) {
throw new ParameterException(
this.commandLine,
"--privacy-public-key-file must be set if isQuorum is set in the genesis file.",
e);
}
// throws exception if invalid base 64
Base64.getDecoder().decode(key);

return key;
}

private void ensureAllNodesAreInAllowlist(
final Collection<EnodeURL> enodeAddresses,
final LocalPermissioningConfiguration permissioningConfiguration) {
Expand Down Expand Up @@ -2314,7 +2266,7 @@ public BesuControllerBuilder getControllerBuilder() {
.nodeKey(new NodeKey(securityModule()))
.metricsSystem(metricsSystem.get())
.messagePermissioningProviders(permissioningService.getMessagePermissioningProviders())
.privacyParameters(privacyParameters(storageProvider))
.privacyParameters(privacyParameters())
.pkiBlockCreationConfiguration(maybePkiBlockCreationConfiguration())
.clock(Clock.systemUTC())
.isRevertReasonEnabled(isRevertReasonEnabled)
Expand Down Expand Up @@ -2807,7 +2759,7 @@ private boolean contractPermissionsEnabled() {
|| permissionsOptionGroup.permissionsAccountsContractEnabled;
}

private PrivacyParameters privacyParameters(final KeyValueStorageProvider storageProvider) {
private PrivacyParameters privacyParameters() {

CommandLineUtils.checkOptionDependencies(
logger,
Expand Down Expand Up @@ -2836,7 +2788,7 @@ private PrivacyParameters privacyParameters(final KeyValueStorageProvider storag
}
if (isGoQuorumCompatibilityMode) {
throw new ParameterException(
commandLine, String.format("%s %s", "GoQuorum mode", errorSuffix));
commandLine, String.format("GoQuorum privacy is no longer supported in Besu"));
}

if (Boolean.TRUE.equals(privacyOptionGroup.isPrivacyMultiTenancyEnabled)
Expand Down Expand Up @@ -2898,20 +2850,12 @@ private PrivacyParameters privacyParameters(final KeyValueStorageProvider storag
privacyOptionGroup.privacyTlsKnownEnclaveFile);
}
privacyParametersBuilder.setEnclaveFactory(new EnclaveFactory(vertx));
} else if (isGoQuorumCompatibilityMode) {
privacyParametersBuilder.setGoQuorumPrivacyParameters(
Optional.of(configureGoQuorumPrivacy(storageProvider)));
}

if (Boolean.FALSE.equals(privacyOptionGroup.isPrivacyEnabled) && anyPrivacyApiEnabled()) {
logger.warn("Privacy is disabled. Cannot use EEA/PRIV API methods when not using Privacy.");
}

if (!isGoQuorumCompatibilityMode
&& (jsonRPCHttpOptionGroup.rpcHttpApis.contains(RpcApis.GOQUORUM.name())
|| jsonRPCWebsocketOptionGroup.rpcWsApis.contains(RpcApis.GOQUORUM.name()))) {
logger.warn("Cannot use GOQUORUM API methods when not in GoQuorum mode.");
}
privacyParametersBuilder.setPrivacyService(privacyPluginService);
final PrivacyParameters privacyParameters = privacyParametersBuilder.build();

Expand All @@ -2924,14 +2868,6 @@ private PrivacyParameters privacyParameters(final KeyValueStorageProvider storag
return privacyParameters;
}

private WorldStateArchive createPrivateWorldStateArchive(final StorageProvider storageProvider) {
final WorldStateStorage privateWorldStateStorage =
storageProvider.createPrivateWorldStateStorage();
final WorldStatePreimageStorage preimageStorage =
storageProvider.createPrivateWorldStatePreimageStorage();
return new DefaultWorldStateArchive(privateWorldStateStorage, preimageStorage);
}

private boolean anyPrivacyApiEnabled() {
return jsonRPCHttpOptionGroup.rpcHttpApis.contains(RpcApis.EEA.name())
|| jsonRPCWebsocketOptionGroup.rpcWsApis.contains(RpcApis.EEA.name())
Expand Down Expand Up @@ -2968,7 +2904,6 @@ private KeyValueStorageProvider keyValueStorageProvider(final String name) {
"No KeyValueStorageFactory found for key: " + name)))
.withCommonConfiguration(pluginCommonConfiguration)
.withMetricsSystem(getMetricsSystem())
.isGoQuorumCompatibilityMode(isGoQuorumCompatibilityMode.booleanValue())
.build();
}
return this.keyValueStorageProvider;
Expand Down Expand Up @@ -3508,8 +3443,7 @@ private Optional<String> getEcCurveFromGenesisFile() {
/** Enables Go Quorum Compatibility mode. Visible for testing. */
@VisibleForTesting
protected void enableGoQuorumCompatibilityMode() {
// this static flag is read by the RLP decoder
GoQuorumOptions.setGoQuorumCompatibilityMode(true);
// this static flag is still used for GoQuorum permissioning compatibility
isGoQuorumCompatibilityMode = true;
}

Expand Down
54 changes: 1 addition & 53 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4545,13 +4545,7 @@ public void privacyWithGoQuorumModeMustError() throws IOException {
"--privacy-enabled", "--genesis-file", genesisFile.toString(), "--min-gas-price", "0");

assertThat(commandErrorOutput.toString(UTF_8))
.contains("GoQuorum mode cannot be enabled with privacy.");
assertThat(commandOutput.toString(UTF_8)).isEmpty();
verify(mockLogger, atLeast(1))
.warn(
DEPRECATION_WARNING_MSG,
"isQuorum mode in genesis file (GoQuorum-compatible privacy mode)",
"--privacy-enabled");
.contains("GoQuorum privacy is no longer supported in Besu");
}

@Rule public TemporaryFolder testFolder = new TemporaryFolder();
Expand Down Expand Up @@ -5142,52 +5136,6 @@ public void quorumInteropEnabledFailsWithoutGasPriceSetToZero() throws IOExcepti
"--min-gas-price must be set to zero if isQuorum mode is enabled in the genesis file.");
}

@Test
public void quorumInteropEnabledSucceedsWithGasPriceSetToZero() throws IOException {
final Path genesisFile =
createFakeGenesisFile(VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID);
parseCommand(
"--genesis-file",
genesisFile.toString(),
"--min-gas-price",
"0",
"--privacy-public-key-file",
ENCLAVE_PUBLIC_KEY_PATH);
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void quorumInteropEnabledFailsIfEnclaveKeyFileDoesNotExist() throws IOException {
final Path genesisFile =
createFakeGenesisFile(VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID);
parseCommand(
"--genesis-file",
genesisFile.toString(),
"--min-gas-price",
"0",
"--privacy-public-key-file",
"ThisFileDoesNotExist");
assertThat(commandErrorOutput.toString(UTF_8))
.contains("--privacy-public-key-file must be set if isQuorum is set in the genesis file.");
}

@Test
public void quorumInteropEnabledFailsIfEnclaveKeyFileIsNotSet() throws IOException {
final Path genesisFile =
createFakeGenesisFile(VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID);
parseCommand("--genesis-file", genesisFile.toString(), "--min-gas-price", "0");
assertThat(commandErrorOutput.toString(UTF_8))
.contains("--privacy-public-key-file must be set if isQuorum is set in the genesis file.");
}

@Test
public void quorumInteropEnabledFailsWithMainnetDefaultNetwork() throws IOException {
final Path genesisFile = createFakeGenesisFile(INVALID_GENESIS_QUORUM_INTEROP_ENABLED_MAINNET);
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 quorumInteropEnabledFailsWithMainnetChainId() throws IOException {
final Path genesisFile =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,6 @@ protected Vertx createVertx(final VertxOptions vertxOptions) {
return vertx;
}

@Override
protected void enableGoQuorumCompatibilityMode() {
// We do *not* set the static GoQuorumOptions for test runs as
// these are only allowed to be set once during the program
// runtime.
isGoQuorumCompatibilityMode = true;
}

public CommandSpec getSpec() {
return spec;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ public static ProtocolSchedule create(
epochManager,
cliqueConfig.getBlockPeriodSeconds(),
localNodeAddress,
builder,
privacyParameters.getGoQuorumPrivacyParameters().isPresent())),
builder)),
privacyParameters,
isRevertReasonEnabled,
config.isQuorum(),
evmConfiguration)
.createProtocolSchedule();
}
Expand All @@ -110,8 +108,7 @@ private static ProtocolSpecBuilder applyCliqueSpecificModifications(
final EpochManager epochManager,
final long secondsBetweenBlocks,
final Address localNodeAddress,
final ProtocolSpecBuilder specBuilder,
final boolean goQuorumMode) {
final ProtocolSpecBuilder specBuilder) {

return specBuilder
.blockHeaderValidatorBuilder(
Expand All @@ -121,7 +118,7 @@ private static ProtocolSpecBuilder applyCliqueSpecificModifications(
baseFeeMarket ->
getBlockHeaderValidator(epochManager, secondsBetweenBlocks, baseFeeMarket))
.blockBodyValidatorBuilder(MainnetBlockBodyValidator::new)
.blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder(goQuorumMode))
.blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder())
.blockImporterBuilder(MainnetBlockImporter::new)
.difficultyCalculator(new CliqueDifficultyCalculator(localNodeAddress))
.blockReward(Wei.ZERO)
Expand Down
Loading

0 comments on commit 044aff1

Please sign in to comment.