Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix: gethify eth call errors (#2133) #2186

Merged
merged 12 commits into from
Jan 25, 2022
Merged

Conversation

MicaiahReid
Copy link
Contributor

@MicaiahReid MicaiahReid commented Jan 25, 2022

Before this change, errors from eth_call were formatted in our "non-standard" vmErrorsOnRPCResponse format, which uses the error's data property to store some extra helpful information (program counter, hash, etc.):

{
   "error": {
     "message": "...",
     "code": ...
     "data": {
          ... bunch of props, like `hash` and `programCounter`...
         "result": "<raw revert hex string>" <---- this moves (See below)
     }
   } 
}

Now, the error's data property only contains the raw revert hex string, which should more closely match real node's error handling:

{
   "error": {
     "message": "...", // <- we'll change the message
     "code": ...
     "data": "<raw revert hex string>"  <---- new home
   } 
}

Our hope is that this will allow users to remove any conditionals handling errors differently between Ganache and real Ethereum nodes.

@MicaiahReid MicaiahReid changed the title fix: gethify eth call errors fix: gethify eth call errors (#2133) Jan 25, 2022
@MicaiahReid MicaiahReid merged commit d5c3bcb into develop Jan 25, 2022
@MicaiahReid MicaiahReid deleted the fix/gethify-eth_call-errors branch January 25, 2022 21:24
@fabianorodrigo
Copy link

Guys,
I have a doubt about this changes implemented on v7.0.1.

I'm using the package @openzeppelin/test-helpers in my unit tests, where I have oracles like this:

await expectRevert( gameContract.bet(score, betTokenAmount, { from: bettor, }), "ERC20: transfer amount exceeds allowance" );
Won't Ganache give me that message I passed to revert inside my contract?

Sorry if I misunderstand. It's because when I run run the above test on Ganache v2.5.4 it works/passes, but after upgrading to v7.0.1 it's failing:

`
Wrong kind of exception received
+ expected - actual

  -Transaction: 0x3dfa34902aaceb3fd6e7176180d65bc9c0b7ec664ddad54c5700ab2f42d6214c exited with an error (status 0). 
  -     Please check that the transaction:
  -     - satisfies all conditions set by Solidity `require` statements.
  -     - does not trigger a Solidity `revert` statement.
  +ERC20: transfer amount exceeds allowance`

@davidmurdoch
Copy link
Member

@fabianorodrigo Have you updated your truffle version to the latest version?

@cds-amal
Copy link
Member

cds-amal commented Feb 2, 2022

hi @fabianorodrigo, you'll need to update to the latest version of truffle npm -g uninstall truffle && npm -g install truffle and your project tests should work. Note, I pushed a PR to align your tests with openzeppelin-test-helper documentation that you should review.

@fabianorodrigo
Copy link

@cds-amal ,
Thank you very much! I've already updated to Truffle v5.4.31 but after reading your answer I realized that it was at another workstation.
Now I updated Truffle and everything is fine.
Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants