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

Error: Transaction hash is "NULL" while executing Privacy enabled On-chain permission (Client Lib Web3j) #3504

Closed
jann2005 opened this issue Mar 1, 2022 · 12 comments
Assignees
Labels
TeamRevenant GH issues worked on by Revenant Team

Comments

@jann2005
Copy link

jann2005 commented Mar 1, 2022

Description

I wanted to create a network with Privacy enabled On chain permission to execute a transaction with

Steps to re-produce -
a. I have created 3 Besu nodes with privacy enabled.
b. Each node is running a tressera node inside.
c. --privacy-flexible-groups-enabled="true"
d. Using Ethash consensus. (I have tested with CLIQE and IBFT. Its same)
e. Created Privacy group with 2 participants by generating 32 bit random unique Id
f . Call to create privOnChainCreatePrivacyGroup

Getting Error : Returning Transaction hash null
2022-03-01 14:46:01.800 ERROR 52874 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received: 400; {
"jsonrpc" : "2.0",
"id" : 3,
"error" : {
"code" : -32602,
"message" : "Invalid params"
}
}]

Code Snippet -

    PollingPrivateTransactionReceiptProcessor processor = new PollingPrivateTransactionReceiptProcessor(
            rootBesuNode.getBesuNode(), 15000, 20);

    String txHash = rootBesuNode.getBesuNode()
            .privOnChainCreatePrivacyGroup(besuNetwork.getPrivacyGroupId(),
                    rootBesuNode.getCredential(),
                    rootBesuNode.getEnclaveKey(),
                    participantEnclaveKeyList)
            .send()
            .getTransactionHash(); //***  getResult returning NULL
    // Wait for the transaction to be mined & get the receipt
    System.out.println("Transaction hash => " + txHash);

Stacktrace

Creating privacy group with Member 1 and member 2

enclaveKey=qUWO+tx43cQGfZIH8aKDxVWq1Ks/l3dJyvMsaSmrU38=, privateKey=0xdf02ce17a501f4028dd5a7eaab3ce81cac23b480 Participant List => [qUWO+tx43cQGfZIH8aKDxVWq1Ks/l3dJyvMsaSmrU38=, Zc2aEGkBktD5+OIIe7dmibBsM/Pqm0rTf5WUp+2CyGg=] Privacy groupId => 0oUnzE0j+iJlvFuHRw4eUE0drGfzm3spY8R3fLJzUBg=

2022-03-01 14:46:01.800 ERROR 52874 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received: 400; {
"jsonrpc" : "2.0",
"id" : 3,
"error" : {
"code" : -32602,
"message" : "Invalid params"
}
}] with root cause

org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received: 400; {
"jsonrpc" : "2.0",
"id" : 3,
"error" : {
"code" : -32602,
"message" : "Invalid params"
}
}
at org.web3j.protocol.http.HttpService.performIO(HttpService.java:173) ~[core-5.0.0.jar:na]
at org.web3j.protocol.Service.send(Service.java:48) ~[core-5.0.0.jar:na]
at org.web3j.protocol.core.Request.send(Request.java:87) ~[core-5.0.0.jar:na]
at org.web3j.tx.response.PrivateTransactionReceiptProcessor.sendTransactionReceiptRequest(PrivateTransactionReceiptProcessor.java:35) ~[besu-5.0.0.jar:na]
at org.web3j.tx.response.PollingPrivateTransactionReceiptProcessor.getTransactionReceipt(PollingPrivateTransactionReceiptProcessor.java:44) ~[besu-5.0.0.jar:na]
at org.web3j.tx.response.PollingPrivateTransactionReceiptProcessor.waitForTransactionReceipt(PollingPrivateTransactionReceiptProcessor.java:36) ~[besu-5.0.0.jar:na]
at com.dapp.dappsample.BesuNetwork.getNewNetwork(BesuNetwork.java:57) ~[classes/:na]
.....

Versions

Besu Version - 22.1.0
web3j Lib - 5.0.0
Jopen JDK 11
okHTTP 4.9.3

@jann2005
Copy link
Author

jann2005 commented Mar 2, 2022

Tested with downgraded version of web3j (4.8.7 ), okHTTP (4.3.1) . Its giving same error...

