Closed edzillion closed 5 years ago
Is there any reason to believe the nonce shouldn't be 0? If this is your first transaction, 0 is the right nonce.
I don't know about the invalid response - 0
, but this looks correct:
truffle(development)> let r = await TxRelay.at('0xEc0F9905ae534d4a15d55c687045338Ed5e8fe78')
undefined
truffle(development)> r.getNonce('0xEc0F9905ae534d4a15d55c687045338Ed5e8fe78')
<BN: 0>
Yeah @shkfnly said the same thing: that a 0 response was valid.
Figured it out with @edzillion today. Client was not connected to a blockchain instance.
see: https://github.com/ethers-io/ethers.js/issues/362
Remarkably unhelpful error message from ethers.js
....
Nope. Not fixed.
main_1 | {"message":"[POST] /v1.1.2/relayer/relay","level":"info"}
main_1 | {"message":"Error on getRelayNonce","level":"error"}
But it errors at a different point now:
const result = await metaTxHandler.handle(req)
fromcircles-api
relayController
here:
https://github.com/CirclesUBI/circles-api/blob/1eab92d26c9b5acfa22d7bcbca1d0e534757eb12/src/controllers/relayerController.js#L20
The original error is coming from metatx-server
line 220:
Ok this error is different but for the sake of simplicity I am going to keep the issue here.
It's now erroring
Invalid JSON RPC response: ""
On this line:
const price = await this.web3.eth.getGasPrice()
Very strange because this same function works fine elsewhere in the same file.
I have uninstalled and reinstalled the following packages at the same versions:
"eth-signer": "0.3.4",
"ethereumjs-tx": "1.3.7",
"web3": "1.0.0-beta.48",
"ganache-cli": "6.4.1"
I added a lot of logs to try to figure out where the web3.eth
connection goes down and it seems to be the line just before:
async signRelayerTx (txHex) {
let gp = await this.web3.eth.getGasPrice()
console.log('signRelayerTx', gp)
if (!txHex) throw new Error('no txHex')
const tx = new Transaction(Buffer.from(txHex, 'hex'))
gp = await this.web3.eth.getGasPrice()
console.log('signRelayerTx2', gp)
It fails at the second call to getGasPrice
so something is happening on this line that kills the connection:
const tx = new Transaction(Buffer.from(txHex, 'hex'))
edit: I doubt this is it actually, seems that the failure happens during the time when the debugger is stopping at the breakpoint
Ran all the contract tests locally and they all passed.
59 passing (19s)
I have tested this on iOS on a iphone emulator and same problem occurs.
Posted the issue to the web3
repo FWIW: https://github.com/ethereum/web3.js/issues/2916
Switched to WebsocketProvider
and now I don't have the connection problems.
But both the estimateGas()
and the sendSignedTransaction()
call right at the end are being reverted.
I triggered it through the app and got this error:
(node:21404) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated
Node error: {"message":"VM Exception while processing transaction: revert","code":-32000,"data":{"0xee7231ccd666fe808eception while processing transaction: revert\n at Function.o.fromResults (/app/ganache-core.docker.cli.js:10:82299)che-core.docker.cli.js:47:127744)\n at /app/ganache-core.docker.cli.js:47:127797\n at t.default (/app/ganache-cocli.js:61:1043069)\n at /app/ganache-core.docker.cli.js:61:1681866\n at /app/ganache-core.docker.cli.js:61:16818che-core.docker.cli.js:2:84062)\n at /app/ganache-core.docker.cli.js:2:64530\n at process._tickCallback (internaert","code":-32000,"data":{"0xee7231ccd666fe808e1e5963f5e8b5e28abe7cf23025490ad4d67a44802d2497":{"error":"revert","prosults (/app/ganache-core.docker.cli.js:10:82299)\n at /app/ganache-core.docker.cli.js:47:151347\n at /app/ganach.js:47:127797\n at t.default (/app/ganache-core.docker.cli.js:52:259841)\n at /app/ganache-core.docker.cli.js:47n at /app/ganache-core.docker.cli.js:61:1681889\n at /app/ganache-core.docker.cli.js:61:345680\n at /app/ganas:2:64530\n at process._tickCallback (internal/process/next_tick.js:61:11)","name":"o"}}
I logged the signed raw tx just before the sendSignedTransaction()
call, and then ran that through the console & got the same error:
# truffle console
truffle(development)> let st = await web3.eth.sendSignedTransaction("0xf901ea808504a817c800833d0900940a2cfc3b0475ba28517a6ce223790aa8729e462ca1d06b00f21405780fdc8622baef575727c62418e15928c61a00365bef27d9f8128f022a3956427cdda269100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000086e616e616e616e6100000000000000a4fe5bbf3cf2c1e4c78fa749b59499ceb91a02419ae923acdc79a2d074781c4fde8988fce939cd5425e8eb4b25ac20cecca09")
Thrown:
Error: Returned error: VM Exception while processing transaction: revert
at XMLHttpRequest._onHttpResponseEnd (C:\Users\ed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2-c
at XMLHttpRequest._setReadyState (C:\Users\ed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2-cooki
at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\ed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\
at XMLHttpRequest.request.onreadystatechange (C:\Users\ed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\
at C:\Users\ed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-provider\wrapper.js:112:1
at C:\Users\ed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3-eth\~\web3-core-requestmanager\src\i
at Object.ErrorResponse (C:\Users\ed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3-eth\~\web3-cortruffle(development)>
the code mentioned code -32000
looks similar to this issue, which is related to a package we are using (ethereumjs-tx
). I tried using the 2.0.0
version of the package and got the same error mentioned in that issue.
So looking though the ganache-core
codebase that -32000
code appears to be a problem with subscriptions, which should not happen with the WebSocketprovider
we are now using.
https://github.com/trufflesuite/ganache-core/search?q=%2232000%22&unscoped_q=%2232000%22
Perhaps this was due to my node version being 10.16.0. when I changed to 10.13.0 it worked.
Authsaga.js:
const tx = yield metaTxGenerator.generateMetaTxHash(senderKeyPair, to, data)
metatx-client:
async generateMetaTxHash (keyPair, to, data) { let relayNonce = await this._getNonce(keyPair.address)
...async _getNonce (senderAddress) { console.log('senderAddress', senderAddress) try { let boob = await this.relayContract.getNonce(senderAddress)
the last line errors with:
I have tried running
truffle console
with the output of thesenderAddress
console log above:Apparently, every address run through
getNonce()
will return<BN: 0>