WhiteflagProtocol / whiteflag-api

Reference implementation of the Whiteflag protocol in Node.js that acts as an API to connect applications with the underlying blockchains
https://api.whiteflagprotocol.org
Other
4 stars 5 forks source link

No confirmation after succesfull message transmission on Ethereum #7

Closed ts5746 closed 5 years ago

ts5746 commented 5 years ago

Description

Seems to be an issue with API receiving a transaction confirmation / receipt from the Ethereum blockchain after successful transmission of a message.

Environment / Versions

Software

Blockchain

Ethereum-rinkeby

Symptoms and Problem details

Step to reproduce

Post a valid message on the Ethereum blockchain through the /messages/send endpoint.

Expected result

An HTTP response with status code 200.

Actual result

The result is a timeout and no response is received. Nevertheless, the message is received by other nodes. However, any automatically generated second message is not sent (e.g. a K message with IV after an encrypted message, or a K message with ECDH public key after an A message).

ts5746 commented 5 years ago

It seems that the Whiteflag API does not get the expected receipt after a successful transaction. Needs further investigation.

ts5746 commented 5 years ago

Reproduced on a system that is not behind a reverse proxy. The web3.eth.sendSignedTransaction call in lib/blockchains/ethereum.js returns a promise that unexpectedly rejects, even though the transaction has been processed and also without passing an error err to the function called upon rejection. Eventually the API therefore return a 500 status code.

Updating the web3 package to latest beta version before further testing.

ts5746 commented 5 years ago

Implemented an elaborate use of the promise combined event emitter. The Ethereum web3 API is not fully stable. It seems that the transaction receipt is often returned by a confirmation event rather than by the receipt event or resolved promise. Fix in commit 6367ef6c9ebcdf83c1663afc67b40200c5df54bf (to be further tested).

ts5746 commented 5 years ago

The fix is tested with multiple F messages, and with F/K and A/K message sequences and available in with version 1.0.0-alpha.2 (#8).