@macfarla
Copy link
Contributor

Invalid params indicates that there is an unrecognized parameter or a parameter with an unexpected type or value. Are you able to log exactly what request is being sent to besu on your side?

@macfarla macfarla self-assigned this Mar 15, 2022
@jann2005
Copy link
Author

@macfarla How I can enable the info log to see submitted request on Besu node?

@macfarla
Copy link
Contributor

If you enable DEBUG logging, https://besu.hyperledger.org/en/stable/Reference/CLI/CLI-Syntax/#logging
Then you should see the JSON-RPC request logged eg

2022-03-17 12:14:38.657+10:00 | vert.x-worker-thread-5 | DEBUG | JsonRpcHttpService | JSON-RPC request -> eth_sendRawTransaction [{from=0xfe3b557e8fb62b89f4916b721be55ceb828dbd73, foo=foo, data=608060, gas=0xfffff}]
2022-03-17 12:14:38.660+10:00 | vert.x-worker-thread-5 | DEBUG | JsonRpcHttpService | Invalid Params
org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters: Invalid json rpc parameter at index 0
	at org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.optional(JsonRpcParameter.java:77)
	at org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.required(JsonRpcParameter.java:42)
	at org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest.getRequiredParameter(JsonRpcRequest.java:133)
	at org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext.getRequiredParameter(JsonRpcRequestContext.java:64)
	at org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthSendRawTransaction.response(EthSendRawTransaction.java:66)
	at org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService.process(JsonRpcHttpService.java:770)
	at org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService.lambda$handleJsonSingleRequest$14(JsonRpcHttpService.java:620)
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: (String)"{"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","foo":"foo","data":"608060","gas":"0xfffff"}"; line: 1, column: 1]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
	at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1741)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1515)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1420)
	at com.fasterxml.jackson.databind.DeserializationContext.extractScalarFromObject(DeserializationContext.java:932)
	at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:62)
	at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3629)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3597)
	at org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.optional(JsonRpcParameter.java:75)

@jann2005
Copy link
Author

2022-03-29 15:15:53.270+00:00 | vert.x-eventloop-thread-0 | DEBUG | B3PropagatorExtractorMultipleHeaders | Invalid TraceId in B3 header: null'. Returning INVALID span context.
2022-03-29 15:15:53.271+00:00 | vert.x-worker-thread-14 | DEBUG | JsonRpcHttpService | JSON-RPC request -> eea_sendRawTransaction
2022-03-29 15:15:53.272+00:00 | vert.x-worker-thread-14 | DEBUG | PrivateTransactionValidator | Validating private transaction MessageCall{nonce=0, gasPrice=0x0000000000000000000000000000000000000000000000000000000000000000, gasLimit=3000000, to=0x000000000000000000000000000000000000007c, value=0x0000000000000000000000000000000000000000000000000000000000000000, sig=Signature{r=15780616953724346673799140178395557176942412958318181789933101425405489385367, s=36094561631821807878862945533627749183401129955559212214679311777054650690643, recId=0}, chainId=2018, payload=0xb4926e2500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002a9458efadc78ddc4067d9207f1a283c555aad4ab3f977749caf32c6929ab537f65cd9a10690192d0f9f8e2087bb76689b06c33f3ea9b4ad37f9594a7ed82c868, privateFrom=0xa9458efadc78ddc4067d9207f1a283c555aad4ab3f977749caf32c6929ab537f, privacyGroupId=0xd2490e98276ab31b0797741c730d372a00fcbceabb82797386510f5a1e3ab0da, restriction=RESTRICTED}
2022-03-29 15:15:53.272+00:00 | vert.x-worker-thread-14 | DEBUG | PrivateTransactionValidator | Private Transaction failed signature validation WRONG_CHAIN_ID, Transaction was meant for chain id 2018, not this chain id 1337
2022-03-29 15:15:53.277+00:00 | vert.x-eventloop-thread-0 | DEBUG | B3PropagatorExtractorMultipleHeaders | Invalid TraceId in B3 header: null'. Returning INVALID span context.
2022-03-29 15:15:53.279+00:00 | vert.x-worker-thread-4 | DEBUG | JsonRpcHttpService | JSON-RPC request -> priv_getTransactionReceipt
2022-03-29 15:15:53.279+00:00 | vert.x-worker-thread-4 | DEBUG | JsonRpcHttpService | Invalid Params
org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters: Missing required json rpc parameter at index 0
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.lambda$required$0(JsonRpcParameter.java:42)
at java.base/java.util.Optional.orElseThrow(Optional.java:408)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.required(JsonRpcParameter.java:40)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest.getRequiredParameter(JsonRpcRequest.java:133)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext.getRequiredParameter(JsonRpcRequestContext.java:64)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetTransactionReceipt.response(PrivGetTransactionReceipt.java:70)
at org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService.process(JsonRpcHttpService.java:721)
at org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService.lambda$handleJsonSingleRequest$13(JsonRpcHttpService.java:585)
at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)

