-
Notifications
You must be signed in to change notification settings - Fork 5k
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
A contract call which triggers multiple events of the same name throws error (but tx is successful) #2542
Comments
Thanks for opening this issue! I'll test and fix it if required asap. |
I've opened a PR to fix the issue whereby web3 thinks a successful tx was a revert |
I just verified angus-hamill's fix, I am running into the same issue against an actual geth node vs ganache on beta 50 |
Am having a duplicate issue, my TX receipt is {... "status": true ...} and parseInt(true) resolves to NaN, which is boolean falsy in JS. This happens for me with contract creation under betas 48 & 50. I fixed with Boolean(parseInt(receipt.status) || receipt.status) but @angus-hamill has a more appropriate method in the PR for production, it looks like. |
I found the real source of this issue if you check the PR. Turns out it is actually a web3js problem and not just caused by supporting ganache |
@angus-hamill would you mind re-opening this PR, currently web3 throws an error for all tx against a live Geth node which is a non-starter |
I don't have permission to unfortunately! |
@HardlyDifficult Also running into this issue |
This is an ongoing issue, parsing returned receipts is currently being done incorrectly. I'm handling it in my project as detailed with my comment here but the code can also be "fixed" by patching the responsible observer function. My file at /node_modules/web3-core-method/lib/methods/transaction/AbstractObservedTransactionMethod.js just needed the following change:
|
This also appears to be related to this issue which was apparently fixed (?) already. Possible revert? |
Running into this issue on Beta 50 |
@SwissArmyBud This isn't an issue of web3.js. The status field should have the value https://wiki.parity.io/JSONRPC-eth-module#eth_gettransactionreceipt |
@nivida This is an issue with THIS line in the incoming receipt formatter being passed to THIS line which I mentioned in the PR post I put up. Currently this is probably breaking the following Issues ( ONE, TWO, THREE, FOUR ) and is because Web3 is calling Boolean(parseInt(receipt.status)) on a boolean output from its own Formatter.js, linked above. My receipt from Geth is the following BEFORE the formatter:
You will notice it follows the correct HEX encoding for the "status" field. My receipt from Geth is the following AFTER the formatter:
The formatter has now turned my API correct HEX value into a Type(Boolean). Web3 then uses that formatted receipt to check (in the AbstractObserver, linked above) the following
So essentially, once the transaction receipt passes through the Formatter, the Observer will NEVER see the receipt as passing the EVM revert check. This is obviously incorrect behavior. |
Filed a PR, in the mean time anyone who doesn't mind compiling/using their own Web3 modules can grab a copy from the fix branch. |
For people looking for a workaround: As per this comment, it seems to work if you manually encode and send the transaction. Instead of: contract.methods.myMethod(...input).send() Use: web3.eth.sendTransaction({
to: contract.address,
data: web3.eth.abi.encodeFunctionCall(
contract.jsonInterface.getMethod('myMethod').abiItem,
input,
),
}) (Note that the snippets above are using web3@2.0.0-alpha.1 which has a slightly different ABI class/api I believe.) |
Description
When a contract has an event defined and attempts to make an external call to another contract which emits an event with the same name, the call fails.
More specifically: we are creating a contract with implements ERC721. ERC721 has the following event:
Our contract then attempts to call transferFrom on an ERC20 token, which emits the following:
The issue occurs when that Transfer event is emitted.
I've tested this using Truffle, Web3 beta 37, and Web3 beta 50. All of them fail, but each in a slightly different way.
Expected behavior
Calling a function which triggers multiple events which happened to be named the same should work like any other call.
Actual behavior
Web3 beta 50 throws the error below. However if you catch the error and ignore it, the transaction is successful.
Steps to reproduce the behavior
I created a sample repo which tries to demonstrate the issue using as simple of contracts as possible: https://github.com/hardlydifficult/SolidityBugInvestigation_EventsWithTheSameName
Clone the repo and run
And see
test/Test.js
Error Logs
Gists
Versions
This was originally filled with Truffle here: trufflesuite/truffle#1729
But after more investigation, it appears to be a Web3 issue.
The text was updated successfully, but these errors were encountered: