Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go quorum interop #1782

Merged
merged 61 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
8e524d1
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
31ab133
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
eb693b1
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
e3631a9
changes based on comments
pinges Nov 26, 2020
a760ba0
changes based on comments
pinges Nov 26, 2020
1970507
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Nov 26, 2020
d254e22
changes based on comments
pinges Nov 26, 2020
5a37b4b
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 1, 2020
700eff0
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 3, 2020
55e59d4
add quorum raw private transactions
pinges Dec 14, 2020
2985980
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 14, 2020
424a33d
some changes
pinges Dec 15, 2020
b12bc00
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 16, 2020
dbbd27e
merge privacy configuration
pinges Dec 17, 2020
2c43940
Initial goquorum private tx processing
lucassaldanha Dec 17, 2020
119a9d2
Added GoQuorumKeyValueStorage
lucassaldanha Dec 18, 2020
4adcf0b
Removed unecessary classes
lucassaldanha Dec 22, 2020
8774a89
Clenup
lucassaldanha Dec 27, 2020
28687be
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 30, 2020
2b0fefc
private Tx mined by quorum, but import into besu fails with 'invalid …
pinges Dec 31, 2020
a785608
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Jan 11, 2021
5e4635f
tests passing after rebase with Lucas branch
pinges Jan 11, 2021
d2e2506
spotless
pinges Jan 11, 2021
b0a1aed
merged in changes from master. All tests passing
pinges Jan 12, 2021
410cd83
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 12, 2021
4af37ab
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 13, 2021
47e9c11
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Jan 13, 2021
5f811ef
Merge branch 'createQuorumTransaction' into goQuorumInterop
pinges Jan 13, 2021
f69dd2a
add some debug sout
pinges Jan 13, 2021
a2e28ce
remove receive RPC method
pinges Jan 14, 2021
232100b
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 14, 2021
1d9431c
make quorum privacy configuration not use static
pinges Jan 15, 2021
f019692
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 15, 2021
063cd03
fix compile
pinges Jan 17, 2021
f9d5be1
fix test
pinges Jan 17, 2021
bfb8f17
fix test failure
pinges Jan 18, 2021
565bbf9
fix test failure
pinges Jan 18, 2021
dfbbc0e
fix test failure
pinges Jan 18, 2021
0bc3b6e
fix test failure
pinges Jan 18, 2021
e744047
fix test failure
pinges Jan 18, 2021
ee0e4b3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 18, 2021
365618b
fix AT NullPointerExceptions
pinges Jan 19, 2021
f45b539
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 19, 2021
424dff5
remove another static field
pinges Jan 19, 2021
b0db717
some cleanup
pinges Jan 19, 2021
ffa56b3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
bafc3d6
more cleanup
pinges Jan 20, 2021
1cad6ce
even more cleanup
pinges Jan 20, 2021
0042fdf
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
da6c97e
and even more cleanup
pinges Jan 20, 2021
17eec25
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
1fb251d
fix a unit test
pinges Jan 20, 2021
c806616
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
314234e
fixes after review from Sally
pinges Jan 22, 2021
7e7ebd3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 22, 2021
73e96f2
merge master and somes fixes after review from Mark
pinges Jan 27, 2021
97dfe34
changes after comments from Lucas
pinges Jan 27, 2021
64ab12e
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 27, 2021
a9d583e
fix spotless
pinges Jan 27, 2021
d08eb35
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 28, 2021
8710904
remove some comments
pinges Jan 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests passing after rebase with Lucas branch
Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
  • Loading branch information
pinges committed Jan 11, 2021
commit 5e4635fd43c4a4c64e5806c61a0b1dbf2d10229e
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Optional<Bytes> maybePrivacyGroupId = privateTransaction.getPrivacyGroupId();

final Optional<PrivacyGroup> maybePrivacyGroup =
findPrivacyGroup(maybePrivacyGroupId, enclavePublicKey, privateTransaction);
findPrivacyGroup(
privacyController, maybePrivacyGroupId, enclavePublicKey, privateTransaction);

final ValidationResult<TransactionInvalidReason> validationResult =
privacyController.validatePrivateTransaction(privateTransaction, enclavePublicKey);
Expand All @@ -95,14 +96,15 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
id, convertTransactionInvalidReason(validationResult.getInvalidReason()));
}

final Transaction privacyMarkerTransaction =
createPMT(privateTransaction, maybePrivacyGroup, maybePrivacyGroupId, enclavePublicKey);

return transactionPool
.addLocalTransaction(privacyMarkerTransaction)
.either(
() -> new JsonRpcSuccessResponse(id, privacyMarkerTransaction.getHash().toString()),
errorReason -> getJsonRpcErrorResponse(id, errorReason));
final JsonRpcResponse ret =
createPMTAndAddToTxPool(
id,
privateTransaction,
maybePrivacyGroup,
maybePrivacyGroupId,
enclavePublicKey,
Address.DEFAULT_PRIVACY);
return ret;

} catch (final JsonRpcErrorResponseException e) {
return new JsonRpcErrorResponse(id, e.getJsonRpcError());
Expand All @@ -115,6 +117,7 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
}

