Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go quorum interop #1782

Merged
merged 61 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
8e524d1
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
31ab133
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
eb693b1
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
e3631a9
changes based on comments
pinges Nov 26, 2020
a760ba0
changes based on comments
pinges Nov 26, 2020
1970507
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Nov 26, 2020
d254e22
changes based on comments
pinges Nov 26, 2020
5a37b4b
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 1, 2020
700eff0
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 3, 2020
55e59d4
add quorum raw private transactions
pinges Dec 14, 2020
2985980
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 14, 2020
424a33d
some changes
pinges Dec 15, 2020
b12bc00
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 16, 2020
dbbd27e
merge privacy configuration
pinges Dec 17, 2020
2c43940
Initial goquorum private tx processing
lucassaldanha Dec 17, 2020
119a9d2
Added GoQuorumKeyValueStorage
lucassaldanha Dec 18, 2020
4adcf0b
Removed unecessary classes
lucassaldanha Dec 22, 2020
8774a89
Clenup
lucassaldanha Dec 27, 2020
28687be
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 30, 2020
2b0fefc
private Tx mined by quorum, but import into besu fails with 'invalid …
pinges Dec 31, 2020
a785608
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Jan 11, 2021
5e4635f
tests passing after rebase with Lucas branch
pinges Jan 11, 2021
d2e2506
spotless
pinges Jan 11, 2021
b0a1aed
merged in changes from master. All tests passing
pinges Jan 12, 2021
410cd83
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 12, 2021
4af37ab
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 13, 2021
47e9c11
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Jan 13, 2021
5f811ef
Merge branch 'createQuorumTransaction' into goQuorumInterop
pinges Jan 13, 2021
f69dd2a
add some debug sout
pinges Jan 13, 2021
a2e28ce
remove receive RPC method
pinges Jan 14, 2021
232100b
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 14, 2021
1d9431c
make quorum privacy configuration not use static
pinges Jan 15, 2021
f019692
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 15, 2021
063cd03
fix compile
pinges Jan 17, 2021
f9d5be1
fix test
pinges Jan 17, 2021
bfb8f17
fix test failure
pinges Jan 18, 2021
565bbf9
fix test failure
pinges Jan 18, 2021
dfbbc0e
fix test failure
pinges Jan 18, 2021
0bc3b6e
fix test failure
pinges Jan 18, 2021
e744047
fix test failure
pinges Jan 18, 2021
ee0e4b3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 18, 2021
365618b
fix AT NullPointerExceptions
pinges Jan 19, 2021
f45b539
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 19, 2021
424dff5
remove another static field
pinges Jan 19, 2021
b0db717
some cleanup
pinges Jan 19, 2021
ffa56b3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
bafc3d6
more cleanup
pinges Jan 20, 2021
1cad6ce
even more cleanup
pinges Jan 20, 2021
0042fdf
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
da6c97e
and even more cleanup
pinges Jan 20, 2021
17eec25
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
1fb251d
fix a unit test
pinges Jan 20, 2021
c806616
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
314234e
fixes after review from Sally
pinges Jan 22, 2021
7e7ebd3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 22, 2021
73e96f2
merge master and somes fixes after review from Mark
pinges Jan 27, 2021
97dfe34
changes after comments from Lucas
pinges Jan 27, 2021
64ab12e
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 27, 2021
a9d583e
fix spotless
pinges Jan 27, 2021
d08eb35
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 28, 2021
8710904
remove some comments
pinges Jan 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 61 additions & 35 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_PORT;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_JSON_RPC_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration.DEFAULT_WEBSOCKET_PORT;
import static org.hyperledger.besu.ethereum.permissioning.QuorumPermissioningConfiguration.QIP714_DEFAULT_BLOCK;
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 @@ -112,16 +112,21 @@
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.p2p.peers.StaticNodesParser;
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;
import org.hyperledger.besu.ethereum.permissioning.QuorumPermissioningConfiguration;
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.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.metrics.BesuMetricCategory;
import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
import org.hyperledger.besu.metrics.MetricsProtocol;
Expand Down Expand Up @@ -912,7 +917,7 @@ void setBannedNodeIds(final List<String> values) {
description = "The URL on which the enclave is running")
private final URI privacyUrl = PrivacyParameters.DEFAULT_ENCLAVE_URL;

