diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/Address.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/Address.java index 7d167048c2..2c99725730 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/Address.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/Address.java @@ -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. * diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/PrivacyParameters.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/PrivacyParameters.java index 14a01b3f96..b46b1fa18b 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/PrivacyParameters.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/PrivacyParameters.java @@ -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; + } } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetPrecompiledContractRegistries.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetPrecompiledContractRegistries.java index f2e84b218d..5907adb28e 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetPrecompiledContractRegistries.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetPrecompiledContractRegistries.java @@ -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())); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index 99fc395486..6ce57e537b 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -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; } diff --git a/pantheon/src/test/resources/everything_config.toml b/pantheon/src/test/resources/everything_config.toml index ef80aa7110..a4fa3171d8 100644 --- a/pantheon/src/test/resources/everything_config.toml +++ b/pantheon/src/test/resources/everything_config.toml @@ -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 \ No newline at end of file +privacy-enabled=false +privacy-precompiled-address=9 \ No newline at end of file