From 183cdaf3e3cdb5a789200fc203593109729a2cdd Mon Sep 17 00:00:00 2001 From: Frank Li <39414003+frankisawesome@users.noreply.github.com> Date: Thu, 25 Nov 2021 16:24:27 +1000 Subject: [PATCH] (internal) Refactor 'onchain' to 'flexible' where applicable (#3075) * CLI option name change Signed-off-by: Frank Li * refactor privacyparameters.java and add deprecation warning Signed-off-by: Frank Li * more refactoring Signed-off-by: Frank Li * add to everything.toml Signed-off-by: Frank Li * bugs Signed-off-by: Frank Li * more missing variable names Signed-off-by: Frank Li * more classes Signed-off-by: Frank Li * more classes Signed-off-by: Frank Li * fix compile error Signed-off-by: Frank Li * add new test to invalidate passing both commands Signed-off-by: Frank Li * more refactoring + more tests Signed-off-by: Frank Li * new batch Signed-off-by: Frank Li * final batch? Signed-off-by: Frank Li * failing unit test Signed-off-by: Frank Li * revert incorrect refactoring back to onchain Signed-off-by: Frank Li * fix unit test Signed-off-by: Frank Li * comment Signed-off-by: Frank Li * comment Signed-off-by: Frank Li * support both privx methods Signed-off-by: Frank Li * add to changelog Signed-off-by: Frank Li * address comment Signed-off-by: Frank Li * add plugin privacy Signed-off-by: Frank Li --- CHANGELOG.md | 1 + .../dsl/node/ProcessBesuNodeRunner.java | 4 +- .../node/configuration/BesuNodeFactory.java | 4 +- .../privacy/PrivacyNodeConfiguration.java | 10 +-- .../privacy/PrivacyNodeFactory.java | 24 +++--- .../acceptance/dsl/privacy/PrivacyNode.java | 6 +- ...pectValidFlexiblePrivacyGroupCreated.java} | 12 +-- .../condition/PrivateTransactionVerifier.java | 14 ++-- ...AddToFlexiblePrivacyGroupTransaction.java} | 4 +- ...reateFlexiblePrivacyGroupTransaction.java} | 4 +- ... FindFlexiblePrivacyGroupTransaction.java} | 10 +-- ... LockFlexiblePrivacyGroupTransaction.java} | 4 +- .../transaction/PrivacyTransactions.java | 28 +++---- ...eFromFlexiblePrivacyGroupTransaction.java} | 4 +- ...nlockFlexiblePrivacyGroupTransaction.java} | 4 +- .../privacy/PrivacyRequestFactory.java | 40 +++++----- ...ava => FlexiblePrivacyAcceptanceTest.java} | 66 +++++++-------- ...=> FlexiblePrivacyAcceptanceTestBase.java} | 36 ++++----- ...StateRootFlexibleGroupAcceptanceTest.java} | 16 ++-- .../privacy/contracts/PrivacyGroupTest.java | 6 +- .../privacy/contracts/PrivacyProxyTest.java | 69 ++++++++-------- ...> FlexibleMultiTenancyAcceptanceTest.java} | 35 ++++---- .../org/hyperledger/besu/RunnerBuilder.java | 16 ++-- .../org/hyperledger/besu/cli/BesuCommand.java | 27 +++++-- .../besu/cli/util/CommandLineUtils.java | 1 + .../util/ConfigOptionSearchAndRunHandler.java | 11 +++ .../org/hyperledger/besu/PrivacyTest.java | 14 ++-- .../hyperledger/besu/cli/BesuCommandTest.java | 36 ++++++++- .../src/test/resources/everything_config.toml | 1 + .../besu/enclave/types/PrivacyGroup.java | 2 +- .../besu/ethereum/api/jsonrpc/RpcMethod.java | 3 +- ...trictedFlexibleEeaSendRawTransaction.java} | 22 ++--- .../priv/PrivDistributeRawTransaction.java | 22 ++--- .../privx/PrivxFindFlexiblePrivacyGroup.java | 80 +++++++++++++++++++ .../privx/PrivxFindOnchainPrivacyGroup.java | 58 ++------------ .../internal/response/JsonRpcError.java | 14 ++-- .../jsonrpc/methods/EeaJsonRpcMethods.java | 6 +- .../jsonrpc/methods/PrivJsonRpcMethods.java | 4 +- .../PrivacyApiGroupJsonRpcMethods.java | 6 +- .../jsonrpc/methods/PrivxJsonRpcMethods.java | 7 +- .../PrivateWebSocketMethodsFactory.java | 6 +- .../eea/BaseEeaSendRawTransaction.java | 6 +- ...tedFlexibleEeaSendRawTransactionTest.java} | 27 ++++--- ...=> PrivxFindFlexiblePrivacyGroupTest.java} | 20 ++--- .../methods/PrivJsonRpcMethodsTest.java | 8 +- .../methods/PrivxJsonRpcMethodsTest.java | 21 ++++- .../besu/ethereum/core/PrivacyParameters.java | 37 ++++----- .../MainnetPrecompiledContractRegistries.java | 10 +-- .../mainnet/PrivacyBlockProcessor.java | 4 +- .../ethereum/mainnet/ProtocolSpecBuilder.java | 12 +-- ...> FlexiblePrivacyPrecompiledContract.java} | 54 +++++++------ ...er.java => FlexiblePrivacyController.java} | 42 +++++----- ...java => FlexiblePrivacyGroupContract.java} | 22 ++--- .../{OnchainUtil.java => FlexibleUtil.java} | 10 +-- .../privacy/PrivateStateGenesisAllocator.java | 24 +++--- .../privacy/PrivateStateRehydration.java | 2 +- ...ment.java => FlexibleGroupManagement.java} | 2 +- .../core/PrivateTransactionDataFixture.java | 6 +- ...nnetPrecompiledContractRegistriesTest.java | 22 ++--- ...exiblePrivacyPrecompiledContractTest.java} | 29 ++++--- ...ava => FlexiblePrivacyControllerTest.java} | 34 ++++---- .../PrivateStateGenesisAllocatorTest.java | 16 ++-- .../PrivateTransactionLocatorTest.java | 4 +- .../evm/processor/MessageCallProcessor.java | 4 +- ...exiblePrivacyGroupManagementContract.java} | 42 +++++----- ...xiblePrivacyGroupManagementInterface.java} | 42 +++++----- ... FlexiblePrivacyGroupManagementProxy.java} | 42 +++++----- ...lexiblePrivacyGroupManagementContract.sol} | 6 +- ...exiblePrivacyGroupManagementInterface.sol} | 4 +- ...> FlexiblePrivacyGroupManagementProxy.sol} | 22 ++--- .../src/main/solidity/generateWrappers.sh | 8 +- 71 files changed, 720 insertions(+), 599 deletions(-) rename acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/{ExpectValidOnchainPrivacyGroupCreated.java => ExpectValidFlexiblePrivacyGroupCreated.java} (80%) rename acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/{AddToOnchainPrivacyGroupTransaction.java => AddToFlexiblePrivacyGroupTransaction.java} (93%) rename acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/{CreateOnchainPrivacyGroupTransaction.java => CreateFlexiblePrivacyGroupTransaction.java} (94%) rename acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/{FindOnchainPrivacyGroupTransaction.java => FindFlexiblePrivacyGroupTransaction.java} (82%) rename acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/{LockOnchainPrivacyGroupTransaction.java => LockFlexiblePrivacyGroupTransaction.java} (92%) rename acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/{RemoveFromOnchainPrivacyGroupTransaction.java => RemoveFromFlexiblePrivacyGroupTransaction.java} (92%) rename acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/{UnlockOnchainPrivacyGroupTransaction.java => UnlockFlexiblePrivacyGroupTransaction.java} (92%) rename acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/{OnchainPrivacyAcceptanceTest.java => FlexiblePrivacyAcceptanceTest.java} (91%) rename acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/{OnchainPrivacyAcceptanceTestBase.java => FlexiblePrivacyAcceptanceTestBase.java} (83%) rename acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/{PrivDebugGetStateRootOnchainGroupAcceptanceTest.java => PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java} (90%) rename acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/{OnchainMultiTenancyAcceptanceTest.java => FlexibleMultiTenancyAcceptanceTest.java} (94%) rename ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/{RestrictedOnchainEeaSendRawTransaction.java => RestrictedFlexibleEeaSendRawTransaction.java} (84%) create mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java rename ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/{RestrictedOnchainEeaSendRawTransactionTest.java => RestrictedFlexibleEeaSendRawTransactionTest.java} (85%) rename ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/{PrivxFindOnchainPrivacyGroupTest.java => PrivxFindFlexiblePrivacyGroupTest.java} (87%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/{OnchainPrivacyPrecompiledContract.java => FlexiblePrivacyPrecompiledContract.java} (87%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/{OnchainPrivacyController.java => FlexiblePrivacyController.java} (90%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/{OnchainPrivacyGroupContract.java => FlexiblePrivacyGroupContract.java} (92%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/{OnchainUtil.java => FlexibleUtil.java} (86%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/group/{OnchainGroupManagement.java => FlexibleGroupManagement.java} (99%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/{OnchainPrivacyPrecompiledContractTest.java => FlexiblePrivacyPrecompiledContractTest.java} (93%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/{OnchainPrivacyControllerTest.java => FlexiblePrivacyControllerTest.java} (93%) rename privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/{DefaultOnchainPrivacyGroupManagementContract.java => DefaultFlexiblePrivacyGroupManagementContract.java} (92%) rename privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/{OnchainPrivacyGroupManagementInterface.java => FlexiblePrivacyGroupManagementInterface.java} (86%) rename privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/{OnchainPrivacyGroupManagementProxy.java => FlexiblePrivacyGroupManagementProxy.java} (94%) rename privacy-contracts/src/main/solidity/{DefaultOnChainPrivacyGroupManagementContract.sol => DefaultFlexiblePrivacyGroupManagementContract.sol} (96%) rename privacy-contracts/src/main/solidity/{OnChainPrivacyGroupManagementInterface.sol => FlexiblePrivacyGroupManagementInterface.sol} (95%) rename privacy-contracts/src/main/solidity/{OnChainPrivacyGroupManagementProxy.sol => FlexiblePrivacyGroupManagementProxy.sol} (67%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a229220678..866ceb31da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java index f39dcc59b0..607224cc85 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java @@ -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()) { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java index 5896f4e2d7..2850b8a239 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java @@ -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)) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeConfiguration.java index 122a3b2c4c..05c989e54a 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeConfiguration.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeConfiguration.java @@ -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() { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeFactory.java index 0527417f88..5f4f358e8b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeFactory.java @@ -64,13 +64,13 @@ public class PrivacyNodeFactory { final PrivacyAccount privacyAccount, final EnclaveType enclaveType, final Optional 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 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 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 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 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, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java index 1553c7ce16..2c14aa6dbc 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java @@ -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); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidOnchainPrivacyGroupCreated.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidFlexiblePrivacyGroupCreated.java similarity index 80% rename from acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidOnchainPrivacyGroupCreated.java rename to acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidFlexiblePrivacyGroupCreated.java index aefced3c50..ce9c93d23d 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidOnchainPrivacyGroupCreated.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidFlexiblePrivacyGroupCreated.java @@ -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 groups = + final List groups = node.execute( - transactions.findOnchainPrivacyGroup( + transactions.findFlexiblePrivacyGroup( Base64String.unwrapList(expected.getMembers()))); assertThat(groups).contains(expected); }); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateTransactionVerifier.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateTransactionVerifier.java index ad4d023709..cfd83b6582 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateTransactionVerifier.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateTransactionVerifier.java @@ -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 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 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( diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToOnchainPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToFlexiblePrivacyGroupTransaction.java similarity index 93% rename from acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToOnchainPrivacyGroupTransaction.java rename to acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToFlexiblePrivacyGroupTransaction.java index d083bab76f..9c879bc421 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToOnchainPrivacyGroupTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToFlexiblePrivacyGroupTransaction.java @@ -26,13 +26,13 @@ import java.util.stream.Collectors; import org.web3j.crypto.Credentials; import org.web3j.utils.Base64String; -public class AddToOnchainPrivacyGroupTransaction implements Transaction { +public class AddToFlexiblePrivacyGroupTransaction implements Transaction { private final Base64String privacyGroupId; private final PrivacyNode adder; private final List addresses; private final Credentials signer; - public AddToOnchainPrivacyGroupTransaction( + public AddToFlexiblePrivacyGroupTransaction( final String privacyGroupId, final PrivacyNode adder, final Credentials signer, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateOnchainPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateFlexiblePrivacyGroupTransaction.java similarity index 94% rename from acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateOnchainPrivacyGroupTransaction.java rename to acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateFlexiblePrivacyGroupTransaction.java index b59e706279..bf2814a4b1 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateOnchainPrivacyGroupTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateFlexiblePrivacyGroupTransaction.java @@ -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 { private final PrivacyNode creator; private final List addresses; private final String privateFrom; - CreateOnchainPrivacyGroupTransaction( + CreateFlexiblePrivacyGroupTransaction( final PrivacyNode creator, final String privateFrom, final List addresses) { this.creator = creator; this.addresses = addresses; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindOnchainPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindFlexiblePrivacyGroupTransaction.java similarity index 82% rename from acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindOnchainPrivacyGroupTransaction.java rename to acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindFlexiblePrivacyGroupTransaction.java index 6864aa18d3..0e8ac95b4f 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindOnchainPrivacyGroupTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindFlexiblePrivacyGroupTransaction.java @@ -27,19 +27,19 @@ import java.util.stream.Collectors; import org.web3j.utils.Base64String; -public class FindOnchainPrivacyGroupTransaction - implements Transaction> { +public class FindFlexiblePrivacyGroupTransaction + implements Transaction> { private final List nodes; - public FindOnchainPrivacyGroupTransaction(final List nodeEnclaveKeys) { + public FindFlexiblePrivacyGroupTransaction(final List nodeEnclaveKeys) { this.nodes = nodeEnclaveKeys.stream().map(Base64String::wrap).collect(Collectors.toList()); } @Override - public List execute(final NodeRequests node) { + public List 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()); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockOnchainPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockFlexiblePrivacyGroupTransaction.java similarity index 92% rename from acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockOnchainPrivacyGroupTransaction.java rename to acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockFlexiblePrivacyGroupTransaction.java index ed878dec26..92ed003ad4 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockOnchainPrivacyGroupTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockFlexiblePrivacyGroupTransaction.java @@ -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 { +public class LockFlexiblePrivacyGroupTransaction implements Transaction { 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; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivacyTransactions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivacyTransactions.java index 48cc53b15f..3763e40bb7 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivacyTransactions.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivacyTransactions.java @@ -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 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 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 nodes) { return new FindPrivacyGroupTransaction(nodes); } - public FindOnchainPrivacyGroupTransaction findOnchainPrivacyGroup(final List nodes) { - return new FindOnchainPrivacyGroupTransaction(nodes); + public FindFlexiblePrivacyGroupTransaction findFlexiblePrivacyGroup(final List 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); } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromOnchainPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromFlexiblePrivacyGroupTransaction.java similarity index 92% rename from acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromOnchainPrivacyGroupTransaction.java rename to acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromFlexiblePrivacyGroupTransaction.java index 74f161c507..7f2712c81d 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromOnchainPrivacyGroupTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromFlexiblePrivacyGroupTransaction.java @@ -22,13 +22,13 @@ import java.io.IOException; import org.web3j.crypto.Credentials; import org.web3j.utils.Base64String; -public class RemoveFromOnchainPrivacyGroupTransaction implements Transaction { +public class RemoveFromFlexiblePrivacyGroupTransaction implements Transaction { 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, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockOnchainPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockFlexiblePrivacyGroupTransaction.java similarity index 92% rename from acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockOnchainPrivacyGroupTransaction.java rename to acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockFlexiblePrivacyGroupTransaction.java index f6f78a253f..98b0236c32 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockOnchainPrivacyGroupTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockFlexiblePrivacyGroupTransaction.java @@ -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 { +public class UnlockFlexiblePrivacyGroupTransaction implements Transaction { 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; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java index ea79c30196..5aa58ff7c4 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java @@ -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 privxFindOnchainPrivacyGroup( + public Request privxFindFlexiblePrivacyGroup( final List 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> { + public static class PrivxFindPrivacyGroupResponse extends Response> { - public List getGroups() { + public List getGroups() { return getResult(); } } - public static class OnchainPrivacyGroup { + public static class FlexiblePrivacyGroup { private final Base64String privacyGroupId; private final List 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 members) { + public FlexiblePrivacyGroup(final String privacyGroupId, final List 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 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 participants) { return Bytes.concatenate( - OnchainGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE, encodeList(participants)); + FlexibleGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE, encodeList(participants)); } private Bytes encodeList(final List participants) { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/OnchainPrivacyAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTest.java similarity index 91% rename from acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/OnchainPrivacyAcceptanceTest.java rename to acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTest.java index 48b707c65f..2db988787e 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/OnchainPrivacyAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTest.java @@ -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 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 deployPrivateContract( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/OnchainPrivacyAcceptanceTestBase.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTestBase.java similarity index 83% rename from acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/OnchainPrivacyAcceptanceTestBase.java rename to acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTestBase.java index 11dc345a2f..7dc2460f82 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/OnchainPrivacyAcceptanceTestBase.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTestBase.java @@ -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 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. * *

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 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 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 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)); } } } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootOnchainGroupAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java similarity index 90% rename from acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootOnchainGroupAcceptanceTest.java rename to acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java index 5f8b6c13f8..e8aef87f37 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootOnchainGroupAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java @@ -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( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java index f487c15ab8..4b2de711eb 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java @@ -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 diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java index 46dfe21d21..560b24572b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java @@ -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 participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); + final List 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 participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); + final List 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 participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); + final List 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 participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); + final List 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 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 participants = onchainPrivacyGroupManagementProxy.getParticipants().send(); + final List participants = flexiblePrivacyGroupManagementProxy.getParticipants().send(); assertThat(participants.size()).isEqualTo(3); assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); assertThat(thirdParticipant.raw()).isEqualTo(participants.get(1)); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/OnchainMultiTenancyAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/FlexibleMultiTenancyAcceptanceTest.java similarity index 94% rename from acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/OnchainMultiTenancyAcceptanceTest.java rename to acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/FlexibleMultiTenancyAcceptanceTest.java index 56d9c10768..80dcf7a0a4 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/OnchainMultiTenancyAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/FlexibleMultiTenancyAcceptanceTest.java @@ -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 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 group = + final List 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 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 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 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)); } } } diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index ee69acf9be..7fcad9f8b4 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -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); } } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 529fd99ede..66d42245ba 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -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()); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java b/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java index 388466893e..0c905538da 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java @@ -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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java b/besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java index 179ad590e3..fa8cde0634 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java @@ -49,12 +49,23 @@ public class ConfigOptionSearchAndRunHandler extends AbstractParseResultHandler< public List handle(final ParseResult parseResult) throws ParameterException { final CommandLine commandLine = parseResult.asCommandLineList().get(0); final Optional 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 findConfigFile( final ParseResult parseResult, final CommandLine commandLine) { if (parseResult.hasMatchedOption("--config-file") diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java index 5a1e20c8f7..127c61bb79 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java @@ -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()) diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index ff7a73815a..e535c5fc4c 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -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 diff --git a/besu/src/test/resources/everything_config.toml b/besu/src/test/resources/everything_config.toml index 8e33898f92..4d063b6f75 100644 --- a/besu/src/test/resources/everything_config.toml +++ b/besu/src/test/resources/everything_config.toml @@ -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 diff --git a/enclave/src/main/java/org/hyperledger/besu/enclave/types/PrivacyGroup.java b/enclave/src/main/java/org/hyperledger/besu/enclave/types/PrivacyGroup.java index bf4517b4b8..134908fedb 100644 --- a/enclave/src/main/java/org/hyperledger/besu/enclave/types/PrivacyGroup.java +++ b/enclave/src/main/java/org/hyperledger/besu/enclave/types/PrivacyGroup.java @@ -86,7 +86,7 @@ public class PrivacyGroup implements Serializable { public enum Type { LEGACY, - ONCHAIN, + FLEXIBLE, PANTHEON } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java index 6c41c39cc3..7b5f7c9866 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java @@ -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"), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnchainEeaSendRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransaction.java similarity index 84% rename from ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnchainEeaSendRawTransaction.java rename to ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransaction.java index 1b45c3946f..8a5d4f07a3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnchainEeaSendRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransaction.java @@ -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) { final Optional 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 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 diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java index 5d1de49235..b53a29ec8f 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java @@ -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 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 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 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); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java new file mode 100644 index 0000000000..7a0f37f7c9 --- /dev/null +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java @@ -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)); + } +} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindOnchainPrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindOnchainPrivacyGroup.java index b7a368a02f..4df3daeafd 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindOnchainPrivacyGroup.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindOnchainPrivacyGroup.java @@ -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(); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java index 694a4d19b5..560642ec08 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java @@ -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."), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EeaJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EeaJsonRpcMethods.java index ae69302b21..8594e2440e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EeaJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EeaJsonRpcMethods.java @@ -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, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethods.java index d079b0cad1..0f6df40d14 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethods.java @@ -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 OFFCHAIN_METHODS = mapOf( new PrivCreatePrivacyGroup(privacyController, privacyIdProvider), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java index 3e352ecdc1..67ff71697e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java @@ -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, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethods.java index 3d2643ebb4..19d1c12ef2 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethods.java @@ -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(); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/methods/PrivateWebSocketMethodsFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/methods/PrivateWebSocketMethodsFactory.java index 4db91fca1e..be15dcd084 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/methods/PrivateWebSocketMethodsFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/methods/PrivateWebSocketMethodsFactory.java @@ -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, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java index f7d90510f5..4e7d2b797f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java @@ -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() diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnchainEeaSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java similarity index 85% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnchainEeaSendRawTransactionTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java index 9aca32542b..17d53afd1f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnchainEeaSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedFlexibleEeaSendRawTransactionTest.java @@ -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 onchainPrivacyGroup = + final Optional 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); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindOnchainPrivacyGroupTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroupTest.java similarity index 87% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindOnchainPrivacyGroupTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroupTest.java index 0ae1d92bdf..c3b94aad0b 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindOnchainPrivacyGroupTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroupTest.java @@ -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 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 result = (List) 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); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethodsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethodsTest.java index dcf005c7ae..98268eebdb 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethodsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivJsonRpcMethodsTest.java @@ -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 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 rpcMethods = privJsonRpcMethods.create(); assertThat(rpcMethods.get(PRIV_CREATE_PRIVACY_GROUP.getMethodName())).isNotNull(); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethodsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethodsTest.java index a187dc6a48..f62257673e 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethodsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivxJsonRpcMethodsTest.java @@ -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 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 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 rpcMethods = privxJsonRpcMethods.create(); + final JsonRpcMethod method = rpcMethods.get(PRIVX_FIND_PRIVACY_GROUP_OLD.getMethodName()); + assertThat(method).isNotNull(); assertThat(method).isInstanceOf(PrivxFindOnchainPrivacyGroup.class); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java index 18a4677c25..845aebddbd 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java @@ -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; 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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java index 26fede1a70..23838a9271 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java @@ -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 { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java index 4dd4882741..75532c66e1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java @@ -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; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java index 3e16aa72ca..8216998f03 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java @@ -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 = diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnchainPrivacyPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContract.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnchainPrivacyPrecompiledContract.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContract.java index 54287012a4..25e04d1edb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnchainPrivacyPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContract.java @@ -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 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 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 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 contractVersionResult = - onchainPrivacyGroupContract.getVersion(privacyGroupId.toBase64String(), Optional.empty()); + flexiblePrivacyGroupContract.getVersion(privacyGroupId.toBase64String(), Optional.empty()); final boolean versionEqual = contractVersionResult.map(version::equals).orElse(false); if (!versionEqual) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyController.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyController.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyController.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyController.java index b3294d31a3..e6bea4535d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyController.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyController.java @@ -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 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 blockNumber) { final Optional 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 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 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 onchainPrivateFor = privacyGroup.getMembers(); + final List 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; } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyGroupContract.java similarity index 92% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyGroupContract.java index 20942b8e1e..dd84f5e361 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyGroupContract.java @@ -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 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 decodeList(final Bytes rlpEncodedList) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainUtil.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexibleUtil.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainUtil.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexibleUtil.java index e3bddc4532..ab3382b481 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainUtil.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexibleUtil.java @@ -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
to = privateTransaction.getTo(); return to.isPresent() - && to.get().equals(ONCHAIN_PRIVACY_PROXY) + && to.get().equals(FLEXIBLE_PRIVACY_PROXY) && privateTransaction .getPayload() .toHexString() diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java index c922111b51..db91fbc454 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java @@ -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(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java index ac240d6261..05edb3d4e7 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java @@ -73,7 +73,7 @@ public class PrivateStateRehydration { final Optional 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()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/group/OnchainGroupManagement.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/group/FlexibleGroupManagement.java similarity index 99% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/group/OnchainGroupManagement.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/group/FlexibleGroupManagement.java index 2920f2d6d7..30d6a704a1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/group/OnchainGroupManagement.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/group/FlexibleGroupManagement.java @@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.privacy.group; import org.apache.tuweni.bytes.Bytes; -public class OnchainGroupManagement { +public class FlexibleGroupManagement { public static final Bytes PROXY_RUNTIME_BYTECODE = Bytes.fromHexString( "608060405234801561001057600080fd5b506004361061009e5760003560e01c80639738968c116100665780639738968c146101b8578063a69df4b5146101d8578063b4926e25146101e2578063f83d08ba146102b0578063fd017797146102ba5761009e565b80630d8e6e2c146100a35780633659cfe6146100c15780635aa68ac0146101055780635c60da1b1461016457806378b9033714610198575b600080fd5b6100ab6102fe565b6040518082815260200191505060405180910390f35b610103600480360360208110156100d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103ab565b005b61010d61083e565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610150578082015181840152602081019050610135565b505050509050019250505060405180910390f35b61016c610987565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101a06109ab565b60405180821515815260200191505060405180910390f35b6101c0610a58565b60405180821515815260200191505060405180910390f35b6101e0610b07565b005b610298600480360360208110156101f857600080fd5b810190808035906020019064010000000081111561021557600080fd5b82018360208201111561022757600080fd5b8035906020019184602083028401116401000000008311171561024957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610b90565b60405180821515815260200191505060405180910390f35b6102b8610c8d565b005b6102e6600480360360208110156102d057600080fd5b8101908080359060200190929190505050610d16565b60405180821515815260200191505060405180910390f35b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff16630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561036a57600080fd5b505afa15801561037e573d6000803e3d6000fd5b505050506040513d602081101561039457600080fd5b810190808051906020019092919050505091505090565b3073ffffffffffffffffffffffffffffffffffffffff166378b903376040518163ffffffff1660e01b815260040160206040518083038186803b1580156103f157600080fd5b505afa158015610405573d6000803e3d6000fd5b505050506040513d602081101561041b57600080fd5b810190808051906020019092919050505061049e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f54686520636f6e7472616374206973206c6f636b65642e00000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610543576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526054815260200180610e5a6054913960600191505060405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff16639738968c6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561058b57600080fd5b505af115801561059f573d6000803e3d6000fd5b505050506040513d60208110156105b557600080fd5b810190808051906020019092919050505061061b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180610eae602f913960400191505060405180910390fd5b60603073ffffffffffffffffffffffffffffffffffffffff16635aa68ac06040518163ffffffff1660e01b815260040160006040518083038186803b15801561066357600080fd5b505afa158015610677573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156106a157600080fd5b81019080805160405193929190846401000000008211156106c157600080fd5b838201915060208201858111156106d757600080fd5b82518660208202830111640100000000821117156106f457600080fd5b8083526020830192505050908051906020019060200280838360005b8381101561072b578082015181840152602081019050610710565b50505050905001604052505050905061074382610e16565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663b4926e25836040518263ffffffff1660e01b81526004018080602001828103825283818151815260200191508051906020019060200280838360005b838110156107d85780820151818401526020810190506107bd565b5050505090500192505050602060405180830381600087803b1580156107fd57600080fd5b505af1158015610811573d6000803e3d6000fd5b505050506040513d602081101561082757600080fd5b810190808051906020019092919050505050505050565b606060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff16635aa68ac06040518163ffffffff1660e01b815260040160006040518083038186803b1580156108ac57600080fd5b505afa1580156108c0573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156108ea57600080fd5b810190808051604051939291908464010000000082111561090a57600080fd5b8382019150602082018581111561092057600080fd5b825186602082028301116401000000008211171561093d57600080fd5b8083526020830192505050908051906020019060200280838360005b83811015610974578082015181840152602081019050610959565b5050505090500160405250505091505090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff166378b903376040518163ffffffff1660e01b815260040160206040518083038186803b158015610a1757600080fd5b505afa158015610a2b573d6000803e3d6000fd5b505050506040513d6020811015610a4157600080fd5b810190808051906020019092919050505091505090565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff16639738968c6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610ac657600080fd5b505af1158015610ada573d6000803e3d6000fd5b505050506040513d6020811015610af057600080fd5b810190808051906020019092919050505091505090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663a69df4b56040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610b7557600080fd5b505af1158015610b89573d6000803e3d6000fd5b5050505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663b4926e25846040518263ffffffff1660e01b81526004018080602001828103825283818151815260200191508051906020019060200280838360005b83811015610c25578082015181840152602081019050610c0a565b5050505090500192505050602060405180830381600087803b158015610c4a57600080fd5b505af1158015610c5e573d6000803e3d6000fd5b505050506040513d6020811015610c7457600080fd5b8101908080519060200190929190505050915050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663f83d08ba6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610cfb57600080fd5b505af1158015610d0f573d6000803e3d6000fd5b5050505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff1663fd017797856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015610d9157600080fd5b505af1158015610da5573d6000803e3d6000fd5b505050506040513d6020811015610dbb57600080fd5b810190808051906020019092919050505090508015610e0c577fef2df0cc0f44b5a36a7de9951ef49ba4d861649244ff89bcf7ffaa1ac7291e89846040518082815260200191505060405180910390a15b8092505050919050565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fe54686520636f6e747261637420746f207570677261646520746f2068617320746f20626520646966666572656e742066726f6d207468652063757272656e74206d616e6167656d656e7420636f6e74726163742e4e6f7420616c6c6f77656420746f207570677261646520746865206d616e6167656d656e7420636f6e74726163742ea26469706673582212203cacc7680fcd907639c87ed995ee91e1de9ef4d7da7437f854fb3a8fbab9b0db64736f6c634300060c0033"); diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java index 103ac6f8b8..a27c7ad0f8 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java @@ -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( diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java index a2f548e998..9aab7ff746 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java @@ -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(); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnchainPrivacyPrecompiledContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContractTest.java similarity index 93% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnchainPrivacyPrecompiledContractTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContractTest.java index 366a6bf153..dc2b497afd 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnchainPrivacyPrecompiledContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContractTest.java @@ -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 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 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, diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyControllerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyControllerTest.java similarity index 93% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyControllerTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyControllerTest.java index 66a4b17753..033553075a 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyControllerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyControllerTest.java @@ -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 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 privacyGroupFound = diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java index 4df561c917..9dbd8e10bd 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java @@ -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); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocatorTest.java index 51c4532d2c..246325806e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocatorTest.java @@ -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(); diff --git a/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java b/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java index 4ef7d23030..962a93804b 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java @@ -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); diff --git a/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/DefaultOnchainPrivacyGroupManagementContract.java b/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/DefaultFlexiblePrivacyGroupManagementContract.java similarity index 92% rename from privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/DefaultOnchainPrivacyGroupManagementContract.java rename to privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/DefaultFlexiblePrivacyGroupManagementContract.java index 1a1eefaef2..73bfd45868 100644 --- a/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/DefaultOnchainPrivacyGroupManagementContract.java +++ b/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/DefaultFlexiblePrivacyGroupManagementContract.java @@ -56,7 +56,7 @@ import org.web3j.tx.gas.ContractGasProvider; *

Generated with web3j version 4.5.16. */ @SuppressWarnings("rawtypes") -public class DefaultOnchainPrivacyGroupManagementContract extends Contract { +public class DefaultFlexiblePrivacyGroupManagementContract extends Contract { public static final String BINARY = "608060405234801561001057600080fd5b50610c6e806100206000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063a69df4b51161005b578063a69df4b51461014a578063b4926e2514610154578063f83d08ba14610222578063fd0177971461022c57610088565b80630d8e6e2c1461008d5780635aa68ac0146100ab57806378b903371461010a5780639738968c1461012a575b600080fd5b610095610270565b6040518082815260200191505060405180910390f35b6100b361027a565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100f65780820151818401526020810190506100db565b505050509050019250505060405180910390f35b6101126102d2565b60405180821515815260200191505060405180910390f35b6101326102e8565b60405180821515815260200191505060405180910390f35b61015261033f565b005b61020a6004803603602081101561016a57600080fd5b810190808035906020019064010000000081111561018757600080fd5b82018360208201111561019957600080fd5b803590602001918460208302840111640100000000831117156101bb57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610437565b60405180821515815260200191505060405180910390f35b61022a6105e3565b005b6102586004803603602081101561024257600080fd5b81019080803590602001909291905050506106d9565b60405180821515815260200191505060405180910390f35b6000600154905090565b606060028054806020026020016040519081016040528092919081815260200182805480156102c857602002820191906000526020600020905b8154815260200190600101908083116102b4575b5050505050905090565b60008060149054906101000a900460ff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614905090565b600060149054906101000a900460ff161561035957600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff161461041a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4f726967696e206e6f7420746865206f776e65722e000000000000000000000081525060200191505060405180910390fd5b6001600060146101000a81548160ff021916908315150217905550565b60008060149054906101000a900460ff161561045257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156104e857326000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff16146105a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4f726967696e206e6f7420746865206f776e65722e000000000000000000000081525060200191505060405180910390fd5b60006105b4836107d3565b90506001600060146101000a81548160ff0219169083151502179055506105d9610a0c565b5080915050919050565b600060149054906101000a900460ff166105fc57600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff16146106bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4f726967696e206e6f7420746865206f776e65722e000000000000000000000081525060200191505060405180910390fd5b60008060146101000a81548160ff021916908315150217905550565b60008060149054906101000a900460ff166106f357600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff16146107b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4f726967696e206e6f7420746865206f776e65722e000000000000000000000081525060200191505060405180910390fd5b60006107bf83610a96565b90506107c9610a0c565b5080915050919050565b6000806001905060005b8351811015610a02576108028482815181106107f557fe5b6020026020010151610b81565b156108a7577fcc7365305ae5f16c463d1383713d699f43c5548bbda5537ee61373ceb9aaf213600085838151811061083657fe5b6020026020010151604051808315158152602001828152602001806020018281038252601b8152602001807f4163636f756e7420697320616c72656164792061204d656d6265720000000000815250602001935050505060405180910390a18180156108a0575060005b91506109f5565b60006108c58583815181106108b857fe5b6020026020010151610ba1565b9050606081610909576040518060400160405280601b81526020017f4163636f756e7420697320616c72656164792061204d656d6265720000000000815250610923565b604051806060016040528060218152602001610c18602191395b90507fcc7365305ae5f16c463d1383713d699f43c5548bbda5537ee61373ceb9aaf2138287858151811061095357fe5b60200260200101518360405180841515815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156109aa57808201518184015260208101905061098f565b50505050905090810190601f1680156109d75780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a18380156109f05750815b935050505b80806001019150506107dd565b5080915050919050565b60006001430340416002604051602001808481526020018373ffffffffffffffffffffffffffffffffffffffff1660601b81526014018280548015610a7057602002820191906000526020600020905b815481526020019060010190808311610a5c575b505093505050506040516020818303038152906040528051906020012060018190555090565b60008060036000848152602001908152602001600020549050600081118015610ac457506002805490508111155b15610b76576002805490508114610b32576000600260016002805490500381548110610aec57fe5b906000526020600020015490508060026001840381548110610b0a57fe5b9060005260206000200181905550816003600083815260200190815260200160002081905550505b6002805480610b3d57fe5b60019003818190600052602060002001600090559055600060036000858152602001908152602001600020819055506001915050610b7c565b60009150505b919050565b600080600360008481526020019081526020016000205414159050919050565b60008060036000848152602001908152602001600020541415610c0d576002829080600181540180825580915050600190039060005260206000200160009091909190915055600280549050600360008481526020019081526020016000208190555060019050610c12565b600090505b91905056fe4d656d626572206163636f756e74206164646564207375636365737366756c6c79a2646970667358221220aaa2dd79ed65e1a55d25832a79d0bd9f47b1b0bae7b719d96723f776987a93b264736f6c634300060c0033"; @@ -85,7 +85,7 @@ public class DefaultOnchainPrivacyGroupManagementContract extends Contract { new TypeReference() {})); @Deprecated - protected DefaultOnchainPrivacyGroupManagementContract( + protected DefaultFlexiblePrivacyGroupManagementContract( String contractAddress, Web3j web3j, Credentials credentials, @@ -94,7 +94,7 @@ public class DefaultOnchainPrivacyGroupManagementContract extends Contract { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } - protected DefaultOnchainPrivacyGroupManagementContract( + protected DefaultFlexiblePrivacyGroupManagementContract( String contractAddress, Web3j web3j, Credentials credentials, @@ -103,7 +103,7 @@ public class DefaultOnchainPrivacyGroupManagementContract extends Contract { } @Deprecated - protected DefaultOnchainPrivacyGroupManagementContract( + protected DefaultFlexiblePrivacyGroupManagementContract( String contractAddress, Web3j web3j, TransactionManager transactionManager, @@ -112,7 +112,7 @@ public class DefaultOnchainPrivacyGroupManagementContract extends Contract { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - protected DefaultOnchainPrivacyGroupManagementContract( + protected DefaultFlexiblePrivacyGroupManagementContract( String contractAddress, Web3j web3j, TransactionManager transactionManager, @@ -246,49 +246,49 @@ public class DefaultOnchainPrivacyGroupManagementContract extends Contract { } @Deprecated - public static DefaultOnchainPrivacyGroupManagementContract load( + public static DefaultFlexiblePrivacyGroupManagementContract load( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { - return new DefaultOnchainPrivacyGroupManagementContract( + return new DefaultFlexiblePrivacyGroupManagementContract( contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated - public static DefaultOnchainPrivacyGroupManagementContract load( + public static DefaultFlexiblePrivacyGroupManagementContract load( String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { - return new DefaultOnchainPrivacyGroupManagementContract( + return new DefaultFlexiblePrivacyGroupManagementContract( contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - public static DefaultOnchainPrivacyGroupManagementContract load( + public static DefaultFlexiblePrivacyGroupManagementContract load( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { - return new DefaultOnchainPrivacyGroupManagementContract( + return new DefaultFlexiblePrivacyGroupManagementContract( contractAddress, web3j, credentials, contractGasProvider); } - public static DefaultOnchainPrivacyGroupManagementContract load( + public static DefaultFlexiblePrivacyGroupManagementContract load( String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { - return new DefaultOnchainPrivacyGroupManagementContract( + return new DefaultFlexiblePrivacyGroupManagementContract( contractAddress, web3j, transactionManager, contractGasProvider); } - public static RemoteCall deploy( + public static RemoteCall deploy( Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { return deployRemoteCall( - DefaultOnchainPrivacyGroupManagementContract.class, + DefaultFlexiblePrivacyGroupManagementContract.class, web3j, credentials, contractGasProvider, @@ -297,10 +297,10 @@ public class DefaultOnchainPrivacyGroupManagementContract extends Contract { } @Deprecated - public static RemoteCall deploy( + public static RemoteCall deploy( Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return deployRemoteCall( - DefaultOnchainPrivacyGroupManagementContract.class, + DefaultFlexiblePrivacyGroupManagementContract.class, web3j, credentials, gasPrice, @@ -309,10 +309,10 @@ public class DefaultOnchainPrivacyGroupManagementContract extends Contract { ""); } - public static RemoteCall deploy( + public static RemoteCall deploy( Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return deployRemoteCall( - DefaultOnchainPrivacyGroupManagementContract.class, + DefaultFlexiblePrivacyGroupManagementContract.class, web3j, transactionManager, contractGasProvider, @@ -321,13 +321,13 @@ public class DefaultOnchainPrivacyGroupManagementContract extends Contract { } @Deprecated - public static RemoteCall deploy( + public static RemoteCall deploy( Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return deployRemoteCall( - DefaultOnchainPrivacyGroupManagementContract.class, + DefaultFlexiblePrivacyGroupManagementContract.class, web3j, transactionManager, gasPrice, diff --git a/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/OnchainPrivacyGroupManagementInterface.java b/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/FlexiblePrivacyGroupManagementInterface.java similarity index 86% rename from privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/OnchainPrivacyGroupManagementInterface.java rename to privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/FlexiblePrivacyGroupManagementInterface.java index 194566d2f4..76738026cd 100644 --- a/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/OnchainPrivacyGroupManagementInterface.java +++ b/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/FlexiblePrivacyGroupManagementInterface.java @@ -47,7 +47,7 @@ import org.web3j.tx.gas.ContractGasProvider; *

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 deploy( + public static RemoteCall 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 deploy( + public static RemoteCall 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 deploy( + public static RemoteCall 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 deploy( + public static RemoteCall deploy( Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return deployRemoteCall( - OnchainPrivacyGroupManagementInterface.class, + FlexiblePrivacyGroupManagementInterface.class, web3j, transactionManager, gasPrice, diff --git a/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/OnchainPrivacyGroupManagementProxy.java b/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/FlexiblePrivacyGroupManagementProxy.java similarity index 94% rename from privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/OnchainPrivacyGroupManagementProxy.java rename to privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/FlexiblePrivacyGroupManagementProxy.java index 12753d1e90..96b22afe95 100644 --- a/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/OnchainPrivacyGroupManagementProxy.java +++ b/privacy-contracts/src/main/java/org/hyperledger/besu/privacy/contracts/generated/FlexiblePrivacyGroupManagementProxy.java @@ -57,7 +57,7 @@ import org.web3j.tx.gas.ContractGasProvider; *

Generated with web3j version 4.5.16. */ @SuppressWarnings("rawtypes") -public class OnchainPrivacyGroupManagementProxy extends Contract { +public class FlexiblePrivacyGroupManagementProxy extends Contract { public static final String BINARY = "608060405234801561001057600080fd5b50604051610fa6380380610fa68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610f12806100946000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80639738968c116100665780639738968c146101b8578063a69df4b5146101d8578063b4926e25146101e2578063f83d08ba146102b0578063fd017797146102ba5761009e565b80630d8e6e2c146100a35780633659cfe6146100c15780635aa68ac0146101055780635c60da1b1461016457806378b9033714610198575b600080fd5b6100ab6102fe565b6040518082815260200191505060405180910390f35b610103600480360360208110156100d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103ab565b005b61010d61083e565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610150578082015181840152602081019050610135565b505050509050019250505060405180910390f35b61016c610987565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101a06109ab565b60405180821515815260200191505060405180910390f35b6101c0610a58565b60405180821515815260200191505060405180910390f35b6101e0610b07565b005b610298600480360360208110156101f857600080fd5b810190808035906020019064010000000081111561021557600080fd5b82018360208201111561022757600080fd5b8035906020019184602083028401116401000000008311171561024957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610b90565b60405180821515815260200191505060405180910390f35b6102b8610c8d565b005b6102e6600480360360208110156102d057600080fd5b8101908080359060200190929190505050610d16565b60405180821515815260200191505060405180910390f35b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff16630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561036a57600080fd5b505afa15801561037e573d6000803e3d6000fd5b505050506040513d602081101561039457600080fd5b810190808051906020019092919050505091505090565b3073ffffffffffffffffffffffffffffffffffffffff166378b903376040518163ffffffff1660e01b815260040160206040518083038186803b1580156103f157600080fd5b505afa158015610405573d6000803e3d6000fd5b505050506040513d602081101561041b57600080fd5b810190808051906020019092919050505061049e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f54686520636f6e7472616374206973206c6f636b65642e00000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610543576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526054815260200180610e5a6054913960600191505060405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff16639738968c6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561058b57600080fd5b505af115801561059f573d6000803e3d6000fd5b505050506040513d60208110156105b557600080fd5b810190808051906020019092919050505061061b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180610eae602f913960400191505060405180910390fd5b60603073ffffffffffffffffffffffffffffffffffffffff16635aa68ac06040518163ffffffff1660e01b815260040160006040518083038186803b15801561066357600080fd5b505afa158015610677573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156106a157600080fd5b81019080805160405193929190846401000000008211156106c157600080fd5b838201915060208201858111156106d757600080fd5b82518660208202830111640100000000821117156106f457600080fd5b8083526020830192505050908051906020019060200280838360005b8381101561072b578082015181840152602081019050610710565b50505050905001604052505050905061074382610e16565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663b4926e25836040518263ffffffff1660e01b81526004018080602001828103825283818151815260200191508051906020019060200280838360005b838110156107d85780820151818401526020810190506107bd565b5050505090500192505050602060405180830381600087803b1580156107fd57600080fd5b505af1158015610811573d6000803e3d6000fd5b505050506040513d602081101561082757600080fd5b810190808051906020019092919050505050505050565b606060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff16635aa68ac06040518163ffffffff1660e01b815260040160006040518083038186803b1580156108ac57600080fd5b505afa1580156108c0573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156108ea57600080fd5b810190808051604051939291908464010000000082111561090a57600080fd5b8382019150602082018581111561092057600080fd5b825186602082028301116401000000008211171561093d57600080fd5b8083526020830192505050908051906020019060200280838360005b83811015610974578082015181840152602081019050610959565b5050505090500160405250505091505090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff166378b903376040518163ffffffff1660e01b815260040160206040518083038186803b158015610a1757600080fd5b505afa158015610a2b573d6000803e3d6000fd5b505050506040513d6020811015610a4157600080fd5b810190808051906020019092919050505091505090565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff16639738968c6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610ac657600080fd5b505af1158015610ada573d6000803e3d6000fd5b505050506040513d6020811015610af057600080fd5b810190808051906020019092919050505091505090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663a69df4b56040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610b7557600080fd5b505af1158015610b89573d6000803e3d6000fd5b5050505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663b4926e25846040518263ffffffff1660e01b81526004018080602001828103825283818151815260200191508051906020019060200280838360005b83811015610c25578082015181840152602081019050610c0a565b5050505090500192505050602060405180830381600087803b158015610c4a57600080fd5b505af1158015610c5e573d6000803e3d6000fd5b505050506040513d6020811015610c7457600080fd5b8101908080519060200190929190505050915050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663f83d08ba6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610cfb57600080fd5b505af1158015610d0f573d6000803e3d6000fd5b5050505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff1663fd017797856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015610d9157600080fd5b505af1158015610da5573d6000803e3d6000fd5b505050506040513d6020811015610dbb57600080fd5b810190808051906020019092919050505090508015610e0c577fef2df0cc0f44b5a36a7de9951ef49ba4d861649244ff89bcf7ffaa1ac7291e89846040518082815260200191505060405180910390a15b8092505050919050565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fe54686520636f6e747261637420746f207570677261646520746f2068617320746f20626520646966666572656e742066726f6d207468652063757272656e74206d616e6167656d656e7420636f6e74726163742e4e6f7420616c6c6f77656420746f207570677261646520746865206d616e6167656d656e7420636f6e74726163742ea26469706673582212207d77b2288fb78b354ca3a252d7513de3d808fcaa42e73f475b95f412c24a314f64736f6c634300060c0033"; @@ -86,7 +86,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { "ParticipantRemoved", Arrays.>asList(new TypeReference() {})); @Deprecated - protected OnchainPrivacyGroupManagementProxy( + protected FlexiblePrivacyGroupManagementProxy( String contractAddress, Web3j web3j, Credentials credentials, @@ -95,7 +95,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } - protected OnchainPrivacyGroupManagementProxy( + protected FlexiblePrivacyGroupManagementProxy( String contractAddress, Web3j web3j, Credentials credentials, @@ -104,7 +104,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { } @Deprecated - protected OnchainPrivacyGroupManagementProxy( + protected FlexiblePrivacyGroupManagementProxy( String contractAddress, Web3j web3j, TransactionManager transactionManager, @@ -113,7 +113,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - protected OnchainPrivacyGroupManagementProxy( + protected FlexiblePrivacyGroupManagementProxy( String contractAddress, Web3j web3j, TransactionManager transactionManager, @@ -261,46 +261,46 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { } @Deprecated - public static OnchainPrivacyGroupManagementProxy load( + public static FlexiblePrivacyGroupManagementProxy load( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { - return new OnchainPrivacyGroupManagementProxy( + return new FlexiblePrivacyGroupManagementProxy( contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated - public static OnchainPrivacyGroupManagementProxy load( + public static FlexiblePrivacyGroupManagementProxy load( String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { - return new OnchainPrivacyGroupManagementProxy( + return new FlexiblePrivacyGroupManagementProxy( contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - public static OnchainPrivacyGroupManagementProxy load( + public static FlexiblePrivacyGroupManagementProxy load( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { - return new OnchainPrivacyGroupManagementProxy( + return new FlexiblePrivacyGroupManagementProxy( contractAddress, web3j, credentials, contractGasProvider); } - public static OnchainPrivacyGroupManagementProxy load( + public static FlexiblePrivacyGroupManagementProxy load( String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { - return new OnchainPrivacyGroupManagementProxy( + return new FlexiblePrivacyGroupManagementProxy( contractAddress, web3j, transactionManager, contractGasProvider); } - public static RemoteCall deploy( + public static RemoteCall deploy( Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, @@ -309,7 +309,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { FunctionEncoder.encodeConstructor( Arrays.asList(new org.web3j.abi.datatypes.Address(160, _implementation))); return deployRemoteCall( - OnchainPrivacyGroupManagementProxy.class, + FlexiblePrivacyGroupManagementProxy.class, web3j, credentials, contractGasProvider, @@ -317,7 +317,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { encodedConstructor); } - public static RemoteCall deploy( + public static RemoteCall deploy( Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, @@ -326,7 +326,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { FunctionEncoder.encodeConstructor( Arrays.asList(new org.web3j.abi.datatypes.Address(160, _implementation))); return deployRemoteCall( - OnchainPrivacyGroupManagementProxy.class, + FlexiblePrivacyGroupManagementProxy.class, web3j, transactionManager, contractGasProvider, @@ -335,7 +335,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { } @Deprecated - public static RemoteCall deploy( + public static RemoteCall deploy( Web3j web3j, Credentials credentials, BigInteger gasPrice, @@ -345,7 +345,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { FunctionEncoder.encodeConstructor( Arrays.asList(new org.web3j.abi.datatypes.Address(160, _implementation))); return deployRemoteCall( - OnchainPrivacyGroupManagementProxy.class, + FlexiblePrivacyGroupManagementProxy.class, web3j, credentials, gasPrice, @@ -355,7 +355,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { } @Deprecated - public static RemoteCall deploy( + public static RemoteCall deploy( Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, @@ -365,7 +365,7 @@ public class OnchainPrivacyGroupManagementProxy extends Contract { FunctionEncoder.encodeConstructor( Arrays.asList(new org.web3j.abi.datatypes.Address(160, _implementation))); return deployRemoteCall( - OnchainPrivacyGroupManagementProxy.class, + FlexiblePrivacyGroupManagementProxy.class, web3j, transactionManager, gasPrice, diff --git a/privacy-contracts/src/main/solidity/DefaultOnChainPrivacyGroupManagementContract.sol b/privacy-contracts/src/main/solidity/DefaultFlexiblePrivacyGroupManagementContract.sol similarity index 96% rename from privacy-contracts/src/main/solidity/DefaultOnChainPrivacyGroupManagementContract.sol rename to privacy-contracts/src/main/solidity/DefaultFlexiblePrivacyGroupManagementContract.sol index 4e9af8406e..2ca8a511ec 100644 --- a/privacy-contracts/src/main/solidity/DefaultOnChainPrivacyGroupManagementContract.sol +++ b/privacy-contracts/src/main/solidity/DefaultFlexiblePrivacyGroupManagementContract.sol @@ -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 ); -} \ No newline at end of file +} diff --git a/privacy-contracts/src/main/solidity/OnChainPrivacyGroupManagementInterface.sol b/privacy-contracts/src/main/solidity/FlexiblePrivacyGroupManagementInterface.sol similarity index 95% rename from privacy-contracts/src/main/solidity/OnChainPrivacyGroupManagementInterface.sol rename to privacy-contracts/src/main/solidity/FlexiblePrivacyGroupManagementInterface.sol index 6e6cc3f096..45a4104347 100644 --- a/privacy-contracts/src/main/solidity/OnChainPrivacyGroupManagementInterface.sol +++ b/privacy-contracts/src/main/solidity/FlexiblePrivacyGroupManagementInterface.sol @@ -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); -} \ No newline at end of file +} diff --git a/privacy-contracts/src/main/solidity/OnChainPrivacyGroupManagementProxy.sol b/privacy-contracts/src/main/solidity/FlexiblePrivacyGroupManagementProxy.sol similarity index 67% rename from privacy-contracts/src/main/solidity/OnChainPrivacyGroupManagementProxy.sol rename to privacy-contracts/src/main/solidity/FlexiblePrivacyGroupManagementProxy.sol index 8c74a4414d..28f47c973f 100644 --- a/privacy-contracts/src/main/solidity/OnChainPrivacyGroupManagementProxy.sol +++ b/privacy-contracts/src/main/solidity/FlexiblePrivacyGroupManagementProxy.sol @@ -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); } diff --git a/privacy-contracts/src/main/solidity/generateWrappers.sh b/privacy-contracts/src/main/solidity/generateWrappers.sh index fe97ee3f81..a78f3781c2 100755 --- a/privacy-contracts/src/main/solidity/generateWrappers.sh +++ b/privacy-contracts/src/main/solidity/generateWrappers.sh @@ -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 \ No newline at end of file +done