[PRIV-54] Use default enclave public key to generate eea_getTransactionReceipt (#1280)

* Use default enclave public key to generate eea_getTransactionReceipt

* Update the docs to reflect the changes

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Puneetha Karamsetty 6 years ago committed by Lucas Saldanha
parent 8fc9ee7243
commit 08d8700795
  1. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eea.java
  2. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/ExpectNoPrivateContractDeployedReceipt.java
  3. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/ExpectNoValidPrivateContractValuesReturned.java
  4. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/ExpectValidPrivateContractDeployedReceipt.java
  5. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/ExpectValidPrivateContractEventsEmitted.java
  6. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/ExpectValidPrivateContractValuesReturned.java
  7. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/ExpectValidPrivateTransactionReceipt.java
  8. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/GetValidPrivateTransactionReceipt.java
  9. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EeaJsonRpcRequestFactory.java
  10. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/Transactions.java
  11. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eea/EeaGetTransactionReceiptTransaction.java
  12. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eea/EeaTransactions.java
  13. 10
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/privacy/DeployPrivateSmartContractAcceptanceTest.java
  14. 28
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/privacy/PrivacyClusterAcceptanceTest.java
  15. 6
      docs/Reference/JSON-RPC-API-Methods.md
  16. 2
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/EeaGetTransactionReceipt.java
  17. 2
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/EeaGetTransactionReceiptTest.java

@ -24,9 +24,8 @@ public class Eea {
this.transactions = transactions;
}
public Condition expectSuccessfulTransactionReceipt(
final String transactionHash, final String publicKey) {
public Condition expectSuccessfulTransactionReceipt(final String transactionHash) {
return new ExpectSuccessfulEeaGetTransactionReceipt(
transactions.getTransactionReceipt(transactionHash, publicKey));
transactions.getTransactionReceipt(transactionHash));
}
}

@ -25,10 +25,9 @@ public class ExpectNoPrivateContractDeployedReceipt extends GetValidPrivateTrans
super(eea, transactions);
}
public void verify(
final PantheonNode node, final String transactionHash, final String publicKey) {
public void verify(final PantheonNode node, final String transactionHash) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, publicKey);
getPrivateTransactionReceipt(node, transactionHash);
assertNull(privateTxReceipt.getContractAddress());
}

@ -26,10 +26,9 @@ public class ExpectNoValidPrivateContractValuesReturned extends GetValidPrivateT
super(eea, transactions);
}
public void verify(
final PantheonNode node, final String transactionHash, final String publicKey) {
public void verify(final PantheonNode node, final String transactionHash) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, publicKey);
getPrivateTransactionReceipt(node, transactionHash);
assertEquals("0x", privateTxReceipt.getOutput());
}

@ -29,10 +29,9 @@ public class ExpectValidPrivateContractDeployedReceipt extends GetValidPrivateTr
this.contractAddress = contractAddress;
}
public void verify(
final PantheonNode node, final String transactionHash, final String publicKey) {
public void verify(final PantheonNode node, final String transactionHash) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, publicKey);
getPrivateTransactionReceipt(node, transactionHash);
assertEquals(contractAddress, privateTxReceipt.getContractAddress());
}

@ -32,10 +32,9 @@ public class ExpectValidPrivateContractEventsEmitted extends GetValidPrivateTran
this.eventValue = eventValue;
}
public void verify(
final PantheonNode node, final String transactionHash, final String publicKey) {
public void verify(final PantheonNode node, final String transactionHash) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, publicKey);
getPrivateTransactionReceipt(node, transactionHash);
String event = privateTxReceipt.getLogs().get(0).getData().substring(66, 130);
assertEquals(

@ -33,10 +33,9 @@ public class ExpectValidPrivateContractValuesReturned extends GetValidPrivateTra
this.returnValue = returnValue;
}
public void verify(
final PantheonNode node, final String transactionHash, final String publicKey) {
public void verify(final PantheonNode node, final String transactionHash) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, publicKey);
getPrivateTransactionReceipt(node, transactionHash);
BytesValue output = BytesValue.fromHexString(privateTxReceipt.getOutput());
assertEquals(new BigInteger(returnValue), Numeric.decodeQuantity(output.toString()));

@ -26,10 +26,9 @@ public class ExpectValidPrivateTransactionReceipt extends GetValidPrivateTransac
super(eea, transactions);
}
public void verify(
final PantheonNode node, final String transactionHash, final String publicKey) {
public void verify(final PantheonNode node, final String transactionHash) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, publicKey);
getPrivateTransactionReceipt(node, transactionHash);
assertNotNull(privateTxReceipt);
assertThat(privateTxReceipt.getFrom()).isNotBlank();
}

@ -30,11 +30,11 @@ public abstract class GetValidPrivateTransactionReceipt {
}
ResponseTypes.PrivateTransactionReceipt getPrivateTransactionReceipt(
final PantheonNode node, final String transactionHash, final String publicKey) {
final PantheonNode node, final String transactionHash) {
waitFor(() -> node.verify(eea.expectSuccessfulTransactionReceipt(transactionHash, publicKey)));
waitFor(() -> node.verify(eea.expectSuccessfulTransactionReceipt(transactionHash)));
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
node.execute(transactions.getPrivateTransactionReceipt(transactionHash, publicKey));
node.execute(transactions.getPrivateTransactionReceipt(transactionHash));
return privateTxReceipt;
}
}

@ -38,10 +38,10 @@ public class EeaJsonRpcRequestFactory {
}
public Request<?, PrivateTransactionReceiptResponse> eeaGetTransactionReceipt(
final String txHash, final String publicKey) {
final String txHash) {
return new Request<>(
"eea_getTransactionReceipt",
Lists.newArrayList(txHash, publicKey),
Lists.newArrayList(txHash),
web3jService,
PrivateTransactionReceiptResponse.class);
}

@ -144,8 +144,8 @@ public class Transactions {
}
public EeaGetTransactionReceiptTransaction getPrivateTransactionReceipt(
final String transactionHash, final String publicKey) {
return new EeaGetTransactionReceiptTransaction(transactionHash, publicKey);
final String transactionHash) {
return new EeaGetTransactionReceiptTransaction(transactionHash);
}
public PermAddNodeTransaction addNodesToWhitelist(final List<URI> enodeList) {

@ -24,18 +24,16 @@ import java.io.IOException;
public class EeaGetTransactionReceiptTransaction implements Transaction<PrivateTransactionReceipt> {
private final String txHash;
private final String publicKey;
public EeaGetTransactionReceiptTransaction(final String txHash, final String publicKey) {
public EeaGetTransactionReceiptTransaction(final String txHash) {
this.txHash = txHash;
this.publicKey = publicKey;
}
@Override
public PrivateTransactionReceipt execute(final JsonRequestFactories node) {
try {
final PrivateTransactionReceiptResponse result =
node.eea().eeaGetTransactionReceipt(txHash, publicKey).send();
node.eea().eeaGetTransactionReceipt(txHash).send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getResult();

@ -14,8 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea;
public class EeaTransactions {
public EeaGetTransactionReceiptTransaction getTransactionReceipt(
final String transactionHash, final String pubKey) {
return new EeaGetTransactionReceiptTransaction(transactionHash, pubKey);
public EeaGetTransactionReceiptTransaction getTransactionReceipt(final String transactionHash) {
return new EeaGetTransactionReceiptTransaction(transactionHash);
}
}

@ -91,7 +91,7 @@ public class DeployPrivateSmartContractAcceptanceTest extends PrivateAcceptanceT
privateTransactionVerifier
.validPrivateContractDeployed(CONTRACT_ADDRESS.toString())
.verify(minerNode, transactionHash, PUBLIC_KEY);
.verify(minerNode, transactionHash);
}
@Test
@ -101,9 +101,7 @@ public class DeployPrivateSmartContractAcceptanceTest extends PrivateAcceptanceT
final String transactionHash =
minerNode.execute(transactions.createPrivateRawTransaction(storeValue));
privateTransactionVerifier
.validEventReturned("1000")
.verify(minerNode, transactionHash, PUBLIC_KEY);
privateTransactionVerifier.validEventReturned("1000").verify(minerNode, transactionHash);
}
@Test
@ -116,9 +114,7 @@ public class DeployPrivateSmartContractAcceptanceTest extends PrivateAcceptanceT
final String transactionHash =
minerNode.execute(transactions.createPrivateRawTransaction(getValue));
privateTransactionVerifier
.validOutputReturned("1000")
.verify(minerNode, transactionHash, PUBLIC_KEY);
privateTransactionVerifier.validOutputReturned("1000").verify(minerNode, transactionHash);
}
@After

@ -146,7 +146,7 @@ public class PrivacyClusterAcceptanceTest extends PrivateAcceptanceTestBase {
privateTransactionVerifier
.validPrivateContractDeployed(CONTRACT_ADDRESS.toString())
.verify(node2, transactionHash, PUBLIC_KEY_2);
.verify(node2, transactionHash);
}
@Test
@ -156,13 +156,11 @@ public class PrivacyClusterAcceptanceTest extends PrivateAcceptanceTestBase {
privateTransactionVerifier
.validPrivateContractDeployed(CONTRACT_ADDRESS.toString())
.verify(node2, transactionHash, PUBLIC_KEY_2);
.verify(node2, transactionHash);
transactionHash = node2.execute(transactions.createPrivateRawTransaction(storeValueFromNode2));
privateTransactionVerifier
.validEventReturned("1000")
.verify(node1, transactionHash, PUBLIC_KEY_1);
privateTransactionVerifier.validEventReturned("1000").verify(node1, transactionHash);
}
@Test
@ -172,23 +170,17 @@ public class PrivacyClusterAcceptanceTest extends PrivateAcceptanceTestBase {
privateTransactionVerifier
.validPrivateContractDeployed(CONTRACT_ADDRESS.toString())
.verify(node2, transactionHash, PUBLIC_KEY_2);
.verify(node2, transactionHash);
transactionHash = node2.execute(transactions.createPrivateRawTransaction(storeValueFromNode2));
privateTransactionVerifier
.validEventReturned("1000")
.verify(node1, transactionHash, PUBLIC_KEY_1);
privateTransactionVerifier.validEventReturned("1000").verify(node1, transactionHash);
transactionHash = node2.execute(transactions.createPrivateRawTransaction(getValueFromNode2));
privateTransactionVerifier
.validOutputReturned("1000")
.verify(node2, transactionHash, PUBLIC_KEY_2);
privateTransactionVerifier.validOutputReturned("1000").verify(node2, transactionHash);
privateTransactionVerifier
.validOutputReturned("1000")
.verify(node1, transactionHash, PUBLIC_KEY_1);
privateTransactionVerifier.validOutputReturned("1000").verify(node1, transactionHash);
}
@Test
@ -196,9 +188,7 @@ public class PrivacyClusterAcceptanceTest extends PrivateAcceptanceTestBase {
final String transactionHash =
node1.execute(transactions.deployPrivateSmartContract(deployContractFromNode1));
privateTransactionVerifier
.noPrivateContractDeployed()
.verify(node3, transactionHash, PUBLIC_KEY_3);
privateTransactionVerifier.noPrivateContractDeployed().verify(node3, transactionHash);
}
@Test
@ -208,7 +198,7 @@ public class PrivacyClusterAcceptanceTest extends PrivateAcceptanceTestBase {
final String transactionHash =
node3.execute(transactions.createPrivateRawTransaction(getValueFromNode3));
privateTransactionVerifier.noValidOutputReturned().verify(node3, transactionHash, PUBLIC_KEY_3);
privateTransactionVerifier.noValidOutputReturned().verify(node3, transactionHash);
}
@Test(expected = RuntimeException.class)

@ -2648,19 +2648,17 @@ are not available.
`data` - 32-byte hash of a transaction.
`data` - Orion node public key
**Returns**
`Object` - [Private Transaction receipt object](JSON-RPC-API-Objects.md#private-transaction-receipt-object), or `null` if no receipt found.
!!! example
```bash tab="curl HTTP request"
curl -X POST --data '{"jsonrpc":"2.0","method":"eea_getTransactionReceipt","params":["0xf3ab9693ad92e277bf785e1772f29fb1864904bbbe87b0470455ddb082caab9d", "g59BmTeJIn7HIcnq8VQWgyh/pDbvbt2eyP0Ii60aDDw="],"id":1}' http://127.0.0.1:8545
curl -X POST --data '{"jsonrpc":"2.0","method":"eea_getTransactionReceipt","params":["0xf3ab9693ad92e277bf785e1772f29fb1864904bbbe87b0470455ddb082caab9d"],"id":1}' http://127.0.0.1:8545
```
```bash tab="wscat WS request"
{"jsonrpc":"2.0","method":"eea_getTransactionReceipt","params":["0xf3ab9693ad92e277bf785e1772f29fb1864904bbbe87b0470455ddb082caab9d", "g59BmTeJIn7HIcnq8VQWgyh/pDbvbt2eyP0Ii60aDDw="],"id":1}
{"jsonrpc":"2.0","method":"eea_getTransactionReceipt","params":["0xf3ab9693ad92e277bf785e1772f29fb1864904bbbe87b0470455ddb082caab9d"],"id":1}
```
```json tab="JSON result"

@ -77,7 +77,6 @@ public class EeaGetTransactionReceipt implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequest request) {
LOG.trace("Executing eea_getTransactionReceipt");
final Hash transactionHash = parameters.required(request.getParams(), 0, Hash.class);
final String publicKey = parameters.required(request.getParams(), 1, String.class);
final Optional<TransactionLocation> maybeLocation =
blockchain.getBlockchain().getTransactionLocation(transactionHash);
if (!maybeLocation.isPresent()) {
@ -91,6 +90,7 @@ public class EeaGetTransactionReceipt implements JsonRpcMethod {
final Hash blockhash = location.getBlockHash();
final long blockNumber = blockchain.getBlockchain().getBlockHeader(blockhash).get().getNumber();
final String publicKey = privacyParameters.getEnclavePublicKey();
PrivateTransaction privateTransaction;
String privacyGroupId;
try {

@ -155,7 +155,7 @@ public class EeaGetTransactionReceiptTest {
final EeaGetTransactionReceipt eeaGetTransactionReceipt =
new EeaGetTransactionReceipt(blockchainQueries, enclave, parameters, privacyParameters);
final Object[] params = new Object[] {transaction.hash(), "EnclavePublicKey"};
final Object[] params = new Object[] {transaction.hash()};
final JsonRpcRequest request = new JsonRpcRequest("1", "eea_getTransactionReceipt", params);
when(blockchainQueries.getBlockchain()).thenReturn(blockchain);

Loading…
Cancel
Save