Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit ce3b476
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Fri Aug 19 16:37:54 2022 +0100

    changelog

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 606c53a
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Fri Aug 19 16:12:41 2022 +0100

    small refactor

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 1441f72
Merge: b78403b 3a2aeab
Author: Miguel Angel Rojo <freemanz1486@gmail.com>
Date:   Fri Aug 19 15:32:51 2022 +0100

    Merge branch 'hyperledger:main' into flexible-privacy-ec-encryptor

commit b78403b
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Fri Aug 19 15:23:17 2022 +0100

    flexible multitenancy working as well

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit b68efc2
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Fri Aug 19 13:31:28 2022 +0100

    removed unused constructor

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit c6f7c48
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Fri Aug 19 13:21:23 2022 +0100

    fixed removeparticipant smart contract method

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 09e51ef
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Fri Aug 19 11:22:17 2022 +0100

    added encryptor type to flexible method in the factory

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 4a804fc
Author: Fabio Di Fabio <fabio.difabio@consensys.net>
Date:   Thu Aug 18 21:45:07 2022 +0200

    Refactor and fix retrying get block switching peer (hyperledger#4256)

    * Refactor retrying peer task switching peers at every try

    RetryingGetBlockFromPeersTask had a problem that prevented to complete
    when all the peers were tried without success, and that also had the
    consequence to not removing the failed requested block for the internal
    caches in BlockPropagationManager, that could cause a stall since that
    block will to be tried to be retrieved again.

    Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

commit 8d1de9e
Author: garyschulte <garyschulte@gmail.com>
Date:   Thu Aug 18 12:17:56 2022 -0700

    implement tentative mainnet TTD (hyperledger#4260)

    * implement tentative mainnet TTD
    * fix unit test breakage
    * add to change log

    Signed-off-by: garyschulte <garyschulte@gmail.com>

commit 95f95a1
Author: Justin Florentine <justin+github@florentine.us>
Date:   Thu Aug 18 14:51:37 2022 -0400

    Panda prove ments (hyperledger#4267)

    * breaks pandas up, test coverage

    Signed-off-by: Justin Florentine <justin+github@florentine.us>

commit 5bb9a30
Author: garyschulte <garyschulte@gmail.com>
Date:   Thu Aug 18 10:52:50 2022 -0700

    Bugfix/clique post merge fast sync (hyperledger#4276)

    * if merge enabled, wrap two clique rules in composed Attached rule to enable fast-sync to proceed normally for post-merge networks
    * move BlockPropagationManager warning to debug until hyperledger#4274

    Signed-off-by: garyschulte <garyschulte@gmail.com>

commit 95d0825
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Fri Aug 19 10:43:15 2022 +0100

    test fixed

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 6c2f17a
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 19:07:39 2022 +0100

    reverted some logs

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 57faef6
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 19:07:00 2022 +0100

    reverted some logs

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit ecde451
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 18:49:03 2022 +0100

    reverted some logs

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit d6625e7
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 18:43:43 2022 +0100

    reverted some logs

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit d554b7a
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 18:42:09 2022 +0100

    reverted some logs

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit e4663e7
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 18:38:20 2022 +0100

    fixed issue with decodelist and no elements

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 2188c66
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 18:36:59 2022 +0100

    fixed issue with decodelist and no elements

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 84881d7
Author: Danno Ferrin <danno.ferrin@gmail.com>
Date:   Wed Aug 17 22:40:26 2022 -0600

    Gradle repository maintenance (hyperledger#4273)

    Cleanup repository references and limit scope of non-mavenCentral
    repositories.

    Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>

commit 93cc7b7
Author: Stefan Pingel <16143240+pinges@users.noreply.github.com>
Date:   Thu Aug 18 11:49:09 2022 +1000

    make obvious when a breach of protocol is logged, add peer in some places (hyperledger#4268)

    Signed-off-by: Stefan <stefan.pingel@consensys.net>
    Co-authored-by: Sally MacFarlane <sally.macfarlane@consensys.net>

commit d0283f4
Author: Justin Florentine <justin+github@florentine.us>
Date:   Wed Aug 17 15:48:53 2022 -0400

    Block prop on first final (hyperledger#4265)

    * start filtering peers after 1 finalized instead of 2
    * stops counting finalized, and starts filtering on first finalized
    * DefaultSynchronizer now listens to Forkhoice messages so it can stop block propagation at finalization, as opposed to TTD (previous behavior)

    Signed-off-by: Justin Florentine <justin+github@florentine.us>

commit 2e2ea1f
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 17:24:22 2022 +0100

    modified flexibleutil so it works with dynamic byte arrays, some logs to remove

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 0464ccc
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 11:42:16 2022 +0100

    smart contracts adapted, changed bytecodes

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 0cf4586
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 11:02:08 2022 +0100

    smart contracts adapted, changed bytecodes

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 56a0ea3
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Thu Aug 18 10:36:45 2022 +0100

    added some logs, to be reverted

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 952085d
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Wed Aug 17 17:52:09 2022 +0100

    solidity contracts changed so they use bytes instead of bytes32

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 2d956f0
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Wed Aug 17 17:45:26 2022 +0100

    solidity contracts changed so they use bytes instead of bytes32

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit d91db9c
Author: garyschulte <garyschulte@gmail.com>
Date:   Tue Aug 16 11:35:07 2022 -0700

    getProof encoding fix for 4249 (hyperledger#4261)

    * getProof encoding fix for 4249

    Signed-off-by: garyschulte <garyschulte@gmail.com>

commit e154a47
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Wed Aug 17 17:38:27 2022 +0100

    solidity contracts changed so they use bytes instead of bytes32

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 46e2e41
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Wed Aug 17 13:34:55 2022 +0100

    modified flexibleutil to support ec keys

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

commit 4159147
Author: Fabio Di Fabio <fabio.difabio@consensys.net>
Date:   Tue Aug 16 11:17:00 2022 +0200

    Fix off-by-one error in AbstractRetryingPeerTask (hyperledger#4254)

    Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

commit 2813ce7
Author: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
Date:   Tue Aug 16 10:37:22 2022 +0100

    first commit with the flexible privacy tests adapted

    Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>

Signed-off-by: Miguel Rojo <miguelangel.rojofernandez@mastercard.com>
  • Loading branch information
freemanzMrojo committed Aug 19, 2022
1 parent 3a2aeab commit 86f4659
Show file tree
Hide file tree
Showing 20 changed files with 325 additions and 146 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 22.7.1

### Breaking Changes
- Flexible Privacy Groups support to Tessera's EC encryptor (contracts modified) [#4282](https://github.com/hyperledger/besu/pull/4282)

### Additions and Improvements
- Introduce a cap to reputation score increase [#4230](https://github.com/hyperledger/besu/pull/4230)
- Add experimental CLI option for `--Xp2p-peer-lower-bound` [#4200](https://github.com/hyperledger/besu/pull/4200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationFactory;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.account.PrivacyAccount;
import org.hyperledger.enclave.testutil.EnclaveEncryptorType;
import org.hyperledger.enclave.testutil.EnclaveKeyConfiguration;
import org.hyperledger.enclave.testutil.EnclaveType;

Expand Down Expand Up @@ -233,8 +234,11 @@ public PrivacyNode createFlexiblePrivacyGroupEnabledMinerNode(
final BesuNodeConfigurationBuilder besuNodeConfigurationBuilder =
new BesuNodeConfigurationBuilder();
if (multiTenancyEnabled) {
besuNodeConfigurationBuilder.jsonRpcAuthenticationConfiguration(
"authentication/auth_priv.toml");
final String authPrivTomlPath =
EnclaveEncryptorType.EC.equals(privacyAccount.getEnclaveEncryptorType())
? "authentication/auth_priv_ec_pubkey.toml"
: "authentication/auth_priv.toml";
besuNodeConfigurationBuilder.jsonRpcAuthenticationConfiguration(authPrivTomlPath);
}
return create(
new PrivacyNodeConfiguration(
Expand All @@ -252,7 +256,9 @@ public PrivacyNode createFlexiblePrivacyGroupEnabledMinerNode(
.keyFilePath(privacyAccount.getPrivateKeyPath())
.build(),
new EnclaveKeyConfiguration(
privacyAccount.getEnclaveKeyPaths(), privacyAccount.getEnclavePrivateKeyPaths())),
privacyAccount.getEnclaveKeyPaths(),
privacyAccount.getEnclavePrivateKeyPaths(),
privacyAccount.getEnclaveEncryptorType())),
enclaveType,
containerNetwork);
}
Expand All @@ -279,7 +285,9 @@ public PrivacyNode createFlexiblePrivacyGroupEnabledNode(
.webSocketEnabled()
.build(),
new EnclaveKeyConfiguration(
privacyAccount.getEnclaveKeyPaths(), privacyAccount.getEnclavePrivateKeyPaths())),
privacyAccount.getEnclaveKeyPaths(),
privacyAccount.getEnclavePrivateKeyPaths(),
privacyAccount.getEnclaveEncryptorType())),
enclaveType,
containerNetwork);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
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.FLEXIBLE_PRIVACY_PROXY;
Expand All @@ -41,6 +40,14 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.tuweni.bytes.Bytes;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.Utils;
import org.web3j.abi.datatypes.Bool;
import org.web3j.abi.datatypes.DynamicArray;
import org.web3j.abi.datatypes.DynamicBytes;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.besu.Besu;
Expand Down Expand Up @@ -102,8 +109,6 @@ public static class GetPrivacyPrecompileAddressResponse extends Response<Address
public static class GetPrivateTransactionResponse
extends Response<PrivateTransactionGroupResponse> {}

public static class JsonRpcSuccessResponseResponse extends Response<String> {}

public static class CreatePrivacyGroupResponse extends Response<String> {}

public static class DeletePrivacyGroupResponse extends Response<String> {}
Expand Down Expand Up @@ -232,7 +237,13 @@ public String privxRemoveFromPrivacyGroup(
}

private Bytes encodeRemoveFromGroupFunctionCall(final Bytes toRemove) {
return Bytes.concatenate(FlexibleGroupManagement.REMOVE_PARTICIPANT_METHOD_SIGNATURE, toRemove);
final Function function =
new Function(
"removeParticipant",
Arrays.asList(new DynamicBytes(toRemove.toArrayUnsafe())),
Arrays.asList(new TypeReference<Bool>() {}));

return Bytes.fromHexString(FunctionEncoder.encode(function));
}

public String privxLockPrivacyGroup(
Expand Down Expand Up @@ -588,29 +599,19 @@ public String getTransactionHash() {
}

private Bytes encodeAddToGroupFunctionCall(final List<Bytes> participants) {
return Bytes.concatenate(
FlexibleGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE, encodeList(participants));
}

private Bytes encodeList(final List<Bytes> participants) {
final Bytes dynamicParameterOffset = encodeLong(32);
final Bytes length = encodeLong(participants.size());
return Bytes.concatenate(
dynamicParameterOffset,
length,
Bytes.fromHexString(
participants.stream()
.map(Bytes::toUnprefixedHexString)
.collect(Collectors.joining(""))));
}

// long to uint256, 8 bytes big endian, so left padded by 24 bytes
private static Bytes encodeLong(final long l) {
checkArgument(l >= 0, "Unsigned value must be positive");
final byte[] longBytes = new byte[8];
for (int i = 0; i < 8; i++) {
longBytes[i] = (byte) ((l >> ((7 - i) * 8)) & 0xFF);
}
return Bytes.concatenate(Bytes.wrap(new byte[24]), Bytes.wrap(longBytes));
final Function function =
new Function(
"addParticipants",
Arrays.asList(
new DynamicArray<>(
DynamicBytes.class,
Utils.typeMap(
participants.stream()
.map(Bytes::toArrayUnsafe)
.collect(Collectors.toList()),
DynamicBytes.class))),
Collections.emptyList());

return Bytes.fromHexString(FunctionEncoder.encode(function));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.EC;
import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.NACL;
import static org.hyperledger.enclave.testutil.EnclaveType.TESSERA;
import static org.junit.runners.Parameterized.Parameters;

import org.hyperledger.besu.tests.acceptance.dsl.condition.eth.EthConditions;
Expand Down Expand Up @@ -53,14 +56,21 @@
public class FlexiblePrivacyAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase {

private final EnclaveType enclaveType;
private final EnclaveEncryptorType enclaveEncryptorType;

public FlexiblePrivacyAcceptanceTest(final EnclaveType enclaveType) {
public FlexiblePrivacyAcceptanceTest(
final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) {
this.enclaveType = enclaveType;
this.enclaveEncryptorType = enclaveEncryptorType;
}

@Parameters(name = "{0}")
public static Collection<EnclaveType> enclaveTypes() {
return EnclaveType.valuesForTests();
@Parameters(name = "{0} enclave type with {1} encryptor")
public static Collection<Object[]> enclaveParameters() {
return Arrays.asList(
new Object[][] {
{TESSERA, NACL},
{TESSERA, EC}
});
}

private PrivacyNode alice;
Expand All @@ -82,21 +92,21 @@ public void setUp() throws Exception {
alice =
privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode(
"node1",
PrivacyAccountResolver.ALICE.resolve(EnclaveEncryptorType.NACL),
PrivacyAccountResolver.ALICE.resolve(enclaveEncryptorType),
false,
enclaveType,
Optional.of(containerNetwork));
bob =
privacyBesu.createFlexiblePrivacyGroupEnabledNode(
"node2",
PrivacyAccountResolver.BOB.resolve(EnclaveEncryptorType.NACL),
PrivacyAccountResolver.BOB.resolve(enclaveEncryptorType),
false,
enclaveType,
Optional.of(containerNetwork));
charlie =
privacyBesu.createFlexiblePrivacyGroupEnabledNode(
"node3",
PrivacyAccountResolver.CHARLIE.resolve(EnclaveEncryptorType.NACL),
PrivacyAccountResolver.CHARLIE.resolve(enclaveEncryptorType),
false,
enclaveType,
Optional.of(containerNetwork));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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.ExpectValidFlexiblePrivacyGroupCreated;
Expand All @@ -32,6 +31,10 @@
import java.util.stream.Collectors;

import org.apache.tuweni.bytes.Bytes;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.Utils;
import org.web3j.abi.datatypes.DynamicArray;
import org.web3j.abi.datatypes.DynamicBytes;
import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract;
Expand Down Expand Up @@ -79,8 +82,7 @@ protected String createFlexiblePrivacyGroup(
final String commitmentHash =
callGetParticipantsMethodAndReturnCommitmentHash(privacyGroupId, groupCreator, privateFrom);
final PrivateTransactionReceipt expectedReceipt =
buildExpectedAddMemberTransactionReceipt(
privacyGroupId, groupCreator, addresses.toArray(new String[] {}));
buildExpectedAddMemberTransactionReceipt(privacyGroupId, groupCreator, addresses);

for (final PrivacyNode member : members) {
member.verify(
Expand All @@ -103,7 +105,7 @@ protected String callGetParticipantsMethodAndReturnCommitmentHash(
}

protected PrivateTransactionReceipt buildExpectedAddMemberTransactionReceipt(
final String privacyGroupId, final PrivacyNode groupCreator, final String[] members) {
final String privacyGroupId, final PrivacyNode groupCreator, final List<String> members) {
return buildExpectedAddMemberTransactionReceipt(
privacyGroupId, groupCreator, groupCreator.getEnclaveKey(), members);
}
Expand All @@ -112,18 +114,26 @@ protected PrivateTransactionReceipt buildExpectedAddMemberTransactionReceipt(
final String privacyGroupId,
final PrivacyNode groupCreator,
final String privateFrom,
final String[] members) {
final List<String> members) {

final StringBuilder output = new StringBuilder();
// hex prefix
output.append("0x");
// Dynamic array offset
output.append("0000000000000000000000000000000000000000000000000000000000000020");
// Length of the array (with padded zeros to the left)
output.append(Quantity.longToPaddedHex(members.length, 32).substring(2));
// Each member enclave key converted from Base64 to bytes
for (final String member : members) {
output.append(Bytes.fromBase64String(member).toUnprefixedHexString());
}

final String encodedParameters =
FunctionEncoder.encode(
"",
Arrays.asList(
new DynamicArray<>(
DynamicBytes.class,
Utils.typeMap(
members.stream()
.map(Bytes::fromBase64String)
.map(Bytes::toArrayUnsafe)
.collect(Collectors.toList()),
DynamicBytes.class))));

output.append(encodedParameters);

return new PrivateTransactionReceipt(
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.EC;
import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.NACL;
import static org.hyperledger.enclave.testutil.EnclaveType.TESSERA;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
Expand All @@ -32,6 +35,7 @@
import org.hyperledger.enclave.testutil.EnclaveType;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand All @@ -53,14 +57,21 @@
public class FlexibleMultiTenancyAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase {

private final EnclaveType enclaveType;
private final EnclaveEncryptorType enclaveEncryptorType;

public FlexibleMultiTenancyAcceptanceTest(final EnclaveType enclaveType) {
public FlexibleMultiTenancyAcceptanceTest(
final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) {
this.enclaveType = enclaveType;
this.enclaveEncryptorType = enclaveEncryptorType;
}

@Parameterized.Parameters(name = "{0}")
public static Collection<EnclaveType> enclaveTypes() {
return EnclaveType.valuesForTests();
@Parameterized.Parameters(name = "{0} enclave type with {1} encryptor")
public static Collection<Object[]> enclaveParameters() {
return Arrays.asList(
new Object[][] {
{TESSERA, NACL},
{TESSERA, EC}
});
}

private static final PermissioningTransactions permissioningTransactions =
Expand All @@ -75,7 +86,7 @@ public void setUp() throws Exception {
alice =
privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode(
"node1",
PrivacyAccountResolver.MULTI_TENANCY.resolve(EnclaveEncryptorType.NACL),
PrivacyAccountResolver.MULTI_TENANCY.resolve(enclaveEncryptorType),
true,
enclaveType,
Optional.empty());
Expand Down Expand Up @@ -448,7 +459,7 @@ private String createFlexiblePrivacyGroup(final MultiTenancyPrivacyGroup group)
privacyGroupId, groupCreatorNode, groupCreatorTenant);
final PrivateTransactionReceipt expectedReceipt =
buildExpectedAddMemberTransactionReceipt(
privacyGroupId, groupCreatorNode, groupCreatorTenant, members.toArray(new String[] {}));
privacyGroupId, groupCreatorNode, groupCreatorTenant, members);

for (final MultiTenancyPrivacyNode mtpn : multiTenancyPrivacyNodes) {
final PrivacyNode privacyNode = mtpn.getPrivacyNode();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Users.user]
password = "$2a$10$l3GA7K8g6rJ/Yv.YFSygCuI9byngpEzxgWS9qEg5emYDZomQW7fGC"
permissions = ["fakePermission", "*:*"]
privacyPublicKey = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAES8nC4qT/KdoAoTSF3qs/47DUsDihyVbWiRjZAiyvqp9eSDkqV1RzlM+58oOwnpFRwvWNZM+AxMVxT+MvxdsqMA=="

[Users.user2]
password = "$2a$10$0ikMUcSYugKmnXilimhc1eGNnfMRvKt2PxQJPo1oCemN16QL2NNo."
permissions = ["fakePermission", "*:*"]
privacyPublicKey = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEXIgZqRA25V+3nN+Do6b5r0jiUunub6ubjPhqwHpPxP44uUYh9RKCQNRnsqCJ9PjeTnC8R3ieJk7HWAlycU1bug=="

[Users.user3]
password = "$2a$10$Mydyzpul6CtgPRbUd6It2OpZDOfqOocpi6.UYhlyU5aphQHi1iQZq"
permissions = ["fakePermission", "*:*"]
privacyPublicKey = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFl85WnNPyzSEX+evc774xoqUQdjSnQMTE1uIyMOve+iVwjs6dUEUwz5teiKuUUf63a/qYe4n6SGnQ7HnmtDViQ=="

[Users.failUser]
password = "$2a$10$l3GA7K8g6rJ/Yv.YFSygCuI9byngpEzxgWS9qEg5emYDZomQW7fGC"
permissions = ["fakePermission", "*:*"]
privacyPublicKey = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE30vyCv2v4EHwqnr0LEGaCX6GWfmYIIxLRw1PISeFsOk1tmY2hAYjEHkaZzu31SlFx0ickh10MEublBnrxCiJIA=="
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY;
import static org.hyperledger.besu.ethereum.privacy.FlexiblePrivacyGroupContract.decodeList;
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;

Expand Down Expand Up @@ -130,7 +129,11 @@ public Optional<PrivacyGroup> findPrivacyGroupByGroupId(
if (rlpInput.nextSize() > 0) {
return Optional.of(
new PrivacyGroup(
privacyGroupId, PrivacyGroup.Type.FLEXIBLE, "", "", decodeList(rlpInput.raw())));
privacyGroupId,
PrivacyGroup.Type.FLEXIBLE,
"",
"",
FlexibleUtil.decodeList(rlpInput.raw())));
}
}
return Optional.empty();
Expand Down Expand Up @@ -283,6 +286,7 @@ private Optional<String> buildAndSendAddPayload(
enclave.send(bytes.toBase64String(), privacyUserId, privateFor).getKey());
}
}

return Optional.empty();
}

Expand Down
Loading

0 comments on commit 86f4659

Please sign in to comment.