Optional<PrivacyGroup> findPrivacyGroup(
final PrivacyController privacyController,
final Optional<Bytes> maybePrivacyGroupId,
final String enclavePublicKey,
final PrivateTransaction privateTransaction) {
Expand All @@ -123,15 +126,23 @@ Optional<PrivacyGroup> findPrivacyGroup(
return maybePrivacyGroup;
}

Transaction createPMT(
JsonRpcResponse createPMTAndAddToTxPool(
final Object id,
final PrivateTransaction privateTransaction,
final Optional<PrivacyGroup> maybePrivacyGroup,
final Optional<Bytes> maybePrivacyGroupId,
final String enclavePublicKey) {
final String enclavePublicKey,
final Address privacyPrecompileAddress) {
final String privateTransactionLookupId =
privacyController.sendTransaction(privateTransaction, enclavePublicKey, maybePrivacyGroup);
return privacyController.createPrivacyMarkerTransaction(
privateTransactionLookupId, privateTransaction, Address.DEFAULT_PRIVACY);
final Transaction privacyMarkerTransaction =
privacyController.createPrivacyMarkerTransaction(
privateTransactionLookupId, privateTransaction, privacyPrecompileAddress);
return transactionPool
.addLocalTransaction(privacyMarkerTransaction)
.either(
() -> new JsonRpcSuccessResponse(id, privacyMarkerTransaction.getHash().toString()),
errorReason -> getJsonRpcErrorResponse(id, errorReason));
}

JsonRpcErrorResponse getJsonRpcErrorResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class JsonRpcErrorResponseException extends RuntimeException {

private final JsonRpcError jsonRpcError;

public JsonRpcErrorResponseException(final JsonRpcError error) {
public JsonRpcErrorResponseException(final JsonRpcError onchainPrivacyGroupIdNotAvailable) {
super();
this.jsonRpcError = error;
this.jsonRpcError = onchainPrivacyGroupIdNotAvailable;
}

public JsonRpcError getJsonRpcError() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import static org.hyperledger.besu.ethereum.privacy.PrivacyGroupUtil.findOnchainPrivacyGroup;

import org.hyperledger.besu.enclave.types.PrivacyGroup;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.EnclavePublicKeyProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
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.core.Address;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
Expand All @@ -39,8 +42,14 @@ public OnChainEeaSendRawTransaction(
super(transactionPool, privacyController, enclavePublicKeyProvider);
}

@Override
public String getName() {
return RpcMethod.EEA_SEND_RAW_TRANSACTION.getMethodName();
}

@Override
Optional<PrivacyGroup> findPrivacyGroup(
final PrivacyController privacyController,
final Optional<Bytes> maybePrivacyGroupId,
final String enclavePublicKey,
final PrivateTransaction privateTransaction) {
Expand All @@ -57,22 +66,29 @@ Optional<PrivacyGroup> findPrivacyGroup(
}

@Override
Transaction createPMT(
JsonRpcResponse createPMTAndAddToTxPool(
final Object id,
final PrivateTransaction privateTransaction,
final Optional<PrivacyGroup> maybePrivacyGroup,
final Optional<Bytes> maybePrivacyGroupId,
final String enclavePublicKey) {
final String enclavePublicKey,
final Address privacyPrecompiledAddress) {
final Bytes privacyGroupId = maybePrivacyGroupId.get();
final String privateTransactionLookupId =
privacyController.sendTransaction(privateTransaction, enclavePublicKey, maybePrivacyGroup);
final Bytes privacyGroupId =
maybePrivacyGroupId.get(); // exists, as it has been checked in findPrivacyGroup
final Optional<String> addPayloadPrivateTransactionLookupId =
privacyController.buildAndSendAddPayload(
privateTransaction, Bytes32.wrap(privacyGroupId), enclavePublicKey);
return privacyController.createPrivacyMarkerTransaction(
buildCompoundLookupId(privateTransactionLookupId, addPayloadPrivateTransactionLookupId),
privateTransaction,
Address.ONCHAIN_PRIVACY);
final Transaction privacyMarkerTransaction =
privacyController.createPrivacyMarkerTransaction(
buildCompoundLookupId(privateTransactionLookupId, addPayloadPrivateTransactionLookupId),
privateTransaction,
Address.ONCHAIN_PRIVACY);
return transactionPool
.addLocalTransaction(privacyMarkerTransaction)
.either(
() -> new JsonRpcSuccessResponse(id, privacyMarkerTransaction.getHash().toString()),
errorReason -> getJsonRpcErrorResponse(id, errorReason));
}

private String buildCompoundLookupId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -232,6 +233,24 @@ public void validTransactionPrivacyGroupIsSentToTransactionPool() {
verify(transactionPool).addLocalTransaction(any(Transaction.class));
}


@Test
public void eeaTransactionFailsWhenOnchainPrivacyGroupFeatureIsEnabled() {
method =
new OnChainEeaSendRawTransaction(
transactionPool, privacyController, enclavePublicKeyProvider);

final JsonRpcRequestContext request = getJsonRpcRequestContext();

final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(
request.getRequest().getId(), JsonRpcError.ONCHAIN_PRIVACY_GROUP_ID_NOT_AVAILABLE);

final JsonRpcResponse actualResponse = method.response(request);

assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}

private JsonRpcRequestContext getJsonRpcRequestContext() {
return new JsonRpcRequestContext(
new JsonRpcRequest(
Expand All @@ -240,7 +259,7 @@ private JsonRpcRequestContext getJsonRpcRequestContext() {
}

@Test
public void transactionFailsIfPrivacyGroupDoesNotExist() {
public void onChainPrivacyGroupTransactionFailsWhenFeatureIsNotEnabled() {
method =
new EeaSendRawTransaction(transactionPool, privacyController, enclavePublicKeyProvider);

Expand Down