Skip to content

Commit

Permalink
Cherrypick g cprivacy (#2514)
Browse files Browse the repository at this point in the history
* add eth_getQuorumPayload (#2470)

* add eth_getQuorumPayload

Signed-off-by: Stefan Pingel <[email protected]>

* remove unnecessary CLI flag (#2478)

* remove unnecessary CLI flag

Signed-off-by: Stefan Pingel <[email protected]>

* no trace for method calls in private tx simulator (#2482)

* no trace for method calls in private tx simulator

Signed-off-by: Sally MacFarlane <[email protected]>

* GraphQL schema + adapter updates to handle GoQuorum transaction fields (#2490)

* Added graphQL schema update and associated Adapter methods.

Signed-off-by: Mark Terry <[email protected]>
Signed-off-by: Stefan Pingel <[email protected]>

* let acceptanceTestsQuorum fail the loop

Signed-off-by: Stefan Pingel <[email protected]>

Co-authored-by: Sally MacFarlane <[email protected]>
Co-authored-by: mark-terry <[email protected]>
  • Loading branch information
3 people authored Jul 8, 2021
1 parent 1e48e6d commit 4a4730c
Show file tree
Hide file tree
Showing 23 changed files with 436 additions and 196 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 21.7.1

### Additions and Improvements
- `priv_call` now uses NO_TRACING OperationTracer implementation which improves memory usage [\#2482](https://github.com/hyperledger/besu/pull/2482)

## 21.7.0

### Additions and Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class PermissioningPluginTest extends AcceptanceTestBase {

@Before
public void setUp() throws Exception {
BesuNodeConfigurationBuilder builder =
final BesuNodeConfigurationBuilder builder =
new BesuNodeConfigurationBuilder()
.miningEnabled(false)
.plugins(Collections.singletonList("testPlugins"))
Expand Down Expand Up @@ -86,9 +86,9 @@ public void transactionsAreNotSendToBlockPendingTransactionsNode() {
final Account account = accounts.createAccount("account-one");
final Amount balance = Amount.ether(20);

TransferTransaction tx = accountTransactions.createTransfer(account, balance);
final TransferTransaction tx = accountTransactions.createTransfer(account, balance);

Hash txHash = aliceNode.execute(tx);
final Hash txHash = aliceNode.execute(tx);

aliceNode.verify(txPoolConditions.inTransactionPool(txHash));
bobNode.verify(txPoolConditions.inTransactionPool(txHash));
Expand Down
4 changes: 3 additions & 1 deletion besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,9 @@ public Runner build() {

Optional<GraphQLHttpService> graphQLHttpService = Optional.empty();
if (graphQLConfiguration.isEnabled()) {
final GraphQLDataFetchers fetchers = new GraphQLDataFetchers(supportedCapabilities);
final GraphQLDataFetchers fetchers =
new GraphQLDataFetchers(
supportedCapabilities, privacyParameters.getGoQuorumPrivacyParameters());
final GraphQLDataFetcherContextImpl dataFetcherContext =
new GraphQLDataFetcherContextImpl(
blockchainQueries,
Expand Down
67 changes: 22 additions & 45 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
"Allow for incoming connections to be prioritized randomly. This will prevent (typically small, stable) networks from forming impenetrable peer cliques. (default: ${DEFAULT-VALUE})")
private final Boolean randomPeerPriority = false;

private GenesisConfigOptions genesisConfigOptions;

@Option(
names = {"--banned-node-ids", "--banned-node-id"},
paramLabel = MANDATORY_NODE_ID_FORMAT_HELP,
Expand Down Expand Up @@ -1080,12 +1082,6 @@ void setBannedNodeIds(final List<String> values) {
description = "Maximum gas price for eth_gasPrice (default: ${DEFAULT-VALUE})")
private final Long apiGasPriceMax = 500_000_000_000L;

@Option(
names = {"--goquorum-compatibility-enabled"},
hidden = true,
description = "Start Besu in GoQuorum compatibility mode (default: ${DEFAULT-VALUE})")
private final Boolean isGoQuorumCompatibilityMode = false;

@CommandLine.Option(
names = {"--static-nodes-file"},
paramLabel = MANDATORY_FILE_FORMAT_HELP,
Expand Down Expand Up @@ -1114,6 +1110,7 @@ void setBannedNodeIds(final List<String> values) {
private Vertx vertx;
private EnodeDnsConfiguration enodeDnsConfiguration;
private KeyValueStorageProvider keyValueStorageProvider;
private Boolean isGoQuorumCompatibilityMode = false;

public BesuCommand(
final Logger logger,
Expand Down Expand Up @@ -1190,6 +1187,17 @@ public void run() {

try {
configureLogging(true);

// Set the goquorum compatibility mode based on the genesis file
if (genesisFile != null) {
genesisConfigOptions = readGenesisConfigOptions();
if (genesisConfigOptions.isQuorum()) {
// this static flag is read by the RLP decoder
GoQuorumOptions.goQuorumCompatibilityMode = true;
isGoQuorumCompatibilityMode = true;
}
}

instantiateSignatureAlgorithmFactory();
configureNativeLibs();
logger.info("Starting Besu version: {}", BesuInfo.nodeName(identityString));
Expand Down Expand Up @@ -1533,7 +1541,7 @@ private void issueOptionWarnings() {
CommandLineUtils.checkMultiOptionDependencies(
logger,
commandLine,
List.of("--miner-enabled", "--goquorum-compatibility-enabled"),
"--min-gas-price ignored because none of --miner-enabled or isQuorum (in genesis file) was defined.",
List.of(!isMiningEnabled, !isGoQuorumCompatibilityMode),
singletonList("--min-gas-price"));

Expand Down Expand Up @@ -1564,7 +1572,6 @@ private void configure() throws Exception {

ethNetworkConfig = updateNetworkConfig(getNetwork());

checkGoQuorumGenesisConfig();
checkGoQuorumCompatibilityConfig(ethNetworkConfig);

jsonRpcConfiguration = jsonRpcConfiguration();
Expand Down Expand Up @@ -1626,7 +1633,7 @@ private String readEnclaveKey() {
} catch (final Exception e) {
throw new ParameterException(
this.commandLine,
"--privacy-public-key-file must be set when --goquorum-compatibility-enabled is set to true.",
"--privacy-public-key-file must be set if isQuorum is set in the genesis file.",
e);
}
if (key.length() != 44) {
Expand Down Expand Up @@ -2050,7 +2057,6 @@ private Optional<GoQuorumPermissioningConfiguration> quorumPermissioningConfig()
}

try {
final GenesisConfigOptions genesisConfigOptions = readGenesisConfigOptions();
final OptionalLong qip714BlockNumber = genesisConfigOptions.getQip714BlockNumber();
return Optional.of(
GoQuorumPermissioningConfiguration.enabled(
Expand Down Expand Up @@ -2080,7 +2086,7 @@ private PrivacyParameters privacyParameters(final KeyValueStorageProvider storag
CommandLineUtils.checkMultiOptionDependencies(
logger,
commandLine,
List.of("--privacy-enabled", "--goquorum-compatibility-enabled"),
"--privacy-url and/or --privacy-public-key-file ignored because none of --privacy-enabled or isQuorum (in genesis file) was defined.",
List.of(!isPrivacyEnabled, !isGoQuorumCompatibilityMode),
List.of("--privacy-url", "--privacy-public-key-file"));

Expand Down Expand Up @@ -2601,42 +2607,16 @@ private void addPortIfEnabled(
}
}

private void checkGoQuorumGenesisConfig() {
if (genesisFile != null) {
if (readGenesisConfigOptions().isQuorum() && !isGoQuorumCompatibilityMode) {
throw new IllegalStateException(
"Cannot use GoQuorum genesis file without GoQuorum privacy enabled");
}
}
}

private void checkGoQuorumCompatibilityConfig(final EthNetworkConfig ethNetworkConfig) {
if (isGoQuorumCompatibilityMode) {
if (genesisFile == null) {
throw new ParameterException(
this.commandLine,
"--genesis-file must be specified if GoQuorum compatibility mode is enabled.");
}

final GenesisConfigOptions genesisConfigOptions = readGenesisConfigOptions();

// this static flag is read by the RLP decoder
GoQuorumOptions.goQuorumCompatibilityMode = true;

if (!genesisConfigOptions.isQuorum()) {
throw new IllegalStateException(
"GoQuorum compatibility mode (enabled) can only be used if genesis file has 'isQuorum' flag set to true.");
}

if (!minTransactionGasPrice.isZero()) {
throw new ParameterException(
this.commandLine,
"--min-gas-price must be set to zero if GoQuorum compatibility is enabled in the genesis config.");
"--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, "GoQuorum compatibility mode (enabled) cannot be used on Mainnet.");
throw new ParameterException(this.commandLine, "isQuorum mode cannot be used on Mainnet.");
}
}
}
Expand Down Expand Up @@ -2681,7 +2661,7 @@ private void instantiateSignatureAlgorithmFactory() {
return;
}

Optional<String> ecCurve = getEcCurveFromGenesisFile();
final Optional<String> ecCurve = getEcCurveFromGenesisFile();

if (ecCurve.isEmpty()) {
SignatureAlgorithmFactory.setDefaultInstance();
Expand All @@ -2690,7 +2670,7 @@ private void instantiateSignatureAlgorithmFactory() {

try {
SignatureAlgorithmFactory.setInstance(SignatureAlgorithmType.create(ecCurve.get()));
} catch (IllegalArgumentException e) {
} catch (final IllegalArgumentException e) {
throw new CommandLine.InitializationException(
new StringBuilder()
.append("Invalid genesis file configuration for ecCurve. ")
Expand All @@ -2703,9 +2683,6 @@ private Optional<String> getEcCurveFromGenesisFile() {
if (genesisFile == null) {
return Optional.empty();
}

GenesisConfigOptions options = readGenesisConfigOptions();

return options.getEcCurve();
return genesisConfigOptions.getEcCurve();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,25 @@ public static void checkOptionDependencies(
* that could replace this. See https://github.com/remkop/picocli/issues/295
*
* @param logger the logger instance used to log the warning
* @param commandLine the command line containing the options we want to check
* @param mainOptions the names of the main options to test dependency against. Only used for
* display.
* @param commandLine the command line containing the options we want to check display.
* @param stringToLog the string that is going to be logged.
* @param isMainOptionCondition the conditions to test dependent options against. If all
* conditions are true, dependent options will be checked.
* @param dependentOptionsNames a list of option names that can't be used if condition is met.
* Example: if --min-gas-price is in the list and condition is that either --miner-enabled or
* --goquorum-compatibility-enabled should not be false, we log a warning.
* Example: if --min-gas-price is in the list and condition is that --miner-enabled should not
* be false, we log a warning.
*/
public static void checkMultiOptionDependencies(
final Logger logger,
final CommandLine commandLine,
final List<String> mainOptions,
final String stringToLog,
final List<Boolean> isMainOptionCondition,
final List<String> dependentOptionsNames) {
if (isMainOptionCondition.stream().allMatch(isTrue -> isTrue)) {
final String affectedOptions = getAffectedOptions(commandLine, dependentOptionsNames);

if (!affectedOptions.isEmpty()) {
final String joinedMainOptions =
StringUtils.joiningWithLastDelimiter(", ", " or ").apply(mainOptions);
logger.warn(MULTI_DEPENDENCY_WARNING_MSG, affectedOptions, joinedMainOptions);
logger.warn(stringToLog);
}
}
}
Expand Down
Loading

0 comments on commit 4a4730c

Please sign in to comment.