(internal) Refactor 'onchain' to 'flexible' where applicable (#3075)

* CLI option name change

Signed-off-by: Frank Li <b439988l@gmail.com>

* refactor privacyparameters.java and add deprecation warning

Signed-off-by: Frank Li <b439988l@gmail.com>

* more refactoring

Signed-off-by: Frank Li <b439988l@gmail.com>

* add to everything.toml

Signed-off-by: Frank Li <b439988l@gmail.com>

* bugs

Signed-off-by: Frank Li <b439988l@gmail.com>

* more missing variable names

Signed-off-by: Frank Li <b439988l@gmail.com>

* more classes

Signed-off-by: Frank Li <b439988l@gmail.com>

* more classes

Signed-off-by: Frank Li <b439988l@gmail.com>

* fix compile error

Signed-off-by: Frank Li <b439988l@gmail.com>

* add new test to invalidate passing both commands

Signed-off-by: Frank Li <b439988l@gmail.com>

* more refactoring + more tests

Signed-off-by: Frank Li <b439988l@gmail.com>

* new batch

Signed-off-by: Frank Li <b439988l@gmail.com>

* final batch?

Signed-off-by: Frank Li <b439988l@gmail.com>

* failing unit test

Signed-off-by: Frank Li <b439988l@gmail.com>

* revert incorrect refactoring back to onchain

Signed-off-by: Frank Li <b439988l@gmail.com>

* fix unit test

Signed-off-by: Frank Li <b439988l@gmail.com>

* comment

Signed-off-by: Frank Li <b439988l@gmail.com>

* comment

Signed-off-by: Frank Li <b439988l@gmail.com>

* support both privx methods

Signed-off-by: Frank Li <b439988l@gmail.com>

* add to changelog

Signed-off-by: Frank Li <b439988l@gmail.com>

* address comment

Signed-off-by: Frank Li <b439988l@gmail.com>

* add plugin privacy

Signed-off-by: Frank Li <b439988l@gmail.com>
pull/3104/head
Frank Li 3 years ago committed by GitHub
parent bf2fa40b4f
commit 183cdaf3e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
  3. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java
  4. 10
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeConfiguration.java
  5. 24
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeFactory.java
  6. 6
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java
  7. 12
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidFlexiblePrivacyGroupCreated.java
  8. 14
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateTransactionVerifier.java
  9. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToFlexiblePrivacyGroupTransaction.java
  10. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateFlexiblePrivacyGroupTransaction.java
  11. 10
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindFlexiblePrivacyGroupTransaction.java
  12. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockFlexiblePrivacyGroupTransaction.java
  13. 28
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivacyTransactions.java
  14. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromFlexiblePrivacyGroupTransaction.java
  15. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockFlexiblePrivacyGroupTransaction.java
  16. 40
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java
  17. 66
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTest.java
  18. 36
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTestBase.java
  19. 16
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java
  20. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java
  21. 69
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java
  22. 35
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/FlexibleMultiTenancyAcceptanceTest.java
  23. 16
      besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
  24. 27
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  25. 1
      besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java
  26. 11
      besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java
  27. 14
      besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
  28. 36
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  29. 1
      besu/src/test/resources/everything_config.toml
  30. 2
      enclave/src/main/java/org/hyperledger/besu/enclave/types/PrivacyGroup.java
  31. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java
  32. 22
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransaction.java
  33. 22
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java
  34. 80
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java
  35. 58
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindOnchainPrivacyGroup.java
  36. 14
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java
  37. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EeaJsonRpcMethods.java
  38. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethods.java
  39. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java
  40. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethods.java
  41. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/methods/PrivateWebSocketMethodsFactory.java
  42. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java
  43. 27
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java
  44. 20
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroupTest.java
  45. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethodsTest.java
  46. 21
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethodsTest.java
  47. 37
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java
  48. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java
  49. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java
  50. 12
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java
  51. 54
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContract.java
  52. 42
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyController.java
  53. 22
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyGroupContract.java
  54. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexibleUtil.java
  55. 24
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java
  56. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java
  57. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/group/FlexibleGroupManagement.java
  58. 6
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java
  59. 22
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java
  60. 29
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContractTest.java
  61. 34
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyControllerTest.java
  62. 16
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java
  63. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocatorTest.java
  64. 4
      evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java
  65. 42
      privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/DefaultFlexiblePrivacyGroupManagementContract.java
  66. 42
      privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/FlexiblePrivacyGroupManagementInterface.java
  67. 42
      privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/FlexiblePrivacyGroupManagementProxy.java
  68. 6
      privacy-contracts/src/main/solidity/DefaultFlexiblePrivacyGroupManagementContract.sol
  69. 4
      privacy-contracts/src/main/solidity/FlexiblePrivacyGroupManagementInterface.sol
  70. 22
      privacy-contracts/src/main/solidity/FlexiblePrivacyGroupManagementProxy.sol
  71. 8
      privacy-contracts/src/main/solidity/generateWrappers.sh

@ -4,6 +4,7 @@
### Additions and Improvements ### Additions and Improvements
- Adding support of the NO_COLOR environment variable as described in the [NO_COLOR](https://no-color.org/) standard [#3085](https://github.com/hyperledger/besu/pull/3085) - Adding support of the NO_COLOR environment variable as described in the [NO_COLOR](https://no-color.org/) standard [#3085](https://github.com/hyperledger/besu/pull/3085)
- Add `privx_findFlexiblePrivacyGroup` RPC Method, `privx_findOnchainPrivacyGroup` will be removed in a future release [#3075](https://github.com/hyperledger/besu/pull/3075)
### Bug Fixes ### Bug Fixes
### Early Access Features ### Early Access Features

@ -135,8 +135,8 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
params.add(node.homeDirectory().resolve("key").toString()); params.add(node.homeDirectory().resolve("key").toString());
} }
if (node.getPrivacyParameters().isOnchainPrivacyGroupsEnabled()) { if (node.getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
params.add("--privacy-onchain-groups-enabled"); params.add("--privacy-flexible-groups-enabled");
} }
if (node.getPrivacyParameters().isPrivacyPluginEnabled()) { if (node.getPrivacyParameters().isPrivacyPluginEnabled()) {

@ -224,14 +224,14 @@ public class BesuNodeFactory {
final String enclaveUrl, final String enclaveUrl,
final String authFile, final String authFile,
final String privTransactionSigningKey, final String privTransactionSigningKey,
final boolean enableOnchainPrivacy) final boolean enableFlexiblePrivacy)
throws IOException, URISyntaxException { throws IOException, URISyntaxException {
final PrivacyParameters.Builder privacyParametersBuilder = new PrivacyParameters.Builder(); final PrivacyParameters.Builder privacyParametersBuilder = new PrivacyParameters.Builder();
final PrivacyParameters privacyParameters = final PrivacyParameters privacyParameters =
privacyParametersBuilder privacyParametersBuilder
.setMultiTenancyEnabled(true) .setMultiTenancyEnabled(true)
.setEnabled(true) .setEnabled(true)
.setOnchainPrivacyGroupsEnabled(enableOnchainPrivacy) .setFlexiblePrivacyGroupsEnabled(enableFlexiblePrivacy)
.setStorageProvider(new InMemoryPrivacyStorageProvider()) .setStorageProvider(new InMemoryPrivacyStorageProvider())
.setEnclaveFactory(new EnclaveFactory(Vertx.vertx())) .setEnclaveFactory(new EnclaveFactory(Vertx.vertx()))
.setEnclaveUrl(URI.create(enclaveUrl)) .setEnclaveUrl(URI.create(enclaveUrl))

@ -19,7 +19,7 @@ import org.hyperledger.enclave.testutil.EnclaveKeyConfiguration;
public class PrivacyNodeConfiguration { public class PrivacyNodeConfiguration {
private final boolean isOnchainPrivacyGroupEnabled; private final boolean isFlexiblePrivacyGroupEnabled;
private final boolean isMultitenancyEnabled; private final boolean isMultitenancyEnabled;
private final boolean isPrivacyPluginEnabled; private final boolean isPrivacyPluginEnabled;
private final BesuNodeConfiguration besuConfig; private final BesuNodeConfiguration besuConfig;
@ -31,20 +31,20 @@ public class PrivacyNodeConfiguration {
} }
public PrivacyNodeConfiguration( public PrivacyNodeConfiguration(
final boolean isOnchainPrivacyGroupEnabled, final boolean isFlexiblePrivacyGroupEnabled,
final boolean isMultitenancyEnabled, final boolean isMultitenancyEnabled,
final boolean isPrivacyPluginEnabled, final boolean isPrivacyPluginEnabled,
final BesuNodeConfiguration besuConfig, final BesuNodeConfiguration besuConfig,
final EnclaveKeyConfiguration keyConfig) { final EnclaveKeyConfiguration keyConfig) {
this.isOnchainPrivacyGroupEnabled = isOnchainPrivacyGroupEnabled; this.isFlexiblePrivacyGroupEnabled = isFlexiblePrivacyGroupEnabled;
this.besuConfig = besuConfig; this.besuConfig = besuConfig;
this.keyConfig = keyConfig; this.keyConfig = keyConfig;
this.isMultitenancyEnabled = isMultitenancyEnabled; this.isMultitenancyEnabled = isMultitenancyEnabled;
this.isPrivacyPluginEnabled = isPrivacyPluginEnabled; this.isPrivacyPluginEnabled = isPrivacyPluginEnabled;
} }
public boolean isOnchainPrivacyGroupEnabled() { public boolean isFlexiblePrivacyGroupEnabled() {
return isOnchainPrivacyGroupEnabled; return isFlexiblePrivacyGroupEnabled;
} }
public boolean isMultitenancyEnabled() { public boolean isMultitenancyEnabled() {

@ -64,13 +64,13 @@ public class PrivacyNodeFactory {
final PrivacyAccount privacyAccount, final PrivacyAccount privacyAccount,
final EnclaveType enclaveType, final EnclaveType enclaveType,
final Optional<Network> containerNetwork, final Optional<Network> containerNetwork,
final boolean isOnchainPrivacyGroupEnabled, final boolean isFlexiblePrivacyGroupEnabled,
final boolean isMultitenancyEnabled, final boolean isMultitenancyEnabled,
final boolean isPrivacyPluginEnabled) final boolean isPrivacyPluginEnabled)
throws IOException { throws IOException {
return create( return create(
new PrivacyNodeConfiguration( new PrivacyNodeConfiguration(
isOnchainPrivacyGroupEnabled, isFlexiblePrivacyGroupEnabled,
isMultitenancyEnabled, isMultitenancyEnabled,
isPrivacyPluginEnabled, isPrivacyPluginEnabled,
new BesuNodeConfigurationBuilder() new BesuNodeConfigurationBuilder()
@ -104,13 +104,13 @@ public class PrivacyNodeFactory {
final PrivacyAccount privacyAccount, final PrivacyAccount privacyAccount,
final EnclaveType enclaveType, final EnclaveType enclaveType,
final Optional<Network> containerNetwork, final Optional<Network> containerNetwork,
final boolean isOnchainPrivacyGroupEnabled, final boolean isFlexiblePrivacyGroupEnabled,
final boolean isMultitenancyEnabled, final boolean isMultitenancyEnabled,
final boolean isPrivacyPluginEnabled) final boolean isPrivacyPluginEnabled)
throws IOException { throws IOException {
return create( return create(
new PrivacyNodeConfiguration( new PrivacyNodeConfiguration(
isOnchainPrivacyGroupEnabled, isFlexiblePrivacyGroupEnabled,
isMultitenancyEnabled, isMultitenancyEnabled,
isPrivacyPluginEnabled, isPrivacyPluginEnabled,
new BesuNodeConfigurationBuilder() new BesuNodeConfigurationBuilder()
@ -144,14 +144,14 @@ public class PrivacyNodeFactory {
final boolean minerEnabled, final boolean minerEnabled,
final EnclaveType enclaveType, final EnclaveType enclaveType,
final Optional<Network> containerNetwork, final Optional<Network> containerNetwork,
final boolean isOnchainPrivacyGroupEnabled, final boolean isFlexiblePrivacyGroupEnabled,
final boolean isMultitenancyEnabled, final boolean isMultitenancyEnabled,
final boolean isPrivacyPluginEnabled, final boolean isPrivacyPluginEnabled,
final String unrestrictedPrefix) final String unrestrictedPrefix)
throws IOException { throws IOException {
return create( return create(
new PrivacyNodeConfiguration( new PrivacyNodeConfiguration(
isOnchainPrivacyGroupEnabled, isFlexiblePrivacyGroupEnabled,
isMultitenancyEnabled, isMultitenancyEnabled,
isPrivacyPluginEnabled, isPrivacyPluginEnabled,
new BesuNodeConfigurationBuilder() new BesuNodeConfigurationBuilder()
@ -179,14 +179,14 @@ public class PrivacyNodeFactory {
final boolean minerEnabled, final boolean minerEnabled,
final EnclaveType enclaveType, final EnclaveType enclaveType,
final Optional<Network> containerNetwork, final Optional<Network> containerNetwork,
final boolean isOnchainPrivacyGroupEnabled, final boolean isFlexiblePrivacyGroupEnabled,
final boolean isMultitenancyEnabled, final boolean isMultitenancyEnabled,
final boolean isPrivacyPluginEnabled, final boolean isPrivacyPluginEnabled,
final String unrestrictedPrefix) final String unrestrictedPrefix)
throws IOException { throws IOException {
return create( return create(
new PrivacyNodeConfiguration( new PrivacyNodeConfiguration(
isOnchainPrivacyGroupEnabled, isFlexiblePrivacyGroupEnabled,
isMultitenancyEnabled, isMultitenancyEnabled,
isPrivacyPluginEnabled, isPrivacyPluginEnabled,
new BesuNodeConfigurationBuilder() new BesuNodeConfigurationBuilder()
@ -215,14 +215,14 @@ public class PrivacyNodeFactory {
final PrivacyAccount privacyAccount, final PrivacyAccount privacyAccount,
final EnclaveType enclaveType, final EnclaveType enclaveType,
final Optional<Network> containerNetwork, final Optional<Network> containerNetwork,
final boolean isOnchainPrivacyGroupEnabled, final boolean isFlexiblePrivacyGroupEnabled,
final boolean isMultitenancyEnabled, final boolean isMultitenancyEnabled,
final boolean isPrivacyPluginEnabled, final boolean isPrivacyPluginEnabled,
final String unrestrictedPrefix) final String unrestrictedPrefix)
throws IOException { throws IOException {
return create( return create(
new PrivacyNodeConfiguration( new PrivacyNodeConfiguration(
isOnchainPrivacyGroupEnabled, isFlexiblePrivacyGroupEnabled,
isMultitenancyEnabled, isMultitenancyEnabled,
isPrivacyPluginEnabled, isPrivacyPluginEnabled,
new BesuNodeConfigurationBuilder() new BesuNodeConfigurationBuilder()
@ -244,7 +244,7 @@ public class PrivacyNodeFactory {
containerNetwork); containerNetwork);
} }
public PrivacyNode createOnchainPrivacyGroupEnabledMinerNode( public PrivacyNode createFlexiblePrivacyGroupEnabledMinerNode(
final String name, final String name,
final PrivacyAccount privacyAccount, final PrivacyAccount privacyAccount,
final boolean multiTenancyEnabled, final boolean multiTenancyEnabled,
@ -278,7 +278,7 @@ public class PrivacyNodeFactory {
containerNetwork); containerNetwork);
} }
public PrivacyNode createOnchainPrivacyGroupEnabledNode( public PrivacyNode createFlexiblePrivacyGroupEnabledNode(
final String name, final String name,
final PrivacyAccount privacyAccount, final PrivacyAccount privacyAccount,
final boolean multiTenancyEnabled, final boolean multiTenancyEnabled,

@ -73,7 +73,7 @@ public class PrivacyNode implements AutoCloseable {
private final EnclaveTestHarness enclave; private final EnclaveTestHarness enclave;
private final BesuNode besu; private final BesuNode besu;
private final Vertx vertx; private final Vertx vertx;
private final boolean isOnchainPrivacyEnabled; private final boolean isFlexiblePrivacyEnabled;
private final boolean isMultitenancyEnabled; private final boolean isMultitenancyEnabled;
private final boolean isPrivacyPluginEnabled; private final boolean isPrivacyPluginEnabled;
@ -91,7 +91,7 @@ public class PrivacyNode implements AutoCloseable {
final BesuNodeConfiguration besuConfig = config; final BesuNodeConfiguration besuConfig = config;
isOnchainPrivacyEnabled = privacyConfiguration.isOnchainPrivacyGroupEnabled(); isFlexiblePrivacyEnabled = privacyConfiguration.isFlexiblePrivacyGroupEnabled();
isMultitenancyEnabled = privacyConfiguration.isMultitenancyEnabled(); isMultitenancyEnabled = privacyConfiguration.isMultitenancyEnabled();
isPrivacyPluginEnabled = privacyConfiguration.isPrivacyPluginEnabled(); isPrivacyPluginEnabled = privacyConfiguration.isPrivacyPluginEnabled();
@ -203,7 +203,7 @@ public class PrivacyNode implements AutoCloseable {
.setStorageProvider(createKeyValueStorageProvider(dataDir, dbDir)) .setStorageProvider(createKeyValueStorageProvider(dataDir, dbDir))
.setPrivateKeyPath(KeyPairUtil.getDefaultKeyFile(besu.homeDirectory()).toPath()) .setPrivateKeyPath(KeyPairUtil.getDefaultKeyFile(besu.homeDirectory()).toPath())
.setEnclaveFactory(new EnclaveFactory(vertx)) .setEnclaveFactory(new EnclaveFactory(vertx))
.setOnchainPrivacyGroupsEnabled(isOnchainPrivacyEnabled) .setFlexiblePrivacyGroupsEnabled(isFlexiblePrivacyEnabled)
.setMultiTenancyEnabled(isMultitenancyEnabled) .setMultiTenancyEnabled(isMultitenancyEnabled)
.setPrivacyPluginEnabled(isPrivacyPluginEnabled); .setPrivacyPluginEnabled(isPrivacyPluginEnabled);

@ -26,14 +26,14 @@ import java.util.concurrent.TimeUnit;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.web3j.utils.Base64String; import org.web3j.utils.Base64String;
public class ExpectValidOnchainPrivacyGroupCreated implements PrivateCondition { public class ExpectValidFlexiblePrivacyGroupCreated implements PrivateCondition {
private final PrivacyTransactions transactions; private final PrivacyTransactions transactions;
private final PrivacyRequestFactory.OnchainPrivacyGroup expected; private final PrivacyRequestFactory.FlexiblePrivacyGroup expected;
public ExpectValidOnchainPrivacyGroupCreated( public ExpectValidFlexiblePrivacyGroupCreated(
final PrivacyTransactions transactions, final PrivacyTransactions transactions,
final PrivacyRequestFactory.OnchainPrivacyGroup expected) { final PrivacyRequestFactory.FlexiblePrivacyGroup expected) {
this.transactions = transactions; this.transactions = transactions;
this.expected = expected; this.expected = expected;
} }
@ -43,9 +43,9 @@ public class ExpectValidOnchainPrivacyGroupCreated implements PrivateCondition {
Awaitility.waitAtMost(20, TimeUnit.SECONDS) Awaitility.waitAtMost(20, TimeUnit.SECONDS)
.untilAsserted( .untilAsserted(
() -> { () -> {
final List<PrivacyRequestFactory.OnchainPrivacyGroup> groups = final List<PrivacyRequestFactory.FlexiblePrivacyGroup> groups =
node.execute( node.execute(
transactions.findOnchainPrivacyGroup( transactions.findFlexiblePrivacyGroup(
Base64String.unwrapList(expected.getMembers()))); Base64String.unwrapList(expected.getMembers())));
assertThat(groups).contains(expected); assertThat(groups).contains(expected);
}); });

@ -16,7 +16,7 @@ package org.hyperledger.besu.tests.acceptance.dsl.privacy.condition;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions; import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory.OnchainPrivacyGroup; import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory.FlexiblePrivacyGroup;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -61,7 +61,7 @@ public class PrivateTransactionVerifier {
return new ExpectValidPrivacyGroupCreated(transactions, expected); return new ExpectValidPrivacyGroupCreated(transactions, expected);
} }
public ExpectValidOnchainPrivacyGroupCreated onchainPrivacyGroupExists( public ExpectValidFlexiblePrivacyGroupCreated flexiblePrivacyGroupExists(
final String privacyGroupId, final PrivacyNode... members) { final String privacyGroupId, final PrivacyNode... members) {
final List<Base64String> membersEnclaveKeys = final List<Base64String> membersEnclaveKeys =
@ -69,16 +69,16 @@ public class PrivateTransactionVerifier {
.map(PrivacyNode::getEnclaveKey) .map(PrivacyNode::getEnclaveKey)
.map(Base64String::wrap) .map(Base64String::wrap)
.collect(Collectors.toList()); .collect(Collectors.toList());
return onchainPrivacyGroupExists(privacyGroupId, membersEnclaveKeys); return flexiblePrivacyGroupExists(privacyGroupId, membersEnclaveKeys);
} }
public ExpectValidOnchainPrivacyGroupCreated onchainPrivacyGroupExists( public ExpectValidFlexiblePrivacyGroupCreated flexiblePrivacyGroupExists(
final String privacyGroupId, final List<Base64String> membersEnclaveKeys) { final String privacyGroupId, final List<Base64String> membersEnclaveKeys) {
final OnchainPrivacyGroup expectedGroup = final FlexiblePrivacyGroup expectedGroup =
new OnchainPrivacyGroup(privacyGroupId, membersEnclaveKeys); new FlexiblePrivacyGroup(privacyGroupId, membersEnclaveKeys);
return new ExpectValidOnchainPrivacyGroupCreated(transactions, expectedGroup); return new ExpectValidFlexiblePrivacyGroupCreated(transactions, expectedGroup);
} }
public ExpectInternalErrorPrivateTransactionReceipt internalErrorPrivateTransactionReceipt( public ExpectInternalErrorPrivateTransactionReceipt internalErrorPrivateTransactionReceipt(

@ -26,13 +26,13 @@ import java.util.stream.Collectors;
import org.web3j.crypto.Credentials; import org.web3j.crypto.Credentials;
import org.web3j.utils.Base64String; import org.web3j.utils.Base64String;
public class AddToOnchainPrivacyGroupTransaction implements Transaction<String> { public class AddToFlexiblePrivacyGroupTransaction implements Transaction<String> {
private final Base64String privacyGroupId; private final Base64String privacyGroupId;
private final PrivacyNode adder; private final PrivacyNode adder;
private final List<String> addresses; private final List<String> addresses;
private final Credentials signer; private final Credentials signer;
public AddToOnchainPrivacyGroupTransaction( public AddToFlexiblePrivacyGroupTransaction(
final String privacyGroupId, final String privacyGroupId,
final PrivacyNode adder, final PrivacyNode adder,
final Credentials signer, final Credentials signer,

@ -22,13 +22,13 @@ import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequ
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
public class CreateOnchainPrivacyGroupTransaction public class CreateFlexiblePrivacyGroupTransaction
implements Transaction<PrivxCreatePrivacyGroupResponse> { implements Transaction<PrivxCreatePrivacyGroupResponse> {
private final PrivacyNode creator; private final PrivacyNode creator;
private final List<String> addresses; private final List<String> addresses;
private final String privateFrom; private final String privateFrom;
CreateOnchainPrivacyGroupTransaction( CreateFlexiblePrivacyGroupTransaction(
final PrivacyNode creator, final String privateFrom, final List<String> addresses) { final PrivacyNode creator, final String privateFrom, final List<String> addresses) {
this.creator = creator; this.creator = creator;
this.addresses = addresses; this.addresses = addresses;

@ -27,19 +27,19 @@ import java.util.stream.Collectors;
import org.web3j.utils.Base64String; import org.web3j.utils.Base64String;
public class FindOnchainPrivacyGroupTransaction public class FindFlexiblePrivacyGroupTransaction
implements Transaction<List<PrivacyRequestFactory.OnchainPrivacyGroup>> { implements Transaction<List<PrivacyRequestFactory.FlexiblePrivacyGroup>> {
private final List<Base64String> nodes; private final List<Base64String> nodes;
public FindOnchainPrivacyGroupTransaction(final List<String> nodeEnclaveKeys) { public FindFlexiblePrivacyGroupTransaction(final List<String> nodeEnclaveKeys) {
this.nodes = nodeEnclaveKeys.stream().map(Base64String::wrap).collect(Collectors.toList()); this.nodes = nodeEnclaveKeys.stream().map(Base64String::wrap).collect(Collectors.toList());
} }
@Override @Override
public List<PrivacyRequestFactory.OnchainPrivacyGroup> execute(final NodeRequests node) { public List<PrivacyRequestFactory.FlexiblePrivacyGroup> execute(final NodeRequests node) {
try { try {
PrivxFindPrivacyGroupResponse result = PrivxFindPrivacyGroupResponse result =
node.privacy().privxFindOnchainPrivacyGroup(nodes).send(); node.privacy().privxFindFlexiblePrivacyGroup(nodes).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
if (result.hasError()) { if (result.hasError()) {
throw new RuntimeException(result.getError().getMessage()); throw new RuntimeException(result.getError().getMessage());

@ -24,12 +24,12 @@ import org.web3j.crypto.Credentials;
import org.web3j.protocol.exceptions.TransactionException; import org.web3j.protocol.exceptions.TransactionException;
import org.web3j.utils.Base64String; import org.web3j.utils.Base64String;
public class LockOnchainPrivacyGroupTransaction implements Transaction<String> { public class LockFlexiblePrivacyGroupTransaction implements Transaction<String> {
private final Base64String privacyGroupId; private final Base64String privacyGroupId;
private final PrivacyNode locker; private final PrivacyNode locker;
private final Credentials signer; private final Credentials signer;
public LockOnchainPrivacyGroupTransaction( public LockFlexiblePrivacyGroupTransaction(
final String privacyGroupId, final PrivacyNode locker, final Credentials signer) { final String privacyGroupId, final PrivacyNode locker, final Credentials signer) {
this.privacyGroupId = Base64String.wrap(privacyGroupId); this.privacyGroupId = Base64String.wrap(privacyGroupId);
this.locker = locker; this.locker = locker;

@ -51,44 +51,44 @@ public class PrivacyTransactions {
return new RestrictedCreatePrivacyGroupTransaction(name, description, nodes); return new RestrictedCreatePrivacyGroupTransaction(name, description, nodes);
} }
public CreateOnchainPrivacyGroupTransaction createOnchainPrivacyGroup( public CreateFlexiblePrivacyGroupTransaction createFlexiblePrivacyGroup(
final PrivacyNode creator, final PrivacyNode creator,
final String privateFrom, final String privateFrom,
final List<String> addresses, final List<String> addresses,
final String token) { final String token) {
creator.getBesu().useAuthenticationTokenInHeaderForJsonRpc(token); creator.getBesu().useAuthenticationTokenInHeaderForJsonRpc(token);
return new CreateOnchainPrivacyGroupTransaction(creator, privateFrom, addresses); return new CreateFlexiblePrivacyGroupTransaction(creator, privateFrom, addresses);
} }
public CreateOnchainPrivacyGroupTransaction createOnchainPrivacyGroup( public CreateFlexiblePrivacyGroupTransaction createFlexiblePrivacyGroup(
final PrivacyNode creator, final String privateFrom, final List<String> addresses) { final PrivacyNode creator, final String privateFrom, final List<String> addresses) {
return new CreateOnchainPrivacyGroupTransaction(creator, privateFrom, addresses); return new CreateFlexiblePrivacyGroupTransaction(creator, privateFrom, addresses);
} }
public AddToOnchainPrivacyGroupTransaction addToPrivacyGroup( public AddToFlexiblePrivacyGroupTransaction addToPrivacyGroup(
final String privacyGroupId, final String privacyGroupId,
final PrivacyNode adder, final PrivacyNode adder,
final Credentials signer, final Credentials signer,
final PrivacyNode... nodes) { final PrivacyNode... nodes) {
return new AddToOnchainPrivacyGroupTransaction(privacyGroupId, adder, signer, nodes); return new AddToFlexiblePrivacyGroupTransaction(privacyGroupId, adder, signer, nodes);
} }
public LockOnchainPrivacyGroupTransaction privxLockPrivacyGroupAndCheck( public LockFlexiblePrivacyGroupTransaction privxLockPrivacyGroupAndCheck(
final String privacyGroupId, final PrivacyNode locker, final Credentials signer) { final String privacyGroupId, final PrivacyNode locker, final Credentials signer) {
return new LockOnchainPrivacyGroupTransaction(privacyGroupId, locker, signer); return new LockFlexiblePrivacyGroupTransaction(privacyGroupId, locker, signer);
} }
public UnlockOnchainPrivacyGroupTransaction privxUnlockPrivacyGroupAndCheck( public UnlockFlexiblePrivacyGroupTransaction privxUnlockPrivacyGroupAndCheck(
final String privacyGroupId, final PrivacyNode locker, final Credentials signer) { final String privacyGroupId, final PrivacyNode locker, final Credentials signer) {
return new UnlockOnchainPrivacyGroupTransaction(privacyGroupId, locker, signer); return new UnlockFlexiblePrivacyGroupTransaction(privacyGroupId, locker, signer);
} }
public FindPrivacyGroupTransaction findPrivacyGroup(final List<String> nodes) { public FindPrivacyGroupTransaction findPrivacyGroup(final List<String> nodes) {
return new FindPrivacyGroupTransaction(nodes); return new FindPrivacyGroupTransaction(nodes);
} }
public FindOnchainPrivacyGroupTransaction findOnchainPrivacyGroup(final List<String> nodes) { public FindFlexiblePrivacyGroupTransaction findFlexiblePrivacyGroup(final List<String> nodes) {
return new FindOnchainPrivacyGroupTransaction(nodes); return new FindFlexiblePrivacyGroupTransaction(nodes);
} }
public PrivDistributeTransactionTransaction privDistributeTransaction( public PrivDistributeTransactionTransaction privDistributeTransaction(
@ -115,12 +115,12 @@ public class PrivacyTransactions {
return new PrivGetLogsTransaction(privacyGroupId, filterParameter); return new PrivGetLogsTransaction(privacyGroupId, filterParameter);
} }
public RemoveFromOnchainPrivacyGroupTransaction removeFromPrivacyGroup( public RemoveFromFlexiblePrivacyGroupTransaction removeFromPrivacyGroup(
final String privacyGroupId, final String privacyGroupId,
final String remover, final String remover,
final Credentials signer, final Credentials signer,
final String memberToRemove) { final String memberToRemove) {
return new RemoveFromOnchainPrivacyGroupTransaction( return new RemoveFromFlexiblePrivacyGroupTransaction(
privacyGroupId, remover, signer, memberToRemove); privacyGroupId, remover, signer, memberToRemove);
} }

@ -22,13 +22,13 @@ import java.io.IOException;
import org.web3j.crypto.Credentials; import org.web3j.crypto.Credentials;
import org.web3j.utils.Base64String; import org.web3j.utils.Base64String;
public class RemoveFromOnchainPrivacyGroupTransaction implements Transaction<String> { public class RemoveFromFlexiblePrivacyGroupTransaction implements Transaction<String> {
private final Base64String privacyGroupId; private final Base64String privacyGroupId;
private final String remover; private final String remover;
private final String toRemove; private final String toRemove;
private final Credentials signer; private final Credentials signer;
public RemoveFromOnchainPrivacyGroupTransaction( public RemoveFromFlexiblePrivacyGroupTransaction(
final String privacyGroupId, final String privacyGroupId,
final String remover, final String remover,
final Credentials signer, final Credentials signer,

@ -24,12 +24,12 @@ import org.web3j.crypto.Credentials;
import org.web3j.protocol.exceptions.TransactionException; import org.web3j.protocol.exceptions.TransactionException;
import org.web3j.utils.Base64String; import org.web3j.utils.Base64String;
public class UnlockOnchainPrivacyGroupTransaction implements Transaction<String> { public class UnlockFlexiblePrivacyGroupTransaction implements Transaction<String> {
private final Base64String privacyGroupId; private final Base64String privacyGroupId;
private final PrivacyNode locker; private final PrivacyNode locker;
private final Credentials signer; private final Credentials signer;
public UnlockOnchainPrivacyGroupTransaction( public UnlockFlexiblePrivacyGroupTransaction(
final String privacyGroupId, final PrivacyNode locker, final Credentials signer) { final String privacyGroupId, final PrivacyNode locker, final Credentials signer) {
this.privacyGroupId = Base64String.wrap(privacyGroupId); this.privacyGroupId = Base64String.wrap(privacyGroupId);
this.locker = locker; this.locker = locker;

@ -17,14 +17,14 @@ package org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import org.hyperledger.besu.crypto.SecureRandomProvider; import org.hyperledger.besu.crypto.SecureRandomProvider;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.enclave.types.PrivacyGroup;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.parameters.CreatePrivacyGroupParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.parameters.CreatePrivacyGroupParameter;
import org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement; import org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivateTransactionGroupResponse; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivateTransactionGroupResponse;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter; import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter;
@ -185,7 +185,7 @@ public class PrivacyRequestFactory {
nonce, nonce,
BigInteger.valueOf(1000), BigInteger.valueOf(1000),
BigInteger.valueOf(3000000), BigInteger.valueOf(3000000),
ONCHAIN_PRIVACY_PROXY.toHexString(), FLEXIBLE_PRIVACY_PROXY.toHexString(),
payload.toHexString(), payload.toHexString(),
Base64String.wrap(adder.getEnclaveKey()), Base64String.wrap(adder.getEnclaveKey()),
privacyGroupId, privacyGroupId,
@ -218,7 +218,7 @@ public class PrivacyRequestFactory {
nonce, nonce,
BigInteger.valueOf(1000), BigInteger.valueOf(1000),
BigInteger.valueOf(3000000), BigInteger.valueOf(3000000),
ONCHAIN_PRIVACY_PROXY.toHexString(), FLEXIBLE_PRIVACY_PROXY.toHexString(),
payload.toHexString(), payload.toHexString(),
Base64String.wrap(removerTenant), Base64String.wrap(removerTenant),
privacyGroupId, privacyGroupId,
@ -232,7 +232,7 @@ public class PrivacyRequestFactory {
} }
private Bytes encodeRemoveFromGroupFunctionCall(final Bytes toRemove) { private Bytes encodeRemoveFromGroupFunctionCall(final Bytes toRemove) {
return Bytes.concatenate(OnchainGroupManagement.REMOVE_PARTICIPANT_METHOD_SIGNATURE, toRemove); return Bytes.concatenate(FlexibleGroupManagement.REMOVE_PARTICIPANT_METHOD_SIGNATURE, toRemove);
} }
public String privxLockPrivacyGroup( public String privxLockPrivacyGroup(
@ -242,7 +242,7 @@ public class PrivacyRequestFactory {
locker, locker,
privacyGroupId, privacyGroupId,
signer, signer,
OnchainGroupManagement.LOCK_GROUP_METHOD_SIGNATURE.toHexString()); FlexibleGroupManagement.LOCK_GROUP_METHOD_SIGNATURE.toHexString());
} }
public String privxUnlockPrivacyGroup( public String privxUnlockPrivacyGroup(
@ -252,7 +252,7 @@ public class PrivacyRequestFactory {
locker, locker,
privacyGroupId, privacyGroupId,
signer, signer,
OnchainGroupManagement.UNLOCK_GROUP_METHOD_SIGNATURE.toHexString()); FlexibleGroupManagement.UNLOCK_GROUP_METHOD_SIGNATURE.toHexString());
} }
private String privxLockOrUnlockPrivacyGroup( private String privxLockOrUnlockPrivacyGroup(
@ -272,7 +272,7 @@ public class PrivacyRequestFactory {
nonce, nonce,
BigInteger.valueOf(1000), BigInteger.valueOf(1000),
BigInteger.valueOf(3000000), BigInteger.valueOf(3000000),
ONCHAIN_PRIVACY_PROXY.toHexString(), FLEXIBLE_PRIVACY_PROXY.toHexString(),
callData, callData,
Base64String.wrap(locker.getEnclaveKey()), Base64String.wrap(locker.getEnclaveKey()),
privacyGroupId, privacyGroupId,
@ -312,7 +312,7 @@ public class PrivacyRequestFactory {
BigInteger.ZERO, BigInteger.ZERO,
BigInteger.valueOf(1000), BigInteger.valueOf(1000),
BigInteger.valueOf(3000000), BigInteger.valueOf(3000000),
ONCHAIN_PRIVACY_PROXY.toHexString(), FLEXIBLE_PRIVACY_PROXY.toHexString(),
payload.toHexString(), payload.toHexString(),
Base64String.wrap(privateFrom), Base64String.wrap(privateFrom),
Base64String.wrap(privacyGroupId.toArrayUnsafe()), Base64String.wrap(privacyGroupId.toArrayUnsafe()),
@ -327,10 +327,10 @@ public class PrivacyRequestFactory {
return new PrivxCreatePrivacyGroupResponse(privacyGroupId.toBase64String(), transactionHash); return new PrivxCreatePrivacyGroupResponse(privacyGroupId.toBase64String(), transactionHash);
} }
public Request<?, PrivxFindPrivacyGroupResponse> privxFindOnchainPrivacyGroup( public Request<?, PrivxFindPrivacyGroupResponse> privxFindFlexiblePrivacyGroup(
final List<Base64String> nodes) { final List<Base64String> nodes) {
return new Request<>( return new Request<>(
"privx_findOnChainPrivacyGroup", "privx_findFlexiblePrivacyGroup",
singletonList(nodes), singletonList(nodes),
web3jService, web3jService,
PrivxFindPrivacyGroupResponse.class); PrivxFindPrivacyGroupResponse.class);
@ -487,14 +487,14 @@ public class PrivacyRequestFactory {
DebugGetStateRoot.class); DebugGetStateRoot.class);
} }
public static class PrivxFindPrivacyGroupResponse extends Response<List<OnchainPrivacyGroup>> { public static class PrivxFindPrivacyGroupResponse extends Response<List<FlexiblePrivacyGroup>> {
public List<OnchainPrivacyGroup> getGroups() { public List<FlexiblePrivacyGroup> getGroups() {
return getResult(); return getResult();
} }
} }
public static class OnchainPrivacyGroup { public static class FlexiblePrivacyGroup {
private final Base64String privacyGroupId; private final Base64String privacyGroupId;
private final List<Base64String> members; private final List<Base64String> members;
@ -502,11 +502,11 @@ public class PrivacyRequestFactory {
private final String description; private final String description;
public enum Type { public enum Type {
ONCHAIN FLEXIBLE
} }
@JsonCreator @JsonCreator
public OnchainPrivacyGroup( public FlexiblePrivacyGroup(
@JsonProperty(value = "privacyGroupId") final String privacyGroupId, @JsonProperty(value = "privacyGroupId") final String privacyGroupId,
@JsonProperty(value = "type") final Type type, @JsonProperty(value = "type") final Type type,
@JsonProperty(value = "name") final String name, @JsonProperty(value = "name") final String name,
@ -515,7 +515,7 @@ public class PrivacyRequestFactory {
this(privacyGroupId, members); this(privacyGroupId, members);
} }
public OnchainPrivacyGroup(final String privacyGroupId, final List<Base64String> members) { public FlexiblePrivacyGroup(final String privacyGroupId, final List<Base64String> members) {
this.privacyGroupId = Base64String.wrap(privacyGroupId); this.privacyGroupId = Base64String.wrap(privacyGroupId);
this.name = ""; this.name = "";
this.description = ""; this.description = "";
@ -535,7 +535,7 @@ public class PrivacyRequestFactory {
} }
public Type getType() { public Type getType() {
return Type.ONCHAIN; return Type.FLEXIBLE;
} }
public List<Base64String> getMembers() { public List<Base64String> getMembers() {
@ -550,7 +550,7 @@ public class PrivacyRequestFactory {
if (o == null || getClass() != o.getClass()) { if (o == null || getClass() != o.getClass()) {
return false; return false;
} }
final OnchainPrivacyGroup that = (OnchainPrivacyGroup) o; final FlexiblePrivacyGroup that = (FlexiblePrivacyGroup) o;
return getPrivacyGroupId().equals(that.getPrivacyGroupId()) return getPrivacyGroupId().equals(that.getPrivacyGroupId())
&& getName().equals(that.getName()) && getName().equals(that.getName())
&& getDescription().equals(that.getDescription()) && getDescription().equals(that.getDescription())
@ -589,7 +589,7 @@ public class PrivacyRequestFactory {
private Bytes encodeAddToGroupFunctionCall(final List<Bytes> participants) { private Bytes encodeAddToGroupFunctionCall(final List<Bytes> participants) {
return Bytes.concatenate( return Bytes.concatenate(
OnchainGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE, encodeList(participants)); FlexibleGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE, encodeList(participants));
} }
private Bytes encodeList(final List<Bytes> participants) { private Bytes encodeList(final List<Bytes> participants) {

@ -16,7 +16,7 @@ package org.hyperledger.besu.tests.acceptance.privacy;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.junit.runners.Parameterized.Parameters; import static org.junit.runners.Parameterized.Parameters;
import org.hyperledger.besu.tests.acceptance.dsl.condition.eth.EthConditions; import org.hyperledger.besu.tests.acceptance.dsl.condition.eth.EthConditions;
@ -48,11 +48,11 @@ import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract; import org.web3j.tx.Contract;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBase { public class FlexiblePrivacyAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase {
private final EnclaveType enclaveType; private final EnclaveType enclaveType;
public OnchainPrivacyAcceptanceTest(final EnclaveType enclaveType) { public FlexiblePrivacyAcceptanceTest(final EnclaveType enclaveType) {
this.enclaveType = enclaveType; this.enclaveType = enclaveType;
} }
@ -78,21 +78,21 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
final Network containerNetwork = Network.newNetwork(); final Network containerNetwork = Network.newNetwork();
alice = alice =
privacyBesu.createOnchainPrivacyGroupEnabledMinerNode( privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode(
"node1", "node1",
privacyAccountResolver.resolve(0), privacyAccountResolver.resolve(0),
false, false,
enclaveType, enclaveType,
Optional.of(containerNetwork)); Optional.of(containerNetwork));
bob = bob =
privacyBesu.createOnchainPrivacyGroupEnabledNode( privacyBesu.createFlexiblePrivacyGroupEnabledNode(
"node2", "node2",
privacyAccountResolver.resolve(1), privacyAccountResolver.resolve(1),
false, false,
enclaveType, enclaveType,
Optional.of(containerNetwork)); Optional.of(containerNetwork));
charlie = charlie =
privacyBesu.createOnchainPrivacyGroupEnabledNode( privacyBesu.createFlexiblePrivacyGroupEnabledNode(
"node3", "node3",
privacyAccountResolver.resolve(2), privacyAccountResolver.resolve(2),
false, false,
@ -103,13 +103,13 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test @Test
public void nodeCanCreatePrivacyGroup() { public void nodeCanCreatePrivacyGroup() {
final String privacyGroupId = createOnchainPrivacyGroup(alice); final String privacyGroupId = createFlexiblePrivacyGroup(alice);
checkOnchainPrivacyGroupExists(privacyGroupId, alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
} }
@Test @Test
public void deployingMustGiveValidReceipt() { public void deployingMustGiveValidReceipt() {
final String privacyGroupId = createOnchainPrivacyGroup(alice, bob); final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob);
final Contract eventEmitter = deployPrivateContract(EventEmitter.class, privacyGroupId, alice); final Contract eventEmitter = deployPrivateContract(EventEmitter.class, privacyGroupId, alice);
final String commitmentHash = getContractDeploymentCommitmentHash(eventEmitter); final String commitmentHash = getContractDeploymentCommitmentHash(eventEmitter);
@ -119,7 +119,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test @Test
public void canAddParticipantToGroup() { public void canAddParticipantToGroup() {
final String privacyGroupId = createOnchainPrivacyGroup(alice, bob); final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob);
final Contract eventEmitter = deployPrivateContract(EventEmitter.class, privacyGroupId, alice); final Contract eventEmitter = deployPrivateContract(EventEmitter.class, privacyGroupId, alice);
final String commitmentHash = getContractDeploymentCommitmentHash(eventEmitter); final String commitmentHash = getContractDeploymentCommitmentHash(eventEmitter);
@ -128,14 +128,14 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
final Credentials aliceCredentials = Credentials.create(alice.getTransactionSigningKey()); final Credentials aliceCredentials = Credentials.create(alice.getTransactionSigningKey());
lockPrivacyGroup(privacyGroupId, alice, aliceCredentials); lockPrivacyGroup(privacyGroupId, alice, aliceCredentials);
addMembersToPrivacyGroup(privacyGroupId, alice, aliceCredentials, charlie); addMembersToPrivacyGroup(privacyGroupId, alice, aliceCredentials, charlie);
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob, charlie); checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob, charlie);
charlie.verify(privateTransactionVerifier.existingPrivateTransactionReceipt(commitmentHash)); charlie.verify(privateTransactionVerifier.existingPrivateTransactionReceipt(commitmentHash));
} }
@Test @Test
public void removedMemberCannotSendTransactionToGroup() { public void removedMemberCannotSendTransactionToGroup() {
final String privacyGroupId = createOnchainPrivacyGroup(alice, bob); final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob);
final String removeHash = final String removeHash =
removeFromPrivacyGroup( removeFromPrivacyGroup(
@ -145,12 +145,12 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
assertThatThrownBy(() -> deployPrivateContract(EventEmitter.class, privacyGroupId, bob)) assertThatThrownBy(() -> deployPrivateContract(EventEmitter.class, privacyGroupId, bob))
.isInstanceOf(RuntimeException.class) .isInstanceOf(RuntimeException.class)
.hasMessageContaining("Onchain Privacy group does not exist."); .hasMessageContaining("Flexible Privacy group does not exist.");
} }
@Test @Test
public void canInteractWithPrivateGenesisPreCompile() throws Exception { public void canInteractWithPrivateGenesisPreCompile() throws Exception {
final String privacyGroupId = createOnchainPrivacyGroup(alice, bob); final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob);
final EventEmitter eventEmitter = final EventEmitter eventEmitter =
alice.execute( alice.execute(
@ -195,15 +195,15 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test @Test
public void memberCanBeAddedAfterBeingRemoved() { public void memberCanBeAddedAfterBeingRemoved() {
final String privacyGroupId = createOnchainPrivacyGroup(alice); final String privacyGroupId = createFlexiblePrivacyGroup(alice);
checkOnchainPrivacyGroupExists(privacyGroupId, alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
lockPrivacyGroup(privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey())); lockPrivacyGroup(privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()));
addMembersToPrivacyGroup( addMembersToPrivacyGroup(
privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob); privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob);
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob); checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob);
final EventEmitter eventEmitter = final EventEmitter eventEmitter =
deployPrivateContract(EventEmitter.class, privacyGroupId, alice); deployPrivateContract(EventEmitter.class, privacyGroupId, alice);
@ -219,7 +219,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
removeFromPrivacyGroup( removeFromPrivacyGroup(
privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob); privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob);
checkOnchainPrivacyGroupExists(privacyGroupId, alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
final int valueSetWhileBobWas_NOT_aMember = 1337; final int valueSetWhileBobWas_NOT_aMember = 1337;
final PrivateTransactionReceipt receiptWhileBobRemoved = final PrivateTransactionReceipt receiptWhileBobRemoved =
@ -238,7 +238,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
addMembersToPrivacyGroup( addMembersToPrivacyGroup(
privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob); privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob);
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob); checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob);
checkEmitterValue( checkEmitterValue(
Lists.newArrayList(alice, bob), Lists.newArrayList(alice, bob),
@ -311,8 +311,8 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test @Test
public void bobCanAddCharlieAfterBeingAddedByAlice() { public void bobCanAddCharlieAfterBeingAddedByAlice() {
final String privacyGroupId = createOnchainPrivacyGroup(alice); final String privacyGroupId = createFlexiblePrivacyGroup(alice);
checkOnchainPrivacyGroupExists(privacyGroupId, alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
final EventEmitter eventEmitter = final EventEmitter eventEmitter =
alice.execute( alice.execute(
privateContractTransactions.createSmartContractWithPrivacyGroupId( privateContractTransactions.createSmartContractWithPrivacyGroupId(
@ -335,7 +335,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
alice.execute( alice.execute(
privacyTransactions.addToPrivacyGroup(privacyGroupId, alice, aliceCredentials, bob)); privacyTransactions.addToPrivacyGroup(privacyGroupId, alice, aliceCredentials, bob));
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob); checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob);
bob.execute( bob.execute(
privacyTransactions.privxLockPrivacyGroupAndCheck(privacyGroupId, bob, aliceCredentials)); privacyTransactions.privxLockPrivacyGroupAndCheck(privacyGroupId, bob, aliceCredentials));
@ -369,7 +369,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
alice.getBesu().verify(ethConditions.miningStatus(true)); alice.getBesu().verify(ethConditions.miningStatus(true));
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob, charlie); checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob, charlie);
final Optional<TransactionReceipt> aliceAddReceipt = final Optional<TransactionReceipt> aliceAddReceipt =
alice.execute(ethTransactions.getTransactionReceipt(bobAddHash)); alice.execute(ethTransactions.getTransactionReceipt(bobAddHash));
@ -409,7 +409,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
new PrivateTransactionReceipt( new PrivateTransactionReceipt(
null, null,
alice.getAddress().toHexString(), alice.getAddress().toHexString(),
ONCHAIN_PRIVACY_PROXY.toHexString(), FLEXIBLE_PRIVACY_PROXY.toHexString(),
"0x", "0x",
Collections.emptyList(), Collections.emptyList(),
null, null,
@ -472,13 +472,13 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
removeFromPrivacyGroup(privacyGroupId, bob, aliceCredentials, charlie); removeFromPrivacyGroup(privacyGroupId, bob, aliceCredentials, charlie);
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob); checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob);
} }
@Test @Test
public void canOnlyCallProxyContractWhenGroupLocked() { public void canOnlyCallProxyContractWhenGroupLocked() {
final String privacyGroupId = createOnchainPrivacyGroup(alice); final String privacyGroupId = createFlexiblePrivacyGroup(alice);
checkOnchainPrivacyGroupExists(privacyGroupId, alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
final EventEmitter eventEmitter = final EventEmitter eventEmitter =
alice.execute( alice.execute(
@ -542,10 +542,10 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test @Test
public void addMembersToTwoGroupsInTheSameBlock() { public void addMembersToTwoGroupsInTheSameBlock() {
final String privacyGroupId1 = createOnchainPrivacyGroup(alice); final String privacyGroupId1 = createFlexiblePrivacyGroup(alice);
final String privacyGroupId2 = createOnchainPrivacyGroup(bob); final String privacyGroupId2 = createFlexiblePrivacyGroup(bob);
checkOnchainPrivacyGroupExists(privacyGroupId1, alice); checkFlexiblePrivacyGroupExists(privacyGroupId1, alice);
checkOnchainPrivacyGroupExists(privacyGroupId2, bob); checkFlexiblePrivacyGroupExists(privacyGroupId2, bob);
lockPrivacyGroup(privacyGroupId1, alice, Credentials.create(alice.getTransactionSigningKey())); lockPrivacyGroup(privacyGroupId1, alice, Credentials.create(alice.getTransactionSigningKey()));
lockPrivacyGroup(privacyGroupId2, bob, Credentials.create(bob.getTransactionSigningKey())); lockPrivacyGroup(privacyGroupId2, bob, Credentials.create(bob.getTransactionSigningKey()));
@ -571,8 +571,8 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
alice.execute(minerTransactions.minerStart()); alice.execute(minerTransactions.minerStart());
checkOnchainPrivacyGroupExists(privacyGroupId1, alice, charlie); checkFlexiblePrivacyGroupExists(privacyGroupId1, alice, charlie);
checkOnchainPrivacyGroupExists(privacyGroupId2, bob, alice); checkFlexiblePrivacyGroupExists(privacyGroupId2, bob, alice);
} }
private <T extends Contract> T deployPrivateContract( private <T extends Contract> T deployPrivateContract(

@ -15,14 +15,14 @@
package org.hyperledger.besu.tests.acceptance.privacy; package org.hyperledger.besu.tests.acceptance.privacy;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyAcceptanceTestBase; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyAcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.ExpectValidOnchainPrivacyGroupCreated; import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.ExpectValidFlexiblePrivacyGroupCreated;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.CreateOnchainPrivacyGroupTransaction; import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.CreateFlexiblePrivacyGroupTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory; import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory;
import java.util.Arrays; import java.util.Arrays;
@ -37,16 +37,16 @@ import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract; import org.web3j.tx.Contract;
import org.web3j.utils.Base64String; import org.web3j.utils.Base64String;
public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase { public class FlexiblePrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase {
protected String createOnchainPrivacyGroup(final PrivacyNode... members) { protected String createFlexiblePrivacyGroup(final PrivacyNode... members) {
final List<String> addresses = final List<String> addresses =
Arrays.stream(members).map(PrivacyNode::getEnclaveKey).collect(Collectors.toList()); Arrays.stream(members).map(PrivacyNode::getEnclaveKey).collect(Collectors.toList());
return createOnchainPrivacyGroup(members[0].getEnclaveKey(), addresses, members); return createFlexiblePrivacyGroup(members[0].getEnclaveKey(), addresses, members);
} }
/** /**
* Create an onchain privacy group. The privacy group id will be randomly generated. * Create an flexible privacy group. The privacy group id will be randomly generated.
* *
* <p>This method also checks that each node member has successfully processed the transaction and * <p>This method also checks that each node member has successfully processed the transaction and
* has the expected list of member for the group. * has the expected list of member for the group.
@ -55,13 +55,13 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
* the creator of the group. * the creator of the group.
* @return the id of the privacy group * @return the id of the privacy group
*/ */
protected String createOnchainPrivacyGroup( protected String createFlexiblePrivacyGroup(
final String privateFrom, final List<String> addresses, final PrivacyNode... members) { final String privateFrom, final List<String> addresses, final PrivacyNode... members) {
final PrivacyNode groupCreator = members[0]; final PrivacyNode groupCreator = members[0];
final CreateOnchainPrivacyGroupTransaction createTx = final CreateFlexiblePrivacyGroupTransaction createTx =
privacyTransactions.createOnchainPrivacyGroup(groupCreator, privateFrom, addresses); privacyTransactions.createFlexiblePrivacyGroup(groupCreator, privateFrom, addresses);
final PrivacyRequestFactory.PrivxCreatePrivacyGroupResponse createResponse = final PrivacyRequestFactory.PrivxCreatePrivacyGroupResponse createResponse =
groupCreator.execute(createTx); groupCreator.execute(createTx);
@ -73,7 +73,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
.collect(Collectors.toList()); .collect(Collectors.toList());
for (final PrivacyNode member : members) { for (final PrivacyNode member : members) {
member.verify(onchainPrivacyGroupExists(privacyGroupId, membersEnclaveKeys)); member.verify(flexiblePrivacyGroupExists(privacyGroupId, membersEnclaveKeys));
} }
final String commitmentHash = final String commitmentHash =
@ -95,7 +95,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
final String privacyGroupId, final PrivacyNode groupCreator, final String privateFrom) { final String privacyGroupId, final PrivacyNode groupCreator, final String privateFrom) {
return groupCreator.execute( return groupCreator.execute(
privateContractTransactions.callOnchainPermissioningSmartContract( privateContractTransactions.callOnchainPermissioningSmartContract(
ONCHAIN_PRIVACY_PROXY.toHexString(), FLEXIBLE_PRIVACY_PROXY.toHexString(),
GET_PARTICIPANTS_METHOD_SIGNATURE.toString(), GET_PARTICIPANTS_METHOD_SIGNATURE.toString(),
groupCreator.getTransactionSigningKey(), groupCreator.getTransactionSigningKey(),
privateFrom, privateFrom,
@ -128,7 +128,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
return new PrivateTransactionReceipt( return new PrivateTransactionReceipt(
null, null,
groupCreator.getAddress().toHexString(), groupCreator.getAddress().toHexString(),
ONCHAIN_PRIVACY_PROXY.toHexString(), FLEXIBLE_PRIVACY_PROXY.toHexString(),
output.toString(), output.toString(),
Collections.emptyList(), Collections.emptyList(),
null, null,
@ -140,9 +140,9 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
null); null);
} }
protected ExpectValidOnchainPrivacyGroupCreated onchainPrivacyGroupExists( protected ExpectValidFlexiblePrivacyGroupCreated flexiblePrivacyGroupExists(
final String privacyGroupId, final List<Base64String> members) { final String privacyGroupId, final List<Base64String> members) {
return privateTransactionVerifier.onchainPrivacyGroupExists(privacyGroupId, members); return privateTransactionVerifier.flexiblePrivacyGroupExists(privacyGroupId, members);
} }
protected String getContractDeploymentCommitmentHash(final Contract contract) { protected String getContractDeploymentCommitmentHash(final Contract contract) {
@ -161,7 +161,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
* @param privacyGroupId the id of the privacy group * @param privacyGroupId the id of the privacy group
* @param members the list of member in the privacy group * @param members the list of member in the privacy group
*/ */
protected void checkOnchainPrivacyGroupExists( protected void checkFlexiblePrivacyGroupExists(
final String privacyGroupId, final PrivacyNode... members) { final String privacyGroupId, final PrivacyNode... members) {
final List<Base64String> membersEnclaveKeys = final List<Base64String> membersEnclaveKeys =
Arrays.stream(members) Arrays.stream(members)
@ -170,7 +170,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
.collect(Collectors.toList()); .collect(Collectors.toList());
for (final PrivacyNode member : members) { for (final PrivacyNode member : members) {
member.verify(onchainPrivacyGroupExists(privacyGroupId, membersEnclaveKeys)); member.verify(flexiblePrivacyGroupExists(privacyGroupId, membersEnclaveKeys));
} }
} }
} }

@ -38,12 +38,12 @@ import org.junit.runners.Parameterized.Parameters;
import org.testcontainers.containers.Network; import org.testcontainers.containers.Network;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class PrivDebugGetStateRootOnchainGroupAcceptanceTest public class PrivDebugGetStateRootFlexibleGroupAcceptanceTest
extends OnchainPrivacyAcceptanceTestBase { extends FlexiblePrivacyAcceptanceTestBase {
private final EnclaveType enclaveType; private final EnclaveType enclaveType;
public PrivDebugGetStateRootOnchainGroupAcceptanceTest(final EnclaveType enclaveType) { public PrivDebugGetStateRootFlexibleGroupAcceptanceTest(final EnclaveType enclaveType) {
this.enclaveType = enclaveType; this.enclaveType = enclaveType;
} }
@ -60,14 +60,14 @@ public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
final Network containerNetwork = Network.newNetwork(); final Network containerNetwork = Network.newNetwork();
aliceNode = aliceNode =
privacyBesu.createOnchainPrivacyGroupEnabledMinerNode( privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode(
"alice-node", "alice-node",
PrivacyAccountResolver.ALICE, PrivacyAccountResolver.ALICE,
false, false,
enclaveType, enclaveType,
Optional.of(containerNetwork)); Optional.of(containerNetwork));
bobNode = bobNode =
privacyBesu.createOnchainPrivacyGroupEnabledNode( privacyBesu.createFlexiblePrivacyGroupEnabledNode(
"bob-node", "bob-node",
PrivacyAccountResolver.BOB, PrivacyAccountResolver.BOB,
false, false,
@ -79,7 +79,7 @@ public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
@Test @Test
public void nodesInGroupShouldHaveSameStateRoot() { public void nodesInGroupShouldHaveSameStateRoot() {
final String privacyGroupId = createOnchainPrivacyGroup(aliceNode, bobNode); final String privacyGroupId = createFlexiblePrivacyGroup(aliceNode, bobNode);
final Hash aliceStateRootId = final Hash aliceStateRootId =
aliceNode aliceNode
@ -112,7 +112,7 @@ public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
waitForBlockHeight(aliceNode, 2); waitForBlockHeight(aliceNode, 2);
waitForBlockHeight(bobNode, 2); waitForBlockHeight(bobNode, 2);
final String privacyGroupId = createOnchainPrivacyGroup(aliceNode, bobNode); final String privacyGroupId = createFlexiblePrivacyGroup(aliceNode, bobNode);
waitForBlockHeight(aliceNode, 10); waitForBlockHeight(aliceNode, 10);
waitForBlockHeight(bobNode, 10); waitForBlockHeight(bobNode, 10);
@ -140,7 +140,7 @@ public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
@Test @Test
public void canInteractWithPrivateGenesisPreCompile() throws Exception { public void canInteractWithPrivateGenesisPreCompile() throws Exception {
final String privacyGroupId = createOnchainPrivacyGroup(aliceNode, bobNode); final String privacyGroupId = createFlexiblePrivacyGroup(aliceNode, bobNode);
final EventEmitter eventEmitter = final EventEmitter eventEmitter =
aliceNode.execute( aliceNode.execute(

@ -16,7 +16,7 @@ package org.hyperledger.besu.tests.acceptance.privacy.contracts;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.privacy.contracts.generated.DefaultOnchainPrivacyGroupManagementContract; import org.hyperledger.besu.privacy.contracts.generated.DefaultFlexiblePrivacyGroupManagementContract;
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
@ -40,7 +40,7 @@ public class PrivacyGroupTest extends AcceptanceTestBase {
Base64String.wrap("Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="); Base64String.wrap("Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=");
private final Base64String thirdParticipant = private final Base64String thirdParticipant =
Base64String.wrap("Jo2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="); Base64String.wrap("Jo2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=");
private DefaultOnchainPrivacyGroupManagementContract defaultPrivacyGroupManagementContract; private DefaultFlexiblePrivacyGroupManagementContract defaultPrivacyGroupManagementContract;
private static final String RAW_FIRST_PARTICIPANT = "0x5aa68ac0"; private static final String RAW_FIRST_PARTICIPANT = "0x5aa68ac0";
private static final String RAW_ADD_PARTICIPANT = private static final String RAW_ADD_PARTICIPANT =
@ -61,7 +61,7 @@ public class PrivacyGroupTest extends AcceptanceTestBase {
defaultPrivacyGroupManagementContract = defaultPrivacyGroupManagementContract =
minerNode.execute( minerNode.execute(
contractTransactions.createSmartContract( contractTransactions.createSmartContract(
DefaultOnchainPrivacyGroupManagementContract.class)); DefaultFlexiblePrivacyGroupManagementContract.class));
} }
@Test @Test

@ -17,8 +17,8 @@ package org.hyperledger.besu.tests.acceptance.privacy.contracts;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.hyperledger.besu.privacy.contracts.generated.DefaultOnchainPrivacyGroupManagementContract; import org.hyperledger.besu.privacy.contracts.generated.DefaultFlexiblePrivacyGroupManagementContract;
import org.hyperledger.besu.privacy.contracts.generated.OnchainPrivacyGroupManagementProxy; import org.hyperledger.besu.privacy.contracts.generated.FlexiblePrivacyGroupManagementProxy;
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.account.Accounts; import org.hyperledger.besu.tests.acceptance.dsl.account.Accounts;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
@ -45,58 +45,59 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
Base64String.wrap("9iaJ6OObl6TUWYjXAOyZsL0VaDPwF+tRFkMwwYSeqqw="); Base64String.wrap("9iaJ6OObl6TUWYjXAOyZsL0VaDPwF+tRFkMwwYSeqqw=");
private final Base64String thirdParticipant = private final Base64String thirdParticipant =
Base64String.wrap("Jo2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="); Base64String.wrap("Jo2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=");
private OnchainPrivacyGroupManagementProxy onchainPrivacyGroupManagementProxy; private FlexiblePrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy;
private static final String RAW_GET_PARTICIPANTS = "0x5aa68ac0"; private static final String RAW_GET_PARTICIPANTS = "0x5aa68ac0";
private static final String RAW_ADD_PARTICIPANT = private static final String RAW_ADD_PARTICIPANT =
"0xb4926e2500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001f772b2ee55f016431cefe724a05814324bb96e9afdb73e338665a693d4653678"; "0xb4926e2500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001f772b2ee55f016431cefe724a05814324bb96e9afdb73e338665a693d4653678";
private BesuNode minerNode; private BesuNode minerNode;
private DefaultOnchainPrivacyGroupManagementContract defaultOnchainPrivacyGroupManagementContract; private DefaultFlexiblePrivacyGroupManagementContract
defaultFlexiblePrivacyGroupManagementContract;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
minerNode = besu.createMinerNode("node"); minerNode = besu.createMinerNode("node");
cluster.start(minerNode); cluster.start(minerNode);
defaultOnchainPrivacyGroupManagementContract = defaultFlexiblePrivacyGroupManagementContract =
minerNode.execute( minerNode.execute(
contractTransactions.createSmartContract( contractTransactions.createSmartContract(
DefaultOnchainPrivacyGroupManagementContract.class)); DefaultFlexiblePrivacyGroupManagementContract.class));
onchainPrivacyGroupManagementProxy = flexiblePrivacyGroupManagementProxy =
minerNode.execute( minerNode.execute(
contractTransactions.createSmartContract( contractTransactions.createSmartContract(
OnchainPrivacyGroupManagementProxy.class, FlexiblePrivacyGroupManagementProxy.class,
defaultOnchainPrivacyGroupManagementContract.getContractAddress())); defaultFlexiblePrivacyGroupManagementContract.getContractAddress()));
} }
@Test @Test
public void rlp() throws Exception { public void rlp() throws Exception {
assertThat(onchainPrivacyGroupManagementProxy.isValid()).isEqualTo(true); assertThat(flexiblePrivacyGroupManagementProxy.isValid()).isEqualTo(true);
contractVerifier contractVerifier
.validTransactionReceipt(onchainPrivacyGroupManagementProxy.getContractAddress()) .validTransactionReceipt(flexiblePrivacyGroupManagementProxy.getContractAddress())
.verify(onchainPrivacyGroupManagementProxy); .verify(flexiblePrivacyGroupManagementProxy);
assertThat(RAW_GET_PARTICIPANTS) assertThat(RAW_GET_PARTICIPANTS)
.isEqualTo(onchainPrivacyGroupManagementProxy.getParticipants().encodeFunctionCall()); .isEqualTo(flexiblePrivacyGroupManagementProxy.getParticipants().encodeFunctionCall());
assertThat(RAW_ADD_PARTICIPANT) assertThat(RAW_ADD_PARTICIPANT)
.isEqualTo( .isEqualTo(
onchainPrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy
.addParticipants(List.of(firstParticipant.raw())) .addParticipants(List.of(firstParticipant.raw()))
.encodeFunctionCall()); .encodeFunctionCall());
} }
@Test @Test
public void deploysWithNoParticipant() throws Exception { public void deploysWithNoParticipant() throws Exception {
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(0); assertThat(participants.size()).isEqualTo(0);
} }
@Test @Test
public void canAddParticipants() throws Exception { public void canAddParticipants() throws Exception {
onchainPrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy
.addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw())) .addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw()))
.send(); .send();
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(2); assertThat(participants.size()).isEqualTo(2);
assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); assertThat(firstParticipant.raw()).isEqualTo(participants.get(0));
assertThat(secondParticipant.raw()).isEqualTo(participants.get(1)); assertThat(secondParticipant.raw()).isEqualTo(participants.get(1));
@ -104,18 +105,18 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
@Test @Test
public void nonOwnerCannotUpgrade() throws Exception { public void nonOwnerCannotUpgrade() throws Exception {
onchainPrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy
.addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw())) .addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw()))
.send(); .send();
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(2); assertThat(participants.size()).isEqualTo(2);
assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); assertThat(firstParticipant.raw()).isEqualTo(participants.get(0));
assertThat(secondParticipant.raw()).isEqualTo(participants.get(1)); assertThat(secondParticipant.raw()).isEqualTo(participants.get(1));
final DefaultOnchainPrivacyGroupManagementContract upgradedContract = final DefaultFlexiblePrivacyGroupManagementContract upgradedContract =
minerNode.execute( minerNode.execute(
contractTransactions.createSmartContract( contractTransactions.createSmartContract(
DefaultOnchainPrivacyGroupManagementContract.class)); DefaultFlexiblePrivacyGroupManagementContract.class));
final HttpService httpService = final HttpService httpService =
new HttpService( new HttpService(
@ -123,9 +124,9 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
final Web3j web3j = Web3j.build(httpService); final Web3j web3j = Web3j.build(httpService);
// load the proxy contract, use it with another signer // load the proxy contract, use it with another signer
final OnchainPrivacyGroupManagementProxy proxyContractAccount2 = final FlexiblePrivacyGroupManagementProxy proxyContractAccount2 =
OnchainPrivacyGroupManagementProxy.load( FlexiblePrivacyGroupManagementProxy.load(
onchainPrivacyGroupManagementProxy.getContractAddress(), flexiblePrivacyGroupManagementProxy.getContractAddress(),
web3j, web3j,
Credentials.create(Accounts.GENESIS_ACCOUNT_TWO_PRIVATE_KEY), Credentials.create(Accounts.GENESIS_ACCOUNT_TWO_PRIVATE_KEY),
new DefaultGasProvider()); new DefaultGasProvider());
@ -138,22 +139,22 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
@Test @Test
public void ownerCanUpgrade() throws Exception { public void ownerCanUpgrade() throws Exception {
onchainPrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy
.addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw())) .addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw()))
.send(); .send();
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(2); assertThat(participants.size()).isEqualTo(2);
assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); assertThat(firstParticipant.raw()).isEqualTo(participants.get(0));
assertThat(secondParticipant.raw()).isEqualTo(participants.get(1)); assertThat(secondParticipant.raw()).isEqualTo(participants.get(1));
final DefaultOnchainPrivacyGroupManagementContract upgradedContract = final DefaultFlexiblePrivacyGroupManagementContract upgradedContract =
minerNode.execute( minerNode.execute(
contractTransactions.createSmartContract( contractTransactions.createSmartContract(
DefaultOnchainPrivacyGroupManagementContract.class)); DefaultFlexiblePrivacyGroupManagementContract.class));
onchainPrivacyGroupManagementProxy.upgradeTo(upgradedContract.getContractAddress()).send(); flexiblePrivacyGroupManagementProxy.upgradeTo(upgradedContract.getContractAddress()).send();
final List<byte[]> participantsAfterUpgrade = final List<byte[]> participantsAfterUpgrade =
onchainPrivacyGroupManagementProxy.getParticipants().send(); flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participantsAfterUpgrade.size()).isEqualTo(2); assertThat(participantsAfterUpgrade.size()).isEqualTo(2);
assertThat(firstParticipant.raw()).isEqualTo(participantsAfterUpgrade.get(0)); assertThat(firstParticipant.raw()).isEqualTo(participantsAfterUpgrade.get(0));
assertThat(secondParticipant.raw()).isEqualTo(participantsAfterUpgrade.get(1)); assertThat(secondParticipant.raw()).isEqualTo(participantsAfterUpgrade.get(1));
@ -161,14 +162,14 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
@Test @Test
public void canAddTwiceToContractWhenCallLock() throws Exception { public void canAddTwiceToContractWhenCallLock() throws Exception {
onchainPrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy
.addParticipants(Arrays.asList(firstParticipant.raw(), thirdParticipant.raw())) .addParticipants(Arrays.asList(firstParticipant.raw(), thirdParticipant.raw()))
.send(); .send();
onchainPrivacyGroupManagementProxy.lock().send(); flexiblePrivacyGroupManagementProxy.lock().send();
onchainPrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy
.addParticipants(Collections.singletonList(secondParticipant.raw())) .addParticipants(Collections.singletonList(secondParticipant.raw()))
.send(); .send();
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(3); assertThat(participants.size()).isEqualTo(3);
assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); assertThat(firstParticipant.raw()).isEqualTo(participants.get(0));
assertThat(thirdParticipant.raw()).isEqualTo(participants.get(1)); assertThat(thirdParticipant.raw()).isEqualTo(participants.get(1));

@ -22,11 +22,11 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.account.PrivacyAccountResolver; import org.hyperledger.besu.tests.acceptance.dsl.privacy.account.PrivacyAccountResolver;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.contract.CallPrivateSmartContractFunction; import org.hyperledger.besu.tests.acceptance.dsl.privacy.contract.CallPrivateSmartContractFunction;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.CreateOnchainPrivacyGroupTransaction; import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.CreateFlexiblePrivacyGroupTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter; import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.perm.PermissioningTransactions; import org.hyperledger.besu.tests.acceptance.dsl.transaction.perm.PermissioningTransactions;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory; import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory;
import org.hyperledger.besu.tests.acceptance.privacy.OnchainPrivacyAcceptanceTestBase; import org.hyperledger.besu.tests.acceptance.privacy.FlexiblePrivacyAcceptanceTestBase;
import org.hyperledger.besu.tests.web3j.generated.EventEmitter; import org.hyperledger.besu.tests.web3j.generated.EventEmitter;
import org.hyperledger.enclave.testutil.EnclaveType; import org.hyperledger.enclave.testutil.EnclaveType;
@ -49,11 +49,11 @@ import org.web3j.utils.Base64String;
import org.web3j.utils.Restriction; import org.web3j.utils.Restriction;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceTestBase { public class FlexibleMultiTenancyAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase {
private final EnclaveType enclaveType; private final EnclaveType enclaveType;
public OnchainMultiTenancyAcceptanceTest(final EnclaveType enclaveType) { public FlexibleMultiTenancyAcceptanceTest(final EnclaveType enclaveType) {
this.enclaveType = enclaveType; this.enclaveType = enclaveType;
} }
@ -72,7 +72,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
alice = alice =
privacyBesu.createOnchainPrivacyGroupEnabledMinerNode( privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode(
"node1", PrivacyAccountResolver.MULTI_TENANCY, true, enclaveType, Optional.empty()); "node1", PrivacyAccountResolver.MULTI_TENANCY, true, enclaveType, Optional.empty());
final BesuNode aliceBesu = alice.getBesu(); final BesuNode aliceBesu = alice.getBesu();
privacyCluster.startNodes(alice); privacyCluster.startNodes(alice);
@ -103,7 +103,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
@Test @Test
public void createPrivacyGroup() { public void createPrivacyGroup() {
createOnchainPrivacyGroup(alice); createFlexiblePrivacyGroup(alice);
} }
@Test @Test
@ -111,7 +111,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
final MultiTenancyPrivacyGroup privacyGroup = new MultiTenancyPrivacyGroup(); final MultiTenancyPrivacyGroup privacyGroup = new MultiTenancyPrivacyGroup();
privacyGroup.addNodeWithTenants( privacyGroup.addNodeWithTenants(
aliceMultiTenancyPrivacyNode, aliceMultiTenancyPrivacyNode.getTenants()); aliceMultiTenancyPrivacyNode, aliceMultiTenancyPrivacyNode.getTenants());
createOnchainPrivacyGroup(privacyGroup); createFlexiblePrivacyGroup(privacyGroup);
} }
@Test @Test
@ -120,7 +120,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
final List<String> tenants = aliceMultiTenancyPrivacyNode.getTenants(); final List<String> tenants = aliceMultiTenancyPrivacyNode.getTenants();
final String removedTenant = tenants.remove(tenants.size() - 1); final String removedTenant = tenants.remove(tenants.size() - 1);
twoTenantsFromAlice.addNodeWithTenants(aliceMultiTenancyPrivacyNode, tenants); twoTenantsFromAlice.addNodeWithTenants(aliceMultiTenancyPrivacyNode, tenants);
final String privacyGroupId = createOnchainPrivacyGroup(twoTenantsFromAlice); final String privacyGroupId = createFlexiblePrivacyGroup(twoTenantsFromAlice);
final MultiTenancyPrivacyNode multiTenancyPrivacyNode = final MultiTenancyPrivacyNode multiTenancyPrivacyNode =
twoTenantsFromAlice.getPrivacyNodes().get(0); twoTenantsFromAlice.getPrivacyNodes().get(0);
@ -250,9 +250,10 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
.getBesu() .getBesu()
.useAuthenticationTokenInHeaderForJsonRpc( .useAuthenticationTokenInHeaderForJsonRpc(
multiTenancyPrivacyNode.getTokenForTenant(tenant)); multiTenancyPrivacyNode.getTokenForTenant(tenant));
final List<PrivacyRequestFactory.OnchainPrivacyGroup> group = final List<PrivacyRequestFactory.FlexiblePrivacyGroup> group =
privacyNode.execute( privacyNode.execute(
privacyTransactions.findOnchainPrivacyGroup(Base64String.unwrapList(base64StringList))); privacyTransactions.findFlexiblePrivacyGroup(
Base64String.unwrapList(base64StringList)));
assertThat(group.size()).isEqualTo(1); assertThat(group.size()).isEqualTo(1);
assertThat(group.get(0).getMembers()).containsAll(base64StringList).hasSize(2); assertThat(group.get(0).getMembers()).containsAll(base64StringList).hasSize(2);
@ -264,9 +265,9 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
assertThatThrownBy( assertThatThrownBy(
() -> () ->
privacyNode.execute( privacyNode.execute(
privacyTransactions.findOnchainPrivacyGroup( privacyTransactions.findFlexiblePrivacyGroup(
Base64String.unwrapList(base64StringList)))) Base64String.unwrapList(base64StringList))))
.hasMessageContaining("Error finding onchain privacy group"); .hasMessageContaining("Error finding flexible privacy group");
// check that a member can do a priv_call // check that a member can do a priv_call
privacyNode privacyNode
@ -318,7 +319,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
final MultiTenancyPrivacyGroup allTenantsFromAlice = new MultiTenancyPrivacyGroup(); final MultiTenancyPrivacyGroup allTenantsFromAlice = new MultiTenancyPrivacyGroup();
final List<String> tenants = aliceMultiTenancyPrivacyNode.getTenants(); final List<String> tenants = aliceMultiTenancyPrivacyNode.getTenants();
allTenantsFromAlice.addNodeWithTenants(aliceMultiTenancyPrivacyNode, tenants); allTenantsFromAlice.addNodeWithTenants(aliceMultiTenancyPrivacyNode, tenants);
final String privacyGroupId = createOnchainPrivacyGroup(allTenantsFromAlice); final String privacyGroupId = createFlexiblePrivacyGroup(allTenantsFromAlice);
final MultiTenancyPrivacyNode multiTenancyPrivacyNode = final MultiTenancyPrivacyNode multiTenancyPrivacyNode =
allTenantsFromAlice.getPrivacyNodes().get(0); allTenantsFromAlice.getPrivacyNodes().get(0);
final String groupCreatingTenant = allTenantsFromAlice.getGroupCreatingTenant(); final String groupCreatingTenant = allTenantsFromAlice.getGroupCreatingTenant();
@ -407,7 +408,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
.hasMessageContaining("Unauthorized"); .hasMessageContaining("Unauthorized");
} }
private String createOnchainPrivacyGroup(final MultiTenancyPrivacyGroup group) { private String createFlexiblePrivacyGroup(final MultiTenancyPrivacyGroup group) {
final List<MultiTenancyPrivacyNode> multiTenancyPrivacyNodes = group.getPrivacyNodes(); final List<MultiTenancyPrivacyNode> multiTenancyPrivacyNodes = group.getPrivacyNodes();
final MultiTenancyPrivacyNode groupCreatorMultiTenancyPrivacyNode = final MultiTenancyPrivacyNode groupCreatorMultiTenancyPrivacyNode =
multiTenancyPrivacyNodes.get(0); multiTenancyPrivacyNodes.get(0);
@ -415,8 +416,8 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
final String groupCreatorTenant = group.getGroupCreatingTenant(); final String groupCreatorTenant = group.getGroupCreatingTenant();
final List<String> members = group.getTenants(); final List<String> members = group.getTenants();
final String token = groupCreatorMultiTenancyPrivacyNode.getTokenForTenant(groupCreatorTenant); final String token = groupCreatorMultiTenancyPrivacyNode.getTokenForTenant(groupCreatorTenant);
final CreateOnchainPrivacyGroupTransaction createTx = final CreateFlexiblePrivacyGroupTransaction createTx =
privacyTransactions.createOnchainPrivacyGroup( privacyTransactions.createFlexiblePrivacyGroup(
groupCreatorNode, groupCreatorTenant, members, token); groupCreatorNode, groupCreatorTenant, members, token);
final PrivacyRequestFactory.PrivxCreatePrivacyGroupResponse createResponse = final PrivacyRequestFactory.PrivxCreatePrivacyGroupResponse createResponse =
@ -432,7 +433,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
privacyNode privacyNode
.getBesu() .getBesu()
.useAuthenticationTokenInHeaderForJsonRpc(mtpn.getTokenForTenant(tenant)); .useAuthenticationTokenInHeaderForJsonRpc(mtpn.getTokenForTenant(tenant));
privacyNode.verify(onchainPrivacyGroupExists(privacyGroupId, base64StringList)); privacyNode.verify(flexiblePrivacyGroupExists(privacyGroupId, base64StringList));
} }
} }
} }

@ -19,7 +19,7 @@ import static java.util.Objects.isNull;
import static java.util.function.Predicate.isEqual; import static java.util.function.Predicate.isEqual;
import static java.util.function.Predicate.not; import static java.util.function.Predicate.not;
import static org.hyperledger.besu.controller.BesuController.CACHE_PATH; import static org.hyperledger.besu.controller.BesuController.CACHE_PATH;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import org.hyperledger.besu.cli.config.EthNetworkConfig; import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.controller.BesuController;
@ -60,7 +60,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.OnchainPrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract;
import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration; import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.RlpxConfiguration; import org.hyperledger.besu.ethereum.p2p.config.RlpxConfiguration;
@ -925,17 +925,17 @@ public class RunnerBuilder {
private void createPrivateTransactionObserver( private void createPrivateTransactionObserver(
final PrivateTransactionObserver privateTransactionObserver, final PrivateTransactionObserver privateTransactionObserver,
final PrivacyParameters privacyParameters) { final PrivacyParameters privacyParameters) {
// register privateTransactionObserver as observer of events fired by the onchain precompile. // register privateTransactionObserver as observer of events fired by the flexible precompile.
if (privacyParameters.isOnchainPrivacyGroupsEnabled() if (privacyParameters.isFlexiblePrivacyGroupsEnabled()
&& privacyParameters.isMultiTenancyEnabled()) { && privacyParameters.isMultiTenancyEnabled()) {
final OnchainPrivacyPrecompiledContract onchainPrivacyPrecompiledContract = final FlexiblePrivacyPrecompiledContract flexiblePrivacyPrecompiledContract =
(OnchainPrivacyPrecompiledContract) (FlexiblePrivacyPrecompiledContract)
besuController besuController
.getProtocolSchedule() .getProtocolSchedule()
.getByBlockNumber(1) .getByBlockNumber(1)
.getPrecompileContractRegistry() .getPrecompileContractRegistry()
.get(ONCHAIN_PRIVACY); .get(FLEXIBLE_PRIVACY);
onchainPrivacyPrecompiledContract.addPrivateTransactionObserver(privateTransactionObserver); flexiblePrivacyPrecompiledContract.addPrivateTransactionObserver(privateTransactionObserver);
} }
} }

@ -21,6 +21,7 @@ import static java.util.Collections.singletonList;
import static org.hyperledger.besu.cli.DefaultCommandValues.getDefaultBesuDataPath; import static org.hyperledger.besu.cli.DefaultCommandValues.getDefaultBesuDataPath;
import static org.hyperledger.besu.cli.config.NetworkName.MAINNET; import static org.hyperledger.besu.cli.config.NetworkName.MAINNET;
import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPENDENCY_WARNING_MSG; import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPENDENCY_WARNING_MSG;
import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPRECATION_WARNING_MSG;
import static org.hyperledger.besu.controller.BesuController.DATABASE_PATH; import static org.hyperledger.besu.controller.BesuController.DATABASE_PATH;
import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT; import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_PORT; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_PORT;
@ -989,10 +990,17 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final Boolean migratePrivateDatabase = false; private final Boolean migratePrivateDatabase = false;
@Option( @Option(
names = {"--privacy-flexible-groups-enabled", "--privacy-onchain-groups-enabled"}, names = {"--privacy-flexible-groups-enabled"},
description = "Enable flexible (onchain) privacy groups (default: ${DEFAULT-VALUE})") description = "Enable flexible privacy groups (default: ${DEFAULT-VALUE})")
private final Boolean isFlexiblePrivacyGroupsEnabled = false; private final Boolean isFlexiblePrivacyGroupsEnabled = false;
@Option(
hidden = true,
names = {"--privacy-onchain-groups-enabled"},
description =
"!!DEPRECATED!! Use `--privacy-flexible-groups-enabled` instead. Enable flexible (onchain) privacy groups (default: ${DEFAULT-VALUE})")
private final Boolean isOnchainPrivacyGroupsEnabled = false;
@Option( @Option(
names = {"--target-gas-limit"}, names = {"--target-gas-limit"},
description = description =
@ -1474,9 +1482,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
"No Payload Provider has been provided. You must register one when enabling privacy plugin!"); "No Payload Provider has been provided. You must register one when enabling privacy plugin!");
} }
if (unstablePrivacyPluginOptions.isPrivacyPluginEnabled() && isFlexiblePrivacyGroupsEnabled) { if (unstablePrivacyPluginOptions.isPrivacyPluginEnabled()
&& (isFlexiblePrivacyGroupsEnabled || isOnchainPrivacyGroupsEnabled)) {
throw new ParameterException( throw new ParameterException(
commandLine, "Privacy Plugin can not be used with flexible (onchain) privacy groups"); commandLine, "Privacy Plugin can not be used with flexible privacy groups");
} }
} }
} }
@ -1666,6 +1675,13 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
"--node-private-key-file", "--node-private-key-file",
"--security-module=" + DEFAULT_SECURITY_MODULE); "--security-module=" + DEFAULT_SECURITY_MODULE);
} }
if (isOnchainPrivacyGroupsEnabled) {
logger.warn(
DEPRECATION_WARNING_MSG,
"--privacy-onchain-groups-enabled",
"--privacy-flexible-groups-enabled");
}
} }
private void configure() throws Exception { private void configure() throws Exception {
@ -2253,7 +2269,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
privacyParametersBuilder.setEnabled(true); privacyParametersBuilder.setEnabled(true);
privacyParametersBuilder.setEnclaveUrl(privacyUrl); privacyParametersBuilder.setEnclaveUrl(privacyUrl);
privacyParametersBuilder.setMultiTenancyEnabled(isPrivacyMultiTenancyEnabled); privacyParametersBuilder.setMultiTenancyEnabled(isPrivacyMultiTenancyEnabled);
privacyParametersBuilder.setOnchainPrivacyGroupsEnabled(isFlexiblePrivacyGroupsEnabled); privacyParametersBuilder.setFlexiblePrivacyGroupsEnabled(
isFlexiblePrivacyGroupsEnabled || isOnchainPrivacyGroupsEnabled);
privacyParametersBuilder.setPrivacyPluginEnabled( privacyParametersBuilder.setPrivacyPluginEnabled(
unstablePrivacyPluginOptions.isPrivacyPluginEnabled()); unstablePrivacyPluginOptions.isPrivacyPluginEnabled());

@ -28,6 +28,7 @@ public class CommandLineUtils {
"{} has been ignored because {} was not defined on the command line."; "{} has been ignored because {} was not defined on the command line.";
public static final String MULTI_DEPENDENCY_WARNING_MSG = public static final String MULTI_DEPENDENCY_WARNING_MSG =
"{} ignored because none of {} was defined."; "{} ignored because none of {} was defined.";
public static final String DEPRECATION_WARNING_MSG = "{} has been deprecated, use {} instead.";
/** /**
* Check if options are passed that require an option to be true to have any effect and log a * Check if options are passed that require an option to be true to have any effect and log a

@ -49,12 +49,23 @@ public class ConfigOptionSearchAndRunHandler extends AbstractParseResultHandler<
public List<Object> handle(final ParseResult parseResult) throws ParameterException { public List<Object> handle(final ParseResult parseResult) throws ParameterException {
final CommandLine commandLine = parseResult.asCommandLineList().get(0); final CommandLine commandLine = parseResult.asCommandLineList().get(0);
final Optional<File> configFile = findConfigFile(parseResult, commandLine); final Optional<File> configFile = findConfigFile(parseResult, commandLine);
validatePrivacyOptions(parseResult, commandLine);
commandLine.setDefaultValueProvider(createDefaultValueProvider(commandLine, configFile)); commandLine.setDefaultValueProvider(createDefaultValueProvider(commandLine, configFile));
commandLine.parseWithHandlers( commandLine.parseWithHandlers(
resultHandler, exceptionHandler, parseResult.originalArgs().toArray(new String[0])); resultHandler, exceptionHandler, parseResult.originalArgs().toArray(new String[0]));
return new ArrayList<>(); return new ArrayList<>();
} }
private void validatePrivacyOptions(
final ParseResult parseResult, final CommandLine commandLine) {
if (parseResult.hasMatchedOption("--privacy-onchain-groups-enabled")
&& parseResult.hasMatchedOption("--privacy-flexible-groups-enabled")) {
throw new ParameterException(
commandLine,
"The `--privacy-onchain-groups-enabled` option is deprecated and you should only use `--privacy-flexible-groups-enabled`");
}
}
private Optional<File> findConfigFile( private Optional<File> findConfigFile(
final ParseResult parseResult, final CommandLine commandLine) { final ParseResult parseResult, final CommandLine commandLine) {
if (parseResult.hasMatchedOption("--config-file") if (parseResult.hasMatchedOption("--config-file")

@ -16,7 +16,7 @@ package org.hyperledger.besu;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.controller.BesuController;
@ -81,16 +81,16 @@ public class PrivacyTest {
} }
@Test @Test
public void onchainEnabledPrivacy() throws IOException, URISyntaxException { public void flexibleEnabledPrivacy() throws IOException, URISyntaxException {
final BesuController besuController = setUpControllerWithPrivacyEnabled(true); final BesuController besuController = setUpControllerWithPrivacyEnabled(true);
final PrecompiledContract onchainPrecompiledContract = final PrecompiledContract flexiblePrecompiledContract =
getPrecompile(besuController, ONCHAIN_PRIVACY); getPrecompile(besuController, FLEXIBLE_PRIVACY);
assertThat(onchainPrecompiledContract.getName()).isEqualTo("OnchainPrivacy"); assertThat(flexiblePrecompiledContract.getName()).isEqualTo("FlexiblePrivacy");
} }
private BesuController setUpControllerWithPrivacyEnabled(final boolean onchainEnabled) private BesuController setUpControllerWithPrivacyEnabled(final boolean flexibleEnabled)
throws IOException, URISyntaxException { throws IOException, URISyntaxException {
final Path dataDir = folder.newFolder().toPath(); final Path dataDir = folder.newFolder().toPath();
final Path dbDir = dataDir.resolve("database"); final Path dbDir = dataDir.resolve("database");
@ -100,7 +100,7 @@ public class PrivacyTest {
.setEnclaveUrl(new URI("http://127.0.0.1:8000")) .setEnclaveUrl(new URI("http://127.0.0.1:8000"))
.setStorageProvider(createKeyValueStorageProvider(dataDir, dbDir)) .setStorageProvider(createKeyValueStorageProvider(dataDir, dbDir))
.setEnclaveFactory(new EnclaveFactory(vertx)) .setEnclaveFactory(new EnclaveFactory(vertx))
.setOnchainPrivacyGroupsEnabled(onchainEnabled) .setFlexiblePrivacyGroupsEnabled(flexibleEnabled)
.build(); .build();
return new BesuController.Builder() return new BesuController.Builder()
.fromGenesisConfig(GenesisConfigFile.mainnet()) .fromGenesisConfig(GenesisConfigFile.mainnet())

@ -26,6 +26,7 @@ import static org.hyperledger.besu.cli.config.NetworkName.MORDOR;
import static org.hyperledger.besu.cli.config.NetworkName.RINKEBY; import static org.hyperledger.besu.cli.config.NetworkName.RINKEBY;
import static org.hyperledger.besu.cli.config.NetworkName.ROPSTEN; import static org.hyperledger.besu.cli.config.NetworkName.ROPSTEN;
import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPENDENCY_WARNING_MSG; import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPENDENCY_WARNING_MSG;
import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPRECATION_WARNING_MSG;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.ETH; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.ETH;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.NET; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.NET;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.PERM; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.PERM;
@ -1660,6 +1661,16 @@ public class BesuCommandTest extends CommandTestAbstract {
"The `--ethstats-contact` requires ethstats server URL to be provided. Either remove --ethstats-contact or provide a URL (via --ethstats=nodename:secret@host:port)"); "The `--ethstats-contact` requires ethstats server URL to be provided. Either remove --ethstats-contact or provide a URL (via --ethstats=nodename:secret@host:port)");
} }
@Test
public void privacyOnchainGroupsEnabledCannotBeUsedWithPrivacyFlexibleGroupsEnabled() {
parseCommand("--privacy-onchain-groups-enabled", "--privacy-flexible-groups-enabled");
Mockito.verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString())
.contains(
"The `--privacy-onchain-groups-enabled` option is deprecated and you should only use `--privacy-flexible-groups-enabled`");
}
@Test @Test
public void parsesValidBonsaiTrieLimitBackLayersOption() { public void parsesValidBonsaiTrieLimitBackLayersOption() {
parseCommand("--Xdata-storage-format", "BONSAI", "--Xbonsai-maximum-back-layers-to-load", "11"); parseCommand("--Xdata-storage-format", "BONSAI", "--Xbonsai-maximum-back-layers-to-load", "11");
@ -3511,7 +3522,7 @@ public class BesuCommandTest extends CommandTestAbstract {
} }
@Test @Test
public void onchainPrivacyGroupEnabledFlagDefaultValueIsFalse() { public void flexiblePrivacyGroupEnabledFlagDefaultValueIsFalse() {
parseCommand( parseCommand(
"--privacy-enabled", "--privacy-enabled",
"--privacy-public-key-file", "--privacy-public-key-file",
@ -3529,7 +3540,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue(); final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue();
assertThat(privacyParameters.isOnchainPrivacyGroupsEnabled()).isEqualTo(false); assertThat(privacyParameters.isFlexiblePrivacyGroupsEnabled()).isEqualTo(false);
} }
@Test @Test
@ -3552,7 +3563,24 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue(); final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue();
assertThat(privacyParameters.isOnchainPrivacyGroupsEnabled()).isEqualTo(true); assertThat(privacyParameters.isFlexiblePrivacyGroupsEnabled()).isEqualTo(true);
}
@Test
public void onchainPrivacyGroupEnabledOptionIsDeprecated() {
parseCommand(
"--privacy-enabled",
"--privacy-public-key-file",
ENCLAVE_PUBLIC_KEY_PATH,
"--privacy-onchain-groups-enabled",
"--min-gas-price",
"0");
verify(mockLogger)
.warn(
DEPRECATION_WARNING_MSG,
"--privacy-onchain-groups-enabled",
"--privacy-flexible-groups-enabled");
} }
@Test @Test
@ -3575,7 +3603,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue(); final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue();
assertThat(privacyParameters.isOnchainPrivacyGroupsEnabled()).isEqualTo(true); assertThat(privacyParameters.isFlexiblePrivacyGroupsEnabled()).isEqualTo(true);
} }
@Test @Test

@ -148,6 +148,7 @@ privacy-multi-tenancy-enabled=true
privacy-marker-transaction-signing-key-file="./signerKey" privacy-marker-transaction-signing-key-file="./signerKey"
privacy-enable-database-migration=false privacy-enable-database-migration=false
privacy-onchain-groups-enabled=false privacy-onchain-groups-enabled=false
privacy-flexible-groups-enabled=false
# Transaction Pool # Transaction Pool
tx-pool-retention-hours=999 tx-pool-retention-hours=999

@ -86,7 +86,7 @@ public class PrivacyGroup implements Serializable {
public enum Type { public enum Type {
LEGACY, LEGACY,
ONCHAIN, FLEXIBLE,
PANTHEON PANTHEON
} }
} }

@ -64,7 +64,8 @@ public enum RpcMethod {
PRIV_GET_FILTER_LOGS("priv_getFilterLogs"), PRIV_GET_FILTER_LOGS("priv_getFilterLogs"),
PRIV_SUBSCRIBE("priv_subscribe"), PRIV_SUBSCRIBE("priv_subscribe"),
PRIV_UNSUBSCRIBE("priv_unsubscribe"), PRIV_UNSUBSCRIBE("priv_unsubscribe"),
PRIVX_FIND_PRIVACY_GROUP("privx_findOnChainPrivacyGroup"), PRIVX_FIND_PRIVACY_GROUP_OLD("privx_findOnchainPrivacyGroup"),
PRIVX_FIND_PRIVACY_GROUP("privx_findFlexiblePrivacyGroup"),
EEA_SEND_RAW_TRANSACTION("eea_sendRawTransaction"), EEA_SEND_RAW_TRANSACTION("eea_sendRawTransaction"),
ETH_ACCOUNTS("eth_accounts"), ETH_ACCOUNTS("eth_accounts"),
ETH_BLOCK_NUMBER("eth_blockNumber"), ETH_BLOCK_NUMBER("eth_blockNumber"),

@ -14,7 +14,7 @@
*/ */
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.enclave.types.PrivacyGroup;
@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.OnchainUtil; import org.hyperledger.besu.ethereum.privacy.FlexibleUtil;
import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
@ -37,12 +37,12 @@ import java.util.Optional;
import io.vertx.ext.auth.User; import io.vertx.ext.auth.User;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTransaction { public class RestrictedFlexibleEeaSendRawTransaction extends AbstractEeaSendRawTransaction {
private final PrivacyController privacyController; private final PrivacyController privacyController;
private final PrivacyIdProvider privacyIdProvider; private final PrivacyIdProvider privacyIdProvider;
public RestrictedOnchainEeaSendRawTransaction( public RestrictedFlexibleEeaSendRawTransaction(
final TransactionPool transactionPool, final TransactionPool transactionPool,
final PrivacyIdProvider privacyIdProvider, final PrivacyIdProvider privacyIdProvider,
final PrivateMarkerTransactionFactory privateMarkerTransactionFactory, final PrivateMarkerTransactionFactory privateMarkerTransactionFactory,
@ -71,7 +71,7 @@ public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTr
final Optional<User> user) { final Optional<User> user) {
final Optional<Bytes> maybePrivacyGroupId = privateTransaction.getPrivacyGroupId(); final Optional<Bytes> maybePrivacyGroupId = privateTransaction.getPrivacyGroupId();
if (maybePrivacyGroupId.isEmpty()) { if (maybePrivacyGroupId.isEmpty()) {
throw new JsonRpcErrorResponseException(JsonRpcError.ONCHAIN_PRIVACY_GROUP_ID_NOT_AVAILABLE); throw new JsonRpcErrorResponseException(JsonRpcError.FLEXIBLE_PRIVACY_GROUP_ID_NOT_AVAILABLE);
} }
final Bytes privacyGroupId = maybePrivacyGroupId.get(); final Bytes privacyGroupId = maybePrivacyGroupId.get();
@ -81,20 +81,20 @@ public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTr
privacyController.findPrivacyGroupByGroupId(privacyGroupId.toBase64String(), privacyUserId); privacyController.findPrivacyGroupByGroupId(privacyGroupId.toBase64String(), privacyUserId);
final boolean isGroupAdditionTransaction = final boolean isGroupAdditionTransaction =
OnchainUtil.isGroupAdditionTransaction(privateTransaction); FlexibleUtil.isGroupAdditionTransaction(privateTransaction);
if (maybePrivacyGroup.isEmpty() && !isGroupAdditionTransaction) { if (maybePrivacyGroup.isEmpty() && !isGroupAdditionTransaction) {
throw new JsonRpcErrorResponseException(JsonRpcError.ONCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST); throw new JsonRpcErrorResponseException(JsonRpcError.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
} }
if (isGroupAdditionTransaction) { if (isGroupAdditionTransaction) {
final List<String> participantsFromParameter = final List<String> participantsFromParameter =
OnchainUtil.getParticipantsFromParameter(privateTransaction.getPayload()); FlexibleUtil.getParticipantsFromParameter(privateTransaction.getPayload());
if (maybePrivacyGroup.isEmpty()) { if (maybePrivacyGroup.isEmpty()) {
maybePrivacyGroup = maybePrivacyGroup =
Optional.of( Optional.of(
new PrivacyGroup( new PrivacyGroup(
privacyGroupId.toBase64String(), privacyGroupId.toBase64String(),
PrivacyGroup.Type.ONCHAIN, PrivacyGroup.Type.FLEXIBLE,
null, null,
null, null,
participantsFromParameter)); participantsFromParameter));
@ -104,7 +104,7 @@ public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTr
} }
if (!maybePrivacyGroup.get().getMembers().contains(privacyUserId)) { if (!maybePrivacyGroup.get().getMembers().contains(privacyUserId)) {
throw new JsonRpcErrorResponseException(JsonRpcError.ONCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST); throw new JsonRpcErrorResponseException(JsonRpcError.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
} }
final String pmtPayload = final String pmtPayload =
@ -112,7 +112,7 @@ public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTr
privateTransaction, privacyUserId, maybePrivacyGroup); privateTransaction, privacyUserId, maybePrivacyGroup);
return createPrivateMarkerTransaction( return createPrivateMarkerTransaction(
sender, ONCHAIN_PRIVACY, pmtPayload, privateTransaction, privacyUserId); sender, FLEXIBLE_PRIVACY, pmtPayload, privateTransaction, privacyUserId);
} }
@Override @Override

@ -31,8 +31,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.FlexibleUtil;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException; import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException;
import org.hyperledger.besu.ethereum.privacy.OnchainUtil;
import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
@ -51,15 +51,15 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
private static final Logger LOG = getLogger(); private static final Logger LOG = getLogger();
private final PrivacyController privacyController; private final PrivacyController privacyController;
private final PrivacyIdProvider privacyIdProvider; private final PrivacyIdProvider privacyIdProvider;
private final boolean onchainPrivacyGroupsEnabled; private final boolean flexiblePrivacyGroupsEnabled;
public PrivDistributeRawTransaction( public PrivDistributeRawTransaction(
final PrivacyController privacyController, final PrivacyController privacyController,
final PrivacyIdProvider privacyIdProvider, final PrivacyIdProvider privacyIdProvider,
final boolean onchainPrivacyGroupsEnabled) { final boolean flexiblePrivacyGroupsEnabled) {
this.privacyController = privacyController; this.privacyController = privacyController;
this.privacyIdProvider = privacyIdProvider; this.privacyIdProvider = privacyIdProvider;
this.onchainPrivacyGroupsEnabled = onchainPrivacyGroupsEnabled; this.flexiblePrivacyGroupsEnabled = flexiblePrivacyGroupsEnabled;
} }
@Override @Override
@ -84,8 +84,8 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
final Optional<Bytes> maybePrivacyGroupId = privateTransaction.getPrivacyGroupId(); final Optional<Bytes> maybePrivacyGroupId = privateTransaction.getPrivacyGroupId();
if (onchainPrivacyGroupsEnabled && maybePrivacyGroupId.isEmpty()) { if (flexiblePrivacyGroupsEnabled && maybePrivacyGroupId.isEmpty()) {
return new JsonRpcErrorResponse(id, JsonRpcError.ONCHAIN_PRIVACY_GROUP_ID_NOT_AVAILABLE); return new JsonRpcErrorResponse(id, JsonRpcError.FLEXIBLE_PRIVACY_GROUP_ID_NOT_AVAILABLE);
} }
Optional<PrivacyGroup> maybePrivacyGroup = Optional<PrivacyGroup> maybePrivacyGroup =
@ -93,16 +93,16 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
gId -> gId ->
privacyController.findPrivacyGroupByGroupId(gId.toBase64String(), privacyUserId)); privacyController.findPrivacyGroupByGroupId(gId.toBase64String(), privacyUserId));
if (onchainPrivacyGroupsEnabled) { if (flexiblePrivacyGroupsEnabled) {
if (OnchainUtil.isGroupAdditionTransaction(privateTransaction)) { if (FlexibleUtil.isGroupAdditionTransaction(privateTransaction)) {
final List<String> participantsFromParameter = final List<String> participantsFromParameter =
OnchainUtil.getParticipantsFromParameter(privateTransaction.getPayload()); FlexibleUtil.getParticipantsFromParameter(privateTransaction.getPayload());
if (maybePrivacyGroup.isEmpty()) { if (maybePrivacyGroup.isEmpty()) {
maybePrivacyGroup = maybePrivacyGroup =
Optional.of( Optional.of(
new PrivacyGroup( new PrivacyGroup(
maybePrivacyGroupId.get().toBase64String(), maybePrivacyGroupId.get().toBase64String(),
PrivacyGroup.Type.ONCHAIN, PrivacyGroup.Type.FLEXIBLE,
"", "",
"", "",
participantsFromParameter)); participantsFromParameter));
@ -110,7 +110,7 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
maybePrivacyGroup.get().addMembers(participantsFromParameter); maybePrivacyGroup.get().addMembers(participantsFromParameter);
} }
if (maybePrivacyGroup.isEmpty()) { if (maybePrivacyGroup.isEmpty()) {
return new JsonRpcErrorResponse(id, JsonRpcError.ONCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST); return new JsonRpcErrorResponse(id, JsonRpcError.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
} }
} }

@ -0,0 +1,80 @@
/*
* Copyright ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx;
import static org.apache.logging.log4j.LogManager.getLogger;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.FIND_FLEXIBLE_PRIVACY_GROUP_ERROR;
import org.hyperledger.besu.enclave.types.PrivacyGroup;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import java.util.Arrays;
import graphql.com.google.common.collect.Lists;
import org.apache.logging.log4j.Logger;
public class PrivxFindFlexiblePrivacyGroup implements JsonRpcMethod {
private static final Logger LOG = getLogger();
private final PrivacyController privacyController;
private final PrivacyIdProvider privacyIdProvider;
public PrivxFindFlexiblePrivacyGroup(
final PrivacyController privacyController, final PrivacyIdProvider privacyIdProvider) {
this.privacyController = privacyController;
this.privacyIdProvider = privacyIdProvider;
}
@Override
public String getName() {
return RpcMethod.PRIVX_FIND_PRIVACY_GROUP.getMethodName();
}
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
LOG.trace("Executing {}", RpcMethod.PRIVX_FIND_PRIVACY_GROUP.getMethodName());
final String[] addresses = requestContext.getRequiredParameter(0, String[].class);
LOG.trace("Finding a privacy group with members {}", Arrays.toString(addresses));
final PrivacyGroup[] response;
try {
response =
privacyController.findPrivacyGroupByMembers(
Arrays.asList(addresses),
privacyIdProvider.getPrivacyUserId(requestContext.getUser()));
} catch (final MultiTenancyValidationException e) {
LOG.error("Unauthorized privacy multi-tenancy rpc request. {}", e.getMessage());
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), FIND_FLEXIBLE_PRIVACY_GROUP_ERROR);
} catch (final Exception e) {
LOG.error("Failed to fetch flexible privacy group", e);
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), FIND_FLEXIBLE_PRIVACY_GROUP_ERROR);
}
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(), Lists.newArrayList(response));
}
}

@ -1,5 +1,5 @@
/* /*
* Copyright ConsenSys AG. * Copyright contributors to Hyperledger Besu
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at * the License. You may obtain a copy of the License at
@ -14,67 +14,21 @@
*/ */
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx;
import static org.apache.logging.log4j.LogManager.getLogger;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.FIND_ONCHAIN_PRIVACY_GROUP_ERROR;
import org.hyperledger.besu.enclave.types.PrivacyGroup;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException;
import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import java.util.Arrays; // Use PrivxFindFlexiblePrivacyGroup instead
@Deprecated
import graphql.com.google.common.collect.Lists; public class PrivxFindOnchainPrivacyGroup extends PrivxFindFlexiblePrivacyGroup {
import org.apache.logging.log4j.Logger;
public class PrivxFindOnchainPrivacyGroup implements JsonRpcMethod {
private static final Logger LOG = getLogger();
private final PrivacyController privacyController;
private final PrivacyIdProvider privacyIdProvider;
public PrivxFindOnchainPrivacyGroup( public PrivxFindOnchainPrivacyGroup(
final PrivacyController privacyController, final PrivacyIdProvider privacyIdProvider) { final PrivacyController privacyController, final PrivacyIdProvider privacyIdProvider) {
this.privacyController = privacyController; super(privacyController, privacyIdProvider);
this.privacyIdProvider = privacyIdProvider;
} }
@Override @Override
public String getName() { public String getName() {
return RpcMethod.PRIVX_FIND_PRIVACY_GROUP.getMethodName(); return RpcMethod.PRIVX_FIND_PRIVACY_GROUP_OLD.getMethodName();
}
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
LOG.trace("Executing {}", RpcMethod.PRIVX_FIND_PRIVACY_GROUP.getMethodName());
final String[] addresses = requestContext.getRequiredParameter(0, String[].class);
LOG.trace("Finding a privacy group with members {}", Arrays.toString(addresses));
final PrivacyGroup[] response;
try {
response =
privacyController.findPrivacyGroupByMembers(
Arrays.asList(addresses),
privacyIdProvider.getPrivacyUserId(requestContext.getUser()));
} catch (final MultiTenancyValidationException e) {
LOG.error("Unauthorized privacy multi-tenancy rpc request. {}", e.getMessage());
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), FIND_ONCHAIN_PRIVACY_GROUP_ERROR);
} catch (final Exception e) {
LOG.error("Failed to fetch on chain privacy group", e);
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), FIND_ONCHAIN_PRIVACY_GROUP_ERROR);
}
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(), Lists.newArrayList(response));
} }
} }

@ -129,7 +129,7 @@ public enum JsonRpcError {
DELETE_PRIVACY_GROUP_ERROR(-50100, "Error deleting privacy group"), DELETE_PRIVACY_GROUP_ERROR(-50100, "Error deleting privacy group"),
ETHER_VALUE_NOT_SUPPORTED(-50100, "ether value is not supported for private transactions"), ETHER_VALUE_NOT_SUPPORTED(-50100, "ether value is not supported for private transactions"),
FIND_PRIVACY_GROUP_ERROR(-50100, "Error finding privacy group"), FIND_PRIVACY_GROUP_ERROR(-50100, "Error finding privacy group"),
FIND_ONCHAIN_PRIVACY_GROUP_ERROR(-50100, "Error finding onchain privacy group"), FIND_FLEXIBLE_PRIVACY_GROUP_ERROR(-50100, "Error finding flexible privacy group"),
GOQUORUM_NO_PRIVATE_FOR( GOQUORUM_NO_PRIVATE_FOR(
-50100, "No privateFor specified in rawTxArgs for GoQuorum raw private transaction."), -50100, "No privateFor specified in rawTxArgs for GoQuorum raw private transaction."),
GOQUORUM_ONLY_STANDARD_MODE_SUPPORTED( GOQUORUM_ONLY_STANDARD_MODE_SUPPORTED(
@ -140,15 +140,15 @@ public enum JsonRpcError {
GOQUORUM_V_VALUE(-50100, "Signature v value not 37 or 38 for GoQuorum private transaction."), GOQUORUM_V_VALUE(-50100, "Signature v value not 37 or 38 for GoQuorum private transaction."),
GET_PRIVATE_TRANSACTION_NONCE_ERROR(-50100, "Unable to determine nonce for account in group."), GET_PRIVATE_TRANSACTION_NONCE_ERROR(-50100, "Unable to determine nonce for account in group."),
OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST(-50100, "Offchain Privacy group does not exist."), OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST(-50100, "Offchain Privacy group does not exist."),
ONCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST(-50100, "Onchain Privacy group does not exist."), FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST(-50100, "Flexible Privacy group does not exist."),
ONCHAIN_PRIVACY_GROUP_NOT_ENABLED(-50100, "Onchain privacy groups not enabled."), FLEXIBLE_PRIVACY_GROUP_NOT_ENABLED(-50100, "Flexible privacy groups not enabled."),
OFFCHAIN_PRIVACY_GROUP_NOT_ENABLED( OFFCHAIN_PRIVACY_GROUP_NOT_ENABLED(
-50100, "Offchain privacy group can't be used with Onchain privacy groups enabled."), -50100, "Offchain privacy group can't be used with Flexible privacy groups enabled."),
ONCHAIN_PRIVACY_GROUP_ID_NOT_AVAILABLE( FLEXIBLE_PRIVACY_GROUP_ID_NOT_AVAILABLE(
-50100, "Private transactions to onchain privacy groups must use privacyGroupId"), -50100, "Private transactions to flexible privacy groups must use privacyGroupId"),
PMT_FAILED_INTRINSIC_GAS_EXCEEDS_LIMIT( PMT_FAILED_INTRINSIC_GAS_EXCEEDS_LIMIT(
-50100, -50100,
"Private Marker Transaction failed due to intrinsic gas exceeding the limit. Gas limit used from the Private Transaction."), "Privacy Marker Transaction failed due to intrinsic gas exceeding the limit. Gas limit used from the Private Transaction."),
PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY( PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY(
-50100, "Private from does not match enclave public key"), -50100, "Private from does not match enclave public key"),
VALUE_NOT_ZERO(-50100, "We cannot transfer ether in a private transaction yet."), VALUE_NOT_ZERO(-50100, "We cannot transfer ether in a private transaction yet."),

@ -19,8 +19,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.PluginEeaSendRawTransaction; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.PluginEeaSendRawTransaction;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.RestrictedFlexibleEeaSendRawTransaction;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.RestrictedOffchainEeaSendRawTransaction; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.RestrictedOffchainEeaSendRawTransaction;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.RestrictedOnchainEeaSendRawTransaction;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetEeaTransactionCount; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetEeaTransactionCount;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@ -66,9 +66,9 @@ public class EeaJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
privacyController, privacyController,
getGasCalculator()), getGasCalculator()),
new PrivGetEeaTransactionCount(privacyController, privacyIdProvider)); new PrivGetEeaTransactionCount(privacyController, privacyIdProvider));
} else if (getPrivacyParameters().isOnchainPrivacyGroupsEnabled()) { } else if (getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
return mapOf( return mapOf(
new RestrictedOnchainEeaSendRawTransaction( new RestrictedFlexibleEeaSendRawTransaction(
transactionPool, transactionPool,
privacyIdProvider, privacyIdProvider,
privateMarkerTransactionFactory, privateMarkerTransactionFactory,

@ -75,7 +75,7 @@ public class PrivJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
new PrivDistributeRawTransaction( new PrivDistributeRawTransaction(
privacyController, privacyController,
privacyIdProvider, privacyIdProvider,
getPrivacyParameters().isOnchainPrivacyGroupsEnabled()), getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()),
new PrivGetCode(getBlockchainQueries(), privacyController, privacyIdProvider), new PrivGetCode(getBlockchainQueries(), privacyController, privacyIdProvider),
new PrivGetLogs( new PrivGetLogs(
getBlockchainQueries(), getPrivacyQueries(), privacyController, privacyIdProvider), getBlockchainQueries(), getPrivacyQueries(), privacyController, privacyIdProvider),
@ -91,7 +91,7 @@ public class PrivJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
new PrivNewFilter(filterManager, privacyController, privacyIdProvider), new PrivNewFilter(filterManager, privacyController, privacyIdProvider),
new PrivUninstallFilter(filterManager, privacyController, privacyIdProvider)); new PrivUninstallFilter(filterManager, privacyController, privacyIdProvider));
if (!getPrivacyParameters().isOnchainPrivacyGroupsEnabled()) { if (!getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
final Map<String, JsonRpcMethod> OFFCHAIN_METHODS = final Map<String, JsonRpcMethod> OFFCHAIN_METHODS =
mapOf( mapOf(
new PrivCreatePrivacyGroup(privacyController, privacyIdProvider), new PrivCreatePrivacyGroup(privacyController, privacyIdProvider),

@ -25,8 +25,8 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.privacy.ChainHeadPrivateNonceProvider; import org.hyperledger.besu.ethereum.privacy.ChainHeadPrivateNonceProvider;
import org.hyperledger.besu.ethereum.privacy.FlexiblePrivacyController;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController; import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController;
import org.hyperledger.besu.ethereum.privacy.OnchainPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PluginPrivacyController; import org.hyperledger.besu.ethereum.privacy.PluginPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateNonceProvider; import org.hyperledger.besu.ethereum.privacy.PrivateNonceProvider;
@ -137,9 +137,9 @@ public abstract class PrivacyApiGroupJsonRpcMethods extends ApiGroupJsonRpcMetho
privacyParameters.getPrivateWorldStateReader()); privacyParameters.getPrivateWorldStateReader());
} else { } else {
final PrivacyController privacyController; final PrivacyController privacyController;
if (privacyParameters.isOnchainPrivacyGroupsEnabled()) { if (privacyParameters.isFlexiblePrivacyGroupsEnabled()) {
privacyController = privacyController =
new OnchainPrivacyController( new FlexiblePrivacyController(
getBlockchainQueries().getBlockchain(), getBlockchainQueries().getBlockchain(),
privacyParameters, privacyParameters,
chainId, chainId,

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx.PrivxFindFlexiblePrivacyGroup;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx.PrivxFindOnchainPrivacyGroup; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx.PrivxFindOnchainPrivacyGroup;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@ -47,8 +48,10 @@ public class PrivxJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
final PrivacyController privacyController, final PrivacyController privacyController,
final PrivacyIdProvider privacyIdProvider, final PrivacyIdProvider privacyIdProvider,
final PrivateMarkerTransactionFactory privateMarkerTransactionFactory) { final PrivateMarkerTransactionFactory privateMarkerTransactionFactory) {
if (getPrivacyParameters().isOnchainPrivacyGroupsEnabled()) { if (getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
return mapOf(new PrivxFindOnchainPrivacyGroup(privacyController, privacyIdProvider)); return mapOf(
new PrivxFindFlexiblePrivacyGroup(privacyController, privacyIdProvider),
new PrivxFindOnchainPrivacyGroup(privacyController, privacyIdProvider));
} else { } else {
return Map.of(); return Map.of();
} }

@ -22,8 +22,8 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.privacy.ChainHeadPrivateNonceProvider; import org.hyperledger.besu.ethereum.privacy.ChainHeadPrivateNonceProvider;
import org.hyperledger.besu.ethereum.privacy.FlexiblePrivacyController;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController; import org.hyperledger.besu.ethereum.privacy.MultiTenancyPrivacyController;
import org.hyperledger.besu.ethereum.privacy.OnchainPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PluginPrivacyController; import org.hyperledger.besu.ethereum.privacy.PluginPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateNonceProvider; import org.hyperledger.besu.ethereum.privacy.PrivateNonceProvider;
@ -77,9 +77,9 @@ public class PrivateWebSocketMethodsFactory {
privacyParameters.getPrivateWorldStateReader()); privacyParameters.getPrivateWorldStateReader());
} else { } else {
final PrivacyController restrictedPrivacyController; final PrivacyController restrictedPrivacyController;
if (privacyParameters.isOnchainPrivacyGroupsEnabled()) { if (privacyParameters.isFlexiblePrivacyGroupsEnabled()) {
restrictedPrivacyController = restrictedPrivacyController =
new OnchainPrivacyController( new FlexiblePrivacyController(
blockchainQueries.getBlockchain(), blockchainQueries.getBlockchain(),
privacyParameters, privacyParameters,
chainId, chainId,

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY;
import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.KeyPair;
@ -67,12 +67,12 @@ public class BaseEeaSendRawTransaction {
final GasCalculator gasCalculator = new BerlinGasCalculator(); final GasCalculator gasCalculator = new BerlinGasCalculator();
final Transaction PUBLIC_ONCHAIN_TRANSACTION = final Transaction PUBLIC_FLEXIBLE_TRANSACTION =
new Transaction( new Transaction(
0L, 0L,
Wei.of(1), Wei.of(1),
21000L, 21000L,
Optional.of(ONCHAIN_PRIVACY), Optional.of(FLEXIBLE_PRIVACY),
Wei.ZERO, Wei.ZERO,
SIGNATURE_ALGORITHM_SUPPLIER SIGNATURE_ALGORITHM_SUPPLIER
.get() .get()

@ -37,17 +37,17 @@ import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class RestrictedOnchainEeaSendRawTransactionTest extends BaseEeaSendRawTransaction { public class RestrictedFlexibleEeaSendRawTransactionTest extends BaseEeaSendRawTransaction {
static final String ENCLAVE_PUBLIC_KEY = "S28yYlZxRCtuTmxOWUw1RUU3eTNJZE9udmlmdGppaXo="; static final String ENCLAVE_PUBLIC_KEY = "S28yYlZxRCtuTmxOWUw1RUU3eTNJZE9udmlmdGppaXo=";
final PrivacyIdProvider privacyIdProvider = (user) -> ENCLAVE_PUBLIC_KEY; final PrivacyIdProvider privacyIdProvider = (user) -> ENCLAVE_PUBLIC_KEY;
RestrictedOnchainEeaSendRawTransaction method; RestrictedFlexibleEeaSendRawTransaction method;
@Before @Before
public void before() { public void before() {
method = method =
new RestrictedOnchainEeaSendRawTransaction( new RestrictedFlexibleEeaSendRawTransaction(
transactionPool, transactionPool,
privacyIdProvider, privacyIdProvider,
privateMarkerTransactionFactory, privateMarkerTransactionFactory,
@ -56,7 +56,7 @@ public class RestrictedOnchainEeaSendRawTransactionTest extends BaseEeaSendRawTr
} }
@Test @Test
public void validOnchainTransactionPrivacyGroupIsSentToTransactionPool() { public void validFlexibleTransactionPrivacyGroupIsSentToTransactionPool() {
when(privacyController.validatePrivateTransaction(any(), any())) when(privacyController.validatePrivateTransaction(any(), any()))
.thenReturn(ValidationResult.valid()); .thenReturn(ValidationResult.valid());
when(transactionPool.addLocalTransaction(any(Transaction.class))) when(transactionPool.addLocalTransaction(any(Transaction.class)))
@ -65,12 +65,13 @@ public class RestrictedOnchainEeaSendRawTransactionTest extends BaseEeaSendRawTr
when(privacyController.createPrivateMarkerTransactionPayload(any(), any(), any())) when(privacyController.createPrivateMarkerTransactionPayload(any(), any(), any()))
.thenReturn(MOCK_ORION_KEY); .thenReturn(MOCK_ORION_KEY);
final Optional<PrivacyGroup> onchainPrivacyGroup = final Optional<PrivacyGroup> flexiblePrivacyGroup =
Optional.of( Optional.of(
new PrivacyGroup( new PrivacyGroup(
"", PrivacyGroup.Type.ONCHAIN, "", "", Arrays.asList(ENCLAVE_PUBLIC_KEY))); "", PrivacyGroup.Type.FLEXIBLE, "", "", Arrays.asList(ENCLAVE_PUBLIC_KEY)));
when(privacyController.findPrivacyGroupByGroupId(any(), any())).thenReturn(onchainPrivacyGroup); when(privacyController.findPrivacyGroupByGroupId(any(), any()))
.thenReturn(flexiblePrivacyGroup);
final JsonRpcSuccessResponse expectedResponse = final JsonRpcSuccessResponse expectedResponse =
new JsonRpcSuccessResponse( new JsonRpcSuccessResponse(
@ -80,7 +81,7 @@ public class RestrictedOnchainEeaSendRawTransactionTest extends BaseEeaSendRawTr
final JsonRpcResponse actualResponse = method.response(validPrivacyGroupTransactionRequest); final JsonRpcResponse actualResponse = method.response(validPrivacyGroupTransactionRequest);
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
verify(transactionPool).addLocalTransaction(PUBLIC_ONCHAIN_TRANSACTION); verify(transactionPool).addLocalTransaction(PUBLIC_FLEXIBLE_TRANSACTION);
} }
@Test @Test
@ -91,7 +92,7 @@ public class RestrictedOnchainEeaSendRawTransactionTest extends BaseEeaSendRawTr
final JsonRpcResponse expectedResponse = final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse( new JsonRpcErrorResponse(
validPrivateForTransactionRequest.getRequest().getId(), validPrivateForTransactionRequest.getRequest().getId(),
JsonRpcError.ONCHAIN_PRIVACY_GROUP_ID_NOT_AVAILABLE); JsonRpcError.FLEXIBLE_PRIVACY_GROUP_ID_NOT_AVAILABLE);
final JsonRpcResponse actualResponse = method.response(validPrivateForTransactionRequest); final JsonRpcResponse actualResponse = method.response(validPrivateForTransactionRequest);
@ -99,7 +100,7 @@ public class RestrictedOnchainEeaSendRawTransactionTest extends BaseEeaSendRawTr
} }
@Test @Test
public void offchainPrivacyGroupTransactionFailsWhenOnchainPrivacyGroupFeatureIsEnabled() { public void offchainPrivacyGroupTransactionFailsWhenFlexiblePrivacyGroupFeatureIsEnabled() {
when(privacyController.validatePrivateTransaction(any(), any())) when(privacyController.validatePrivateTransaction(any(), any()))
.thenReturn(ValidationResult.valid()); .thenReturn(ValidationResult.valid());
@ -108,7 +109,7 @@ public class RestrictedOnchainEeaSendRawTransactionTest extends BaseEeaSendRawTr
final JsonRpcResponse expectedResponse = final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse( new JsonRpcErrorResponse(
validPrivacyGroupTransactionRequest.getRequest().getId(), validPrivacyGroupTransactionRequest.getRequest().getId(),
JsonRpcError.ONCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST); JsonRpcError.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
final JsonRpcResponse actualResponse = method.response(validPrivacyGroupTransactionRequest); final JsonRpcResponse actualResponse = method.response(validPrivacyGroupTransactionRequest);
@ -116,14 +117,14 @@ public class RestrictedOnchainEeaSendRawTransactionTest extends BaseEeaSendRawTr
} }
@Test @Test
public void onchainPrivacyGroupTransactionFailsWhenGroupDoesNotExist() { public void flexiblePrivacyGroupTransactionFailsWhenGroupDoesNotExist() {
when(privacyController.validatePrivateTransaction(any(), any())) when(privacyController.validatePrivateTransaction(any(), any()))
.thenReturn(ValidationResult.valid()); .thenReturn(ValidationResult.valid());
final JsonRpcResponse expectedResponse = final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse( new JsonRpcErrorResponse(
validPrivacyGroupTransactionRequest.getRequest().getId(), validPrivacyGroupTransactionRequest.getRequest().getId(),
JsonRpcError.ONCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST); JsonRpcError.FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST);
final JsonRpcResponse actualResponse = method.response(validPrivacyGroupTransactionRequest); final JsonRpcResponse actualResponse = method.response(validPrivacyGroupTransactionRequest);

@ -42,7 +42,7 @@ import org.assertj.core.util.Lists;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class PrivxFindOnchainPrivacyGroupTest { public class PrivxFindFlexiblePrivacyGroupTest {
private static final String ENCLAVE_PUBLIC_KEY = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; private static final String ENCLAVE_PUBLIC_KEY = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=";
private static final List<String> ADDRESSES = private static final List<String> ADDRESSES =
List.of( List.of(
@ -59,7 +59,7 @@ public class PrivxFindOnchainPrivacyGroupTest {
private JsonRpcRequestContext request; private JsonRpcRequestContext request;
private PrivacyGroup privacyGroup; private PrivacyGroup privacyGroup;
private PrivxFindOnchainPrivacyGroup privxFindOnchainPrivacyGroup; private PrivxFindFlexiblePrivacyGroup privxFindFlexiblePrivacyGroup;
@Before @Before
public void setUp() { public void setUp() {
@ -67,7 +67,7 @@ public class PrivxFindOnchainPrivacyGroupTest {
when(privacyParameters.isEnabled()).thenReturn(true); when(privacyParameters.isEnabled()).thenReturn(true);
request = request =
new JsonRpcRequestContext( new JsonRpcRequestContext(
new JsonRpcRequest("1", "privx_findOnChainPrivacyGroup", new Object[] {ADDRESSES}), new JsonRpcRequest("1", "privx_findFlexiblePrivacyGroup", new Object[] {ADDRESSES}),
user); user);
privacyGroup = new PrivacyGroup(); privacyGroup = new PrivacyGroup();
privacyGroup.setName(""); privacyGroup.setName("");
@ -75,8 +75,8 @@ public class PrivxFindOnchainPrivacyGroupTest {
privacyGroup.setPrivacyGroupId("privacy group id"); privacyGroup.setPrivacyGroupId("privacy group id");
privacyGroup.setMembers(Lists.list("member1")); privacyGroup.setMembers(Lists.list("member1"));
privxFindOnchainPrivacyGroup = privxFindFlexiblePrivacyGroup =
new PrivxFindOnchainPrivacyGroup(privacyController, privacyIdProvider); new PrivxFindFlexiblePrivacyGroup(privacyController, privacyIdProvider);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -86,7 +86,7 @@ public class PrivxFindOnchainPrivacyGroupTest {
.thenReturn(new PrivacyGroup[] {privacyGroup}); .thenReturn(new PrivacyGroup[] {privacyGroup});
final JsonRpcSuccessResponse response = final JsonRpcSuccessResponse response =
(JsonRpcSuccessResponse) privxFindOnchainPrivacyGroup.response(request); (JsonRpcSuccessResponse) privxFindFlexiblePrivacyGroup.response(request);
final List<PrivacyGroup> result = (List<PrivacyGroup>) response.getResult(); final List<PrivacyGroup> result = (List<PrivacyGroup>) response.getResult();
assertThat(result).hasSize(1); assertThat(result).hasSize(1);
assertThat(result.get(0)).usingRecursiveComparison().isEqualTo(privacyGroup); assertThat(result.get(0)).usingRecursiveComparison().isEqualTo(privacyGroup);
@ -99,8 +99,8 @@ public class PrivxFindOnchainPrivacyGroupTest {
.thenThrow(new EnclaveClientException(500, "some failure")); .thenThrow(new EnclaveClientException(500, "some failure"));
final JsonRpcErrorResponse response = final JsonRpcErrorResponse response =
(JsonRpcErrorResponse) privxFindOnchainPrivacyGroup.response(request); (JsonRpcErrorResponse) privxFindFlexiblePrivacyGroup.response(request);
assertThat(response.getError()).isEqualTo(JsonRpcError.FIND_ONCHAIN_PRIVACY_GROUP_ERROR); assertThat(response.getError()).isEqualTo(JsonRpcError.FIND_FLEXIBLE_PRIVACY_GROUP_ERROR);
verify(privacyController).findPrivacyGroupByMembers(ADDRESSES, ENCLAVE_PUBLIC_KEY); verify(privacyController).findPrivacyGroupByMembers(ADDRESSES, ENCLAVE_PUBLIC_KEY);
} }
@ -111,8 +111,8 @@ public class PrivxFindOnchainPrivacyGroupTest {
final JsonRpcResponse expectedResponse = final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse( new JsonRpcErrorResponse(
request.getRequest().getId(), JsonRpcError.FIND_ONCHAIN_PRIVACY_GROUP_ERROR); request.getRequest().getId(), JsonRpcError.FIND_FLEXIBLE_PRIVACY_GROUP_ERROR);
final JsonRpcResponse response = privxFindOnchainPrivacyGroup.response(request); final JsonRpcResponse response = privxFindFlexiblePrivacyGroup.response(request);
assertThat(response).isEqualTo(expectedResponse); assertThat(response).isEqualTo(expectedResponse);
verify(privacyController).findPrivacyGroupByMembers(ADDRESSES, ENCLAVE_PUBLIC_KEY); verify(privacyController).findPrivacyGroupByMembers(ADDRESSES, ENCLAVE_PUBLIC_KEY);
} }

@ -57,8 +57,8 @@ public class PrivJsonRpcMethodsTest {
} }
@Test @Test
public void offchainPrivacyGroupMethodsAreDisabledWhenOnchainPrivacyGroupIsEnabled() { public void offchainPrivacyGroupMethodsAreDisabledWhenFlexiblePrivacyGroupIsEnabled() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(true); when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(true);
final Map<String, JsonRpcMethod> rpcMethods = privJsonRpcMethods.create(); final Map<String, JsonRpcMethod> rpcMethods = privJsonRpcMethods.create();
assertThat(rpcMethods.get(PRIV_CREATE_PRIVACY_GROUP.getMethodName())).isNull(); assertThat(rpcMethods.get(PRIV_CREATE_PRIVACY_GROUP.getMethodName())).isNull();
@ -67,8 +67,8 @@ public class PrivJsonRpcMethodsTest {
} }
@Test @Test
public void offchainPrivacyGroupMethodsAreEnabledWhenOnchainPrivacyGroupIsDisabled() { public void offchainPrivacyGroupMethodsAreEnabledWhenFlexiblePrivacyGroupIsDisabled() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(false); when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(false);
final Map<String, JsonRpcMethod> rpcMethods = privJsonRpcMethods.create(); final Map<String, JsonRpcMethod> rpcMethods = privJsonRpcMethods.create();
assertThat(rpcMethods.get(PRIV_CREATE_PRIVACY_GROUP.getMethodName())).isNotNull(); assertThat(rpcMethods.get(PRIV_CREATE_PRIVACY_GROUP.getMethodName())).isNotNull();

@ -16,10 +16,12 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.methods;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod.PRIVX_FIND_PRIVACY_GROUP; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod.PRIVX_FIND_PRIVACY_GROUP;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod.PRIVX_FIND_PRIVACY_GROUP_OLD;
import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx.PrivxFindFlexiblePrivacyGroup;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx.PrivxFindOnchainPrivacyGroup; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx.PrivxFindOnchainPrivacyGroup;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@ -54,8 +56,8 @@ public class PrivxJsonRpcMethodsTest {
} }
@Test @Test
public void privxFindPrivacyGroupMethodIsDisabledWhenOnchainPrivacyGroupIsDisabled() { public void privxFindPrivacyGroupMethodIsDisabledWhenFlexiblePrivacyGroupIsDisabled() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(false); when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(false);
final Map<String, JsonRpcMethod> rpcMethods = privxJsonRpcMethods.create(); final Map<String, JsonRpcMethod> rpcMethods = privxJsonRpcMethods.create();
final JsonRpcMethod method = rpcMethods.get(PRIVX_FIND_PRIVACY_GROUP.getMethodName()); final JsonRpcMethod method = rpcMethods.get(PRIVX_FIND_PRIVACY_GROUP.getMethodName());
@ -63,11 +65,22 @@ public class PrivxJsonRpcMethodsTest {
} }
@Test @Test
public void privxFindPrivacyGroupMethodIsEnabledWhenOnchainPrivacyGroupIsEnabled() { public void privxFindPrivacyGroupMethodIsEnabledWhenFlexiblePrivacyGroupIsEnabled() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(true); when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(true);
final Map<String, JsonRpcMethod> rpcMethods = privxJsonRpcMethods.create(); final Map<String, JsonRpcMethod> rpcMethods = privxJsonRpcMethods.create();
final JsonRpcMethod method = rpcMethods.get(PRIVX_FIND_PRIVACY_GROUP.getMethodName()); final JsonRpcMethod method = rpcMethods.get(PRIVX_FIND_PRIVACY_GROUP.getMethodName());
assertThat(method).isNotNull();
assertThat(method).isInstanceOf(PrivxFindFlexiblePrivacyGroup.class);
}
@Deprecated
@Test
public void privxFindOnchainPrivacyGroupMethodIsStillEnabled() {
when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(true);
final Map<String, JsonRpcMethod> rpcMethods = privxJsonRpcMethods.create();
final JsonRpcMethod method = rpcMethods.get(PRIVX_FIND_PRIVACY_GROUP_OLD.getMethodName());
assertThat(method).isNotNull(); assertThat(method).isNotNull();
assertThat(method).isInstanceOf(PrivxFindOnchainPrivacyGroup.class); assertThat(method).isInstanceOf(PrivxFindOnchainPrivacyGroup.class);
} }

@ -49,11 +49,12 @@ public class PrivacyParameters {
// Last address that can be generated for a pre-compiled contract // Last address that can be generated for a pre-compiled contract
public static final Integer PRIVACY = Byte.MAX_VALUE - 1; public static final Integer PRIVACY = Byte.MAX_VALUE - 1;
public static final Address DEFAULT_PRIVACY = Address.precompiled(PRIVACY); public static final Address DEFAULT_PRIVACY = Address.precompiled(PRIVACY);
public static final Address ONCHAIN_PRIVACY = Address.precompiled(PRIVACY - 1); public static final Address FLEXIBLE_PRIVACY = Address.precompiled(PRIVACY - 1);
// Onchain privacy management contracts (injected in private state) // Flexible privacy management contracts (injected in private state)
public static final Address ONCHAIN_PRIVACY_PROXY = Address.precompiled(PRIVACY - 2); public static final Address FLEXIBLE_PRIVACY_PROXY = Address.precompiled(PRIVACY - 2);
public static final Address DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT = Address.precompiled(PRIVACY - 3); public static final Address DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT =
Address.precompiled(PRIVACY - 3);
public static final Address PLUGIN_PRIVACY = Address.precompiled(PRIVACY - 4); public static final Address PLUGIN_PRIVACY = Address.precompiled(PRIVACY - 4);
@ -70,7 +71,7 @@ public class PrivacyParameters {
private WorldStateArchive privateWorldStateArchive; private WorldStateArchive privateWorldStateArchive;
private PrivateStateStorage privateStateStorage; private PrivateStateStorage privateStateStorage;
private boolean multiTenancyEnabled; private boolean multiTenancyEnabled;
private boolean onchainPrivacyGroupsEnabled; private boolean flexiblePrivacyGroupsEnabled;
private boolean privacyPluginEnabled; private boolean privacyPluginEnabled;
private PrivateStateRootResolver privateStateRootResolver; private PrivateStateRootResolver privateStateRootResolver;
private PrivateWorldStateReader privateWorldStateReader; private PrivateWorldStateReader privateWorldStateReader;
@ -80,8 +81,8 @@ public class PrivacyParameters {
public Address getPrivacyAddress() { public Address getPrivacyAddress() {
if (isPrivacyPluginEnabled()) { if (isPrivacyPluginEnabled()) {
return PLUGIN_PRIVACY; return PLUGIN_PRIVACY;
} else if (isOnchainPrivacyGroupsEnabled()) { } else if (isFlexiblePrivacyGroupsEnabled()) {
return ONCHAIN_PRIVACY; return FLEXIBLE_PRIVACY;
} else { } else {
return DEFAULT_PRIVACY; return DEFAULT_PRIVACY;
} }
@ -168,12 +169,12 @@ public class PrivacyParameters {
return multiTenancyEnabled; return multiTenancyEnabled;
} }
private void setOnchainPrivacyGroupsEnabled(final boolean onchainPrivacyGroupsEnabled) { private void setFlexiblePrivacyGroupsEnabled(final boolean flexiblePrivacyGroupsEnabled) {
this.onchainPrivacyGroupsEnabled = onchainPrivacyGroupsEnabled; this.flexiblePrivacyGroupsEnabled = flexiblePrivacyGroupsEnabled;
} }
public boolean isOnchainPrivacyGroupsEnabled() { public boolean isFlexiblePrivacyGroupsEnabled() {
return onchainPrivacyGroupsEnabled; return flexiblePrivacyGroupsEnabled;
} }
private void setPrivacyPluginEnabled(final boolean privacyPluginEnabled) { private void setPrivacyPluginEnabled(final boolean privacyPluginEnabled) {
@ -225,7 +226,7 @@ public class PrivacyParameters {
// but privacy parameters is built before the plugin has had a chance to register a provider // but privacy parameters is built before the plugin has had a chance to register a provider
// and have cli options instantiated // and have cli options instantiated
return new PrivateStateGenesisAllocator( return new PrivateStateGenesisAllocator(
onchainPrivacyGroupsEnabled, createPrivateGenesisProvider()); flexiblePrivacyGroupsEnabled, createPrivateGenesisProvider());
} }
private PrivacyGroupGenesisProvider createPrivateGenesisProvider() { private PrivacyGroupGenesisProvider createPrivateGenesisProvider() {
@ -246,8 +247,8 @@ public class PrivacyParameters {
+ multiTenancyEnabled + multiTenancyEnabled
+ ", privacyPluginEnabled = " + ", privacyPluginEnabled = "
+ privacyPluginEnabled + privacyPluginEnabled
+ ", onchainPrivacyGroupsEnabled = " + ", flexiblePrivacyGroupsEnabled = "
+ onchainPrivacyGroupsEnabled + flexiblePrivacyGroupsEnabled
+ ", enclaveUri='" + ", enclaveUri='"
+ enclaveUri + enclaveUri
+ ", privatePayloadEncryptionService='" + ", privatePayloadEncryptionService='"
@ -269,7 +270,7 @@ public class PrivacyParameters {
private Path privacyKeyStoreFile; private Path privacyKeyStoreFile;
private Path privacyKeyStorePasswordFile; private Path privacyKeyStorePasswordFile;
private Path privacyTlsKnownEnclaveFile; private Path privacyTlsKnownEnclaveFile;
private boolean onchainPrivacyGroupsEnabled; private boolean flexiblePrivacyGroupsEnabled;
private boolean privacyPluginEnabled; private boolean privacyPluginEnabled;
private Optional<GoQuorumPrivacyParameters> goQuorumPrivacyParameters; private Optional<GoQuorumPrivacyParameters> goQuorumPrivacyParameters;
private PrivacyPluginService privacyPluginService; private PrivacyPluginService privacyPluginService;
@ -319,8 +320,8 @@ public class PrivacyParameters {
return this; return this;
} }
public Builder setOnchainPrivacyGroupsEnabled(final boolean onchainPrivacyGroupsEnabled) { public Builder setFlexiblePrivacyGroupsEnabled(final boolean flexiblePrivacyGroupsEnabled) {
this.onchainPrivacyGroupsEnabled = onchainPrivacyGroupsEnabled; this.flexiblePrivacyGroupsEnabled = flexiblePrivacyGroupsEnabled;
return this; return this;
} }
@ -394,7 +395,7 @@ public class PrivacyParameters {
} }
config.setEnabled(enabled); config.setEnabled(enabled);
config.setMultiTenancyEnabled(multiTenancyEnabled); config.setMultiTenancyEnabled(multiTenancyEnabled);
config.setOnchainPrivacyGroupsEnabled(onchainPrivacyGroupsEnabled); config.setFlexiblePrivacyGroupsEnabled(flexiblePrivacyGroupsEnabled);
config.setPrivacyPluginEnabled(privacyPluginEnabled); config.setPrivacyPluginEnabled(privacyPluginEnabled);
config.setGoQuorumPrivacyParameters(goQuorumPrivacyParameters); config.setGoQuorumPrivacyParameters(goQuorumPrivacyParameters);
return config; return config;

@ -15,14 +15,14 @@
package org.hyperledger.besu.ethereum.mainnet; package org.hyperledger.besu.ethereum.mainnet;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY;
import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForBLS12; import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForBLS12;
import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForByzantium; import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForByzantium;
import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForFrontier; import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForFrontier;
import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForIstanbul; import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForIstanbul;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.OnchainPrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract;
import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry;
@ -76,10 +76,10 @@ public abstract class MainnetPrecompiledContractRegistries {
precompiledContractConfiguration.getPrivacyParameters())); precompiledContractConfiguration.getPrivacyParameters()));
} else if (precompiledContractConfiguration } else if (precompiledContractConfiguration
.getPrivacyParameters() .getPrivacyParameters()
.isOnchainPrivacyGroupsEnabled()) { .isFlexiblePrivacyGroupsEnabled()) {
registry.put( registry.put(
ONCHAIN_PRIVACY, FLEXIBLE_PRIVACY,
new OnchainPrivacyPrecompiledContract( new FlexiblePrivacyPrecompiledContract(
precompiledContractConfiguration.getGasCalculator(), precompiledContractConfiguration.getGasCalculator(),
precompiledContractConfiguration.getPrivacyParameters())); precompiledContractConfiguration.getPrivacyParameters()));
} else { } else {

@ -14,7 +14,7 @@
*/ */
package org.hyperledger.besu.ethereum.mainnet; package org.hyperledger.besu.ethereum.mainnet;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.Enclave;
@ -161,7 +161,7 @@ public class PrivacyBlockProcessor implements BlockProcessor {
private boolean onchainAddToGroupPrivateMarkerTransactions(final Transaction t) { private boolean onchainAddToGroupPrivateMarkerTransactions(final Transaction t) {
return t.getTo().isPresent() return t.getTo().isPresent()
&& t.getTo().equals(Optional.of(ONCHAIN_PRIVACY)) && t.getTo().equals(Optional.of(FLEXIBLE_PRIVACY))
&& t.getPayload().size() == 64; && t.getPayload().size() == 64;
} }

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.core.BlockImporter;
import org.hyperledger.besu.ethereum.core.GoQuorumPrivacyParameters; import org.hyperledger.besu.ethereum.core.GoQuorumPrivacyParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.OnchainPrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor;
@ -326,10 +326,10 @@ public class ProtocolSpecBuilder {
(PrivacyPluginPrecompiledContract) precompileContractRegistry.get(PLUGIN_PRIVACY); (PrivacyPluginPrecompiledContract) precompileContractRegistry.get(PLUGIN_PRIVACY);
privacyPluginPrecompiledContract.setPrivateTransactionProcessor( privacyPluginPrecompiledContract.setPrivateTransactionProcessor(
privateTransactionProcessor); privateTransactionProcessor);
} else if (privacyParameters.isOnchainPrivacyGroupsEnabled()) { } else if (privacyParameters.isFlexiblePrivacyGroupsEnabled()) {
final OnchainPrivacyPrecompiledContract onchainPrivacyPrecompiledContract = final FlexiblePrivacyPrecompiledContract flexiblePrivacyPrecompiledContract =
(OnchainPrivacyPrecompiledContract) precompileContractRegistry.get(ONCHAIN_PRIVACY); (FlexiblePrivacyPrecompiledContract) precompileContractRegistry.get(FLEXIBLE_PRIVACY);
onchainPrivacyPrecompiledContract.setPrivateTransactionProcessor( flexiblePrivacyPrecompiledContract.setPrivateTransactionProcessor(
privateTransactionProcessor); privateTransactionProcessor);
} else { } else {
final PrivacyPrecompiledContract privacyPrecompiledContract = final PrivacyPrecompiledContract privacyPrecompiledContract =

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.mainnet.precompiles.privacy; package org.hyperledger.besu.ethereum.mainnet.precompiles.privacy;
import static org.hyperledger.besu.datatypes.Hash.fromPlugin; import static org.hyperledger.besu.datatypes.Hash.fromPlugin;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE; import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE;
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER; import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER;
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH; import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH;
@ -27,7 +27,7 @@ import org.hyperledger.besu.enclave.types.ReceiveResponse;
import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.privacy.OnchainPrivacyGroupContract; import org.hyperledger.besu.ethereum.privacy.FlexiblePrivacyGroupContract;
import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator; import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator;
import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionObserver; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionObserver;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt;
import org.hyperledger.besu.ethereum.privacy.VersionedPrivateTransaction; import org.hyperledger.besu.ethereum.privacy.VersionedPrivateTransaction;
import org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement; import org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
@ -57,14 +57,14 @@ import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes32;
public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContract { public class FlexiblePrivacyPrecompiledContract extends PrivacyPrecompiledContract {
private static final Logger LOG = LogManager.getLogger(); private static final Logger LOG = LogManager.getLogger();
private final Subscribers<PrivateTransactionObserver> privateTransactionEventObservers = private final Subscribers<PrivateTransactionObserver> privateTransactionEventObservers =
Subscribers.create(); Subscribers.create();
public OnchainPrivacyPrecompiledContract( public FlexiblePrivacyPrecompiledContract(
final GasCalculator gasCalculator, final GasCalculator gasCalculator,
final Enclave enclave, final Enclave enclave,
final WorldStateArchive worldStateArchive, final WorldStateArchive worldStateArchive,
@ -76,10 +76,10 @@ public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac
worldStateArchive, worldStateArchive,
privateStateRootResolver, privateStateRootResolver,
privateStateGenesisAllocator, privateStateGenesisAllocator,
"OnchainPrivacy"); "FlexiblePrivacy");
} }
public OnchainPrivacyPrecompiledContract( public FlexiblePrivacyPrecompiledContract(
final GasCalculator gasCalculator, final PrivacyParameters privacyParameters) { final GasCalculator gasCalculator, final PrivacyParameters privacyParameters) {
this( this(
gasCalculator, gasCalculator,
@ -222,8 +222,8 @@ public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac
final MutableWorldState disposablePrivateState, final MutableWorldState disposablePrivateState,
final WorldUpdater privateWorldStateUpdater, final WorldUpdater privateWorldStateUpdater,
final Bytes privateFrom) { final Bytes privateFrom) {
final OnchainPrivacyGroupContract onchainPrivacyGroupContract = final FlexiblePrivacyGroupContract flexiblePrivacyGroupContract =
new OnchainPrivacyGroupContract( new FlexiblePrivacyGroupContract(
messageFrame, messageFrame,
currentBlockHeader, currentBlockHeader,
disposablePrivateState, disposablePrivateState,
@ -232,7 +232,7 @@ public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac
privateTransactionProcessor); privateTransactionProcessor);
final boolean isAddingParticipant = isAddingParticipant(privateTransaction); final boolean isAddingParticipant = isAddingParticipant(privateTransaction);
final boolean isContractLocked = isContractLocked(onchainPrivacyGroupContract, privacyGroupId); final boolean isContractLocked = isContractLocked(flexiblePrivacyGroupContract, privacyGroupId);
if (isAddingParticipant && !isContractLocked) { if (isAddingParticipant && !isContractLocked) {
LOG.debug( LOG.debug(
@ -242,7 +242,7 @@ public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac
return false; return false;
} }
if (isContractLocked && !isTargettingOnchainPrivacyProxy(privateTransaction)) { if (isContractLocked && !isTargettingFlexiblePrivacyProxy(privateTransaction)) {
LOG.debug( LOG.debug(
"Privacy Group {} is locked while trying to execute transaction with commitment {}", "Privacy Group {} is locked while trying to execute transaction with commitment {}",
privacyGroupId.toHexString(), privacyGroupId.toHexString(),
@ -250,7 +250,8 @@ public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac
return false; return false;
} }
if (!onchainPrivacyGroupVersionMatches(onchainPrivacyGroupContract, privacyGroupId, version)) { if (!flexiblePrivacyGroupVersionMatches(
flexiblePrivacyGroupContract, privacyGroupId, version)) {
LOG.debug( LOG.debug(
"Privacy group version mismatch while trying to execute transaction with commitment {}", "Privacy group version mismatch while trying to execute transaction with commitment {}",
(Hash) messageFrame.getContextVariable(KEY_TRANSACTION_HASH)); (Hash) messageFrame.getContextVariable(KEY_TRANSACTION_HASH));
@ -261,7 +262,7 @@ public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac
isAddingParticipant, isAddingParticipant,
privateTransaction, privateTransaction,
privateFrom, privateFrom,
onchainPrivacyGroupContract, flexiblePrivacyGroupContract,
privacyGroupId)) { privacyGroupId)) {
LOG.debug( LOG.debug(
"PrivateTransaction with hash {} cannot execute in privacy group {} because privateFrom" "PrivateTransaction with hash {} cannot execute in privacy group {} because privateFrom"
@ -279,10 +280,10 @@ public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac
final boolean isAddingParticipant, final boolean isAddingParticipant,
final PrivateTransaction privateTransaction, final PrivateTransaction privateTransaction,
final Bytes privateFrom, final Bytes privateFrom,
final OnchainPrivacyGroupContract onchainPrivacyGroupContract, final FlexiblePrivacyGroupContract flexiblePrivacyGroupContract,
final Bytes32 privacyGroupId) { final Bytes32 privacyGroupId) {
final List<String> members = final List<String> members =
onchainPrivacyGroupContract flexiblePrivacyGroupContract
.getPrivacyGroupByIdAndBlockHash(privacyGroupId.toBase64String(), Optional.empty()) .getPrivacyGroupByIdAndBlockHash(privacyGroupId.toBase64String(), Optional.empty())
.map(PrivacyGroup::getMembers) .map(PrivacyGroup::getMembers)
.orElse(Collections.emptyList()); .orElse(Collections.emptyList());
@ -312,41 +313,42 @@ public class OnchainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac
return input.slice(4).toBase64String(); return input.slice(4).toBase64String();
} }
private boolean isTargettingOnchainPrivacyProxy(final PrivateTransaction privateTransaction) { private boolean isTargettingFlexiblePrivacyProxy(final PrivateTransaction privateTransaction) {
return privateTransaction.getTo().isPresent() return privateTransaction.getTo().isPresent()
&& privateTransaction.getTo().get().equals(ONCHAIN_PRIVACY_PROXY); && privateTransaction.getTo().get().equals(FLEXIBLE_PRIVACY_PROXY);
} }
private boolean isAddingParticipant(final PrivateTransaction privateTransaction) { private boolean isAddingParticipant(final PrivateTransaction privateTransaction) {
return isTargettingOnchainPrivacyProxy(privateTransaction) return isTargettingFlexiblePrivacyProxy(privateTransaction)
&& privateTransaction && privateTransaction
.getPayload() .getPayload()
.toHexString() .toHexString()
.startsWith(OnchainGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE.toHexString()); .startsWith(FlexibleGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE.toHexString());
} }
private boolean isRemovingParticipant(final PrivateTransaction privateTransaction) { private boolean isRemovingParticipant(final PrivateTransaction privateTransaction) {
return isTargettingOnchainPrivacyProxy(privateTransaction) return isTargettingFlexiblePrivacyProxy(privateTransaction)
&& privateTransaction && privateTransaction
.getPayload() .getPayload()
.toHexString() .toHexString()
.startsWith(OnchainGroupManagement.REMOVE_PARTICIPANT_METHOD_SIGNATURE.toHexString()); .startsWith(FlexibleGroupManagement.REMOVE_PARTICIPANT_METHOD_SIGNATURE.toHexString());
} }
protected boolean isContractLocked( protected boolean isContractLocked(
final OnchainPrivacyGroupContract onchainPrivacyGroupContract, final Bytes32 privacyGroupId) { final FlexiblePrivacyGroupContract flexiblePrivacyGroupContract,
final Bytes32 privacyGroupId) {
final Optional<Bytes32> canExecuteResult = final Optional<Bytes32> canExecuteResult =
onchainPrivacyGroupContract.getCanExecute( flexiblePrivacyGroupContract.getCanExecute(
privacyGroupId.toBase64String(), Optional.empty()); privacyGroupId.toBase64String(), Optional.empty());
return canExecuteResult.map(Bytes::isZero).orElse(true); return canExecuteResult.map(Bytes::isZero).orElse(true);
} }
protected boolean onchainPrivacyGroupVersionMatches( protected boolean flexiblePrivacyGroupVersionMatches(
final OnchainPrivacyGroupContract onchainPrivacyGroupContract, final FlexiblePrivacyGroupContract flexiblePrivacyGroupContract,
final Bytes32 privacyGroupId, final Bytes32 privacyGroupId,
final Bytes32 version) { final Bytes32 version) {
final Optional<Bytes32> contractVersionResult = final Optional<Bytes32> contractVersionResult =
onchainPrivacyGroupContract.getVersion(privacyGroupId.toBase64String(), Optional.empty()); flexiblePrivacyGroupContract.getVersion(privacyGroupId.toBase64String(), Optional.empty());
final boolean versionEqual = contractVersionResult.map(version::equals).orElse(false); final boolean versionEqual = contractVersionResult.map(version::equals).orElse(false);
if (!versionEqual) { if (!versionEqual) {

@ -15,9 +15,9 @@
package org.hyperledger.besu.ethereum.privacy; package org.hyperledger.besu.ethereum.privacy;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.GET_VERSION_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_VERSION_METHOD_SIGNATURE;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
@ -52,13 +52,13 @@ import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt256; import org.apache.tuweni.units.bigints.UInt256;
public class OnchainPrivacyController extends AbstractRestrictedPrivacyController { public class FlexiblePrivacyController extends AbstractRestrictedPrivacyController {
private static final Logger LOG = LogManager.getLogger(); private static final Logger LOG = LogManager.getLogger();
private OnchainPrivacyGroupContract onchainPrivacyGroupContract; private FlexiblePrivacyGroupContract flexiblePrivacyGroupContract;
public OnchainPrivacyController( public FlexiblePrivacyController(
final Blockchain blockchain, final Blockchain blockchain,
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final Optional<BigInteger> chainId, final Optional<BigInteger> chainId,
@ -76,7 +76,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
privacyParameters.getPrivateStateRootResolver()); privacyParameters.getPrivateStateRootResolver());
} }
public OnchainPrivacyController( public FlexiblePrivacyController(
final Blockchain blockchain, final Blockchain blockchain,
final PrivateStateStorage privateStateStorage, final PrivateStateStorage privateStateStorage,
final Enclave enclave, final Enclave enclave,
@ -95,7 +95,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
privateWorldStateReader, privateWorldStateReader,
privateStateRootResolver); privateStateRootResolver);
onchainPrivacyGroupContract = new OnchainPrivacyGroupContract(privateTransactionSimulator); flexiblePrivacyGroupContract = new FlexiblePrivacyGroupContract(privateTransactionSimulator);
} }
@Override @Override
@ -137,7 +137,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
return Optional.of( return Optional.of(
new PrivacyGroup( new PrivacyGroup(
privacyGroupId, privacyGroupId,
PrivacyGroup.Type.ONCHAIN, PrivacyGroup.Type.FLEXIBLE,
"", "",
"", "",
decodeParticipantList(rlpInput.raw()))); decodeParticipantList(rlpInput.raw())));
@ -175,13 +175,13 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
final String description, final String description,
final String privacyUserId) { final String privacyUserId) {
throw new PrivacyConfigurationNotSupportedException( throw new PrivacyConfigurationNotSupportedException(
"Method not supported when using onchain privacy"); "Method not supported when using flexible privacy");
} }
@Override @Override
public String deletePrivacyGroup(final String privacyGroupId, final String privacyUserId) { public String deletePrivacyGroup(final String privacyGroupId, final String privacyUserId) {
throw new PrivacyConfigurationNotSupportedException( throw new PrivacyConfigurationNotSupportedException(
"Method not supported when using onchain privacy"); "Method not supported when using flexible privacy");
} }
@Override @Override
@ -194,9 +194,9 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
public void verifyPrivacyGroupContainsPrivacyUserId( public void verifyPrivacyGroupContainsPrivacyUserId(
final String privacyGroupId, final String privacyUserId, final Optional<Long> blockNumber) { final String privacyGroupId, final String privacyUserId, final Optional<Long> blockNumber) {
final Optional<PrivacyGroup> maybePrivacyGroup = final Optional<PrivacyGroup> maybePrivacyGroup =
onchainPrivacyGroupContract.getPrivacyGroupByIdAndBlockNumber(privacyGroupId, blockNumber); flexiblePrivacyGroupContract.getPrivacyGroupByIdAndBlockNumber(privacyGroupId, blockNumber);
// IF the group exists, check member // IF the group exists, check member
// ELSE member is valid if the group doesn't exist yet - this is normal for onchain privacy // ELSE member is valid if the group doesn't exist yet - this is normal for flexible privacy
// groups // groups
maybePrivacyGroup.ifPresent( maybePrivacyGroup.ifPresent(
group -> { group -> {
@ -290,7 +290,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
final PrivateTransaction privateTransaction, final PrivateTransaction privateTransaction,
final Bytes32 privacyGroupId, final Bytes32 privacyGroupId,
final String privacyUserId) { final String privacyUserId) {
if (OnchainUtil.isGroupAdditionTransaction(privateTransaction)) { if (FlexibleUtil.isGroupAdditionTransaction(privateTransaction)) {
final List<PrivateTransactionMetadata> privateTransactionMetadataList = final List<PrivateTransactionMetadata> privateTransactionMetadataList =
buildTransactionMetadataList(privacyGroupId); buildTransactionMetadataList(privacyGroupId);
if (!privateTransactionMetadataList.isEmpty()) { if (!privateTransactionMetadataList.isEmpty()) {
@ -299,7 +299,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
privacyGroupId, privateTransactionMetadataList, privacyUserId); privacyGroupId, privateTransactionMetadataList, privacyUserId);
final Bytes bytes = serializeAddToGroupPayload(privateTransactionWithMetadataList); final Bytes bytes = serializeAddToGroupPayload(privateTransactionWithMetadataList);
final List<String> privateFor = final List<String> privateFor =
OnchainUtil.getParticipantsFromParameter(privateTransaction.getPayload()); FlexibleUtil.getParticipantsFromParameter(privateTransaction.getPayload());
return Optional.of( return Optional.of(
enclave.send(bytes.toBase64String(), privacyUserId, privateFor).getKey()); enclave.send(bytes.toBase64String(), privacyUserId, privateFor).getKey());
} }
@ -340,16 +340,16 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
privateTransaction.getPrivacyGroupId().orElseThrow().toBase64String(), privateTransaction.getPrivacyGroupId().orElseThrow().toBase64String(),
buildCallParams(GET_VERSION_METHOD_SIGNATURE)); buildCallParams(GET_VERSION_METHOD_SIGNATURE));
new VersionedPrivateTransaction(privateTransaction, version).writeTo(rlpOutput); new VersionedPrivateTransaction(privateTransaction, version).writeTo(rlpOutput);
final List<String> onchainPrivateFor = privacyGroup.getMembers(); final List<String> flexiblePrivateFor = privacyGroup.getMembers();
return enclave.send( return enclave.send(
rlpOutput.encoded().toBase64String(), rlpOutput.encoded().toBase64String(),
privateTransaction.getPrivateFrom().toBase64String(), privateTransaction.getPrivateFrom().toBase64String(),
onchainPrivateFor); flexiblePrivateFor);
} }
CallParameter buildCallParams(final Bytes methodCall) { CallParameter buildCallParams(final Bytes methodCall) {
return new CallParameter( return new CallParameter(
Address.ZERO, ONCHAIN_PRIVACY_PROXY, 3000000, Wei.of(1000), Wei.ZERO, methodCall); Address.ZERO, FLEXIBLE_PRIVACY_PROXY, 3000000, Wei.of(1000), Wei.ZERO, methodCall);
} }
ReceiveResponse retrieveTransaction(final String enclaveKey, final String privacyUserId) { ReceiveResponse retrieveTransaction(final String enclaveKey, final String privacyUserId) {
@ -357,8 +357,8 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
} }
@VisibleForTesting @VisibleForTesting
public void setOnchainPrivacyGroupContract( public void setFlexiblePrivacyGroupContract(
final OnchainPrivacyGroupContract onchainPrivacyGroupContract) { final FlexiblePrivacyGroupContract flexiblePrivacyGroupContract) {
this.onchainPrivacyGroupContract = onchainPrivacyGroupContract; this.flexiblePrivacyGroupContract = flexiblePrivacyGroupContract;
} }
} }

@ -14,10 +14,10 @@
*/ */
package org.hyperledger.besu.ethereum.privacy; package org.hyperledger.besu.ethereum.privacy;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.CAN_EXECUTE_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.CAN_EXECUTE_METHOD_SIGNATURE;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.GET_VERSION_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_VERSION_METHOD_SIGNATURE;
import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.crypto.SECPSignature;
import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithm;
@ -55,7 +55,7 @@ import org.apache.tuweni.units.bigints.UInt256;
It is possible to use it in two different ways that carry different It is possible to use it in two different ways that carry different
lifetime expectations and call semantics: lifetime expectations and call semantics:
1. When constructed using `OnchainPrivacyGroupContract(PrivateTransactionSimulator)` 1. When constructed using `FlexiblePrivacyGroupContract(PrivateTransactionSimulator)`
the object is expected to be long-lived. Methods can be supplied the object is expected to be long-lived. Methods can be supplied
with block height or block hash parameters to select which block's with block height or block hash parameters to select which block's
state is queried. state is queried.
@ -67,7 +67,7 @@ import org.apache.tuweni.units.bigints.UInt256;
that is not on a block boundary. Used this way, the object's life that is not on a block boundary. Used this way, the object's life
time is intended to be short. time is intended to be short.
*/ */
public class OnchainPrivacyGroupContract { public class FlexiblePrivacyGroupContract {
@FunctionalInterface @FunctionalInterface
public interface TransactionSimulator { public interface TransactionSimulator {
Optional<TransactionProcessingResult> simulate( Optional<TransactionProcessingResult> simulate(
@ -79,7 +79,7 @@ public class OnchainPrivacyGroupContract {
final TransactionSimulator transactionSimulator; final TransactionSimulator transactionSimulator;
public OnchainPrivacyGroupContract( public FlexiblePrivacyGroupContract(
final PrivateTransactionSimulator privateTransactionSimulator) { final PrivateTransactionSimulator privateTransactionSimulator) {
transactionSimulator = transactionSimulator =
(privacyGroupId, callData, blockHash, blockNumber) -> { (privacyGroupId, callData, blockHash, blockNumber) -> {
@ -96,7 +96,7 @@ public class OnchainPrivacyGroupContract {
}; };
} }
public OnchainPrivacyGroupContract( public FlexiblePrivacyGroupContract(
final MessageFrame messageFrame, final MessageFrame messageFrame,
final ProcessableBlockHeader currentBlockHeader, final ProcessableBlockHeader currentBlockHeader,
final MutableWorldState disposablePrivateState, final MutableWorldState disposablePrivateState,
@ -168,7 +168,7 @@ public class OnchainPrivacyGroupContract {
if (rlpInput.nextSize() > 0) { if (rlpInput.nextSize() > 0) {
final PrivacyGroup privacyGroup = final PrivacyGroup privacyGroup =
new PrivacyGroup( new PrivacyGroup(
privacyGroupId, PrivacyGroup.Type.ONCHAIN, "", "", decodeList(rlpInput.raw())); privacyGroupId, PrivacyGroup.Type.FLEXIBLE, "", "", decodeList(rlpInput.raw()));
return Optional.of(privacyGroup); return Optional.of(privacyGroup);
} else { } else {
return Optional.empty(); return Optional.empty();
@ -216,7 +216,7 @@ public class OnchainPrivacyGroupContract {
: 0) : 0)
.gasPrice(Wei.of(1000)) .gasPrice(Wei.of(1000))
.gasLimit(3000000) .gasLimit(3000000)
.to(ONCHAIN_PRIVACY_PROXY) .to(FLEXIBLE_PRIVACY_PROXY)
.sender(Address.ZERO) .sender(Address.ZERO)
.value(Wei.ZERO) .value(Wei.ZERO)
.payload(payload) .payload(payload)
@ -226,7 +226,7 @@ public class OnchainPrivacyGroupContract {
private CallParameter buildCallParams(final Bytes methodCall) { private CallParameter buildCallParams(final Bytes methodCall) {
return new CallParameter( return new CallParameter(
Address.ZERO, ONCHAIN_PRIVACY_PROXY, 3000000, Wei.of(1000), Wei.ZERO, methodCall); Address.ZERO, FLEXIBLE_PRIVACY_PROXY, 3000000, Wei.of(1000), Wei.ZERO, methodCall);
} }
private List<String> decodeList(final Bytes rlpEncodedList) { private List<String> decodeList(final Bytes rlpEncodedList) {

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.ethereum.privacy; package org.hyperledger.besu.ethereum.privacy;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
@ -25,14 +25,14 @@ import java.util.Optional;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
public class OnchainUtil { public class FlexibleUtil {
private OnchainUtil() {} private FlexibleUtil() {}
public static boolean isGroupAdditionTransaction(final PrivateTransaction privateTransaction) { public static boolean isGroupAdditionTransaction(final PrivateTransaction privateTransaction) {
final Optional<Address> to = privateTransaction.getTo(); final Optional<Address> to = privateTransaction.getTo();
return to.isPresent() return to.isPresent()
&& to.get().equals(ONCHAIN_PRIVACY_PROXY) && to.get().equals(FLEXIBLE_PRIVACY_PROXY)
&& privateTransaction && privateTransaction
.getPayload() .getPayload()
.toHexString() .toHexString()

@ -14,13 +14,13 @@
*/ */
package org.hyperledger.besu.ethereum.privacy; package org.hyperledger.besu.ethereum.privacy;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement; import org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement;
import org.hyperledger.besu.evm.account.MutableAccount; import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.evm.worldstate.WorldUpdater;
import org.hyperledger.besu.plugin.data.PrivacyGenesis; import org.hyperledger.besu.plugin.data.PrivacyGenesis;
@ -37,13 +37,13 @@ import org.apache.tuweni.units.bigints.UInt256;
public class PrivateStateGenesisAllocator { public class PrivateStateGenesisAllocator {
private static final Logger LOG = LogManager.getLogger(); private static final Logger LOG = LogManager.getLogger();
private final Boolean isOnchainPrivacyEnabled; private final Boolean isFlexiblePrivacyEnabled;
private final PrivacyGroupGenesisProvider privacyGroupGenesisProvider; private final PrivacyGroupGenesisProvider privacyGroupGenesisProvider;
public PrivateStateGenesisAllocator( public PrivateStateGenesisAllocator(
final Boolean isOnchainPrivacyEnabled, final Boolean isFlexiblePrivacyEnabled,
final PrivacyGroupGenesisProvider privacyGroupGenesisProvider) { final PrivacyGroupGenesisProvider privacyGroupGenesisProvider) {
this.isOnchainPrivacyEnabled = isOnchainPrivacyEnabled; this.isFlexiblePrivacyEnabled = isFlexiblePrivacyEnabled;
this.privacyGroupGenesisProvider = privacyGroupGenesisProvider; this.privacyGroupGenesisProvider = privacyGroupGenesisProvider;
} }
@ -87,23 +87,23 @@ public class PrivateStateGenesisAllocator {
}); });
} }
if (isOnchainPrivacyEnabled) { if (isFlexiblePrivacyEnabled) {
// inject management // inject management
final MutableAccount managementContract = final MutableAccount managementContract =
privateWorldStateUpdater.createAccount(DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT).getMutable(); privateWorldStateUpdater.createAccount(DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT).getMutable();
// this is the code for the simple management contract // this is the code for the simple management contract
managementContract.setCode(OnchainGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE); managementContract.setCode(FlexibleGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE);
// inject proxy // inject proxy
final MutableAccount procyContract = final MutableAccount procyContract =
privateWorldStateUpdater.createAccount(ONCHAIN_PRIVACY_PROXY).getMutable(); privateWorldStateUpdater.createAccount(FLEXIBLE_PRIVACY_PROXY).getMutable();
// this is the code for the proxy contract // this is the code for the proxy contract
procyContract.setCode(OnchainGroupManagement.PROXY_RUNTIME_BYTECODE); procyContract.setCode(FlexibleGroupManagement.PROXY_RUNTIME_BYTECODE);
// manually set the management contract address so the proxy can trust it // manually set the management contract address so the proxy can trust it
procyContract.setStorageValue( procyContract.setStorageValue(
UInt256.ZERO, UInt256.fromBytes(Bytes32.leftPad(DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT))); UInt256.ZERO, UInt256.fromBytes(Bytes32.leftPad(DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT)));
} }
privateWorldStateUpdater.commit(); privateWorldStateUpdater.commit();

@ -73,7 +73,7 @@ public class PrivateStateRehydration {
final Optional<Bytes> maybeGroupId = final Optional<Bytes> maybeGroupId =
privateTransactionWithMetadataList.get(0).getPrivateTransaction().getPrivacyGroupId(); privateTransactionWithMetadataList.get(0).getPrivateTransaction().getPrivacyGroupId();
if (maybeGroupId.isEmpty()) { if (maybeGroupId.isEmpty()) {
LOG.debug("Onchain groups must have a group id."); LOG.debug("Flexible groups must have a group id.");
return; return;
} }
final Bytes32 privacyGroupId = Bytes32.wrap(maybeGroupId.get()); final Bytes32 privacyGroupId = Bytes32.wrap(maybeGroupId.get());

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.core;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithm;
@ -90,12 +90,12 @@ public class PrivateTransactionDataFixture {
} }
public static Transaction privateMarkerTransactionOnchain() { public static Transaction privateMarkerTransactionOnchain() {
return privateMarkerTransaction(VALID_BASE64_ENCLAVE_KEY, ONCHAIN_PRIVACY); return privateMarkerTransaction(VALID_BASE64_ENCLAVE_KEY, FLEXIBLE_PRIVACY);
} }
public static Transaction privateMarkerTransactionOnchainAdd() { public static Transaction privateMarkerTransactionOnchainAdd() {
return privateMarkerTransaction( return privateMarkerTransaction(
Bytes.concatenate(VALID_BASE64_ENCLAVE_KEY, VALID_BASE64_ENCLAVE_KEY), ONCHAIN_PRIVACY); Bytes.concatenate(VALID_BASE64_ENCLAVE_KEY, VALID_BASE64_ENCLAVE_KEY), FLEXIBLE_PRIVACY);
} }
private static Transaction privateMarkerTransaction( private static Transaction privateMarkerTransaction(

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.mainnet;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import static org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries.appendPrivacy; import static org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries.appendPrivacy;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -25,7 +25,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.OnchainPrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract;
import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry;
@ -41,28 +41,28 @@ public class MainnetPrecompiledContractRegistriesTest {
new PrecompiledContractConfiguration(gasCalculator, privacyParameters); new PrecompiledContractConfiguration(gasCalculator, privacyParameters);
@Test @Test
public void whenOnchainPrivacyGroupsNotEnabled_defaultPrivacyPrecompileIsInRegistry() { public void whenFlexiblePrivacyGroupsNotEnabled_defaultPrivacyPrecompileIsInRegistry() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(false); when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(false);
when(privacyParameters.isEnabled()).thenReturn(true); when(privacyParameters.isEnabled()).thenReturn(true);
appendPrivacy(reg, config); appendPrivacy(reg, config);
verify(privacyParameters).isEnabled(); verify(privacyParameters).isEnabled();
verify(privacyParameters).isOnchainPrivacyGroupsEnabled(); verify(privacyParameters).isFlexiblePrivacyGroupsEnabled();
assertThat(reg.get(DEFAULT_PRIVACY)).isInstanceOf(PrivacyPrecompiledContract.class); assertThat(reg.get(DEFAULT_PRIVACY)).isInstanceOf(PrivacyPrecompiledContract.class);
assertThat(reg.get(ONCHAIN_PRIVACY)).isNull(); assertThat(reg.get(FLEXIBLE_PRIVACY)).isNull();
} }
@Test @Test
public void whenOnchainPrivacyGroupsEnabled_onchainPrivacyPrecompileIsInRegistry() { public void whenFlexiblePrivacyGroupsEnabled_flexiblePrivacyPrecompileIsInRegistry() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(true); when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(true);
when(privacyParameters.isEnabled()).thenReturn(true); when(privacyParameters.isEnabled()).thenReturn(true);
appendPrivacy(reg, config); appendPrivacy(reg, config);
verify(privacyParameters).isEnabled(); verify(privacyParameters).isEnabled();
verify(privacyParameters).isOnchainPrivacyGroupsEnabled(); verify(privacyParameters).isFlexiblePrivacyGroupsEnabled();
assertThat(reg.get(ONCHAIN_PRIVACY)).isInstanceOf(OnchainPrivacyPrecompiledContract.class); assertThat(reg.get(FLEXIBLE_PRIVACY)).isInstanceOf(FlexiblePrivacyPrecompiledContract.class);
assertThat(reg.get(DEFAULT_PRIVACY)).isNull(); assertThat(reg.get(DEFAULT_PRIVACY)).isNull();
} }
@ -74,7 +74,7 @@ public class MainnetPrecompiledContractRegistriesTest {
verify(privacyParameters).isEnabled(); verify(privacyParameters).isEnabled();
verifyNoMoreInteractions(privacyParameters); verifyNoMoreInteractions(privacyParameters);
assertThat(reg.get(ONCHAIN_PRIVACY)).isNull(); assertThat(reg.get(FLEXIBLE_PRIVACY)).isNull();
assertThat(reg.get(DEFAULT_PRIVACY)).isNull(); assertThat(reg.get(DEFAULT_PRIVACY)).isNull();
} }
} }

@ -69,7 +69,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito; import org.mockito.Mockito;
public class OnchainPrivacyPrecompiledContractTest { public class FlexiblePrivacyPrecompiledContractTest {
@Rule public final TemporaryFolder temp = new TemporaryFolder(); @Rule public final TemporaryFolder temp = new TemporaryFolder();
@ -144,7 +144,7 @@ public class OnchainPrivacyPrecompiledContractTest {
@Test @Test
public void testPayloadFoundInEnclave() { public void testPayloadFoundInEnclave() {
final Enclave enclave = mock(Enclave.class); final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave); final FlexiblePrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final List<Log> logs = new ArrayList<>(); final List<Log> logs = new ArrayList<>();
contract.setPrivateTransactionProcessor( contract.setPrivateTransactionProcessor(
mockPrivateTxProcessor( mockPrivateTxProcessor(
@ -161,7 +161,7 @@ public class OnchainPrivacyPrecompiledContractTest {
new ReceiveResponse(payload, PAYLOAD_TEST_PRIVACY_GROUP_ID, privateFrom); new ReceiveResponse(payload, PAYLOAD_TEST_PRIVACY_GROUP_ID, privateFrom);
when(enclave.receive(any())).thenReturn(response); when(enclave.receive(any())).thenReturn(response);
final OnchainPrivacyPrecompiledContract contractSpy = spy(contract); final FlexiblePrivacyPrecompiledContract contractSpy = spy(contract);
Mockito.doReturn(true) Mockito.doReturn(true)
.when(contractSpy) .when(contractSpy)
.canExecute(any(), any(), any(), any(), any(), any(), any(), any()); .canExecute(any(), any(), any(), any(), any(), any(), any(), any());
@ -195,7 +195,7 @@ public class OnchainPrivacyPrecompiledContractTest {
@Test @Test
public void testEnclaveBelowRequiredVersion() { public void testEnclaveBelowRequiredVersion() {
final Enclave enclave = mock(Enclave.class); final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave); final FlexiblePrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final VersionedPrivateTransaction versionedPrivateTransaction = final VersionedPrivateTransaction versionedPrivateTransaction =
versionedPrivateTransactionBesu(); versionedPrivateTransactionBesu();
final byte[] payload = convertVersionedPrivateTransactionToBytes(versionedPrivateTransaction); final byte[] payload = convertVersionedPrivateTransactionToBytes(versionedPrivateTransaction);
@ -213,7 +213,7 @@ public class OnchainPrivacyPrecompiledContractTest {
@Test @Test
public void testPayloadNotMatchingPrivateFrom() { public void testPayloadNotMatchingPrivateFrom() {
final Enclave enclave = mock(Enclave.class); final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave); final FlexiblePrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final VersionedPrivateTransaction versionedPrivateTransaction = final VersionedPrivateTransaction versionedPrivateTransaction =
versionedPrivateTransactionBesu(); versionedPrivateTransactionBesu();
final byte[] payload = convertVersionedPrivateTransactionToBytes(versionedPrivateTransaction); final byte[] payload = convertVersionedPrivateTransactionToBytes(versionedPrivateTransaction);
@ -260,16 +260,18 @@ public class OnchainPrivacyPrecompiledContractTest {
private void assertThatComputeReturnsEmptyGivenContractMembershipQueryReturns( private void assertThatComputeReturnsEmptyGivenContractMembershipQueryReturns(
final Bytes memberList) { final Bytes memberList) {
final Enclave enclave = mock(Enclave.class); final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave); final FlexiblePrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final List<Log> logs = new ArrayList<>(); final List<Log> logs = new ArrayList<>();
contract.setPrivateTransactionProcessor( contract.setPrivateTransactionProcessor(
mockPrivateTxProcessor( mockPrivateTxProcessor(
TransactionProcessingResult.successful(logs, 0, 0, memberList, null))); TransactionProcessingResult.successful(logs, 0, 0, memberList, null)));
final OnchainPrivacyPrecompiledContract contractSpy = spy(contract); final FlexiblePrivacyPrecompiledContract contractSpy = spy(contract);
Mockito.doReturn(false).when(contractSpy).isContractLocked(any(), any()); Mockito.doReturn(false).when(contractSpy).isContractLocked(any(), any());
Mockito.doReturn(true).when(contractSpy).onchainPrivacyGroupVersionMatches(any(), any(), any()); Mockito.doReturn(true)
.when(contractSpy)
.flexiblePrivacyGroupVersionMatches(any(), any(), any());
final VersionedPrivateTransaction privateTransaction = versionedPrivateTransactionBesu(); final VersionedPrivateTransaction privateTransaction = versionedPrivateTransactionBesu();
final byte[] payload = convertVersionedPrivateTransactionToBytes(privateTransaction); final byte[] payload = convertVersionedPrivateTransactionToBytes(privateTransaction);
@ -289,8 +291,8 @@ public class OnchainPrivacyPrecompiledContractTest {
public void testInvalidPrivateTransaction() { public void testInvalidPrivateTransaction() {
final Enclave enclave = mock(Enclave.class); final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = final FlexiblePrivacyPrecompiledContract contract =
new OnchainPrivacyPrecompiledContract( new FlexiblePrivacyPrecompiledContract(
new SpuriousDragonGasCalculator(), new SpuriousDragonGasCalculator(),
enclave, enclave,
worldStateArchive, worldStateArchive,
@ -302,7 +304,7 @@ public class OnchainPrivacyPrecompiledContractTest {
TransactionProcessingResult.invalid( TransactionProcessingResult.invalid(
ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE)))); ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE))));
final OnchainPrivacyPrecompiledContract contractSpy = spy(contract); final FlexiblePrivacyPrecompiledContract contractSpy = spy(contract);
Mockito.doReturn(true) Mockito.doReturn(true)
.when(contractSpy) .when(contractSpy)
.canExecute(any(), any(), any(), any(), any(), any(), any(), any()); .canExecute(any(), any(), any(), any(), any(), any(), any(), any());
@ -330,8 +332,9 @@ public class OnchainPrivacyPrecompiledContractTest {
return bytesValueRLPOutput.encoded().toBase64String().getBytes(UTF_8); return bytesValueRLPOutput.encoded().toBase64String().getBytes(UTF_8);
} }
private OnchainPrivacyPrecompiledContract buildPrivacyPrecompiledContract(final Enclave enclave) { private FlexiblePrivacyPrecompiledContract buildPrivacyPrecompiledContract(
return new OnchainPrivacyPrecompiledContract( final Enclave enclave) {
return new FlexiblePrivacyPrecompiledContract(
new SpuriousDragonGasCalculator(), new SpuriousDragonGasCalculator(),
enclave, enclave,
worldStateArchive, worldStateArchive,

@ -44,7 +44,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement; import org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateBlockMetadata; import org.hyperledger.besu.ethereum.privacy.storage.PrivateBlockMetadata;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
@ -75,7 +75,7 @@ import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class OnchainPrivacyControllerTest { public class FlexiblePrivacyControllerTest {
private static final String ADDRESS1 = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; private static final String ADDRESS1 = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=";
private static final String ADDRESS2 = "Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="; private static final String ADDRESS2 = "Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=";
@ -84,7 +84,7 @@ public class OnchainPrivacyControllerTest {
private static final String HEX_STRING_32BYTES_VALUE1 = private static final String HEX_STRING_32BYTES_VALUE1 =
"0x0000000000000000000000000000000000000000000000000000000000000001"; "0x0000000000000000000000000000000000000000000000000000000000000001";
private OnchainPrivacyController privacyController; private FlexiblePrivacyController privacyController;
private PrivateTransactionValidator privateTransactionValidator; private PrivateTransactionValidator privateTransactionValidator;
private PrivateNonceProvider privateNonceProvider; private PrivateNonceProvider privateNonceProvider;
private PrivateStateRootResolver privateStateRootResolver; private PrivateStateRootResolver privateStateRootResolver;
@ -94,7 +94,7 @@ public class OnchainPrivacyControllerTest {
private PrivateStateStorage privateStateStorage; private PrivateStateStorage privateStateStorage;
private Enclave enclave; private Enclave enclave;
private String enclavePublicKey; private String enclavePublicKey;
private OnchainPrivacyController brokenPrivacyController; private FlexiblePrivacyController brokenPrivacyController;
private static final byte[] PAYLOAD = new byte[0]; private static final byte[] PAYLOAD = new byte[0];
private static final String TRANSACTION_KEY = "93Ky7lXwFkMc7+ckoFgUMku5bpr9tz4zhmWmk9RlNng="; private static final String TRANSACTION_KEY = "93Ky7lXwFkMc7+ckoFgUMku5bpr9tz4zhmWmk9RlNng=";
@ -106,7 +106,7 @@ public class OnchainPrivacyControllerTest {
Bytes.concatenate(SIMULATOR_RESULT_PREFIX, Base64.decode(ADDRESS1), Base64.decode(ADDRESS2)); Bytes.concatenate(SIMULATOR_RESULT_PREFIX, Base64.decode(ADDRESS1), Base64.decode(ADDRESS2));
private static final PrivacyGroup EXPECTED_PRIVACY_GROUP = private static final PrivacyGroup EXPECTED_PRIVACY_GROUP =
new PrivacyGroup( new PrivacyGroup(
PRIVACY_GROUP_ID, PrivacyGroup.Type.ONCHAIN, "", "", PRIVACY_GROUP_ADDRESSES); PRIVACY_GROUP_ID, PrivacyGroup.Type.FLEXIBLE, "", "", PRIVACY_GROUP_ADDRESSES);
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM = private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
Suppliers.memoize(SignatureAlgorithmFactory::getInstance); Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
@ -136,7 +136,7 @@ public class OnchainPrivacyControllerTest {
enclavePublicKey = EnclaveKeyUtils.loadKey("enclave_key_0.pub"); enclavePublicKey = EnclaveKeyUtils.loadKey("enclave_key_0.pub");
privacyController = privacyController =
new OnchainPrivacyController( new FlexiblePrivacyController(
blockchain, blockchain,
privateStateStorage, privateStateStorage,
enclave, enclave,
@ -146,7 +146,7 @@ public class OnchainPrivacyControllerTest {
privateWorldStateReader, privateWorldStateReader,
privateStateRootResolver); privateStateRootResolver);
brokenPrivacyController = brokenPrivacyController =
new OnchainPrivacyController( new FlexiblePrivacyController(
blockchain, blockchain,
privateStateStorage, privateStateStorage,
brokenMockEnclave(), brokenMockEnclave(),
@ -173,8 +173,8 @@ public class OnchainPrivacyControllerTest {
mockingForCreatesPayloadForAdding(); mockingForCreatesPayloadForAdding();
final PrivateTransaction privateTransaction = final PrivateTransaction privateTransaction =
buildPrivateTransaction(1) buildPrivateTransaction(1)
.payload(OnchainGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE) .payload(FlexibleGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE)
.to(PrivacyParameters.ONCHAIN_PRIVACY_PROXY) .to(PrivacyParameters.FLEXIBLE_PRIVACY_PROXY)
.signAndBuild(KEY_PAIR); .signAndBuild(KEY_PAIR);
final String payload = final String payload =
privacyController.createPrivateMarkerTransactionPayload( privacyController.createPrivateMarkerTransactionPayload(
@ -188,16 +188,16 @@ public class OnchainPrivacyControllerTest {
@Test @Test
public void verifiesGroupContainsUserId() { public void verifiesGroupContainsUserId() {
final OnchainPrivacyGroupContract onchainPrivacyGroupContract = final FlexiblePrivacyGroupContract flexiblePrivacyGroupContract =
mock(OnchainPrivacyGroupContract.class); mock(FlexiblePrivacyGroupContract.class);
when(onchainPrivacyGroupContract.getPrivacyGroupByIdAndBlockNumber(any(), any())) when(flexiblePrivacyGroupContract.getPrivacyGroupByIdAndBlockNumber(any(), any()))
.thenReturn(Optional.of(EXPECTED_PRIVACY_GROUP)); .thenReturn(Optional.of(EXPECTED_PRIVACY_GROUP));
privacyController.setOnchainPrivacyGroupContract(onchainPrivacyGroupContract); privacyController.setFlexiblePrivacyGroupContract(flexiblePrivacyGroupContract);
privacyController.verifyPrivacyGroupContainsPrivacyUserId(PRIVACY_GROUP_ID, ADDRESS1); privacyController.verifyPrivacyGroupContainsPrivacyUserId(PRIVACY_GROUP_ID, ADDRESS1);
} }
@Test @Test
public void findOnchainPrivacyGroups() { public void findFleixblePrivacyGroups() {
mockingForFindPrivacyGroupByMembers(); mockingForFindPrivacyGroupByMembers();
mockingForFindPrivacyGroupById(); mockingForFindPrivacyGroupById();
@ -214,7 +214,7 @@ public class OnchainPrivacyControllerTest {
Assertions.assertThatThrownBy( Assertions.assertThatThrownBy(
() -> privacyController.createPrivacyGroup(Lists.emptyList(), "", "", ADDRESS1)) () -> privacyController.createPrivacyGroup(Lists.emptyList(), "", "", ADDRESS1))
.isInstanceOf(PrivacyConfigurationNotSupportedException.class) .isInstanceOf(PrivacyConfigurationNotSupportedException.class)
.hasMessageContaining("Method not supported when using onchain privacy"); .hasMessageContaining("Method not supported when using flexible privacy");
} }
@Test @Test
@ -222,7 +222,7 @@ public class OnchainPrivacyControllerTest {
Assertions.assertThatThrownBy( Assertions.assertThatThrownBy(
() -> privacyController.deletePrivacyGroup(PRIVACY_GROUP_ID, ADDRESS1)) () -> privacyController.deletePrivacyGroup(PRIVACY_GROUP_ID, ADDRESS1))
.isInstanceOf(PrivacyConfigurationNotSupportedException.class) .isInstanceOf(PrivacyConfigurationNotSupportedException.class)
.hasMessageContaining("Method not supported when using onchain privacy"); .hasMessageContaining("Method not supported when using flexible privacy");
} }
@Test @Test
@ -288,7 +288,7 @@ public class OnchainPrivacyControllerTest {
public void findsPrivacyGroupById() { public void findsPrivacyGroupById() {
final PrivacyGroup privacyGroup = final PrivacyGroup privacyGroup =
new PrivacyGroup( new PrivacyGroup(
PRIVACY_GROUP_ID, PrivacyGroup.Type.ONCHAIN, "", "", PRIVACY_GROUP_ADDRESSES); PRIVACY_GROUP_ID, PrivacyGroup.Type.FLEXIBLE, "", "", PRIVACY_GROUP_ADDRESSES);
mockingForFindPrivacyGroupById(); mockingForFindPrivacyGroupById();
final Optional<PrivacyGroup> privacyGroupFound = final Optional<PrivacyGroup> privacyGroupFound =

@ -16,10 +16,10 @@
package org.hyperledger.besu.ethereum.privacy; package org.hyperledger.besu.ethereum.privacy;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.PROXY_RUNTIME_BYTECODE; import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.PROXY_RUNTIME_BYTECODE;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
@ -131,7 +131,7 @@ public class PrivateStateGenesisAllocatorTest {
assertThat(worldState.frontierRootHash()).isNotEqualTo(EMPTY_ROOT_HASH); assertThat(worldState.frontierRootHash()).isNotEqualTo(EMPTY_ROOT_HASH);
assertThat(worldState.get(ONCHAIN_PRIVACY_PROXY)).isEqualTo(null); assertThat(worldState.get(FLEXIBLE_PRIVACY_PROXY)).isEqualTo(null);
assertGenesisAccountApplied(); assertGenesisAccountApplied();
} }
@ -144,12 +144,12 @@ public class PrivateStateGenesisAllocatorTest {
} }
private void assertManagementContractApplied() { private void assertManagementContractApplied() {
Account managementProxy = worldState.get(ONCHAIN_PRIVACY_PROXY); Account managementProxy = worldState.get(FLEXIBLE_PRIVACY_PROXY);
assertThat(managementProxy.getCode()).isEqualTo(PROXY_RUNTIME_BYTECODE); assertThat(managementProxy.getCode()).isEqualTo(PROXY_RUNTIME_BYTECODE);
assertThat(managementProxy.getStorageValue(UInt256.ZERO)) assertThat(managementProxy.getStorageValue(UInt256.ZERO))
.isEqualTo(UInt256.fromBytes(DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT)); .isEqualTo(UInt256.fromBytes(DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT));
Account managementContract = worldState.get(DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT); Account managementContract = worldState.get(DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT);
assertThat(managementContract.getCode()).isEqualTo(DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE); assertThat(managementContract.getCode()).isEqualTo(DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE);
} }
} }

@ -125,7 +125,7 @@ public class PrivateTransactionLocatorTest {
} }
@Test @Test
public void locateBesuPrivateTransactionSentToOnchainPrivacyGroup() { public void locateBesuPrivateTransactionSentToFlexiblePrivacyGroup() {
final Transaction pmt = PrivateTransactionDataFixture.privateMarkerTransactionOnchain(); final Transaction pmt = PrivateTransactionDataFixture.privateMarkerTransactionOnchain();
final PrivateTransaction privateTransaction = privateTransactionBesu(); final PrivateTransaction privateTransaction = privateTransactionBesu();
@ -159,7 +159,7 @@ public class PrivateTransactionLocatorTest {
} }
@Test @Test
public void locateBesuPrivateTransactionFromAddBlobSentToOnchainPrivacyGroup() { public void locateBesuPrivateTransactionFromAddBlobSentToFlexiblePrivacyGroup() {
final Transaction pmt = PrivateTransactionDataFixture.privateMarkerTransactionOnchain(); final Transaction pmt = PrivateTransactionDataFixture.privateMarkerTransactionOnchain();
final PrivateTransaction privateTransaction = privateTransactionBesu(); final PrivateTransaction privateTransaction = privateTransactionBesu();

@ -153,7 +153,9 @@ public class MessageCallProcessor extends AbstractMessageProcessor {
final Bytes output = contract.compute(frame.getInputData(), frame); final Bytes output = contract.compute(frame.getInputData(), frame);
operationTracer.tracePrecompileCall(frame, gasRequirement, output); operationTracer.tracePrecompileCall(frame, gasRequirement, output);
if (output != null) { if (output != null) {
if (contract.getName().equals("Privacy") || contract.getName().equals("OnchainPrivacy")) { if (contract.getName().equals("Privacy")
|| contract.getName().equals("FlexiblePrivacy")
|| contract.getName().equals("PluginPrivacy")) {
// do not decrement the gas requirement for a privacy pre-compile contract call -> leads // do not decrement the gas requirement for a privacy pre-compile contract call -> leads
// to discrepancies in receipts root between public and private nodes in a network. // to discrepancies in receipts root between public and private nodes in a network.
frame.incrementRemainingGas(gasRequirement); frame.incrementRemainingGas(gasRequirement);

@ -47,7 +47,7 @@ import org.web3j.tx.gas.ContractGasProvider;
* <p>Generated with web3j version 4.5.16. * <p>Generated with web3j version 4.5.16.
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class OnchainPrivacyGroupManagementInterface extends Contract { public class FlexiblePrivacyGroupManagementInterface extends Contract {
public static final String BINARY = ""; public static final String BINARY = "";
public static final String FUNC_ADDPARTICIPANTS = "addParticipants"; public static final String FUNC_ADDPARTICIPANTS = "addParticipants";
@ -67,7 +67,7 @@ public class OnchainPrivacyGroupManagementInterface extends Contract {
public static final String FUNC_UNLOCK = "unlock"; public static final String FUNC_UNLOCK = "unlock";
@Deprecated @Deprecated
protected OnchainPrivacyGroupManagementInterface( protected FlexiblePrivacyGroupManagementInterface(
String contractAddress, String contractAddress,
Web3j web3j, Web3j web3j,
Credentials credentials, Credentials credentials,
@ -76,7 +76,7 @@ public class OnchainPrivacyGroupManagementInterface extends Contract {
super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
} }
protected OnchainPrivacyGroupManagementInterface( protected FlexiblePrivacyGroupManagementInterface(
String contractAddress, String contractAddress,
Web3j web3j, Web3j web3j,
Credentials credentials, Credentials credentials,
@ -85,7 +85,7 @@ public class OnchainPrivacyGroupManagementInterface extends Contract {
} }
@Deprecated @Deprecated
protected OnchainPrivacyGroupManagementInterface( protected FlexiblePrivacyGroupManagementInterface(
String contractAddress, String contractAddress,
Web3j web3j, Web3j web3j,
TransactionManager transactionManager, TransactionManager transactionManager,
@ -94,7 +94,7 @@ public class OnchainPrivacyGroupManagementInterface extends Contract {
super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
} }
protected OnchainPrivacyGroupManagementInterface( protected FlexiblePrivacyGroupManagementInterface(
String contractAddress, String contractAddress,
Web3j web3j, Web3j web3j,
TransactionManager transactionManager, TransactionManager transactionManager,
@ -180,49 +180,49 @@ public class OnchainPrivacyGroupManagementInterface extends Contract {
} }
@Deprecated @Deprecated
public static OnchainPrivacyGroupManagementInterface load( public static FlexiblePrivacyGroupManagementInterface load(
String contractAddress, String contractAddress,
Web3j web3j, Web3j web3j,
Credentials credentials, Credentials credentials,
BigInteger gasPrice, BigInteger gasPrice,
BigInteger gasLimit) { BigInteger gasLimit) {
return new OnchainPrivacyGroupManagementInterface( return new FlexiblePrivacyGroupManagementInterface(
contractAddress, web3j, credentials, gasPrice, gasLimit); contractAddress, web3j, credentials, gasPrice, gasLimit);
} }
@Deprecated @Deprecated
public static OnchainPrivacyGroupManagementInterface load( public static FlexiblePrivacyGroupManagementInterface load(
String contractAddress, String contractAddress,
Web3j web3j, Web3j web3j,
TransactionManager transactionManager, TransactionManager transactionManager,
BigInteger gasPrice, BigInteger gasPrice,
BigInteger gasLimit) { BigInteger gasLimit) {
return new OnchainPrivacyGroupManagementInterface( return new FlexiblePrivacyGroupManagementInterface(
contractAddress, web3j, transactionManager, gasPrice, gasLimit); contractAddress, web3j, transactionManager, gasPrice, gasLimit);
} }
public static OnchainPrivacyGroupManagementInterface load( public static FlexiblePrivacyGroupManagementInterface load(
String contractAddress, String contractAddress,
Web3j web3j, Web3j web3j,
Credentials credentials, Credentials credentials,
ContractGasProvider contractGasProvider) { ContractGasProvider contractGasProvider) {
return new OnchainPrivacyGroupManagementInterface( return new FlexiblePrivacyGroupManagementInterface(
contractAddress, web3j, credentials, contractGasProvider); contractAddress, web3j, credentials, contractGasProvider);
} }
public static OnchainPrivacyGroupManagementInterface load( public static FlexiblePrivacyGroupManagementInterface load(
String contractAddress, String contractAddress,
Web3j web3j, Web3j web3j,
TransactionManager transactionManager, TransactionManager transactionManager,
ContractGasProvider contractGasProvider) { ContractGasProvider contractGasProvider) {
return new OnchainPrivacyGroupManagementInterface( return new FlexiblePrivacyGroupManagementInterface(
contractAddress, web3j, transactionManager, contractGasProvider); contractAddress, web3j, transactionManager, contractGasProvider);
} }
public static RemoteCall<OnchainPrivacyGroupManagementInterface> deploy( public static RemoteCall<FlexiblePrivacyGroupManagementInterface> deploy(
Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
return deployRemoteCall( return deployRemoteCall(
OnchainPrivacyGroupManagementInterface.class, FlexiblePrivacyGroupManagementInterface.class,
web3j, web3j,
credentials, credentials,
contractGasProvider, contractGasProvider,
@ -231,10 +231,10 @@ public class OnchainPrivacyGroupManagementInterface extends Contract {
} }
@Deprecated @Deprecated
public static RemoteCall<OnchainPrivacyGroupManagementInterface> deploy( public static RemoteCall<FlexiblePrivacyGroupManagementInterface> deploy(
Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
return deployRemoteCall( return deployRemoteCall(
OnchainPrivacyGroupManagementInterface.class, FlexiblePrivacyGroupManagementInterface.class,
web3j, web3j,
credentials, credentials,
gasPrice, gasPrice,
@ -243,10 +243,10 @@ public class OnchainPrivacyGroupManagementInterface extends Contract {
""); "");
} }
public static RemoteCall<OnchainPrivacyGroupManagementInterface> deploy( public static RemoteCall<FlexiblePrivacyGroupManagementInterface> deploy(
Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
return deployRemoteCall( return deployRemoteCall(
OnchainPrivacyGroupManagementInterface.class, FlexiblePrivacyGroupManagementInterface.class,
web3j, web3j,
transactionManager, transactionManager,
contractGasProvider, contractGasProvider,
@ -255,13 +255,13 @@ public class OnchainPrivacyGroupManagementInterface extends Contract {
} }
@Deprecated @Deprecated
public static RemoteCall<OnchainPrivacyGroupManagementInterface> deploy( public static RemoteCall<FlexiblePrivacyGroupManagementInterface> deploy(
Web3j web3j, Web3j web3j,
TransactionManager transactionManager, TransactionManager transactionManager,
BigInteger gasPrice, BigInteger gasPrice,
BigInteger gasLimit) { BigInteger gasLimit) {
return deployRemoteCall( return deployRemoteCall(
OnchainPrivacyGroupManagementInterface.class, FlexiblePrivacyGroupManagementInterface.class,
web3j, web3j,
transactionManager, transactionManager,
gasPrice, gasPrice,

@ -13,9 +13,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./OnChainPrivacyGroupManagementInterface.sol"; import "./FlexiblePrivacyGroupManagementInterface.sol";
contract DefaultOnChainPrivacyGroupManagementContract is OnChainPrivacyGroupManagementInterface { contract DefaultFlexiblePrivacyGroupManagementContract is FlexiblePrivacyGroupManagementInterface {
address private _owner; address private _owner;
bool private _canExecute; bool private _canExecute;
@ -128,4 +128,4 @@ contract DefaultOnChainPrivacyGroupManagementContract is OnChainPrivacyGroupMana
bytes32 publicEnclaveKey, bytes32 publicEnclaveKey,
string message string message
); );
} }

@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
interface OnChainPrivacyGroupManagementInterface { interface FlexiblePrivacyGroupManagementInterface {
function addParticipants(bytes32[] calldata publicEnclaveKeys) external returns (bool); function addParticipants(bytes32[] calldata publicEnclaveKeys) external returns (bool);
@ -30,4 +30,4 @@ interface OnChainPrivacyGroupManagementInterface {
function getVersion() external view returns (bytes32); function getVersion() external view returns (bytes32);
function canUpgrade() external returns (bool); function canUpgrade() external returns (bool);
} }

@ -13,9 +13,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./OnChainPrivacyGroupManagementInterface.sol"; import "./FlexiblePrivacyGroupManagementInterface.sol";
contract OnChainPrivacyGroupManagementProxy is OnChainPrivacyGroupManagementInterface { contract FlexiblePrivacyGroupManagementProxy is FlexiblePrivacyGroupManagementInterface {
address public implementation; address public implementation;
@ -28,17 +28,17 @@ contract OnChainPrivacyGroupManagementProxy is OnChainPrivacyGroupManagementInte
} }
function addParticipants(bytes32[] memory _publicEnclaveKeys) public override returns (bool) { function addParticipants(bytes32[] memory _publicEnclaveKeys) public override returns (bool) {
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
return privacyInterface.addParticipants(_publicEnclaveKeys); return privacyInterface.addParticipants(_publicEnclaveKeys);
} }
function getParticipants() view public override returns (bytes32[] memory) { function getParticipants() view public override returns (bytes32[] memory) {
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
return privacyInterface.getParticipants(); return privacyInterface.getParticipants();
} }
function removeParticipant(bytes32 _participant) public override returns (bool) { function removeParticipant(bytes32 _participant) public override returns (bool) {
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
bool result = privacyInterface.removeParticipant(_participant); bool result = privacyInterface.removeParticipant(_participant);
if (result) { if (result) {
emit ParticipantRemoved(_participant); emit ParticipantRemoved(_participant);
@ -47,27 +47,27 @@ contract OnChainPrivacyGroupManagementProxy is OnChainPrivacyGroupManagementInte
} }
function lock() public override { function lock() public override {
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
return privacyInterface.lock(); return privacyInterface.lock();
} }
function unlock() public override { function unlock() public override {
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
return privacyInterface.unlock(); return privacyInterface.unlock();
} }
function canExecute() public view override returns (bool) { function canExecute() public view override returns (bool) {
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
return privacyInterface.canExecute(); return privacyInterface.canExecute();
} }
function getVersion() public view override returns (bytes32) { function getVersion() public view override returns (bytes32) {
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
return privacyInterface.getVersion(); return privacyInterface.getVersion();
} }
function canUpgrade() external override returns (bool) { function canUpgrade() external override returns (bool) {
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
return privacyInterface.canUpgrade(); return privacyInterface.canUpgrade();
} }
@ -77,7 +77,7 @@ contract OnChainPrivacyGroupManagementProxy is OnChainPrivacyGroupManagementInte
require(this.canUpgrade(), "Not allowed to upgrade the management contract."); require(this.canUpgrade(), "Not allowed to upgrade the management contract.");
bytes32[] memory participants = this.getParticipants(); bytes32[] memory participants = this.getParticipants();
_setImplementation(_newImplementation); _setImplementation(_newImplementation);
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation); FlexiblePrivacyGroupManagementInterface privacyInterface = FlexiblePrivacyGroupManagementInterface(implementation);
privacyInterface.addParticipants(participants); privacyInterface.addParticipants(participants);
} }

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
targets=" targets="
OnChainPrivacyGroupManagementInterface FlexiblePrivacyGroupManagementInterface
DefaultOnChainPrivacyGroupManagementContract DefaultFlexiblePrivacyGroupManagementContract
OnChainPrivacyGroupManagementProxy FlexiblePrivacyGroupManagementProxy
" "
for target in ${targets}; do for target in ${targets}; do
@ -23,4 +23,4 @@ for target in ${targets}; do
-p org.hyperledger.besu.privacy.contracts.generated -p org.hyperledger.besu.privacy.contracts.generated
solc --bin-runtime --overwrite -o . ./${target}.sol solc --bin-runtime --overwrite -o . ./${target}.sol
done done

Loading…
Cancel
Save