Closed sajal closed 4 months ago
This seems like it was resolved within titanoboa
¿Qué pasó?
Estamos intentando probar nuestro contrato que utiliza almacenamiento transitorio y nos damos cuenta de que persiste cuando lo probamos con boa+pyevm. Este problema no parece ocurrir cuando se realizan pruebas con ape+hardhat. No estoy seguro de si se trata de un error de boa o pyevm, o de que estoy haciendo algo tonto.
Código que produjo el error
import boa def test_transient(): cont = boa.loads(""" #pragma version 0.3.10 #pragma optimize codesize #pragma evm-version cancun cache: transient(uint256) @external def __init__(): pass @external @nonpayable def set(num: uint256): self.cache = num @external @nonpayable def get() -> uint256: return self.cache """) assert cont.get() == 0 cont.set(100) assert cont.get() == 0
Salida de error completa
(.venv) sajal@sajal-thinkpad:~/workspace/SNIP$ pytest -s tests_boa/test_transient.py ============================================================================================================= test session starts ============================================================================================================== platform linux -- Python 3.10.12, pytest-7.4.4, pluggy-1.5.0 -- /home/sajal/workspace/SNIP/.venv/bin/python cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/home/sajal/workspace/SNIP/.hypothesis/examples')) rootdir: /home/sajal/workspace/SNIP plugins: hypothesis-6.100.4, web3-6.18.0, titanoboa-0.1.10b1, eth-ape-0.7.19.dev1+g2b92c460, cov-5.0.0 collected 1 item tests_boa/test_transient.py::test_transient FAILED =================================================================================================================== FAILURES =================================================================================================================== ________________________________________________________________________________________________________________ test_transient ________________________________________________________________________________________________________________ /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/runner.py:341: in from_call result: Optional[TResult] = func() cls = <class '_pytest.runner.CallInfo'> duration = 0.006614762358367443 excinfo = <ExceptionInfo AssertionError('assert 100 == 0\n + where 100 = VyperContract.get()\n + where VyperContract.get = <...at 0x0880cf17Bd263d3d3a5c09D2D86cCecA3CcbD97c, compiled with vyper-0.3.10+9136169>\\n<storage: cache=0>.get') tblen=16> func = <function call_runtest_hook.<locals>.<lambda> at 0x7fea71c38700> precise_start = 5257806.917176024 precise_stop = 5257806.923790786 reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>) result = None start = 1715333968.3404593 stop = 1715333968.347075 when = 'call' /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/runner.py:262: in <lambda> lambda: ihook(item=item, **kwds), when=when, reraise=reraise ihook = <HookCaller 'pytest_runtest_call'> item = <Function test_transient> kwds = {} /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_hooks.py:513: in __call__ return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) firstresult = False kwargs = {'item': <Function test_transient>} self = <HookCaller 'pytest_runtest_call'> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_manager.py:120: in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) firstresult = False hook_name = 'pytest_runtest_call' kwargs = {'item': <Function test_transient>} methods = [<HookImpl plugin_name='runner', plugin=<module '_pytest.runner' from '/home/sajal/workspace/SNIP/....=None>>, <HookImpl plugin_name='logging-plugin', plugin=<_pytest.logging.LoggingPlugin object at 0x7feaa7660340>>, ...] self = <_pytest.config.PytestPluginManager object at 0x7feaa7f00b50> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_callers.py:182: in _multicall return outcome.get_result() __tracebackhide__ = True args = [<Function test_transient>] caller_kwargs = {'item': <Function test_transient>} exception = AssertionError('assert 100 == 0\n + where 100 = VyperContract.get()\n + where VyperContract.get = <VyperContract at 0x0880cf17Bd263d3d3a5c09D2D86cCecA3CcbD97c, compiled with vyper-0.3.10+9136169>\\n<storage: cache=0>.get') firstresult = False hook_impl = <HookImpl plugin_name='runner', plugin=<module '_pytest.runner' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/runner.py'>> hook_impls = [<HookImpl plugin_name='runner', plugin=<module '_pytest.runner' from '/home/sajal/workspace/SNIP/....=None>>, <HookImpl plugin_name='logging-plugin', plugin=<_pytest.logging.LoggingPlugin object at 0x7feaa7660340>>, ...] hook_name = 'pytest_runtest_call' only_new_style_wrappers = False outcome = <pluggy._result.Result object at 0x7fea73006b30> res = <generator object pytest_runtest_call at 0x7fea71d23990> results = [] teardown = (<generator object PytestApeRunner.pytest_runtest_call at 0x7fea71d23450>, <HookImpl plugin_name='ape-test', plugin=<ape.pytest.runners.PytestApeRunner object at 0x7fea73307c70>>) teardowns = [(<generator object PytestApeRunner.pytest_runtest_call at 0x7fea71d23450>, <HookImpl plugin_name='ape-test', plugin=<...in' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/boa/test/plugin.py'>>), ...] wrapper_gen = <generator object pytest_runtest_call at 0x7fea71d23990> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_result.py:100: in get_result raise exc.with_traceback(exc.__traceback__) __tracebackhide__ = True exc = AssertionError('assert 100 == 0\n + where 100 = VyperContract.get()\n + where VyperContract.get = <VyperContract at 0x0880cf17Bd263d3d3a5c09D2D86cCecA3CcbD97c, compiled with vyper-0.3.10+9136169>\\n<storage: cache=0>.get') self = <pluggy._result.Result object at 0x7fea73006b30> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_callers.py:103: in _multicall res = hook_impl.function(*args) __tracebackhide__ = True args = [<Function test_transient>] caller_kwargs = {'item': <Function test_transient>} exception = AssertionError('assert 100 == 0\n + where 100 = VyperContract.get()\n + where VyperContract.get = <VyperContract at 0x0880cf17Bd263d3d3a5c09D2D86cCecA3CcbD97c, compiled with vyper-0.3.10+9136169>\\n<storage: cache=0>.get') firstresult = False hook_impl = <HookImpl plugin_name='runner', plugin=<module '_pytest.runner' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/runner.py'>> hook_impls = [<HookImpl plugin_name='runner', plugin=<module '_pytest.runner' from '/home/sajal/workspace/SNIP/....=None>>, <HookImpl plugin_name='logging-plugin', plugin=<_pytest.logging.LoggingPlugin object at 0x7feaa7660340>>, ...] hook_name = 'pytest_runtest_call' only_new_style_wrappers = False outcome = <pluggy._result.Result object at 0x7fea73006b30> res = <generator object pytest_runtest_call at 0x7fea71d23990> results = [] teardown = (<generator object PytestApeRunner.pytest_runtest_call at 0x7fea71d23450>, <HookImpl plugin_name='ape-test', plugin=<ape.pytest.runners.PytestApeRunner object at 0x7fea73307c70>>) teardowns = [(<generator object PytestApeRunner.pytest_runtest_call at 0x7fea71d23450>, <HookImpl plugin_name='ape-test', plugin=<...in' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/boa/test/plugin.py'>>), ...] wrapper_gen = <generator object pytest_runtest_call at 0x7fea71d23990> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/runner.py:177: in pytest_runtest_call raise e item = <Function test_transient> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/runner.py:169: in pytest_runtest_call item.runtest() item = <Function test_transient> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/python.py:1792: in runtest self.ihook.pytest_pyfunc_call(pyfuncitem=self) self = <Function test_transient> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_hooks.py:513: in __call__ return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) firstresult = True kwargs = {'pyfuncitem': <Function test_transient>} self = <HookCaller 'pytest_pyfunc_call'> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_manager.py:120: in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) firstresult = True hook_name = 'pytest_pyfunc_call' kwargs = {'pyfuncitem': <Function test_transient>} methods = [<HookImpl plugin_name='python', plugin=<module '_pytest.python' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/python.py'>>] self = <_pytest.config.PytestPluginManager object at 0x7feaa7f00b50> /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_callers.py:139: in _multicall raise exception.with_traceback(exception.__traceback__) __tracebackhide__ = True args = [<Function test_transient>] caller_kwargs = {'pyfuncitem': <Function test_transient>} exception = AssertionError('assert 100 == 0\n + where 100 = VyperContract.get()\n + where VyperContract.get = <VyperContract at 0x0880cf17Bd263d3d3a5c09D2D86cCecA3CcbD97c, compiled with vyper-0.3.10+9136169>\\n<storage: cache=0>.get') firstresult = True hook_impl = <HookImpl plugin_name='python', plugin=<module '_pytest.python' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/python.py'>> hook_impls = [<HookImpl plugin_name='python', plugin=<module '_pytest.python' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/python.py'>>] hook_name = 'pytest_pyfunc_call' only_new_style_wrappers = True result = None results = [] teardowns = [] /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/pluggy/_callers.py:103: in _multicall res = hook_impl.function(*args) __tracebackhide__ = True args = [<Function test_transient>] caller_kwargs = {'pyfuncitem': <Function test_transient>} exception = AssertionError('assert 100 == 0\n + where 100 = VyperContract.get()\n + where VyperContract.get = <VyperContract at 0x0880cf17Bd263d3d3a5c09D2D86cCecA3CcbD97c, compiled with vyper-0.3.10+9136169>\\n<storage: cache=0>.get') firstresult = True hook_impl = <HookImpl plugin_name='python', plugin=<module '_pytest.python' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/python.py'>> hook_impls = [<HookImpl plugin_name='python', plugin=<module '_pytest.python' from '/home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/python.py'>>] hook_name = 'pytest_pyfunc_call' only_new_style_wrappers = True result = None results = [] teardowns = [] /home/sajal/workspace/SNIP/.venv/lib/python3.10/site-packages/_pytest/python.py:194: in pytest_pyfunc_call result = testfunction(**testargs) funcargs = {'_function_isolation': None} pyfuncitem = <Function test_transient> testargs = {} testfunction = <function test_transient at 0x7fea73386950> /home/sajal/workspace/SNIP/tests_boa/test_transient.py:28: in test_transient assert cont.get() == 0 E assert 100 == 0 E + where 100 = VyperContract.get() E + where VyperContract.get = <VyperContract at 0x0880cf17Bd263d3d3a5c09D2D86cCecA3CcbD97c, compiled with vyper-0.3.10+9136169>\n<storage: cache=0>.get cont = <VyperContract at 0x0880cf17Bd263d3d3a5c09D2D86cCecA3CcbD97c, compiled with vyper-0.3.10+9136169> <storage: cache=0> =========================================================================================================== short test summary info ============================================================================================================ FAILED tests_boa/test_transient.py::test_transient - assert 100 == 0 ============================================================================================================== 1 failed in 0.49s ===============================================================================================================
Complete esta sección si sabe cómo esto podría o debería solucionarse
Borre las ranuras de almacenamiento transitorio al final de cada transacción
Versión py-evm
0.10.1b1
Versión de Python
3.10.12
Sistema operativo
Linux 6.5.0-21-genérico
Salida de pip-freeze
aiohttp==3.9.5 aiosignal==1.3.1 annotated-types==0.6.0 ape-alchemy==0.7.2 ape-hardhat==0.7.2 ape-vyper==0.7.1 asttokens==2.4.1 async-timeout==4.0.3 attrs==23.2.0 base58==1.0.3 bitarray==2.9.2 cached-property==1.5.2 cbor2==5.6.3 certifi==2024.2.2 cffi==1.16.0 charset-normalizer==3.3.2 chompjs==1.2.3 ckzg==1.0.1 click==8.1.7 coverage==7.5.1 cryptography==42.0.5 cytoolz==0.12.3 dataclassy==0.11.1 decorator==5.1.1 Deprecated==1.2.14 eip712==0.2.7 eth-account==0.11.2 eth-ape @ git+https://github.com/BiggestLab/ape.git@2b92c460e2fafb398fe3c322cc6a4a382354f83d eth-bloom==3.0.1 eth-hash==0.7.0 eth-keyfile==0.8.1 eth-keys==0.5.1 eth-pydantic-types==0.1.0 eth-rlp==1.0.1 eth-stdlib==0.2.7 eth-tester==0.11.0b2 eth-typing==3.5.2 eth-utils==2.3.1 eth_abi==5.1.0 ethpm-types==0.6.11 evm-trace==0.1.5 evmchains==0.0.7 exceptiongroup==1.2.1 executing==2.0.1 frozenlist==1.4.1 greenlet==3.0.3 hexbytes==0.3.1 hypothesis==6.100.4 idna==3.7 ijson==3.2.3 importlib_metadata==7.1.0 iniconfig==2.0.0 ipython==8.24.0 jedi==0.19.1 jsonschema==4.21.1 jsonschema-specifications==2023.12.1 lazyasd==0.1.4 lru-dict==1.2.0 markdown-it-py==3.0.0 matplotlib-inline==0.1.7 mdurl==0.1.2 morphys==1.0 msgspec==0.18.6 multidict==6.0.5 numpy==1.26.4 packaging==23.2 pandas==1.5.3 parsimonious==0.10.0 parso==0.8.4 pexpect==4.9.0 pluggy==1.5.0 plyvel==1.5.1 prompt-toolkit==3.0.43 protobuf==5.26.1 ptyprocess==0.7.0 pure-eval==0.2.2 py-cid==0.3.0 py-ecc==7.0.1 py-evm==0.10.1b1 py-geth==4.4.0 py-multibase==1.0.3 py-multicodec==0.2.1 py-multihash==0.2.3 pycparser==2.22 pycryptodome==3.20.0 pydantic==2.7.1 pydantic-settings==2.2.1 pydantic_core==2.18.2 PyGithub==1.59.1 Pygments==2.17.2 PyJWT==2.8.0 PyNaCl==1.5.0 pytest==7.4.4 pytest-cov==5.0.0 python-baseconv==1.2.2 python-dateutil==2.9.0.post0 python-dotenv==1.0.1 pytz==2024.1 pyunormalize==15.1.0 PyYAML==6.0.1 referencing==0.35.0 regex==2024.4.28 requests==2.31.0 rich==13.7.1 rlp==4.0.1 rpds-py==0.18.0 safe-pysha3==1.0.4 semantic-version==2.10.0 six==1.16.0 sortedcontainers==2.4.0 SQLAlchemy==2.0.29 stack-data==0.6.3 terminaltables==3.1.10 titanoboa @ git+https://github.com/vyperlang/titanoboa@4eaa59e6c4d884e6280e0d970e566044271942a6 tomli==2.0.1 toolz==0.12.1 tqdm==4.66.2 traitlets==5.14.3 trie==3.0.1 typing_extensions==4.11.0 ujson==5.9.0 urllib3==2.2.1 varint==1.0.2 vvm==0.2.0 vyper==0.3.10 watchdog==3.0.0 wcwidth==0.2.13 web3==6.18.0 websockets==12.0 wrapt==1.16.0 yarl==1.9.4 zipp==3.18.1
What happened?
We are trying to test our contract that uses transient storage and realize that its persisting when testing using boa+pyevm. This issue doesn't appear to occur when testing using ape+hardhat. I'm not sure if this is a bug with boa, or pyevm, or that I'm doing something silly.
Code that produced the error
Full error output
Fill this section in if you know how this could or should be fixed
Clear transient storage slots at end of each transaction
py-evm Version
0.10.1b1
Python Version
3.10.12
Operating System
Linux 6.5.0-21-generic
Output from pip-freeze