Enable CLI config for privacy precompiled contract address (#653)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Puneetha Karamsetty 6 years ago committed by Rob Dawson
parent 2ef0694c6f
commit b3fe49783e
  1. 7
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/Address.java
  2. 11
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/PrivacyParameters.java
  3. 5
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetPrecompiledContractRegistries.java
  4. 8
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  5. 3
      pantheon/src/test/resources/everything_config.toml

@ -39,7 +39,8 @@ public class Address extends DelegatingBytesValue {
public static final Address ALTBN128_PAIRING = Address.precompiled(8);
// Last address that can be generated for a pre-compiled contract
public static final Address DEFAULT_PRIVACY = Address.precompiled(Byte.MAX_VALUE - 1);
public static final Integer PRIVACY = Byte.MAX_VALUE - 1;
public static final Address DEFAULT_PRIVACY = Address.precompiled(PRIVACY);
protected Address(final BytesValue bytes) {
super(bytes);
@ -103,6 +104,10 @@ public class Address extends DelegatingBytesValue {
return new Address(BytesValue.wrap(address));
}
public static Address privacyPrecompiled(final int value) {
return precompiled(value);
}
/**
* Address of the created contract.
*

@ -16,10 +16,10 @@ import java.io.File;
import java.net.URI;
public class PrivacyParameters {
private static final String ORION_URL = "http://localhost:8888";
public static final URI DEFAULT_ORION_URL = URI.create(ORION_URL);
private Integer privacyAddress;
private boolean enabled;
private String url;
private File publicKey;
@ -36,6 +36,7 @@ public class PrivacyParameters {
final PrivacyParameters config = new PrivacyParameters();
config.setEnabled(false);
config.setUrl(ORION_URL);
config.setPrivacyAddress(Address.PRIVACY);
return config;
}
@ -59,4 +60,12 @@ public class PrivacyParameters {
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
public Integer getPrivacyAddress() {
return privacyAddress;
}
public void setPrivacyAddress(final Integer privacyAddress) {
this.privacyAddress = privacyAddress;
}
}

@ -64,8 +64,11 @@ public abstract class MainnetPrecompiledContractRegistries {
public static PrecompileContractRegistry appendPrivacy(
final PrecompileContractRegistry registry,
final PrecompiledContractConfiguration precompiledContractConfiguration) {
Address address =
Address.privacyPrecompiled(
precompiledContractConfiguration.getPrivacyParameters().getPrivacyAddress());
registry.put(
Address.DEFAULT_PRIVACY,
address,
new PrivacyPrecompiledContract(
precompiledContractConfiguration.getGasCalculator(),
precompiledContractConfiguration.getPrivacyParameters()));

@ -498,6 +498,13 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
)
private final Boolean privacyEnabled = false;
@Option(
names = {"--privacy-precompiled-address"},
description =
"The address to which the privacy pre-compiled contract will be mapped to (default: ${DEFAULT-VALUE})"
)
private final Integer privacyPrecompiledAddress = Address.PRIVACY;
public PantheonCommand(
final BlockImporter blockImporter,
final RunnerBuilder runnerBuilder,
@ -686,6 +693,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
privacyParameters.setEnabled(privacyEnabled);
privacyParameters.setUrl(privacyUrl.toString());
privacyParameters.setPublicKey(privacyPublicKeyFile);
privacyParameters.setPrivacyAddress(privacyPrecompiledAddress);
return privacyParameters;
}

@ -71,4 +71,5 @@ nodes-whitelist=["all"]
# Privacy
privacy-url="http://127.0.0.1:8888"
privacy-public-key-file="./pubKey.pub"
privacy-enabled=false
privacy-enabled=false
privacy-precompiled-address=9
Loading…
Cancel
Save