-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: handle error and revert data in EthEstimateGas and EthCall #12553
Conversation
@aarshkshah1992 I am using lotus/node/impl/full/eth_utils.go Line 333 in 0e7292a
|
Best way to test this is to write an itest that deploys a contract that does a divide by 0 (so there's a revert) -> send a transaction that executes the contract -> see what error you get when you call I think you'll then see what I'm talking about. The client should see the contract revert reason in the |
@virajbhartiya: I assume you'll re-request review when you're ready for review again. |
Hey @BigLep, yes I'll request a re-review, currently I'm running into a few issues while testing out on devnet so working on fixing those. |
@aarshkshah1992 me and @virajbhartiya was discussing about returning The changes I have pushed are not complete, need to get your thoughts on it, then will finish the changes. |
@akaladarshi Would be great to first get this working e2e on a calibnet node and we can then discuss the exact semantics of the error message. Also, thanks to both for this ! |
@aarshkshah1992 here is the Here is the response from ethereum node for same data |
@akaladarshi @virajbhartiya Great stuff ! That looks correct. Can you also confirm that we ONLY get this data field for contract reverts and that the response for all other errors is the same as it was before ? Once you confirm that, I think we can implement this for the other API as well. Thanks a lot. |
Reviewed. Thanks a lot. Also need to rebase this on master and fix the conflicts. |
Let's address the current batch of comments for which we have solid answers to @akaladarshi. For stuff that is still unclear/ambiguous -> we can then request a review from Stebalien 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty close, some minor, mostly cosmetic suggestions
Also, I'm down to 2 failures in my local branch of https://github.com/filecoin-project/fevm-contract-tests and I think one of them is about a missing data
field for a reverted contract, so I believe this will solve that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just the go-jsonrpc dependency bump and we can merge this
@virajbhartiya We need to update the version of |
👌 very nice work @akaladarshi & @virajbhartiya! Especially challenging in that you had to coordinate design changes across repos. |
Flagging that I'm having some problems with this testing fevm-contract-tests, I'm not sure we're doing a better job of conforming to expected go-ethereum output with this. Most interestingly, there's a relevant chai assertion from Waffle that's now failing a lot with the Uniswap tests, So I'm getting failures like this:
Coming out of an assertion like this: await expect(reentrant.swapToReenter(pool.address)).to.be.revertedWith('Unable to reenter') Which I believe is unmodified from the upstream uniswap tests. I think that it's worked previously because we included the revert reason in the string and it matches the hardhat way of doing reverts (see Maybe we should be returning the hex string rather than decoding it ourselves in lotus/node/impl/full/eth_utils.go Line 333 in 2387b18
|
Recording some investigation progress as I try and get to the bottom of this. I modified err := &ErrExecutionReverted{
Message: fmt.Sprintf("execution reverted (code=%d, reason=%s, vm error=%s)", exitCode, reason, error),
Data: fmt.Sprintf("0x%x", data),
} If I curl the exact request that the test I'm looking at is making, I can see its response is: {
"error": {
"code": 11,
"message": "execution reverted (code=33, reason=message failed with backtrace:\n00: f01004 (method 3844450837) -- contract reverted (33)\n (RetCode=33), vm error=Error(OLD))",
"data": "0x586408c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034f4c44000000000000000000000000000
0000000000000000000000000000000"
},
"id": 46,
"jsonrpc": "2.0"
} Which has our decoded error message in it, and the point of But modifying
Where's the error message gone? Has our new The code for const reasonsList = error.results && Object.values(error.results).map((o) => o.reason);
const message = (error instanceof Object && 'message' in error) ? error.message : JSON.stringify(error);
const isReverted = reasonsList
? reasonsList.some((r) => r === revertReason)
: message.includes('revert') && message.includes(revertReason); We don't have a |
It seems to be all about the fail: {
"error": {
"code": 1,
"message": "message execution failed: exit 33, revert reason: message failed with backtrace:\n00: f01004 (method 3844450837) -- contract reverted (33)\n (RetCode=33), vm error: Error(O
LD)",
"data": "0x586408c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034f4c440000000000000000000000000000000000000000000000000000000000"
},
"id": 46,
"jsonrpc": "2.0"
} fail: {
"error": {
"code": 11,
"message": "execution reverted (code=33, reason=message failed with backtrace:\n00: f01004 (method 3844450837) -- contract reverted (33)\n (RetCode=33), vm error=Error(OLD))",
"data": "0x586408c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034f4c440000000000000000000000000000000000000000000000000000000000"
},
"id": 46,
"jsonrpc": "2.0"
} pass: {
"error": {
"code": 1,
"message": "message execution failed: exit 33, revert reason: message failed with backtrace:\n00: f01004 (method 3844450837) -- contract reverted (33)\n (RetCode=33), vm error: Error(OLD)"
},
"id": 46,
"jsonrpc": "2.0"
} pass: {
"error": {
"code": 11,
"message": "message execution failed: exit 33, revert reason: message failed with backtrace:\n00: f01004 (method 3844450837) -- contract reverted (33)\n (RetCode=33), vm error: Error(OLD)"
},
"id": 46,
"jsonrpc": "2.0"
} pass: {
"error": {
"code": 11,
"message": "execution reverted (code=33, reason=message failed with backtrace:\n00: f01004 (method 3844450837) -- contract reverted (33)\n (RetCode=33), vm error=Error(OLD))"
},
"id": 46,
"jsonrpc": "2.0"
} |
Got it, Basically, we use cbor to pass these things around, but cbor is foreign to eth-land so we need to unpack. |
addressed in #12675 |
Related Issues
Closes #10311
Proposed Changes
Modified
EthCall
andEthEstimateGas
to handle errors and revert dataChecklist
Before you mark the PR ready for review, please make sure that: