(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
- 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
### Early Access Features

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

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

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

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

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

@ -26,14 +26,14 @@ import java.util.concurrent.TimeUnit;
import org.awaitility.Awaitility;
import org.web3j.utils.Base64String;
public class ExpectValidOnchainPrivacyGroupCreated implements PrivateCondition {
public class ExpectValidFlexiblePrivacyGroupCreated implements PrivateCondition {
private final PrivacyTransactions transactions;
private final PrivacyRequestFactory.OnchainPrivacyGroup expected;
private final PrivacyRequestFactory.FlexiblePrivacyGroup expected;
public ExpectValidOnchainPrivacyGroupCreated(
public ExpectValidFlexiblePrivacyGroupCreated(
final PrivacyTransactions transactions,
final PrivacyRequestFactory.OnchainPrivacyGroup expected) {
final PrivacyRequestFactory.FlexiblePrivacyGroup expected) {
this.transactions = transactions;
this.expected = expected;
}
@ -43,9 +43,9 @@ public class ExpectValidOnchainPrivacyGroupCreated implements PrivateCondition {
Awaitility.waitAtMost(20, TimeUnit.SECONDS)
.untilAsserted(
() -> {
final List<PrivacyRequestFactory.OnchainPrivacyGroup> groups =
final List<PrivacyRequestFactory.FlexiblePrivacyGroup> groups =
node.execute(
transactions.findOnchainPrivacyGroup(
transactions.findFlexiblePrivacyGroup(
Base64String.unwrapList(expected.getMembers())));
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.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.List;
@ -61,7 +61,7 @@ public class PrivateTransactionVerifier {
return new ExpectValidPrivacyGroupCreated(transactions, expected);
}
public ExpectValidOnchainPrivacyGroupCreated onchainPrivacyGroupExists(
public ExpectValidFlexiblePrivacyGroupCreated flexiblePrivacyGroupExists(
final String privacyGroupId, final PrivacyNode... members) {
final List<Base64String> membersEnclaveKeys =
@ -69,16 +69,16 @@ public class PrivateTransactionVerifier {
.map(PrivacyNode::getEnclaveKey)
.map(Base64String::wrap)
.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 OnchainPrivacyGroup expectedGroup =
new OnchainPrivacyGroup(privacyGroupId, membersEnclaveKeys);
final FlexiblePrivacyGroup expectedGroup =
new FlexiblePrivacyGroup(privacyGroupId, membersEnclaveKeys);
return new ExpectValidOnchainPrivacyGroupCreated(transactions, expectedGroup);
return new ExpectValidFlexiblePrivacyGroupCreated(transactions, expectedGroup);
}
public ExpectInternalErrorPrivateTransactionReceipt internalErrorPrivateTransactionReceipt(

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

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

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

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

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

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

@ -24,12 +24,12 @@ import org.web3j.crypto.Credentials;
import org.web3j.protocol.exceptions.TransactionException;
import org.web3j.utils.Base64String;
public class UnlockOnchainPrivacyGroupTransaction implements Transaction<String> {
public class UnlockFlexiblePrivacyGroupTransaction implements Transaction<String> {
private final Base64String privacyGroupId;
private final PrivacyNode locker;
private final Credentials signer;
public UnlockOnchainPrivacyGroupTransaction(
public UnlockFlexiblePrivacyGroupTransaction(
final String privacyGroupId, final PrivacyNode locker, final Credentials signer) {
this.privacyGroupId = Base64String.wrap(privacyGroupId);
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 java.util.Collections.singletonList;
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.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.enclave.types.PrivacyGroup;
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.PrivateTransactionGroupResponse;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter;
@ -185,7 +185,7 @@ public class PrivacyRequestFactory {
nonce,
BigInteger.valueOf(1000),
BigInteger.valueOf(3000000),
ONCHAIN_PRIVACY_PROXY.toHexString(),
FLEXIBLE_PRIVACY_PROXY.toHexString(),
payload.toHexString(),
Base64String.wrap(adder.getEnclaveKey()),
privacyGroupId,
@ -218,7 +218,7 @@ public class PrivacyRequestFactory {
nonce,
BigInteger.valueOf(1000),
BigInteger.valueOf(3000000),
ONCHAIN_PRIVACY_PROXY.toHexString(),
FLEXIBLE_PRIVACY_PROXY.toHexString(),
payload.toHexString(),
Base64String.wrap(removerTenant),
privacyGroupId,
@ -232,7 +232,7 @@ public class PrivacyRequestFactory {
}
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(
@ -242,7 +242,7 @@ public class PrivacyRequestFactory {
locker,
privacyGroupId,
signer,
OnchainGroupManagement.LOCK_GROUP_METHOD_SIGNATURE.toHexString());
FlexibleGroupManagement.LOCK_GROUP_METHOD_SIGNATURE.toHexString());
}
public String privxUnlockPrivacyGroup(
@ -252,7 +252,7 @@ public class PrivacyRequestFactory {
locker,
privacyGroupId,
signer,
OnchainGroupManagement.UNLOCK_GROUP_METHOD_SIGNATURE.toHexString());
FlexibleGroupManagement.UNLOCK_GROUP_METHOD_SIGNATURE.toHexString());
}
private String privxLockOrUnlockPrivacyGroup(
@ -272,7 +272,7 @@ public class PrivacyRequestFactory {
nonce,
BigInteger.valueOf(1000),
BigInteger.valueOf(3000000),
ONCHAIN_PRIVACY_PROXY.toHexString(),
FLEXIBLE_PRIVACY_PROXY.toHexString(),
callData,
Base64String.wrap(locker.getEnclaveKey()),
privacyGroupId,
@ -312,7 +312,7 @@ public class PrivacyRequestFactory {
BigInteger.ZERO,
BigInteger.valueOf(1000),
BigInteger.valueOf(3000000),
ONCHAIN_PRIVACY_PROXY.toHexString(),
FLEXIBLE_PRIVACY_PROXY.toHexString(),
payload.toHexString(),
Base64String.wrap(privateFrom),
Base64String.wrap(privacyGroupId.toArrayUnsafe()),
@ -327,10 +327,10 @@ public class PrivacyRequestFactory {
return new PrivxCreatePrivacyGroupResponse(privacyGroupId.toBase64String(), transactionHash);
}
public Request<?, PrivxFindPrivacyGroupResponse> privxFindOnchainPrivacyGroup(
public Request<?, PrivxFindPrivacyGroupResponse> privxFindFlexiblePrivacyGroup(
final List<Base64String> nodes) {
return new Request<>(
"privx_findOnChainPrivacyGroup",
"privx_findFlexiblePrivacyGroup",
singletonList(nodes),
web3jService,
PrivxFindPrivacyGroupResponse.class);
@ -487,14 +487,14 @@ public class PrivacyRequestFactory {
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();
}
}
public static class OnchainPrivacyGroup {
public static class FlexiblePrivacyGroup {
private final Base64String privacyGroupId;
private final List<Base64String> members;
@ -502,11 +502,11 @@ public class PrivacyRequestFactory {
private final String description;
public enum Type {
ONCHAIN
FLEXIBLE
}
@JsonCreator
public OnchainPrivacyGroup(
public FlexiblePrivacyGroup(
@JsonProperty(value = "privacyGroupId") final String privacyGroupId,
@JsonProperty(value = "type") final Type type,
@JsonProperty(value = "name") final String name,
@ -515,7 +515,7 @@ public class PrivacyRequestFactory {
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.name = "";
this.description = "";
@ -535,7 +535,7 @@ public class PrivacyRequestFactory {
}
public Type getType() {
return Type.ONCHAIN;
return Type.FLEXIBLE;
}
public List<Base64String> getMembers() {
@ -550,7 +550,7 @@ public class PrivacyRequestFactory {
if (o == null || getClass() != o.getClass()) {
return false;
}
final OnchainPrivacyGroup that = (OnchainPrivacyGroup) o;
final FlexiblePrivacyGroup that = (FlexiblePrivacyGroup) o;
return getPrivacyGroupId().equals(that.getPrivacyGroupId())
&& getName().equals(that.getName())
&& getDescription().equals(that.getDescription())
@ -589,7 +589,7 @@ public class PrivacyRequestFactory {
private Bytes encodeAddToGroupFunctionCall(final List<Bytes> participants) {
return Bytes.concatenate(
OnchainGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE, encodeList(participants));
FlexibleGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE, encodeList(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.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 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;
@RunWith(Parameterized.class)
public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBase {
public class FlexiblePrivacyAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase {
private final EnclaveType enclaveType;
public OnchainPrivacyAcceptanceTest(final EnclaveType enclaveType) {
public FlexiblePrivacyAcceptanceTest(final EnclaveType enclaveType) {
this.enclaveType = enclaveType;
}
@ -78,21 +78,21 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
final Network containerNetwork = Network.newNetwork();
alice =
privacyBesu.createOnchainPrivacyGroupEnabledMinerNode(
privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode(
"node1",
privacyAccountResolver.resolve(0),
false,
enclaveType,
Optional.of(containerNetwork));
bob =
privacyBesu.createOnchainPrivacyGroupEnabledNode(
privacyBesu.createFlexiblePrivacyGroupEnabledNode(
"node2",
privacyAccountResolver.resolve(1),
false,
enclaveType,
Optional.of(containerNetwork));
charlie =
privacyBesu.createOnchainPrivacyGroupEnabledNode(
privacyBesu.createFlexiblePrivacyGroupEnabledNode(
"node3",
privacyAccountResolver.resolve(2),
false,
@ -103,13 +103,13 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test
public void nodeCanCreatePrivacyGroup() {
final String privacyGroupId = createOnchainPrivacyGroup(alice);
checkOnchainPrivacyGroupExists(privacyGroupId, alice);
final String privacyGroupId = createFlexiblePrivacyGroup(alice);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
}
@Test
public void deployingMustGiveValidReceipt() {
final String privacyGroupId = createOnchainPrivacyGroup(alice, bob);
final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob);
final Contract eventEmitter = deployPrivateContract(EventEmitter.class, privacyGroupId, alice);
final String commitmentHash = getContractDeploymentCommitmentHash(eventEmitter);
@ -119,7 +119,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test
public void canAddParticipantToGroup() {
final String privacyGroupId = createOnchainPrivacyGroup(alice, bob);
final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob);
final Contract eventEmitter = deployPrivateContract(EventEmitter.class, privacyGroupId, alice);
final String commitmentHash = getContractDeploymentCommitmentHash(eventEmitter);
@ -128,14 +128,14 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
final Credentials aliceCredentials = Credentials.create(alice.getTransactionSigningKey());
lockPrivacyGroup(privacyGroupId, alice, aliceCredentials);
addMembersToPrivacyGroup(privacyGroupId, alice, aliceCredentials, charlie);
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob, charlie);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob, charlie);
charlie.verify(privateTransactionVerifier.existingPrivateTransactionReceipt(commitmentHash));
}
@Test
public void removedMemberCannotSendTransactionToGroup() {
final String privacyGroupId = createOnchainPrivacyGroup(alice, bob);
final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob);
final String removeHash =
removeFromPrivacyGroup(
@ -145,12 +145,12 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
assertThatThrownBy(() -> deployPrivateContract(EventEmitter.class, privacyGroupId, bob))
.isInstanceOf(RuntimeException.class)
.hasMessageContaining("Onchain Privacy group does not exist.");
.hasMessageContaining("Flexible Privacy group does not exist.");
}
@Test
public void canInteractWithPrivateGenesisPreCompile() throws Exception {
final String privacyGroupId = createOnchainPrivacyGroup(alice, bob);
final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob);
final EventEmitter eventEmitter =
alice.execute(
@ -195,15 +195,15 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test
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()));
addMembersToPrivacyGroup(
privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob);
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob);
final EventEmitter eventEmitter =
deployPrivateContract(EventEmitter.class, privacyGroupId, alice);
@ -219,7 +219,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
removeFromPrivacyGroup(
privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob);
checkOnchainPrivacyGroupExists(privacyGroupId, alice);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
final int valueSetWhileBobWas_NOT_aMember = 1337;
final PrivateTransactionReceipt receiptWhileBobRemoved =
@ -238,7 +238,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
addMembersToPrivacyGroup(
privacyGroupId, alice, Credentials.create(alice.getTransactionSigningKey()), bob);
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob);
checkEmitterValue(
Lists.newArrayList(alice, bob),
@ -311,8 +311,8 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test
public void bobCanAddCharlieAfterBeingAddedByAlice() {
final String privacyGroupId = createOnchainPrivacyGroup(alice);
checkOnchainPrivacyGroupExists(privacyGroupId, alice);
final String privacyGroupId = createFlexiblePrivacyGroup(alice);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
final EventEmitter eventEmitter =
alice.execute(
privateContractTransactions.createSmartContractWithPrivacyGroupId(
@ -335,7 +335,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
alice.execute(
privacyTransactions.addToPrivacyGroup(privacyGroupId, alice, aliceCredentials, bob));
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob);
bob.execute(
privacyTransactions.privxLockPrivacyGroupAndCheck(privacyGroupId, bob, aliceCredentials));
@ -369,7 +369,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
alice.getBesu().verify(ethConditions.miningStatus(true));
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob, charlie);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob, charlie);
final Optional<TransactionReceipt> aliceAddReceipt =
alice.execute(ethTransactions.getTransactionReceipt(bobAddHash));
@ -409,7 +409,7 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
new PrivateTransactionReceipt(
null,
alice.getAddress().toHexString(),
ONCHAIN_PRIVACY_PROXY.toHexString(),
FLEXIBLE_PRIVACY_PROXY.toHexString(),
"0x",
Collections.emptyList(),
null,
@ -472,13 +472,13 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
removeFromPrivacyGroup(privacyGroupId, bob, aliceCredentials, charlie);
checkOnchainPrivacyGroupExists(privacyGroupId, alice, bob);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob);
}
@Test
public void canOnlyCallProxyContractWhenGroupLocked() {
final String privacyGroupId = createOnchainPrivacyGroup(alice);
checkOnchainPrivacyGroupExists(privacyGroupId, alice);
final String privacyGroupId = createFlexiblePrivacyGroup(alice);
checkFlexiblePrivacyGroupExists(privacyGroupId, alice);
final EventEmitter eventEmitter =
alice.execute(
@ -542,10 +542,10 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
@Test
public void addMembersToTwoGroupsInTheSameBlock() {
final String privacyGroupId1 = createOnchainPrivacyGroup(alice);
final String privacyGroupId2 = createOnchainPrivacyGroup(bob);
checkOnchainPrivacyGroupExists(privacyGroupId1, alice);
checkOnchainPrivacyGroupExists(privacyGroupId2, bob);
final String privacyGroupId1 = createFlexiblePrivacyGroup(alice);
final String privacyGroupId2 = createFlexiblePrivacyGroup(bob);
checkFlexiblePrivacyGroupExists(privacyGroupId1, alice);
checkFlexiblePrivacyGroupExists(privacyGroupId2, bob);
lockPrivacyGroup(privacyGroupId1, alice, Credentials.create(alice.getTransactionSigningKey()));
lockPrivacyGroup(privacyGroupId2, bob, Credentials.create(bob.getTransactionSigningKey()));
@ -571,8 +571,8 @@ public class OnchainPrivacyAcceptanceTest extends OnchainPrivacyAcceptanceTestBa
alice.execute(minerTransactions.minerStart());
checkOnchainPrivacyGroupExists(privacyGroupId1, alice, charlie);
checkOnchainPrivacyGroupExists(privacyGroupId2, bob, alice);
checkFlexiblePrivacyGroupExists(privacyGroupId1, alice, charlie);
checkFlexiblePrivacyGroupExists(privacyGroupId2, bob, alice);
}
private <T extends Contract> T deployPrivateContract(

@ -15,14 +15,14 @@
package org.hyperledger.besu.tests.acceptance.privacy;
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.privacy.group.OnchainGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
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.tests.acceptance.dsl.privacy.PrivacyAcceptanceTestBase;
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.transaction.CreateOnchainPrivacyGroupTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.ExpectValidFlexiblePrivacyGroupCreated;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.CreateFlexiblePrivacyGroupTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory;
import java.util.Arrays;
@ -37,16 +37,16 @@ import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract;
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 =
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
* has the expected list of member for the group.
@ -55,13 +55,13 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
* the creator of the 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 PrivacyNode groupCreator = members[0];
final CreateOnchainPrivacyGroupTransaction createTx =
privacyTransactions.createOnchainPrivacyGroup(groupCreator, privateFrom, addresses);
final CreateFlexiblePrivacyGroupTransaction createTx =
privacyTransactions.createFlexiblePrivacyGroup(groupCreator, privateFrom, addresses);
final PrivacyRequestFactory.PrivxCreatePrivacyGroupResponse createResponse =
groupCreator.execute(createTx);
@ -73,7 +73,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
.collect(Collectors.toList());
for (final PrivacyNode member : members) {
member.verify(onchainPrivacyGroupExists(privacyGroupId, membersEnclaveKeys));
member.verify(flexiblePrivacyGroupExists(privacyGroupId, membersEnclaveKeys));
}
final String commitmentHash =
@ -95,7 +95,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
final String privacyGroupId, final PrivacyNode groupCreator, final String privateFrom) {
return groupCreator.execute(
privateContractTransactions.callOnchainPermissioningSmartContract(
ONCHAIN_PRIVACY_PROXY.toHexString(),
FLEXIBLE_PRIVACY_PROXY.toHexString(),
GET_PARTICIPANTS_METHOD_SIGNATURE.toString(),
groupCreator.getTransactionSigningKey(),
privateFrom,
@ -128,7 +128,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
return new PrivateTransactionReceipt(
null,
groupCreator.getAddress().toHexString(),
ONCHAIN_PRIVACY_PROXY.toHexString(),
FLEXIBLE_PRIVACY_PROXY.toHexString(),
output.toString(),
Collections.emptyList(),
null,
@ -140,9 +140,9 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
null);
}
protected ExpectValidOnchainPrivacyGroupCreated onchainPrivacyGroupExists(
protected ExpectValidFlexiblePrivacyGroupCreated flexiblePrivacyGroupExists(
final String privacyGroupId, final List<Base64String> members) {
return privateTransactionVerifier.onchainPrivacyGroupExists(privacyGroupId, members);
return privateTransactionVerifier.flexiblePrivacyGroupExists(privacyGroupId, members);
}
protected String getContractDeploymentCommitmentHash(final Contract contract) {
@ -161,7 +161,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
* @param privacyGroupId the id of 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 List<Base64String> membersEnclaveKeys =
Arrays.stream(members)
@ -170,7 +170,7 @@ public class OnchainPrivacyAcceptanceTestBase extends PrivacyAcceptanceTestBase
.collect(Collectors.toList());
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;
@RunWith(Parameterized.class)
public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
extends OnchainPrivacyAcceptanceTestBase {
public class PrivDebugGetStateRootFlexibleGroupAcceptanceTest
extends FlexiblePrivacyAcceptanceTestBase {
private final EnclaveType enclaveType;
public PrivDebugGetStateRootOnchainGroupAcceptanceTest(final EnclaveType enclaveType) {
public PrivDebugGetStateRootFlexibleGroupAcceptanceTest(final EnclaveType enclaveType) {
this.enclaveType = enclaveType;
}
@ -60,14 +60,14 @@ public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
final Network containerNetwork = Network.newNetwork();
aliceNode =
privacyBesu.createOnchainPrivacyGroupEnabledMinerNode(
privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode(
"alice-node",
PrivacyAccountResolver.ALICE,
false,
enclaveType,
Optional.of(containerNetwork));
bobNode =
privacyBesu.createOnchainPrivacyGroupEnabledNode(
privacyBesu.createFlexiblePrivacyGroupEnabledNode(
"bob-node",
PrivacyAccountResolver.BOB,
false,
@ -79,7 +79,7 @@ public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
@Test
public void nodesInGroupShouldHaveSameStateRoot() {
final String privacyGroupId = createOnchainPrivacyGroup(aliceNode, bobNode);
final String privacyGroupId = createFlexiblePrivacyGroup(aliceNode, bobNode);
final Hash aliceStateRootId =
aliceNode
@ -112,7 +112,7 @@ public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
waitForBlockHeight(aliceNode, 2);
waitForBlockHeight(bobNode, 2);
final String privacyGroupId = createOnchainPrivacyGroup(aliceNode, bobNode);
final String privacyGroupId = createFlexiblePrivacyGroup(aliceNode, bobNode);
waitForBlockHeight(aliceNode, 10);
waitForBlockHeight(bobNode, 10);
@ -140,7 +140,7 @@ public class PrivDebugGetStateRootOnchainGroupAcceptanceTest
@Test
public void canInteractWithPrivateGenesisPreCompile() throws Exception {
final String privacyGroupId = createOnchainPrivacyGroup(aliceNode, bobNode);
final String privacyGroupId = createFlexiblePrivacyGroup(aliceNode, bobNode);
final EventEmitter eventEmitter =
aliceNode.execute(

@ -16,7 +16,7 @@ package org.hyperledger.besu.tests.acceptance.privacy.contracts;
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.node.BesuNode;
@ -40,7 +40,7 @@ public class PrivacyGroupTest extends AcceptanceTestBase {
Base64String.wrap("Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=");
private final Base64String thirdParticipant =
Base64String.wrap("Jo2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=");
private DefaultOnchainPrivacyGroupManagementContract defaultPrivacyGroupManagementContract;
private DefaultFlexiblePrivacyGroupManagementContract defaultPrivacyGroupManagementContract;
private static final String RAW_FIRST_PARTICIPANT = "0x5aa68ac0";
private static final String RAW_ADD_PARTICIPANT =
@ -61,7 +61,7 @@ public class PrivacyGroupTest extends AcceptanceTestBase {
defaultPrivacyGroupManagementContract =
minerNode.execute(
contractTransactions.createSmartContract(
DefaultOnchainPrivacyGroupManagementContract.class));
DefaultFlexiblePrivacyGroupManagementContract.class));
}
@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.assertThatThrownBy;
import org.hyperledger.besu.privacy.contracts.generated.DefaultOnchainPrivacyGroupManagementContract;
import org.hyperledger.besu.privacy.contracts.generated.OnchainPrivacyGroupManagementProxy;
import org.hyperledger.besu.privacy.contracts.generated.DefaultFlexiblePrivacyGroupManagementContract;
import org.hyperledger.besu.privacy.contracts.generated.FlexiblePrivacyGroupManagementProxy;
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.account.Accounts;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
@ -45,58 +45,59 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
Base64String.wrap("9iaJ6OObl6TUWYjXAOyZsL0VaDPwF+tRFkMwwYSeqqw=");
private final Base64String thirdParticipant =
Base64String.wrap("Jo2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=");
private OnchainPrivacyGroupManagementProxy onchainPrivacyGroupManagementProxy;
private FlexiblePrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy;
private static final String RAW_GET_PARTICIPANTS = "0x5aa68ac0";
private static final String RAW_ADD_PARTICIPANT =
"0xb4926e2500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001f772b2ee55f016431cefe724a05814324bb96e9afdb73e338665a693d4653678";
private BesuNode minerNode;
private DefaultOnchainPrivacyGroupManagementContract defaultOnchainPrivacyGroupManagementContract;
private DefaultFlexiblePrivacyGroupManagementContract
defaultFlexiblePrivacyGroupManagementContract;
@Before
public void setUp() throws Exception {
minerNode = besu.createMinerNode("node");
cluster.start(minerNode);
defaultOnchainPrivacyGroupManagementContract =
defaultFlexiblePrivacyGroupManagementContract =
minerNode.execute(
contractTransactions.createSmartContract(
DefaultOnchainPrivacyGroupManagementContract.class));
onchainPrivacyGroupManagementProxy =
DefaultFlexiblePrivacyGroupManagementContract.class));
flexiblePrivacyGroupManagementProxy =
minerNode.execute(
contractTransactions.createSmartContract(
OnchainPrivacyGroupManagementProxy.class,
defaultOnchainPrivacyGroupManagementContract.getContractAddress()));
FlexiblePrivacyGroupManagementProxy.class,
defaultFlexiblePrivacyGroupManagementContract.getContractAddress()));
}
@Test
public void rlp() throws Exception {
assertThat(onchainPrivacyGroupManagementProxy.isValid()).isEqualTo(true);
assertThat(flexiblePrivacyGroupManagementProxy.isValid()).isEqualTo(true);
contractVerifier
.validTransactionReceipt(onchainPrivacyGroupManagementProxy.getContractAddress())
.verify(onchainPrivacyGroupManagementProxy);
.validTransactionReceipt(flexiblePrivacyGroupManagementProxy.getContractAddress())
.verify(flexiblePrivacyGroupManagementProxy);
assertThat(RAW_GET_PARTICIPANTS)
.isEqualTo(onchainPrivacyGroupManagementProxy.getParticipants().encodeFunctionCall());
.isEqualTo(flexiblePrivacyGroupManagementProxy.getParticipants().encodeFunctionCall());
assertThat(RAW_ADD_PARTICIPANT)
.isEqualTo(
onchainPrivacyGroupManagementProxy
flexiblePrivacyGroupManagementProxy
.addParticipants(List.of(firstParticipant.raw()))
.encodeFunctionCall());
}
@Test
public void deploysWithNoParticipant() throws Exception {
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send();
final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(0);
}
@Test
public void canAddParticipants() throws Exception {
onchainPrivacyGroupManagementProxy
flexiblePrivacyGroupManagementProxy
.addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw()))
.send();
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send();
final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(2);
assertThat(firstParticipant.raw()).isEqualTo(participants.get(0));
assertThat(secondParticipant.raw()).isEqualTo(participants.get(1));
@ -104,18 +105,18 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
@Test
public void nonOwnerCannotUpgrade() throws Exception {
onchainPrivacyGroupManagementProxy
flexiblePrivacyGroupManagementProxy
.addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw()))
.send();
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send();
final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(2);
assertThat(firstParticipant.raw()).isEqualTo(participants.get(0));
assertThat(secondParticipant.raw()).isEqualTo(participants.get(1));
final DefaultOnchainPrivacyGroupManagementContract upgradedContract =
final DefaultFlexiblePrivacyGroupManagementContract upgradedContract =
minerNode.execute(
contractTransactions.createSmartContract(
DefaultOnchainPrivacyGroupManagementContract.class));
DefaultFlexiblePrivacyGroupManagementContract.class));
final HttpService httpService =
new HttpService(
@ -123,9 +124,9 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
final Web3j web3j = Web3j.build(httpService);
// load the proxy contract, use it with another signer
final OnchainPrivacyGroupManagementProxy proxyContractAccount2 =
OnchainPrivacyGroupManagementProxy.load(
onchainPrivacyGroupManagementProxy.getContractAddress(),
final FlexiblePrivacyGroupManagementProxy proxyContractAccount2 =
FlexiblePrivacyGroupManagementProxy.load(
flexiblePrivacyGroupManagementProxy.getContractAddress(),
web3j,
Credentials.create(Accounts.GENESIS_ACCOUNT_TWO_PRIVATE_KEY),
new DefaultGasProvider());
@ -138,22 +139,22 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
@Test
public void ownerCanUpgrade() throws Exception {
onchainPrivacyGroupManagementProxy
flexiblePrivacyGroupManagementProxy
.addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw()))
.send();
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send();
final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(2);
assertThat(firstParticipant.raw()).isEqualTo(participants.get(0));
assertThat(secondParticipant.raw()).isEqualTo(participants.get(1));
final DefaultOnchainPrivacyGroupManagementContract upgradedContract =
final DefaultFlexiblePrivacyGroupManagementContract upgradedContract =
minerNode.execute(
contractTransactions.createSmartContract(
DefaultOnchainPrivacyGroupManagementContract.class));
DefaultFlexiblePrivacyGroupManagementContract.class));
onchainPrivacyGroupManagementProxy.upgradeTo(upgradedContract.getContractAddress()).send();
flexiblePrivacyGroupManagementProxy.upgradeTo(upgradedContract.getContractAddress()).send();
final List<byte[]> participantsAfterUpgrade =
onchainPrivacyGroupManagementProxy.getParticipants().send();
flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participantsAfterUpgrade.size()).isEqualTo(2);
assertThat(firstParticipant.raw()).isEqualTo(participantsAfterUpgrade.get(0));
assertThat(secondParticipant.raw()).isEqualTo(participantsAfterUpgrade.get(1));
@ -161,14 +162,14 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
@Test
public void canAddTwiceToContractWhenCallLock() throws Exception {
onchainPrivacyGroupManagementProxy
flexiblePrivacyGroupManagementProxy
.addParticipants(Arrays.asList(firstParticipant.raw(), thirdParticipant.raw()))
.send();
onchainPrivacyGroupManagementProxy.lock().send();
onchainPrivacyGroupManagementProxy
flexiblePrivacyGroupManagementProxy.lock().send();
flexiblePrivacyGroupManagementProxy
.addParticipants(Collections.singletonList(secondParticipant.raw()))
.send();
final List<byte[]> participants = onchainPrivacyGroupManagementProxy.getParticipants().send();
final List<byte[]> participants = flexiblePrivacyGroupManagementProxy.getParticipants().send();
assertThat(participants.size()).isEqualTo(3);
assertThat(firstParticipant.raw()).isEqualTo(participants.get(0));
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.account.PrivacyAccountResolver;
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.transaction.perm.PermissioningTransactions;
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.enclave.testutil.EnclaveType;
@ -49,11 +49,11 @@ import org.web3j.utils.Base64String;
import org.web3j.utils.Restriction;
@RunWith(Parameterized.class)
public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceTestBase {
public class FlexibleMultiTenancyAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase {
private final EnclaveType enclaveType;
public OnchainMultiTenancyAcceptanceTest(final EnclaveType enclaveType) {
public FlexibleMultiTenancyAcceptanceTest(final EnclaveType enclaveType) {
this.enclaveType = enclaveType;
}
@ -72,7 +72,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
@Before
public void setUp() throws Exception {
alice =
privacyBesu.createOnchainPrivacyGroupEnabledMinerNode(
privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode(
"node1", PrivacyAccountResolver.MULTI_TENANCY, true, enclaveType, Optional.empty());
final BesuNode aliceBesu = alice.getBesu();
privacyCluster.startNodes(alice);
@ -103,7 +103,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
@Test
public void createPrivacyGroup() {
createOnchainPrivacyGroup(alice);
createFlexiblePrivacyGroup(alice);
}
@Test
@ -111,7 +111,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
final MultiTenancyPrivacyGroup privacyGroup = new MultiTenancyPrivacyGroup();
privacyGroup.addNodeWithTenants(
aliceMultiTenancyPrivacyNode, aliceMultiTenancyPrivacyNode.getTenants());
createOnchainPrivacyGroup(privacyGroup);
createFlexiblePrivacyGroup(privacyGroup);
}
@Test
@ -120,7 +120,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
final List<String> tenants = aliceMultiTenancyPrivacyNode.getTenants();
final String removedTenant = tenants.remove(tenants.size() - 1);
twoTenantsFromAlice.addNodeWithTenants(aliceMultiTenancyPrivacyNode, tenants);
final String privacyGroupId = createOnchainPrivacyGroup(twoTenantsFromAlice);
final String privacyGroupId = createFlexiblePrivacyGroup(twoTenantsFromAlice);
final MultiTenancyPrivacyNode multiTenancyPrivacyNode =
twoTenantsFromAlice.getPrivacyNodes().get(0);
@ -250,9 +250,10 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
.getBesu()
.useAuthenticationTokenInHeaderForJsonRpc(
multiTenancyPrivacyNode.getTokenForTenant(tenant));
final List<PrivacyRequestFactory.OnchainPrivacyGroup> group =
final List<PrivacyRequestFactory.FlexiblePrivacyGroup> group =
privacyNode.execute(
privacyTransactions.findOnchainPrivacyGroup(Base64String.unwrapList(base64StringList)));
privacyTransactions.findFlexiblePrivacyGroup(
Base64String.unwrapList(base64StringList)));
assertThat(group.size()).isEqualTo(1);
assertThat(group.get(0).getMembers()).containsAll(base64StringList).hasSize(2);
@ -264,9 +265,9 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
assertThatThrownBy(
() ->
privacyNode.execute(
privacyTransactions.findOnchainPrivacyGroup(
privacyTransactions.findFlexiblePrivacyGroup(
Base64String.unwrapList(base64StringList))))
.hasMessageContaining("Error finding onchain privacy group");
.hasMessageContaining("Error finding flexible privacy group");
// check that a member can do a priv_call
privacyNode
@ -318,7 +319,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
final MultiTenancyPrivacyGroup allTenantsFromAlice = new MultiTenancyPrivacyGroup();
final List<String> tenants = aliceMultiTenancyPrivacyNode.getTenants();
allTenantsFromAlice.addNodeWithTenants(aliceMultiTenancyPrivacyNode, tenants);
final String privacyGroupId = createOnchainPrivacyGroup(allTenantsFromAlice);
final String privacyGroupId = createFlexiblePrivacyGroup(allTenantsFromAlice);
final MultiTenancyPrivacyNode multiTenancyPrivacyNode =
allTenantsFromAlice.getPrivacyNodes().get(0);
final String groupCreatingTenant = allTenantsFromAlice.getGroupCreatingTenant();
@ -407,7 +408,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
.hasMessageContaining("Unauthorized");
}
private String createOnchainPrivacyGroup(final MultiTenancyPrivacyGroup group) {
private String createFlexiblePrivacyGroup(final MultiTenancyPrivacyGroup group) {
final List<MultiTenancyPrivacyNode> multiTenancyPrivacyNodes = group.getPrivacyNodes();
final MultiTenancyPrivacyNode groupCreatorMultiTenancyPrivacyNode =
multiTenancyPrivacyNodes.get(0);
@ -415,8 +416,8 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
final String groupCreatorTenant = group.getGroupCreatingTenant();
final List<String> members = group.getTenants();
final String token = groupCreatorMultiTenancyPrivacyNode.getTokenForTenant(groupCreatorTenant);
final CreateOnchainPrivacyGroupTransaction createTx =
privacyTransactions.createOnchainPrivacyGroup(
final CreateFlexiblePrivacyGroupTransaction createTx =
privacyTransactions.createFlexiblePrivacyGroup(
groupCreatorNode, groupCreatorTenant, members, token);
final PrivacyRequestFactory.PrivxCreatePrivacyGroupResponse createResponse =
@ -432,7 +433,7 @@ public class OnchainMultiTenancyAcceptanceTest extends OnchainPrivacyAcceptanceT
privacyNode
.getBesu()
.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.not;
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.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.eth.transactions.TransactionPool;
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.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.RlpxConfiguration;
@ -925,17 +925,17 @@ public class RunnerBuilder {
private void createPrivateTransactionObserver(
final PrivateTransactionObserver privateTransactionObserver,
final PrivacyParameters privacyParameters) {
// register privateTransactionObserver as observer of events fired by the onchain precompile.
if (privacyParameters.isOnchainPrivacyGroupsEnabled()
// register privateTransactionObserver as observer of events fired by the flexible precompile.
if (privacyParameters.isFlexiblePrivacyGroupsEnabled()
&& privacyParameters.isMultiTenancyEnabled()) {
final OnchainPrivacyPrecompiledContract onchainPrivacyPrecompiledContract =
(OnchainPrivacyPrecompiledContract)
final FlexiblePrivacyPrecompiledContract flexiblePrivacyPrecompiledContract =
(FlexiblePrivacyPrecompiledContract)
besuController
.getProtocolSchedule()
.getByBlockNumber(1)
.getPrecompileContractRegistry()
.get(ONCHAIN_PRIVACY);
onchainPrivacyPrecompiledContract.addPrivateTransactionObserver(privateTransactionObserver);
.get(FLEXIBLE_PRIVACY);
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.config.NetworkName.MAINNET;
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.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_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;
@Option(
names = {"--privacy-flexible-groups-enabled", "--privacy-onchain-groups-enabled"},
description = "Enable flexible (onchain) privacy groups (default: ${DEFAULT-VALUE})")
names = {"--privacy-flexible-groups-enabled"},
description = "Enable flexible privacy groups (default: ${DEFAULT-VALUE})")
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(
names = {"--target-gas-limit"},
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!");
}
if (unstablePrivacyPluginOptions.isPrivacyPluginEnabled() && isFlexiblePrivacyGroupsEnabled) {
if (unstablePrivacyPluginOptions.isPrivacyPluginEnabled()
&& (isFlexiblePrivacyGroupsEnabled || isOnchainPrivacyGroupsEnabled)) {
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",
"--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 {
@ -2253,7 +2269,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
privacyParametersBuilder.setEnabled(true);
privacyParametersBuilder.setEnclaveUrl(privacyUrl);
privacyParametersBuilder.setMultiTenancyEnabled(isPrivacyMultiTenancyEnabled);
privacyParametersBuilder.setOnchainPrivacyGroupsEnabled(isFlexiblePrivacyGroupsEnabled);
privacyParametersBuilder.setFlexiblePrivacyGroupsEnabled(
isFlexiblePrivacyGroupsEnabled || isOnchainPrivacyGroupsEnabled);
privacyParametersBuilder.setPrivacyPluginEnabled(
unstablePrivacyPluginOptions.isPrivacyPluginEnabled());

@ -28,6 +28,7 @@ public class CommandLineUtils {
"{} has been ignored because {} was not defined on the command line.";
public static final String MULTI_DEPENDENCY_WARNING_MSG =
"{} 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

@ -49,12 +49,23 @@ public class ConfigOptionSearchAndRunHandler extends AbstractParseResultHandler<
public List<Object> handle(final ParseResult parseResult) throws ParameterException {
final CommandLine commandLine = parseResult.asCommandLineList().get(0);
final Optional<File> configFile = findConfigFile(parseResult, commandLine);
validatePrivacyOptions(parseResult, commandLine);
commandLine.setDefaultValueProvider(createDefaultValueProvider(commandLine, configFile));
commandLine.parseWithHandlers(
resultHandler, exceptionHandler, parseResult.originalArgs().toArray(new String[0]));
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(
final ParseResult parseResult, final CommandLine commandLine) {
if (parseResult.hasMatchedOption("--config-file")

@ -16,7 +16,7 @@ package org.hyperledger.besu;
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.ONCHAIN_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.controller.BesuController;
@ -81,16 +81,16 @@ public class PrivacyTest {
}
@Test
public void onchainEnabledPrivacy() throws IOException, URISyntaxException {
public void flexibleEnabledPrivacy() throws IOException, URISyntaxException {
final BesuController besuController = setUpControllerWithPrivacyEnabled(true);
final PrecompiledContract onchainPrecompiledContract =
getPrecompile(besuController, ONCHAIN_PRIVACY);
final PrecompiledContract flexiblePrecompiledContract =
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 {
final Path dataDir = folder.newFolder().toPath();
final Path dbDir = dataDir.resolve("database");
@ -100,7 +100,7 @@ public class PrivacyTest {
.setEnclaveUrl(new URI("http://127.0.0.1:8000"))
.setStorageProvider(createKeyValueStorageProvider(dataDir, dbDir))
.setEnclaveFactory(new EnclaveFactory(vertx))
.setOnchainPrivacyGroupsEnabled(onchainEnabled)
.setFlexiblePrivacyGroupsEnabled(flexibleEnabled)
.build();
return new BesuController.Builder()
.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.ROPSTEN;
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.NET;
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)");
}
@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
public void parsesValidBonsaiTrieLimitBackLayersOption() {
parseCommand("--Xdata-storage-format", "BONSAI", "--Xbonsai-maximum-back-layers-to-load", "11");
@ -3511,7 +3522,7 @@ public class BesuCommandTest extends CommandTestAbstract {
}
@Test
public void onchainPrivacyGroupEnabledFlagDefaultValueIsFalse() {
public void flexiblePrivacyGroupEnabledFlagDefaultValueIsFalse() {
parseCommand(
"--privacy-enabled",
"--privacy-public-key-file",
@ -3529,7 +3540,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty();
final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue();
assertThat(privacyParameters.isOnchainPrivacyGroupsEnabled()).isEqualTo(false);
assertThat(privacyParameters.isFlexiblePrivacyGroupsEnabled()).isEqualTo(false);
}
@Test
@ -3552,7 +3563,24 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty();
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
@ -3575,7 +3603,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty();
final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue();
assertThat(privacyParameters.isOnchainPrivacyGroupsEnabled()).isEqualTo(true);
assertThat(privacyParameters.isFlexiblePrivacyGroupsEnabled()).isEqualTo(true);
}
@Test

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

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

@ -64,7 +64,8 @@ public enum RpcMethod {
PRIV_GET_FILTER_LOGS("priv_getFilterLogs"),
PRIV_SUBSCRIBE("priv_subscribe"),
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"),
ETH_ACCOUNTS("eth_accounts"),
ETH_BLOCK_NUMBER("eth_blockNumber"),

@ -14,7 +14,7 @@
*/
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.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.eth.transactions.TransactionPool;
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.PrivateTransaction;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
@ -37,12 +37,12 @@ import java.util.Optional;
import io.vertx.ext.auth.User;
import org.apache.tuweni.bytes.Bytes;
public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTransaction {
public class RestrictedFlexibleEeaSendRawTransaction extends AbstractEeaSendRawTransaction {
private final PrivacyController privacyController;
private final PrivacyIdProvider privacyIdProvider;
public RestrictedOnchainEeaSendRawTransaction(
public RestrictedFlexibleEeaSendRawTransaction(
final TransactionPool transactionPool,
final PrivacyIdProvider privacyIdProvider,
final PrivateMarkerTransactionFactory privateMarkerTransactionFactory,
@ -71,7 +71,7 @@ public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTr
final Optional<User> user) {
final Optional<Bytes> maybePrivacyGroupId = privateTransaction.getPrivacyGroupId();
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();
@ -81,20 +81,20 @@ public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTr
privacyController.findPrivacyGroupByGroupId(privacyGroupId.toBase64String(), privacyUserId);
final boolean isGroupAdditionTransaction =
OnchainUtil.isGroupAdditionTransaction(privateTransaction);
FlexibleUtil.isGroupAdditionTransaction(privateTransaction);
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) {
final List<String> participantsFromParameter =
OnchainUtil.getParticipantsFromParameter(privateTransaction.getPayload());
FlexibleUtil.getParticipantsFromParameter(privateTransaction.getPayload());
if (maybePrivacyGroup.isEmpty()) {
maybePrivacyGroup =
Optional.of(
new PrivacyGroup(
privacyGroupId.toBase64String(),
PrivacyGroup.Type.ONCHAIN,
PrivacyGroup.Type.FLEXIBLE,
null,
null,
participantsFromParameter));
@ -104,7 +104,7 @@ public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTr
}
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 =
@ -112,7 +112,7 @@ public class RestrictedOnchainEeaSendRawTransaction extends AbstractEeaSendRawTr
privateTransaction, privacyUserId, maybePrivacyGroup);
return createPrivateMarkerTransaction(
sender, ONCHAIN_PRIVACY, pmtPayload, privateTransaction, privacyUserId);
sender, FLEXIBLE_PRIVACY, pmtPayload, privateTransaction, privacyUserId);
}
@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.JsonRpcSuccessResponse;
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.OnchainUtil;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.ethereum.rlp.RLP;
@ -51,15 +51,15 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
private static final Logger LOG = getLogger();
private final PrivacyController privacyController;
private final PrivacyIdProvider privacyIdProvider;
private final boolean onchainPrivacyGroupsEnabled;
private final boolean flexiblePrivacyGroupsEnabled;
public PrivDistributeRawTransaction(
final PrivacyController privacyController,
final PrivacyIdProvider privacyIdProvider,
final boolean onchainPrivacyGroupsEnabled) {
final boolean flexiblePrivacyGroupsEnabled) {
this.privacyController = privacyController;
this.privacyIdProvider = privacyIdProvider;
this.onchainPrivacyGroupsEnabled = onchainPrivacyGroupsEnabled;
this.flexiblePrivacyGroupsEnabled = flexiblePrivacyGroupsEnabled;
}
@Override
@ -84,8 +84,8 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
final Optional<Bytes> maybePrivacyGroupId = privateTransaction.getPrivacyGroupId();
if (onchainPrivacyGroupsEnabled && maybePrivacyGroupId.isEmpty()) {
return new JsonRpcErrorResponse(id, JsonRpcError.ONCHAIN_PRIVACY_GROUP_ID_NOT_AVAILABLE);
if (flexiblePrivacyGroupsEnabled && maybePrivacyGroupId.isEmpty()) {
return new JsonRpcErrorResponse(id, JsonRpcError.FLEXIBLE_PRIVACY_GROUP_ID_NOT_AVAILABLE);
}
Optional<PrivacyGroup> maybePrivacyGroup =
@ -93,16 +93,16 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
gId ->
privacyController.findPrivacyGroupByGroupId(gId.toBase64String(), privacyUserId));
if (onchainPrivacyGroupsEnabled) {
if (OnchainUtil.isGroupAdditionTransaction(privateTransaction)) {
if (flexiblePrivacyGroupsEnabled) {
if (FlexibleUtil.isGroupAdditionTransaction(privateTransaction)) {
final List<String> participantsFromParameter =
OnchainUtil.getParticipantsFromParameter(privateTransaction.getPayload());
FlexibleUtil.getParticipantsFromParameter(privateTransaction.getPayload());
if (maybePrivacyGroup.isEmpty()) {
maybePrivacyGroup =
Optional.of(
new PrivacyGroup(
maybePrivacyGroupId.get().toBase64String(),
PrivacyGroup.Type.ONCHAIN,
PrivacyGroup.Type.FLEXIBLE,
"",
"",
participantsFromParameter));
@ -110,7 +110,7 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod {
maybePrivacyGroup.get().addMembers(participantsFromParameter);
}
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
* 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;
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.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 PrivxFindOnchainPrivacyGroup implements JsonRpcMethod {
private static final Logger LOG = getLogger();
private final PrivacyController privacyController;
private final PrivacyIdProvider privacyIdProvider;
// Use PrivxFindFlexiblePrivacyGroup instead
@Deprecated
public class PrivxFindOnchainPrivacyGroup extends PrivxFindFlexiblePrivacyGroup {
public PrivxFindOnchainPrivacyGroup(
final PrivacyController privacyController, final PrivacyIdProvider privacyIdProvider) {
this.privacyController = privacyController;
this.privacyIdProvider = privacyIdProvider;
super(privacyController, 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_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));
return RpcMethod.PRIVX_FIND_PRIVACY_GROUP_OLD.getMethodName();
}
}

@ -129,7 +129,7 @@ public enum JsonRpcError {
DELETE_PRIVACY_GROUP_ERROR(-50100, "Error deleting privacy group"),
ETHER_VALUE_NOT_SUPPORTED(-50100, "ether value is not supported for private transactions"),
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(
-50100, "No privateFor specified in rawTxArgs for GoQuorum raw private transaction."),
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."),
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."),
ONCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST(-50100, "Onchain Privacy group does not exist."),
ONCHAIN_PRIVACY_GROUP_NOT_ENABLED(-50100, "Onchain privacy groups not enabled."),
FLEXIBLE_PRIVACY_GROUP_DOES_NOT_EXIST(-50100, "Flexible Privacy group does not exist."),
FLEXIBLE_PRIVACY_GROUP_NOT_ENABLED(-50100, "Flexible privacy groups not enabled."),
OFFCHAIN_PRIVACY_GROUP_NOT_ENABLED(
-50100, "Offchain privacy group can't be used with Onchain privacy groups enabled."),
ONCHAIN_PRIVACY_GROUP_ID_NOT_AVAILABLE(
-50100, "Private transactions to onchain privacy groups must use privacyGroupId"),
-50100, "Offchain privacy group can't be used with Flexible privacy groups enabled."),
FLEXIBLE_PRIVACY_GROUP_ID_NOT_AVAILABLE(
-50100, "Private transactions to flexible privacy groups must use privacyGroupId"),
PMT_FAILED_INTRINSIC_GAS_EXCEEDS_LIMIT(
-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(
-50100, "Private from does not match enclave public key"),
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.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.RestrictedFlexibleEeaSendRawTransaction;
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.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@ -66,9 +66,9 @@ public class EeaJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
privacyController,
getGasCalculator()),
new PrivGetEeaTransactionCount(privacyController, privacyIdProvider));
} else if (getPrivacyParameters().isOnchainPrivacyGroupsEnabled()) {
} else if (getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
return mapOf(
new RestrictedOnchainEeaSendRawTransaction(
new RestrictedFlexibleEeaSendRawTransaction(
transactionPool,
privacyIdProvider,
privateMarkerTransactionFactory,

@ -75,7 +75,7 @@ public class PrivJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
new PrivDistributeRawTransaction(
privacyController,
privacyIdProvider,
getPrivacyParameters().isOnchainPrivacyGroupsEnabled()),
getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()),
new PrivGetCode(getBlockchainQueries(), privacyController, privacyIdProvider),
new PrivGetLogs(
getBlockchainQueries(), getPrivacyQueries(), privacyController, privacyIdProvider),
@ -91,7 +91,7 @@ public class PrivJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
new PrivNewFilter(filterManager, privacyController, privacyIdProvider),
new PrivUninstallFilter(filterManager, privacyController, privacyIdProvider));
if (!getPrivacyParameters().isOnchainPrivacyGroupsEnabled()) {
if (!getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
final Map<String, JsonRpcMethod> OFFCHAIN_METHODS =
mapOf(
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.mainnet.ProtocolSchedule;
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.OnchainPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PluginPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateNonceProvider;
@ -137,9 +137,9 @@ public abstract class PrivacyApiGroupJsonRpcMethods extends ApiGroupJsonRpcMetho
privacyParameters.getPrivateWorldStateReader());
} else {
final PrivacyController privacyController;
if (privacyParameters.isOnchainPrivacyGroupsEnabled()) {
if (privacyParameters.isFlexiblePrivacyGroupsEnabled()) {
privacyController =
new OnchainPrivacyController(
new FlexiblePrivacyController(
getBlockchainQueries().getBlockchain(),
privacyParameters,
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.internal.methods.JsonRpcMethod;
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.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@ -47,8 +48,10 @@ public class PrivxJsonRpcMethods extends PrivacyApiGroupJsonRpcMethods {
final PrivacyController privacyController,
final PrivacyIdProvider privacyIdProvider,
final PrivateMarkerTransactionFactory privateMarkerTransactionFactory) {
if (getPrivacyParameters().isOnchainPrivacyGroupsEnabled()) {
return mapOf(new PrivxFindOnchainPrivacyGroup(privacyController, privacyIdProvider));
if (getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
return mapOf(
new PrivxFindFlexiblePrivacyGroup(privacyController, privacyIdProvider),
new PrivxFindOnchainPrivacyGroup(privacyController, privacyIdProvider));
} else {
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.mainnet.ProtocolSchedule;
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.OnchainPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PluginPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateNonceProvider;
@ -77,9 +77,9 @@ public class PrivateWebSocketMethodsFactory {
privacyParameters.getPrivateWorldStateReader());
} else {
final PrivacyController restrictedPrivacyController;
if (privacyParameters.isOnchainPrivacyGroupsEnabled()) {
if (privacyParameters.isFlexiblePrivacyGroupsEnabled()) {
restrictedPrivacyController =
new OnchainPrivacyController(
new FlexiblePrivacyController(
blockchainQueries.getBlockchain(),
privacyParameters,
chainId,

@ -15,7 +15,7 @@
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.ONCHAIN_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY;
import org.hyperledger.besu.crypto.KeyPair;
@ -67,12 +67,12 @@ public class BaseEeaSendRawTransaction {
final GasCalculator gasCalculator = new BerlinGasCalculator();
final Transaction PUBLIC_ONCHAIN_TRANSACTION =
final Transaction PUBLIC_FLEXIBLE_TRANSACTION =
new Transaction(
0L,
Wei.of(1),
21000L,
Optional.of(ONCHAIN_PRIVACY),
Optional.of(FLEXIBLE_PRIVACY),
Wei.ZERO,
SIGNATURE_ALGORITHM_SUPPLIER
.get()

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

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

@ -57,8 +57,8 @@ public class PrivJsonRpcMethodsTest {
}
@Test
public void offchainPrivacyGroupMethodsAreDisabledWhenOnchainPrivacyGroupIsEnabled() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(true);
public void offchainPrivacyGroupMethodsAreDisabledWhenFlexiblePrivacyGroupIsEnabled() {
when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(true);
final Map<String, JsonRpcMethod> rpcMethods = privJsonRpcMethods.create();
assertThat(rpcMethods.get(PRIV_CREATE_PRIVACY_GROUP.getMethodName())).isNull();
@ -67,8 +67,8 @@ public class PrivJsonRpcMethodsTest {
}
@Test
public void offchainPrivacyGroupMethodsAreEnabledWhenOnchainPrivacyGroupIsDisabled() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(false);
public void offchainPrivacyGroupMethodsAreEnabledWhenFlexiblePrivacyGroupIsDisabled() {
when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(false);
final Map<String, JsonRpcMethod> rpcMethods = privJsonRpcMethods.create();
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.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.when;
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.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@ -54,8 +56,8 @@ public class PrivxJsonRpcMethodsTest {
}
@Test
public void privxFindPrivacyGroupMethodIsDisabledWhenOnchainPrivacyGroupIsDisabled() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(false);
public void privxFindPrivacyGroupMethodIsDisabledWhenFlexiblePrivacyGroupIsDisabled() {
when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(false);
final Map<String, JsonRpcMethod> rpcMethods = privxJsonRpcMethods.create();
final JsonRpcMethod method = rpcMethods.get(PRIVX_FIND_PRIVACY_GROUP.getMethodName());
@ -63,11 +65,22 @@ public class PrivxJsonRpcMethodsTest {
}
@Test
public void privxFindPrivacyGroupMethodIsEnabledWhenOnchainPrivacyGroupIsEnabled() {
when(privacyParameters.isOnchainPrivacyGroupsEnabled()).thenReturn(true);
public void privxFindPrivacyGroupMethodIsEnabledWhenFlexiblePrivacyGroupIsEnabled() {
when(privacyParameters.isFlexiblePrivacyGroupsEnabled()).thenReturn(true);
final Map<String, JsonRpcMethod> rpcMethods = privxJsonRpcMethods.create();
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).isInstanceOf(PrivxFindOnchainPrivacyGroup.class);
}

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

@ -15,14 +15,14 @@
package org.hyperledger.besu.ethereum.mainnet;
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.evm.precompile.MainnetPrecompiledContracts.populateForBLS12;
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.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.PrivacyPrecompiledContract;
import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry;
@ -76,10 +76,10 @@ public abstract class MainnetPrecompiledContractRegistries {
precompiledContractConfiguration.getPrivacyParameters()));
} else if (precompiledContractConfiguration
.getPrivacyParameters()
.isOnchainPrivacyGroupsEnabled()) {
.isFlexiblePrivacyGroupsEnabled()) {
registry.put(
ONCHAIN_PRIVACY,
new OnchainPrivacyPrecompiledContract(
FLEXIBLE_PRIVACY,
new FlexiblePrivacyPrecompiledContract(
precompiledContractConfiguration.getGasCalculator(),
precompiledContractConfiguration.getPrivacyParameters()));
} else {

@ -14,7 +14,7 @@
*/
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.enclave.Enclave;
@ -161,7 +161,7 @@ public class PrivacyBlockProcessor implements BlockProcessor {
private boolean onchainAddToGroupPrivateMarkerTransactions(final Transaction t) {
return t.getTo().isPresent()
&& t.getTo().equals(Optional.of(ONCHAIN_PRIVACY))
&& t.getTo().equals(Optional.of(FLEXIBLE_PRIVACY))
&& t.getPayload().size() == 64;
}

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet;
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.ONCHAIN_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY;
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.PrivacyParameters;
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.PrivacyPrecompiledContract;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor;
@ -326,10 +326,10 @@ public class ProtocolSpecBuilder {
(PrivacyPluginPrecompiledContract) precompileContractRegistry.get(PLUGIN_PRIVACY);
privacyPluginPrecompiledContract.setPrivateTransactionProcessor(
privateTransactionProcessor);
} else if (privacyParameters.isOnchainPrivacyGroupsEnabled()) {
final OnchainPrivacyPrecompiledContract onchainPrivacyPrecompiledContract =
(OnchainPrivacyPrecompiledContract) precompileContractRegistry.get(ONCHAIN_PRIVACY);
onchainPrivacyPrecompiledContract.setPrivateTransactionProcessor(
} else if (privacyParameters.isFlexiblePrivacyGroupsEnabled()) {
final FlexiblePrivacyPrecompiledContract flexiblePrivacyPrecompiledContract =
(FlexiblePrivacyPrecompiledContract) precompileContractRegistry.get(FLEXIBLE_PRIVACY);
flexiblePrivacyPrecompiledContract.setPrivateTransactionProcessor(
privateTransactionProcessor);
} else {
final PrivacyPrecompiledContract privacyPrecompiledContract =

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

@ -15,9 +15,9 @@
package org.hyperledger.besu.ethereum.privacy;
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.privacy.group.OnchainGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.GET_VERSION_METHOD_SIGNATURE;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_PARTICIPANTS_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.Hash;
@ -52,13 +52,13 @@ import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
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 OnchainPrivacyGroupContract onchainPrivacyGroupContract;
private FlexiblePrivacyGroupContract flexiblePrivacyGroupContract;
public OnchainPrivacyController(
public FlexiblePrivacyController(
final Blockchain blockchain,
final PrivacyParameters privacyParameters,
final Optional<BigInteger> chainId,
@ -76,7 +76,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
privacyParameters.getPrivateStateRootResolver());
}
public OnchainPrivacyController(
public FlexiblePrivacyController(
final Blockchain blockchain,
final PrivateStateStorage privateStateStorage,
final Enclave enclave,
@ -95,7 +95,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
privateWorldStateReader,
privateStateRootResolver);
onchainPrivacyGroupContract = new OnchainPrivacyGroupContract(privateTransactionSimulator);
flexiblePrivacyGroupContract = new FlexiblePrivacyGroupContract(privateTransactionSimulator);
}
@Override
@ -137,7 +137,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
return Optional.of(
new PrivacyGroup(
privacyGroupId,
PrivacyGroup.Type.ONCHAIN,
PrivacyGroup.Type.FLEXIBLE,
"",
"",
decodeParticipantList(rlpInput.raw())));
@ -175,13 +175,13 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
final String description,
final String privacyUserId) {
throw new PrivacyConfigurationNotSupportedException(
"Method not supported when using onchain privacy");
"Method not supported when using flexible privacy");
}
@Override
public String deletePrivacyGroup(final String privacyGroupId, final String privacyUserId) {
throw new PrivacyConfigurationNotSupportedException(
"Method not supported when using onchain privacy");
"Method not supported when using flexible privacy");
}
@Override
@ -194,9 +194,9 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
public void verifyPrivacyGroupContainsPrivacyUserId(
final String privacyGroupId, final String privacyUserId, final Optional<Long> blockNumber) {
final Optional<PrivacyGroup> maybePrivacyGroup =
onchainPrivacyGroupContract.getPrivacyGroupByIdAndBlockNumber(privacyGroupId, blockNumber);
flexiblePrivacyGroupContract.getPrivacyGroupByIdAndBlockNumber(privacyGroupId, blockNumber);
// 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
maybePrivacyGroup.ifPresent(
group -> {
@ -290,7 +290,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
final PrivateTransaction privateTransaction,
final Bytes32 privacyGroupId,
final String privacyUserId) {
if (OnchainUtil.isGroupAdditionTransaction(privateTransaction)) {
if (FlexibleUtil.isGroupAdditionTransaction(privateTransaction)) {
final List<PrivateTransactionMetadata> privateTransactionMetadataList =
buildTransactionMetadataList(privacyGroupId);
if (!privateTransactionMetadataList.isEmpty()) {
@ -299,7 +299,7 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
privacyGroupId, privateTransactionMetadataList, privacyUserId);
final Bytes bytes = serializeAddToGroupPayload(privateTransactionWithMetadataList);
final List<String> privateFor =
OnchainUtil.getParticipantsFromParameter(privateTransaction.getPayload());
FlexibleUtil.getParticipantsFromParameter(privateTransaction.getPayload());
return Optional.of(
enclave.send(bytes.toBase64String(), privacyUserId, privateFor).getKey());
}
@ -340,16 +340,16 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
privateTransaction.getPrivacyGroupId().orElseThrow().toBase64String(),
buildCallParams(GET_VERSION_METHOD_SIGNATURE));
new VersionedPrivateTransaction(privateTransaction, version).writeTo(rlpOutput);
final List<String> onchainPrivateFor = privacyGroup.getMembers();
final List<String> flexiblePrivateFor = privacyGroup.getMembers();
return enclave.send(
rlpOutput.encoded().toBase64String(),
privateTransaction.getPrivateFrom().toBase64String(),
onchainPrivateFor);
flexiblePrivateFor);
}
CallParameter buildCallParams(final Bytes methodCall) {
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) {
@ -357,8 +357,8 @@ public class OnchainPrivacyController extends AbstractRestrictedPrivacyControlle
}
@VisibleForTesting
public void setOnchainPrivacyGroupContract(
final OnchainPrivacyGroupContract onchainPrivacyGroupContract) {
this.onchainPrivacyGroupContract = onchainPrivacyGroupContract;
public void setFlexiblePrivacyGroupContract(
final FlexiblePrivacyGroupContract flexiblePrivacyGroupContract) {
this.flexiblePrivacyGroupContract = flexiblePrivacyGroupContract;
}
}

@ -14,10 +14,10 @@
*/
package org.hyperledger.besu.ethereum.privacy;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.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.OnchainGroupManagement.GET_VERSION_METHOD_SIGNATURE;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.CAN_EXECUTE_METHOD_SIGNATURE;
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.GET_PARTICIPANTS_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.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
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
with block height or block hash parameters to select which block's
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
time is intended to be short.
*/
public class OnchainPrivacyGroupContract {
public class FlexiblePrivacyGroupContract {
@FunctionalInterface
public interface TransactionSimulator {
Optional<TransactionProcessingResult> simulate(
@ -79,7 +79,7 @@ public class OnchainPrivacyGroupContract {
final TransactionSimulator transactionSimulator;
public OnchainPrivacyGroupContract(
public FlexiblePrivacyGroupContract(
final PrivateTransactionSimulator privateTransactionSimulator) {
transactionSimulator =
(privacyGroupId, callData, blockHash, blockNumber) -> {
@ -96,7 +96,7 @@ public class OnchainPrivacyGroupContract {
};
}
public OnchainPrivacyGroupContract(
public FlexiblePrivacyGroupContract(
final MessageFrame messageFrame,
final ProcessableBlockHeader currentBlockHeader,
final MutableWorldState disposablePrivateState,
@ -168,7 +168,7 @@ public class OnchainPrivacyGroupContract {
if (rlpInput.nextSize() > 0) {
final PrivacyGroup privacyGroup =
new PrivacyGroup(
privacyGroupId, PrivacyGroup.Type.ONCHAIN, "", "", decodeList(rlpInput.raw()));
privacyGroupId, PrivacyGroup.Type.FLEXIBLE, "", "", decodeList(rlpInput.raw()));
return Optional.of(privacyGroup);
} else {
return Optional.empty();
@ -216,7 +216,7 @@ public class OnchainPrivacyGroupContract {
: 0)
.gasPrice(Wei.of(1000))
.gasLimit(3000000)
.to(ONCHAIN_PRIVACY_PROXY)
.to(FLEXIBLE_PRIVACY_PROXY)
.sender(Address.ZERO)
.value(Wei.ZERO)
.payload(payload)
@ -226,7 +226,7 @@ public class OnchainPrivacyGroupContract {
private CallParameter buildCallParams(final Bytes methodCall) {
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) {

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

@ -14,13 +14,13 @@
*/
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.ONCHAIN_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
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.worldstate.WorldUpdater;
import org.hyperledger.besu.plugin.data.PrivacyGenesis;
@ -37,13 +37,13 @@ import org.apache.tuweni.units.bigints.UInt256;
public class PrivateStateGenesisAllocator {
private static final Logger LOG = LogManager.getLogger();
private final Boolean isOnchainPrivacyEnabled;
private final Boolean isFlexiblePrivacyEnabled;
private final PrivacyGroupGenesisProvider privacyGroupGenesisProvider;
public PrivateStateGenesisAllocator(
final Boolean isOnchainPrivacyEnabled,
final Boolean isFlexiblePrivacyEnabled,
final PrivacyGroupGenesisProvider privacyGroupGenesisProvider) {
this.isOnchainPrivacyEnabled = isOnchainPrivacyEnabled;
this.isFlexiblePrivacyEnabled = isFlexiblePrivacyEnabled;
this.privacyGroupGenesisProvider = privacyGroupGenesisProvider;
}
@ -87,23 +87,23 @@ public class PrivateStateGenesisAllocator {
});
}
if (isOnchainPrivacyEnabled) {
if (isFlexiblePrivacyEnabled) {
// inject management
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
managementContract.setCode(OnchainGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE);
managementContract.setCode(FlexibleGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE);
// inject proxy
final MutableAccount procyContract =
privateWorldStateUpdater.createAccount(ONCHAIN_PRIVACY_PROXY).getMutable();
privateWorldStateUpdater.createAccount(FLEXIBLE_PRIVACY_PROXY).getMutable();
// 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
procyContract.setStorageValue(
UInt256.ZERO, UInt256.fromBytes(Bytes32.leftPad(DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT)));
UInt256.ZERO, UInt256.fromBytes(Bytes32.leftPad(DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT)));
}
privateWorldStateUpdater.commit();

@ -73,7 +73,7 @@ public class PrivateStateRehydration {
final Optional<Bytes> maybeGroupId =
privateTransactionWithMetadataList.get(0).getPrivateTransaction().getPrivacyGroupId();
if (maybeGroupId.isEmpty()) {
LOG.debug("Onchain groups must have a group id.");
LOG.debug("Flexible groups must have a group id.");
return;
}
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 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.SignatureAlgorithm;
@ -90,12 +90,12 @@ public class PrivateTransactionDataFixture {
}
public static Transaction privateMarkerTransactionOnchain() {
return privateMarkerTransaction(VALID_BASE64_ENCLAVE_KEY, ONCHAIN_PRIVACY);
return privateMarkerTransaction(VALID_BASE64_ENCLAVE_KEY, FLEXIBLE_PRIVACY);
}
public static Transaction privateMarkerTransactionOnchainAdd() {
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(

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

@ -69,7 +69,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito;
public class OnchainPrivacyPrecompiledContractTest {
public class FlexiblePrivacyPrecompiledContractTest {
@Rule public final TemporaryFolder temp = new TemporaryFolder();
@ -144,7 +144,7 @@ public class OnchainPrivacyPrecompiledContractTest {
@Test
public void testPayloadFoundInEnclave() {
final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final FlexiblePrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final List<Log> logs = new ArrayList<>();
contract.setPrivateTransactionProcessor(
mockPrivateTxProcessor(
@ -161,7 +161,7 @@ public class OnchainPrivacyPrecompiledContractTest {
new ReceiveResponse(payload, PAYLOAD_TEST_PRIVACY_GROUP_ID, privateFrom);
when(enclave.receive(any())).thenReturn(response);
final OnchainPrivacyPrecompiledContract contractSpy = spy(contract);
final FlexiblePrivacyPrecompiledContract contractSpy = spy(contract);
Mockito.doReturn(true)
.when(contractSpy)
.canExecute(any(), any(), any(), any(), any(), any(), any(), any());
@ -195,7 +195,7 @@ public class OnchainPrivacyPrecompiledContractTest {
@Test
public void testEnclaveBelowRequiredVersion() {
final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final FlexiblePrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final VersionedPrivateTransaction versionedPrivateTransaction =
versionedPrivateTransactionBesu();
final byte[] payload = convertVersionedPrivateTransactionToBytes(versionedPrivateTransaction);
@ -213,7 +213,7 @@ public class OnchainPrivacyPrecompiledContractTest {
@Test
public void testPayloadNotMatchingPrivateFrom() {
final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final FlexiblePrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final VersionedPrivateTransaction versionedPrivateTransaction =
versionedPrivateTransactionBesu();
final byte[] payload = convertVersionedPrivateTransactionToBytes(versionedPrivateTransaction);
@ -260,16 +260,18 @@ public class OnchainPrivacyPrecompiledContractTest {
private void assertThatComputeReturnsEmptyGivenContractMembershipQueryReturns(
final Bytes memberList) {
final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final FlexiblePrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave);
final List<Log> logs = new ArrayList<>();
contract.setPrivateTransactionProcessor(
mockPrivateTxProcessor(
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(true).when(contractSpy).onchainPrivacyGroupVersionMatches(any(), any(), any());
Mockito.doReturn(true)
.when(contractSpy)
.flexiblePrivacyGroupVersionMatches(any(), any(), any());
final VersionedPrivateTransaction privateTransaction = versionedPrivateTransactionBesu();
final byte[] payload = convertVersionedPrivateTransactionToBytes(privateTransaction);
@ -289,8 +291,8 @@ public class OnchainPrivacyPrecompiledContractTest {
public void testInvalidPrivateTransaction() {
final Enclave enclave = mock(Enclave.class);
final OnchainPrivacyPrecompiledContract contract =
new OnchainPrivacyPrecompiledContract(
final FlexiblePrivacyPrecompiledContract contract =
new FlexiblePrivacyPrecompiledContract(
new SpuriousDragonGasCalculator(),
enclave,
worldStateArchive,
@ -302,7 +304,7 @@ public class OnchainPrivacyPrecompiledContractTest {
TransactionProcessingResult.invalid(
ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE))));
final OnchainPrivacyPrecompiledContract contractSpy = spy(contract);
final FlexiblePrivacyPrecompiledContract contractSpy = spy(contract);
Mockito.doReturn(true)
.when(contractSpy)
.canExecute(any(), any(), any(), any(), any(), any(), any(), any());
@ -330,8 +332,9 @@ public class OnchainPrivacyPrecompiledContractTest {
return bytesValueRLPOutput.encoded().toBase64String().getBytes(UTF_8);
}
private OnchainPrivacyPrecompiledContract buildPrivacyPrecompiledContract(final Enclave enclave) {
return new OnchainPrivacyPrecompiledContract(
private FlexiblePrivacyPrecompiledContract buildPrivacyPrecompiledContract(
final Enclave enclave) {
return new FlexiblePrivacyPrecompiledContract(
new SpuriousDragonGasCalculator(),
enclave,
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.Transaction;
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.PrivateBlockMetadata;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
@ -75,7 +75,7 @@ import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class OnchainPrivacyControllerTest {
public class FlexiblePrivacyControllerTest {
private static final String ADDRESS1 = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=";
private static final String ADDRESS2 = "Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=";
@ -84,7 +84,7 @@ public class OnchainPrivacyControllerTest {
private static final String HEX_STRING_32BYTES_VALUE1 =
"0x0000000000000000000000000000000000000000000000000000000000000001";
private OnchainPrivacyController privacyController;
private FlexiblePrivacyController privacyController;
private PrivateTransactionValidator privateTransactionValidator;
private PrivateNonceProvider privateNonceProvider;
private PrivateStateRootResolver privateStateRootResolver;
@ -94,7 +94,7 @@ public class OnchainPrivacyControllerTest {
private PrivateStateStorage privateStateStorage;
private Enclave enclave;
private String enclavePublicKey;
private OnchainPrivacyController brokenPrivacyController;
private FlexiblePrivacyController brokenPrivacyController;
private static final byte[] PAYLOAD = new byte[0];
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));
private static final PrivacyGroup EXPECTED_PRIVACY_GROUP =
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 =
Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
@ -136,7 +136,7 @@ public class OnchainPrivacyControllerTest {
enclavePublicKey = EnclaveKeyUtils.loadKey("enclave_key_0.pub");
privacyController =
new OnchainPrivacyController(
new FlexiblePrivacyController(
blockchain,
privateStateStorage,
enclave,
@ -146,7 +146,7 @@ public class OnchainPrivacyControllerTest {
privateWorldStateReader,
privateStateRootResolver);
brokenPrivacyController =
new OnchainPrivacyController(
new FlexiblePrivacyController(
blockchain,
privateStateStorage,
brokenMockEnclave(),
@ -173,8 +173,8 @@ public class OnchainPrivacyControllerTest {
mockingForCreatesPayloadForAdding();
final PrivateTransaction privateTransaction =
buildPrivateTransaction(1)
.payload(OnchainGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE)
.to(PrivacyParameters.ONCHAIN_PRIVACY_PROXY)
.payload(FlexibleGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE)
.to(PrivacyParameters.FLEXIBLE_PRIVACY_PROXY)
.signAndBuild(KEY_PAIR);
final String payload =
privacyController.createPrivateMarkerTransactionPayload(
@ -188,16 +188,16 @@ public class OnchainPrivacyControllerTest {
@Test
public void verifiesGroupContainsUserId() {
final OnchainPrivacyGroupContract onchainPrivacyGroupContract =
mock(OnchainPrivacyGroupContract.class);
when(onchainPrivacyGroupContract.getPrivacyGroupByIdAndBlockNumber(any(), any()))
final FlexiblePrivacyGroupContract flexiblePrivacyGroupContract =
mock(FlexiblePrivacyGroupContract.class);
when(flexiblePrivacyGroupContract.getPrivacyGroupByIdAndBlockNumber(any(), any()))
.thenReturn(Optional.of(EXPECTED_PRIVACY_GROUP));
privacyController.setOnchainPrivacyGroupContract(onchainPrivacyGroupContract);
privacyController.setFlexiblePrivacyGroupContract(flexiblePrivacyGroupContract);
privacyController.verifyPrivacyGroupContainsPrivacyUserId(PRIVACY_GROUP_ID, ADDRESS1);
}
@Test
public void findOnchainPrivacyGroups() {
public void findFleixblePrivacyGroups() {
mockingForFindPrivacyGroupByMembers();
mockingForFindPrivacyGroupById();
@ -214,7 +214,7 @@ public class OnchainPrivacyControllerTest {
Assertions.assertThatThrownBy(
() -> privacyController.createPrivacyGroup(Lists.emptyList(), "", "", ADDRESS1))
.isInstanceOf(PrivacyConfigurationNotSupportedException.class)
.hasMessageContaining("Method not supported when using onchain privacy");
.hasMessageContaining("Method not supported when using flexible privacy");
}
@Test
@ -222,7 +222,7 @@ public class OnchainPrivacyControllerTest {
Assertions.assertThatThrownBy(
() -> privacyController.deletePrivacyGroup(PRIVACY_GROUP_ID, ADDRESS1))
.isInstanceOf(PrivacyConfigurationNotSupportedException.class)
.hasMessageContaining("Method not supported when using onchain privacy");
.hasMessageContaining("Method not supported when using flexible privacy");
}
@Test
@ -288,7 +288,7 @@ public class OnchainPrivacyControllerTest {
public void findsPrivacyGroupById() {
final PrivacyGroup privacyGroup =
new PrivacyGroup(
PRIVACY_GROUP_ID, PrivacyGroup.Type.ONCHAIN, "", "", PRIVACY_GROUP_ADDRESSES);
PRIVACY_GROUP_ID, PrivacyGroup.Type.FLEXIBLE, "", "", PRIVACY_GROUP_ADDRESSES);
mockingForFindPrivacyGroupById();
final Optional<PrivacyGroup> privacyGroupFound =

@ -16,10 +16,10 @@
package org.hyperledger.besu.ethereum.privacy;
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.ONCHAIN_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE;
import static org.hyperledger.besu.ethereum.privacy.group.OnchainGroupManagement.PROXY_RUNTIME_BYTECODE;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_FLEXIBLE_PRIVACY_MANAGEMENT;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement.DEFAULT_GROUP_MANAGEMENT_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.Hash;
@ -131,7 +131,7 @@ public class PrivateStateGenesisAllocatorTest {
assertThat(worldState.frontierRootHash()).isNotEqualTo(EMPTY_ROOT_HASH);
assertThat(worldState.get(ONCHAIN_PRIVACY_PROXY)).isEqualTo(null);
assertThat(worldState.get(FLEXIBLE_PRIVACY_PROXY)).isEqualTo(null);
assertGenesisAccountApplied();
}
@ -144,12 +144,12 @@ public class PrivateStateGenesisAllocatorTest {
}
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.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);
}
}

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

@ -153,7 +153,9 @@ public class MessageCallProcessor extends AbstractMessageProcessor {
final Bytes output = contract.compute(frame.getInputData(), frame);
operationTracer.tracePrecompileCall(frame, gasRequirement, output);
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
// to discrepancies in receipts root between public and private nodes in a network.
frame.incrementRemainingGas(gasRequirement);

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

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

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

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

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

Loading…
Cancel
Save