@CommandLine.Option(
@Option(
names = {"--privacy-public-key-file"},
description = "The enclave's public key file")
private final File privacyPublicKeyFile = null;
Expand Down Expand Up @@ -1082,6 +1087,7 @@ void setBannedNodeIds(final List<String> values) {
Suppliers.memoize(() -> MetricsSystemFactory.create(metricsConfiguration()));
private Vertx vertx;
private EnodeDnsConfiguration enodeDnsConfiguration;
private KeyValueStorageProvider keyValueStorageProvider;

public BesuCommand(
final Logger logger,
Expand Down Expand Up @@ -1546,21 +1552,17 @@ private BesuCommand configure() throws Exception {
.ifPresent(p -> ensureAllNodesAreInAllowlist(staticNodes, p));
metricsConfiguration = metricsConfiguration();

if (isGoQuorumCompatibilityMode) {
configureGoQuorumPrivacy();
}

logger.info("Security Module: {}", securityModuleName);
return this;
}

private void configureGoQuorumPrivacy() {

GoQuorumPrivacyParameters.isEnabled = true;

GoQuorumPrivacyParameters.goQuorumEnclave = createGoQuorumEnclave();

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

private GoQuorumEnclave createGoQuorumEnclave() {
Expand Down Expand Up @@ -1624,6 +1626,7 @@ public BesuController buildController() {
}

public BesuControllerBuilder getControllerBuilder() {
final KeyValueStorageProvider storageProvider = keyValueStorageProvider(keyValueStorageName);
return controllerBuilderFactory
.fromEthNetworkConfig(updateNetworkConfig(getNetwork()), genesisConfigOverrides)
.synchronizerConfiguration(buildSyncConfig())
Expand All @@ -1646,10 +1649,10 @@ public BesuControllerBuilder getControllerBuilder() {
.transactionPoolConfiguration(buildTransactionPoolConfiguration())
.nodeKey(buildNodeKey())
.metricsSystem(metricsSystem.get())
.privacyParameters(privacyParameters())
.privacyParameters(privacyParameters(storageProvider))
.clock(Clock.systemUTC())
.isRevertReasonEnabled(isRevertReasonEnabled)
.storageProvider(keyStorageProvider(keyValueStorageName))
.storageProvider(storageProvider)
.isPruningEnabled(isPruningEnabled())
.pruningConfiguration(
new PrunerConfiguration(pruningBlockConfirmations, pruningBlocksRetained))
Expand Down Expand Up @@ -1990,7 +1993,7 @@ private Optional<PermissioningConfiguration> permissioningConfiguration() throws
return Optional.of(permissioningConfiguration);
}

private Optional<QuorumPermissioningConfiguration> quorumPermissioningConfig() {
private Optional<GoQuorumPermissioningConfiguration> quorumPermissioningConfig() {
if (!isGoQuorumCompatibilityMode) {
return Optional.empty();
}
Expand All @@ -1999,7 +2002,8 @@ private Optional<QuorumPermissioningConfiguration> quorumPermissioningConfig() {
final GenesisConfigOptions genesisConfigOptions = readGenesisConfigOptions();
final OptionalLong qip714BlockNumber = genesisConfigOptions.getQip714BlockNumber();
return Optional.of(
QuorumPermissioningConfiguration.enabled(qip714BlockNumber.orElse(QIP714_DEFAULT_BLOCK)));
GoQuorumPermissioningConfiguration.enabled(
qip714BlockNumber.orElse(QIP714_DEFAULT_BLOCK)));
} catch (final Exception e) {
throw new IllegalStateException("Error reading GoQuorum permissioning options", e);
}
Expand All @@ -2013,7 +2017,7 @@ private boolean contractPermissionsEnabled() {
return permissionsNodesContractEnabled || permissionsAccountsContractEnabled;
}

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

CommandLineUtils.checkOptionDependencies(
logger,
Expand Down Expand Up @@ -2094,10 +2098,18 @@ private PrivacyParameters privacyParameters() {
privacyParametersBuilder.setPrivacyTlsKnownEnclaveFile(privacyTlsKnownEnclaveFile);
}
privacyParametersBuilder.setEnclaveFactory(new EnclaveFactory(vertx));
} else {
if (anyPrivacyApiEnabled()) {
logger.warn("Privacy is disabled. Cannot use EEA/PRIV API methods when not using Privacy.");
}
} else if (isGoQuorumCompatibilityMode) {
privacyParametersBuilder.setGoQuorumPrivacyParameters(
Optional.of(configureGoQuorumPrivacy(storageProvider)));
}

if (!isPrivacyEnabled && anyPrivacyApiEnabled()) {
macfarla marked this conversation as resolved.
Show resolved Hide resolved
logger.warn("Privacy is disabled. Cannot use EEA/PRIV API methods when not using Privacy.");
}

if (!isGoQuorumCompatibilityMode
&& (rpcHttpApis.contains(RpcApis.GOQUORUM) || rpcWsApis.contains(RpcApis.GOQUORUM))) {
logger.warn("Cannot use GOQUORUM API methods when not in GoQuorum mode.");
}

final PrivacyParameters privacyParameters = privacyParametersBuilder.build();
Expand All @@ -2110,6 +2122,14 @@ private PrivacyParameters privacyParameters() {
return privacyParameters;
}

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

private boolean anyPrivacyApiEnabled() {
return rpcHttpApis.contains(RpcApis.EEA)
|| rpcWsApis.contains(RpcApis.EEA)
Expand All @@ -2133,16 +2153,22 @@ private PrivacyKeyValueStorageFactory privacyKeyValueStorageFactory(final String
() -> new StorageException("No KeyValueStorageFactory found for key: " + name));
}

private KeyValueStorageProvider keyStorageProvider(final String name) {
return new KeyValueStorageProviderBuilder()
.withStorageFactory(
storageService
.getByName(name)
.orElseThrow(
() -> new StorageException("No KeyValueStorageFactory found for key: " + name)))
.withCommonConfiguration(pluginCommonConfiguration)
.withMetricsSystem(getMetricsSystem())
.build();
private KeyValueStorageProvider keyValueStorageProvider(final String name) {
if (this.keyValueStorageProvider == null) {
this.keyValueStorageProvider =
new KeyValueStorageProviderBuilder()
.withStorageFactory(
storageService
.getByName(name)
.orElseThrow(
() ->
new StorageException(
"No KeyValueStorageFactory found for key: " + name)))
.withCommonConfiguration(pluginCommonConfiguration)
.withMetricsSystem(getMetricsSystem())
.build();
}
return this.keyValueStorageProvider;
}

private SynchronizerConfiguration buildSyncConfig() {
Expand Down Expand Up @@ -2226,7 +2252,7 @@ private void synchronize(
.autoLogBloomCaching(autoLogBloomCachingEnabled)
.ethstatsUrl(unstableEthstatsOptions.getEthstatsUrl())
.ethstatsContact(unstableEthstatsOptions.getEthstatsContact())
.storageProvider(keyStorageProvider(keyValueStorageName))
.storageProvider(keyValueStorageProvider(keyValueStorageName))
.build();

addShutdownHook(runner);
Expand Down Expand Up @@ -2515,7 +2541,7 @@ private void checkGoQuorumCompatibilityConfig(final EthNetworkConfig ethNetworkC
if (isGoQuorumCompatibilityMode) {
final GenesisConfigOptions genesisConfigOptions = readGenesisConfigOptions();
// this static flag is read by the RLP decoder
GoQuorumOptions.goquorumCompatibilityMode = true;
GoQuorumOptions.goQuorumCompatibilityMode = true;

if (!genesisConfigOptions.isQuorum()) {
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public class GoQuorumOptions {
// To make it easier for tests to reset the value to default
public static final boolean GOQUORUM_COMPATIBILITY_MODE_DEFAULT_VALUE = false;

public static boolean goquorumCompatibilityMode = GOQUORUM_COMPATIBILITY_MODE_DEFAULT_VALUE;
public static boolean goQuorumCompatibilityMode = GOQUORUM_COMPATIBILITY_MODE_DEFAULT_VALUE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.consensus.common.EpochManager;
import org.hyperledger.besu.crypto.NodeKey;
import org.hyperledger.besu.ethereum.MainnetBlockValidator;
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
Expand All @@ -28,6 +27,7 @@
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockBodyValidator;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockImporter;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSpecs;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
Expand Down Expand Up @@ -70,7 +70,8 @@ public static ProtocolSchedule create(
cliqueConfig.getBlockPeriodSeconds(),
localNodeAddress,
builder,
eip1559),
eip1559,
privacyParameters.getGoQuorumPrivacyParameters().isPresent()),
privacyParameters,
isRevertReasonEnabled,
config.isQuorum())
Expand All @@ -89,15 +90,16 @@ private static ProtocolSpecBuilder applyCliqueSpecificModifications(
final long secondsBetweenBlocks,
final Address localNodeAddress,
final ProtocolSpecBuilder specBuilder,
final Optional<EIP1559> eip1559) {
final Optional<EIP1559> eip1559,
final boolean goQuorumMode) {

return specBuilder
.blockHeaderValidatorBuilder(
getBlockHeaderValidator(epochManager, secondsBetweenBlocks, eip1559))
.ommerHeaderValidatorBuilder(
getBlockHeaderValidator(epochManager, secondsBetweenBlocks, eip1559))
.blockBodyValidatorBuilder(MainnetBlockBodyValidator::new)
.blockValidatorBuilder(MainnetBlockValidator::new)
.blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder(goQuorumMode))
.blockImporterBuilder(MainnetBlockImporter::new)
.difficultyCalculator(new CliqueDifficultyCalculator(localNodeAddress))
.blockReward(Wei.ZERO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.MainnetBlockValidator;
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockBodyValidator;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockImporter;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSpecs;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
Expand All @@ -43,7 +43,7 @@ public static ProtocolSchedule create(
return new ProtocolScheduleBuilder(
config,
DEFAULT_CHAIN_ID,
builder -> applyBftChanges(config.getBftConfigOptions(), builder),
builder -> applyBftChanges(config.getBftConfigOptions(), builder, config.isQuorum()),
privacyParameters,
isRevertReasonEnabled,
config.isQuorum())
Expand All @@ -60,7 +60,9 @@ public static ProtocolSchedule create(final GenesisConfigOptions config) {
}

private static ProtocolSpecBuilder applyBftChanges(
final BftConfigOptions configOptions, final ProtocolSpecBuilder builder) {
final BftConfigOptions configOptions,
final ProtocolSpecBuilder builder,
final boolean goQuorumMode) {

if (configOptions.getEpochLength() <= 0) {
throw new IllegalArgumentException("Epoch length in config must be greater than zero");
Expand All @@ -74,7 +76,7 @@ private static ProtocolSpecBuilder applyBftChanges(
.blockHeaderValidatorBuilder(bftBlockHeaderValidator(configOptions.getBlockPeriodSeconds()))
.ommerHeaderValidatorBuilder(bftBlockHeaderValidator(configOptions.getBlockPeriodSeconds()))
.blockBodyValidatorBuilder(MainnetBlockBodyValidator::new)
.blockValidatorBuilder(MainnetBlockValidator::new)
.blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder(goQuorumMode))
.blockImporterBuilder(MainnetBlockImporter::new)
.difficultyCalculator((time, parent, protocolContext) -> BigInteger.ONE)
.blockReward(Wei.of(configOptions.getBlockRewardWei()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.MainnetBlockValidator;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockBodyValidator;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockImporter;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSpecs;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
Expand All @@ -44,7 +44,7 @@ public static ProtocolSchedule create(
return new ProtocolScheduleBuilder(
config,
DEFAULT_CHAIN_ID,
builder -> applyIbftChanges(blockPeriod, builder),
builder -> applyIbftChanges(blockPeriod, builder, config.isQuorum()),
privacyParameters,
isRevertReasonEnabled,
config.isQuorum())
Expand All @@ -57,12 +57,14 @@ public static ProtocolSchedule create(
}

private static ProtocolSpecBuilder applyIbftChanges(
final long secondsBetweenBlocks, final ProtocolSpecBuilder builder) {
final long secondsBetweenBlocks,
final ProtocolSpecBuilder builder,
final boolean goQuorumMode) {
return builder
.blockHeaderValidatorBuilder(ibftBlockHeaderValidator(secondsBetweenBlocks))
.ommerHeaderValidatorBuilder(ibftBlockHeaderValidator(secondsBetweenBlocks))
.blockBodyValidatorBuilder(MainnetBlockBodyValidator::new)
.blockValidatorBuilder(MainnetBlockValidator::new)
.blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder(goQuorumMode))
.blockImporterBuilder(MainnetBlockImporter::new)
.difficultyCalculator((time, parent, protocolContext) -> BigInteger.ONE)
.blockReward(Wei.ZERO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class RpcApis {
public static final RpcApi TX_POOL = new RpcApi("TXPOOL");
public static final RpcApi TRACE = new RpcApi("TRACE");
public static final RpcApi PLUGINS = new RpcApi("PLUGINS");
public static final RpcApi GOQUORUM = new RpcApi("GOQUORUM");

public static final List<RpcApi> DEFAULT_JSON_RPC_APIS = Arrays.asList(ETH, NET, WEB3);

Expand Down Expand Up @@ -64,6 +65,8 @@ public static Optional<RpcApi> valueOf(final String name) {
return Optional.of(TRACE);
} else if (name.equals(PLUGINS.getCliValue())) {
return Optional.of(PLUGINS);
} else if (name.equals(GOQUORUM.getCliValue())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this leaving up to the user to enable the GOQUORUM methods? Do we really need to do this? We should always use the GoQuorum "versions" of the methods if GoQuorum mode is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be an easy change and we should discuss that. Would prefer to do that after the PR is merged!

return Optional.of(GOQUORUM);
} else {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ public enum RpcMethod {
ETH_GET_UNCLE_COUNT_BY_BLOCK_NUMBER("eth_getUncleCountByBlockNumber"),
ETH_GET_WORK("eth_getWork"),
ETH_HASHRATE("eth_hashrate"),
ETH_SUBMIT_HASHRATE("eth_submitHashrate"),
ETH_MINING("eth_mining"),
ETH_NEW_BLOCK_FILTER("eth_newBlockFilter"),
ETH_NEW_FILTER("eth_newFilter"),
ETH_NEW_PENDING_TRANSACTION_FILTER("eth_newPendingTransactionFilter"),
ETH_PROTOCOL_VERSION("eth_protocolVersion"),
ETH_SEND_RAW_PRIVATE_TRANSACTION("eth_sendRawPrivateTransaction"),
ETH_SEND_RAW_TRANSACTION("eth_sendRawTransaction"),
ETH_SEND_TRANSACTION("eth_sendTransaction"),
ETH_SUBMIT_HASHRATE("eth_submitHashrate"),
ETH_SUBMIT_WORK("eth_submitWork"),
ETH_SUBSCRIBE("eth_subscribe"),
ETH_SYNCING("eth_syncing"),
Expand Down
Loading