Skip to content

Commit

Permalink
Disable native encryption in acceptance tests (#835)
Browse files Browse the repository at this point in the history
Add a configuration option that disables the secp256k1 and altbn128 native libraries during acceptance tests.
This option is disabled by default.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
  • Loading branch information
shemnon authored May 7, 2020
1 parent 4708071 commit e8dd0cb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private final boolean discoveryEnabled;
private final List<URI> bootnodes = new ArrayList<>();
private final boolean bootnodeEligible;
private final boolean secp256k1Native;
private final boolean altbn128Native;
private Optional<String> genesisConfig = Optional.empty();
private NodeRequests nodeRequests;
private LoginRequestFactory loginRequestFactory;
Expand All @@ -125,14 +127,14 @@ public BesuNode(
final boolean discoveryEnabled,
final boolean bootnodeEligible,
final boolean revertReasonEnabled,
final boolean secp256k1Native,
final boolean altbn128Native,
final List<String> plugins,
final List<String> extraCLIOptions,
final List<String> staticNodes,
final Optional<PrivacyParameters> privacyParameters,
final Optional<String> runCommand)
throws IOException {
this.bootnodeEligible = bootnodeEligible;
this.revertReasonEnabled = revertReasonEnabled;
this.homeDirectory = dataPath.orElseGet(BesuNode::createTmpDataDirectory);
keyfilePath.ifPresent(
path -> {
Expand All @@ -154,6 +156,10 @@ public BesuNode(
this.p2pEnabled = p2pEnabled;
this.networkingConfiguration = networkingConfiguration;
this.discoveryEnabled = discoveryEnabled;
this.bootnodeEligible = bootnodeEligible;
this.revertReasonEnabled = revertReasonEnabled;
this.secp256k1Native = secp256k1Native;
this.altbn128Native = altbn128Native;
this.runCommand = runCommand;
plugins.forEach(
pluginName -> {
Expand Down Expand Up @@ -562,6 +568,14 @@ public boolean isDevMode() {
return devMode;
}

public boolean isSecp256k1Native() {
return secp256k1Native;
}

public boolean isAltbn128Native() {
return altbn128Native;
}

@Override
public boolean isDiscoveryEnabled() {
return discoveryEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ public void startNode(final BesuNode node) {
params.add("--revert-reason-enabled");
}

params.add("--Xsecp256k1-native-enabled=" + node.isSecp256k1Native());
params.add("--Xaltbn128-native-enabled=" + node.isAltbn128Native());

node.getPermissioningConfiguration()
.flatMap(PermissioningConfiguration::getLocalConfig)
.ifPresent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class BesuNodeConfiguration {
private final boolean discoveryEnabled;
private final boolean bootnodeEligible;
private final boolean revertReasonEnabled;
private final boolean secp256k1Native;
private final boolean altbn128Native;
private final List<String> plugins;
private final List<String> extraCLIOptions;
private final List<String> staticNodes;
Expand All @@ -66,6 +68,8 @@ public class BesuNodeConfiguration {
final boolean discoveryEnabled,
final boolean bootnodeEligible,
final boolean revertReasonEnabled,
final boolean secp256k1Native,
final boolean altbn128Native,
final List<String> plugins,
final List<String> extraCLIOptions,
final List<String> staticNodes,
Expand All @@ -86,6 +90,8 @@ public class BesuNodeConfiguration {
this.discoveryEnabled = discoveryEnabled;
this.bootnodeEligible = bootnodeEligible;
this.revertReasonEnabled = revertReasonEnabled;
this.secp256k1Native = secp256k1Native;
this.altbn128Native = altbn128Native;
this.plugins = plugins;
this.extraCLIOptions = extraCLIOptions;
this.staticNodes = staticNodes;
Expand Down Expand Up @@ -161,6 +167,14 @@ public boolean isRevertReasonEnabled() {
return revertReasonEnabled;
}

public boolean isSecp256k1Native() {
return secp256k1Native;
}

public boolean isAltbn128Native() {
return altbn128Native;
}

public List<String> getStaticNodes() {
return staticNodes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class BesuNodeConfigurationBuilder {
private boolean discoveryEnabled = true;
private boolean bootnodeEligible = true;
private boolean revertReasonEnabled = false;
private boolean secp256K1Native = false;
private boolean altbn128Native = false;
private final List<String> plugins = new ArrayList<>();
private final List<String> extraCLIOptions = new ArrayList<>();
private List<String> staticNodes = new ArrayList<>();
Expand Down Expand Up @@ -251,6 +253,16 @@ public BesuNodeConfigurationBuilder revertReasonEnabled() {
return this;
}

public BesuNodeConfigurationBuilder secp256k1Native() {
this.secp256K1Native = true;
return this;
}

public BesuNodeConfigurationBuilder altbn128() {
this.altbn128Native = true;
return this;
}

public BesuNodeConfigurationBuilder staticNodes(final List<String> staticNodes) {
this.staticNodes = staticNodes;
return this;
Expand Down Expand Up @@ -283,6 +295,8 @@ public BesuNodeConfiguration build() {
discoveryEnabled,
bootnodeEligible,
revertReasonEnabled,
secp256K1Native,
altbn128Native,
plugins,
extraCLIOptions,
staticNodes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public BesuNode create(final BesuNodeConfiguration config) throws IOException {
config.isDiscoveryEnabled(),
config.isBootnodeEligible(),
config.isRevertReasonEnabled(),
config.isSecp256k1Native(),
config.isAltbn128Native(),
config.getPlugins(),
config.getExtraCLIOptions(),
config.getStaticNodes(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public PrivacyNode(final PrivacyNodeConfiguration privacyConfiguration, final Ve
besuConfig.isDiscoveryEnabled(),
besuConfig.isBootnodeEligible(),
besuConfig.isRevertReasonEnabled(),
besuConfig.isSecp256k1Native(),
besuConfig.isAltbn128Native(),
besuConfig.getPlugins(),
besuConfig.getExtraCLIOptions(),
Collections.emptyList(),
Expand Down

0 comments on commit e8dd0cb

Please sign in to comment.