ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
889 stars 131 forks source link

RecursionError when running tests #2206

Closed xrchz closed 3 months ago

xrchz commented 3 months ago

Environment information

$ ape --version
0.8.10
$ ape plugins list
Installed Plugins
  ens 0.8.0
  etherscan 0.8.2
  foundry 0.8.2
  vyper 0.8.4
$ cat ape-config.yaml
plugins:
  - name: vyper
  - name: foundry
  - name: etherscan
foundry:
  host: auto

›What went wrong?

Please include information like:

/home/ramana/vyper/lidont/tests/test_lidont.py:110: in test_cannot_deposit_not_approved
    with reverts("revert: ALLOWANCE_EXCEEDED"):
E   AssertionError: Transaction did not revert.
E   However, an exception of type <class 'RecursionError'> occurred: nonreentrant ContractCache.get:0x2b33CF282f867A7FF693A66e11B0FcC5552e4425.
        ETH_pipe_added = {'pipe': <ETH-pipe 0x33f4f8bf90d8AA3d19fF812B50e79c15Df0d0b03>, 'toggle_valid_receipt': <SharedBlobReceipt 0x24cca334594e0b3f2eb757db665eb6880d0085fc62ce8878fe96e704706d7b39>}
        accounts   = [0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, 0x70997970C51812dc3A010C7d01b50e0d17dc79C8, 0x3C44CdDdB6a900fa2b585dd299e...a2C08b23698B3D3cc7Ca32193d9955, 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f, 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720]
        have_stETH = <SharedBlobReceipt 0xbf36a2e96ca87267a542f219e5d118bb56543f76238e7b942a9be2e05d8eda3c>
        withdrawler = <withdrawler 0xE5b6F5e695BA6E4aeD92B68c4CC8Df1160D69A81>

How can it be fixed?

Fill this in if you have ideas on how the bug could be fixed.

linear[bot] commented 3 months ago

APE-1792 RecursionError when running tests

antazoey commented 3 months ago

Interesting. The recursion error comes from our non-reentrant function (Added in this PR: https://github.com/ApeWorX/ape/pull/1503)

Which I thought existed for unrelated reasons to testing.

I'll investigate more.

antazoey commented 3 months ago

I see some weird things probably related this in the test code, like the usage of internal methods rather than public ape apis.

for example:

project._get_attr('ETH-pipe')

should probably be

project.get_contract('ETH-pipe')

etc.

Edit: after i fixed this locally, I was able to reproduce the failure.

xrchz commented 3 months ago

Yes sorry I already had that fix but hadn't committed - now committed it.

antazoey commented 3 months ago

OK so we fixed the bug, thank you so much for raising this issue. It is not only a bug-fix but a performance upgrade as well (going to try and do some measuring on that).