@jann2005
Copy link
Author

Private Transaction failed signature validation WRONG_CHAIN_ID, Transaction was meant for chain id 2018, not this chain id 1337

Not very sure where from CHAIN_ID 2018 is getting set. In Genesis, .env file, dAPP I am setting chain_id as 1337 . I am using ethash . Genesis file is https://github.com/ConsenSys/permissioning-smart-contracts/blob/main/genesis.json

Please suggest.

@jann2005
Copy link
Author

After investigation I found that below code is setting hardcoded chain_id as 2018 in OnChainPrivacyTransactionBuilder.java which is getting call from JsonRpc2_OBesu.java. Any suggestion is appreciated.

public OnChainPrivacyTransactionBuilder() {
this(2018, ZERO_GAS_PROVIDER, Restriction.RESTRICTED);
}

@jann2005
Copy link
Author

Able to Fix chain_Id issue, however getting issue on " Invalid TraceId in B3 header: null'. Returning INVALID span context." .. Invalid Param.... Below is the log.

2022-03-29 17:36:11.705+00:00 | vert.x-worker-thread-2 | DEBUG | JsonRpcHttpService | JSON-RPC request -> eea_sendRawTransaction
2022-03-29 17:36:11.705+00:00 | vert.x-worker-thread-2 | DEBUG | PrivateTransactionValidator | Validating private transaction MessageCall{nonce=0, gasPrice=0x0000000000000000000000000000000000000000000000000000000000000000, gasLimit=3000000, to=0x000000000000000000000000000000000000007c, value=0x0000000000000000000000000000000000000000000000000000000000000000, sig=Signature{r=16058978644286304058458724073849253893485431500363994063587440206278971209267, s=39891081885136278892597788713517280733448372744091389548146544818622035791148, recId=0}, chainId=1337, payload=0xb4926e2500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002a9458efadc78ddc4067d9207f1a283c555aad4ab3f977749caf32c6929ab537f65cd9a10690192d0f9f8e2087bb76689b06c33f3ea9b4ad37f9594a7ed82c868, privateFrom=0xa9458efadc78ddc4067d9207f1a283c555aad4ab3f977749caf32c6929ab537f, privacyGroupId=0x665d66233266cc955cc6b421d185735529306bfed786882c5b92e361e838b6c9, restriction=RESTRICTED}
2022-03-29 17:36:11.705+00:00 | vert.x-worker-thread-2 | DEBUG | PrivateTransactionValidator | Validating actual nonce 0, with expected nonce 0
2022-03-29 17:36:11.707+00:00 | vert.x-worker-thread-2 | DEBUG | PrivateTransactionValidator | Validating private transaction MessageCall{nonce=0, gasPrice=0x00000000000000000000000000000000000000000000000000000000000003e8, gasLimit=3000000, to=0x000000000000000000000000000000000000007c, value=0x0000000000000000000000000000000000000000000000000000000000000000, sig=Signature{r=57896044618658097711785492504343953926418782139537452191302581570759080747168, s=57896044618658097711785492504343953926418782139537452191302581570759080747168, recId=0}, payload=0x5aa68ac0, privateFrom=0x, privacyGroupId=0x665d66233266cc955cc6b421d185735529306bfed786882c5b92e361e838b6c9, restriction=RESTRICTED}
2022-03-29 17:36:11.707+00:00 | vert.x-worker-thread-2 | DEBUG | PrivateTransactionValidator | Validating actual nonce 0, with expected nonce 0
2022-03-29 17:36:11.712+00:00 | vert.x-worker-thread-2 | DEBUG | PrivateTransactionValidator | Validating private transaction MessageCall{nonce=0, gasPrice=0x00000000000000000000000000000000000000000000000000000000000003e8, gasLimit=3000000, to=0x000000000000000000000000000000000000007c, value=0x0000000000000000000000000000000000000000000000000000000000000000, sig=Signature{r=57896044618658097711785492504343953926418782139537452191302581570759080747168, s=57896044618658097711785492504343953926418782139537452191302581570759080747168, recId=0}, payload=0x0d8e6e2c, privateFrom=0x, privacyGroupId=0x665d66233266cc955cc6b421d185735529306bfed786882c5b92e361e838b6c9, restriction=RESTRICTED}
2022-03-29 17:36:11.712+00:00 | vert.x-worker-thread-2 | DEBUG | PrivateTransactionValidator | Validating actual nonce 0, with expected nonce 0
2022-03-29 17:36:12.001+00:00 | pool-7-thread-3 | DEBUG | MainnetTransactionProcessor | Invalid transaction: transaction nonce 18 does not match sender account nonce 0.
2022-03-29 17:36:12.002+00:00 | pool-7-thread-3 | DEBUG | MainnetTransactionProcessor | Invalid transaction: transaction nonce 19 does not match sender account nonce 0.
2022-03-29 17:36:12.137+00:00 | EthScheduler-Workers-2 | DEBUG | TransactionLogBloomCacher | Caching logs bloom for block 0x60c8.
2022-03-29 17:36:12.143+00:00 | pool-7-thread-3 | DEBUG | BlockMiner | Block creation process cancelled.
2022-03-29 17:36:12.143+00:00 | EthScheduler-Workers-2 | INFO | PersistBlockTask | Imported #24,776 / 0 tx / 0 om / 0 (0.0%) gas / (0xb26ce7e1a7797667e5c2dc9769adc2f036ec8f84c012f0703f51808fa521effe) in 0.019s. Peers: 2
2022-03-29 17:36:12.207+00:00 | vert.x-eventloop-thread-0 | DEBUG | B3PropagatorExtractorMultipleHeaders | Invalid TraceId in B3 header: null'. Returning INVALID span context.
2022-03-29 17:36:12.207+00:00 | vert.x-worker-thread-4 | DEBUG | JsonRpcHttpService | JSON-RPC request -> priv_getTransactionReceipt
2022-03-29 17:36:12.207+00:00 | vert.x-worker-thread-4 | DEBUG | JsonRpcHttpService | Invalid Params
org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters: Missing required json rpc parameter at index 0
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.lambda$required$0(JsonRpcParameter.java:42)
at java.base/java.util.Optional.orElseThrow(Optional.java:408)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.required(JsonRpcParameter.java:40)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest.getRequiredParameter(JsonRpcRequest.java:133)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext.getRequiredParameter(JsonRpcRequestContext.java:64)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetTransactionReceipt.response(PrivGetTransactionReceipt.java:70)
at org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService.process(JsonRpcHttpService.java:721)
at org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService.lambda$handleJsonSingleRequest$13(JsonRpcHttpService.java:585)
at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)

@macfarla
Copy link
Contributor

These DEBUG logs can be ignored: " Invalid TraceId in B3 header: null'. Returning INVALID span context."

This message "Invalid transaction: transaction nonce 19 does not match sender account nonce 0." means that your public transaction nonce is out of sync. This is explained by the failed transactions you've already attempted. If you restart your besu node, the nonce should reset to 0 (pending transactions will be removed). Then you can try sending your transactions again.

@jann2005
Copy link
Author

jann2005 commented Apr 8, 2022

I have re-tested. However , transaction hash is still returning NULL (as described in main issue ). What should I test now?

@macfarla macfarla added the TeamRevenant GH issues worked on by Revenant Team label Apr 18, 2022
@macfarla
Copy link
Contributor

@jann2005 can you share latest logs so we can see what's happening?

@macfarla
Copy link
Contributor

Any update on this one @jann2005?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TeamRevenant GH issues worked on by Revenant Team
Projects
None yet
Development

No branches or pull requests

2 participants