ethereum / eth-tester

Tool suite for testing ethereum applications.
MIT License
365 stars 148 forks source link

`time_travel` still time travels during an exception #296

Open antazoey opened 3 months ago

antazoey commented 3 months ago

What happened?

I tried time traveling to the same time as the current timestamp, and it errored. However, the pending timestamp still seems to have changed.

Code that produced the error

In [2]: type(evm_backend)
Out[2]: eth_tester.backends.pyevm.main.PyEVMBackend

In [3]: current_ts = evm_backend.get_block_by_number("pending")["timestamp"]

In [4]: current_ts
Out[4]: 1722534117

In [5]: evm_backend.time_travel(current_ts)
ValidationError: timestamp must be strictly later than parent, but is 0 seconds before.
- child  : 1722534116
- parent : 1722534116.

In [6]: evm_backend.get_block_by_number("pending")["timestamp"]
Out[6]: 1722534116

Full error output

File ~/virtualenvs/ape08/lib/python3.12/site-packages/eth/vm/base.py:712, in VM.validate_header(cls, header, parent_header)
    710 # timestamp
    711 if header.timestamp <= parent_header.timestamp:
--> 712     raise ValidationError(
    713         "timestamp must be strictly later than parent, "
    714         f"but is {parent_header.timestamp - header.timestamp} seconds before.\n"  # noqa: E501
    715         f"- child  : {header.timestamp}\n"
    716         f"- parent : {parent_header.timestamp}. "
    717     )

ValidationError: timestamp must be strictly later than parent, but is 0 seconds before.
- child  : 1722534116
- parent : 1722534116.

Fill this section in if you know how this could or should be fixed

I am not sure! Somehow revert any changes or validate sooner?

eth-tester Version

0.11.0b2

Python Version

3.12.2

Operating System

macOS

Output from pip freeze

aiohttp==3.9.5
aiosignal==1.3.1
alabaster==0.7.16
altair==5.3.0
annotated-types==0.6.0
anyio==3.7.1
-e git+ssh://git@github.com/unparalleled-js/ape-addressbook.git@077106e0f9a492d11ed39305171662aed9de38db#egg=ape_addressbook
-e git+ssh://git@github.com/antazoey/ape-alchemy.git@bf3c89d18eada55576c9a4376c6559892c319c96#egg=ape_alchemy
-e git+ssh://git@github.com/unparalleled-js/ape-arbitrum.git@7a57714a8df126ca823c1f347cdbd3da85f5dcea#egg=ape_arbitrum
-e git+ssh://git@github.com/antazoey/ape-avalanche.git@fc150593b4793f15c59bf07550bcb863058cb7a2#egg=ape_avalanche
-e git+ssh://git@github.com/antazoey/ape-base.git@6d4fe9f0bb8e624c8a75cf9bb49b7ec8812c7ab9#egg=ape_base
-e git+ssh://git@github.com/ApeWorX/ape-blast.git@b9917c028519e97a7deb74663b87cd31fa8f3e68#egg=ape_blast
-e git+ssh://git@github.com/unparalleled-js/ape-bsc.git@df507da362c5613805780044bc7171656c5fee3b#egg=ape_bsc
-e git+ssh://git@github.com/unparalleled-js/ape-ens.git@8dc31cb5ea44cb28f38b765005fbab3f6c072f9f#egg=ape_ens
ape-etherscan==0.6.11
-e git+ssh://git@github.com/unparalleled-js/ape-fantom.git@c31eec351f8cec203f10d87867f3364b3d259f91#egg=ape_fantom
-e git+ssh://git@github.com/unparalleled-js/ape-foundry.git@1a09913d11e2ca6bf6b17af8317572a851402b78#egg=ape_foundry
-e git+ssh://git@github.com/antazoey/ape-hardhat.git@460bd17c67fcb9e689747fd263a62dbe4e29d1f3#egg=ape_hardhat
-e git+ssh://git@github.com/unparalleled-js/ape-infura.git@29b484ab1413ba83e87a938933497b087406d109#egg=ape_infura
-e git+ssh://git@github.com/unparalleled-js/ape-jules.git@7656a708ef1210129918655bb5113d627f33006d#egg=ape_jules
-e git+ssh://git@github.com/antazoey/ape-keyring.git@b3311fda918f98783c11d83c81afd2b9cdfa9039#egg=ape_keyring
-e git+ssh://git@github.com/ApeWorX/ape-ledger.git@d9938f8344c74b3939a6d249418df53f9411bcc3#egg=ape_ledger
-e git+ssh://git@github.com/antazoey/ape-optimism.git@15dc0bf0b56ca610cffac5521499e2974edf528f#egg=ape_optimism
ape-polygon==0.8.0
-e git+ssh://git@github.com/antazoey/ape-polygon-zkevm.git@0b5e0f92abe1cbc117ffa2ddf658edcddf7d32e4#egg=ape_polygon_zkevm
-e git+ssh://git@github.com/antazoey/ape-safe.git@d68ee561d82aa6f27ec8ff3bdaeacd8f222e1b8a#egg=ape_safe
ape-scroll==0.4.1
ape-simpy @ file:///Users/jules/PycharmProjects/ape-simpy
-e git+ssh://git@github.com/antazoey/ape-solidity.git@0b4cbd7db895c3d8f968b0f0adb469c021a616ba#egg=ape_solidity
-e git+ssh://git@github.com/antazoey/ape-tokens.git@859f683331ec71cd8ff50b7012978d745595876f#egg=ape_tokens
-e git+ssh://git@github.com/unparalleled-js/ape-trezor.git@77957bc5e0738be7e4b1759375943b8dde823244#egg=ape_trezor
-e git+ssh://git@github.com/Aviksaikat/ape-utils.git@a75a77ceceaa7ac875b961472ec60896d29115f0#egg=ape_utils
-e git+ssh://git@github.com/antazoey/ape-vyper.git@6d05c2672c5335a5b5aa7559bd983a76d645d8bd#egg=ape_vyper
-e git+ssh://git@github.com/antazoey/ApePay.git@28426a98f610e30fd535798ccda2956a0d23f719#egg=apepay
appnope==0.1.4
asttokens==2.4.1
attrs==23.2.0
Babel==2.15.0
base58==1.0.3
bitarray==2.9.2
black==24.4.2
bleak==0.22.1
blinker==1.8.2
build==1.2.1
CacheControl==0.14.0
cached-property==1.5.2
cachetools==5.3.3
cbor2==5.6.3
certifi==2024.2.2
cffi==1.16.0
cfgv==3.4.0
charset-normalizer==3.3.2
chompjs==1.2.3
ckzg==1.0.2
cleo==2.1.0
click==8.1.7
comm==0.2.2
commonmark==0.9.1
construct==2.10.70
construct-classes==0.1.2
coverage==7.5.1
crashtest==0.4.1
cryptography==42.0.8
cytoolz==0.12.3
dataclassy==0.11.1
debugpy==1.8.2
decorator==5.1.1
Deprecated==1.2.14
distlib==0.3.8
docutils==0.18.1
dulwich==0.21.7
ecdsa==0.19.0
ECPy==1.2.5
eip712==0.2.7
eth-account==0.11.2
-e git+ssh://git@github.com/antazoey/ape.git@fc724389f509fec738d22e71a760f6f914c10963#egg=eth_ape
eth-bloom==3.0.1
eth-hash==0.7.0
eth-keyfile==0.6.1
eth-keys==0.4.0
eth-pydantic-types==0.1.0
eth-rlp==0.3.0
eth-tester==0.11.0b2
eth-typing==3.5.2
eth-utils==2.3.1
eth_abi==5.1.0
eth_retry==0.1.20
ethpm-types==0.6.14
evm-trace==0.2.0
evmchains==0.0.11
execnet==2.1.1
executing==2.0.1
fastjsonschema==2.20.0
filelock==3.14.0
flake8==7.1.0
flake8-breakpoint==1.1.0
flake8-plugin-utils==1.3.3
flake8-print==4.0.1
flake8-pydantic==0.3.1
frozenlist==1.4.1
future==1.0.0
gitdb==4.0.11
GitPython==3.1.43
gprof2dot==2024.6.6
greenlet==3.0.3
hexbytes==0.3.1
hidapi==0.14.0
hypothesis==6.102.4
hypothesis-jsonschema==0.19.0
identify==2.5.36
idna==3.7
ijson==3.2.3
imagesize==1.4.1
importlib_metadata==7.1.0
iniconfig==2.0.0
installer==0.7.0
ipykernel==6.29.5
ipyrust==0.0.1
ipython==8.24.0
isort==5.13.2
jaraco.classes==3.4.0
jedi==0.19.1
Jinja2==3.1.4
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
jupyter_client==8.6.2
jupyter_core==5.7.2
keyring==24.3.1
lazyasd==0.1.4
ledgerblue==0.1.48
ledgereth==0.9.1
libusb1==3.1.0
linkify-it-py==2.0.3
lru-dict==1.2.0
markdown-it-py==2.2.0
MarkupSafe==2.1.5
matplotlib-inline==0.1.7
mccabe==0.7.0
mdformat==0.7.17
mdformat-gfm==0.3.6
mdformat_frontmatter==2.0.8
mdformat_pyproject==0.0.1
mdformat_tables==0.4.1
mdit-py-plugins==0.4.1
mdurl==0.1.2
mnemonic==0.21
more-itertools==10.3.0
morphys==1.0
mpmath==1.3.0
msgpack==1.0.8
msgspec==0.18.6
multicall==0.9.0
multidict==6.0.5
mypy==1.11.0
mypy-extensions==1.0.0
myst-parser==1.0.0
ndeflib==0.3.3
nest-asyncio==1.6.0
nfcpy==1.0.4
nodeenv==1.8.0
numpy==1.26.4
packaging==23.2
pandas==2.2.2
pandas-stubs==2.2.2.240514
parsimonious==0.10.0
parso==0.8.4
pathspec==0.12.1
pexpect==4.9.0
pillow==10.3.0
pkginfo==1.11.1
platformdirs==4.2.2
pluggy==1.5.0
pockets==0.9.1
poetry==1.8.3
poetry-core==1.9.0
poetry-plugin-export==1.8.0
pre-commit==3.7.1
prometheus_client==0.20.0
prompt-toolkit==3.0.43
protobuf==5.26.1
psutil==6.0.0
ptyprocess==0.7.0
pure-eval==0.2.2
py-cid==0.3.0
py-cpuinfo==9.0.0
py-ecc==6.0.0
py-evm==0.10.1b1
py-geth==5.0.0b3
py-multibase==1.0.3
py-multicodec==0.2.1
py-multihash==0.2.3
py-solc-x==2.0.2
pyarrow==16.1.0
pycodestyle==2.12.0
pycparser==2.22
pycron==3.0.0
pycryptodome==3.20.0
pycryptodomex==3.20.0
pydantic==2.8.2
pydantic-settings==2.2.1
pydantic_core==2.20.1
pydeck==0.9.1
pyDes==2.0.1
pyelftools==0.31
pyethash==0.1.27
pyflakes==3.2.0
pygame==2.6.0
PyGithub==1.59.1
Pygments==2.18.0
PyJWT==2.8.0
PyNaCl==1.5.0
pyobjc-core==10.2
pyobjc-framework-Cocoa==10.2
pyobjc-framework-CoreBluetooth==10.2
pyobjc-framework-libdispatch==10.2
pyproject_hooks==1.1.0
pyserial==3.5
pytest==8.3.2
pytest-cov==5.0.0
pytest-mock==3.14.0
pytest-profiling==1.7.0
pytest-xdist==3.6.1
python-baseconv==1.2.2
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-gnupg==0.5.2
python-u2flib-host==3.0.3
pytz==2024.1
pyunormalize==15.1.0
pyupgrade==3.15.2
PyYAML==6.0.1
pyzmq==26.0.3
rapidfuzz==3.9.4
referencing==0.35.1
regex==2024.5.10
requests==2.31.0
requests-toolbelt==1.0.0
rich==12.6.0
rich-click==1.8.3
rlp==3.0.0
rpds-py==0.18.1
ruamel.yaml==0.18.6
ruamel.yaml.clib==0.2.8
safe-pysha3==1.0.4
semantic-version==2.10.0
setuptools==69.5.1
shellingham==1.5.4
silverback==0.2.1
six==1.16.0
smmap==5.0.1
snekmate==0.1.0
sniffio==1.3.1
snowballstemmer==2.2.0
sortedcontainers==2.4.0
Sphinx==6.2.1
sphinx-click==4.4.0
sphinx-plausible==0.1.2
sphinx-rtd-theme==1.3.0
sphinxcontrib-applehelp==1.0.8
sphinxcontrib-devhelp==1.0.6
sphinxcontrib-htmlhelp==2.0.5
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-napoleon==0.7
sphinxcontrib-qthelp==1.0.7
sphinxcontrib-serializinghtml==1.1.10
SQLAlchemy==2.0.30
stack-data==0.6.3
streamlit==1.36.0
taskiq==0.6.0
taskiq-dependencies==1.5.3
tenacity==8.4.2
tokenize-rt==5.2.0
tokenlists==0.1.7
toml==0.10.2
tomlkit==0.13.0
toolz==0.12.1
tornado==6.4.1
tqdm==4.66.4
traitlets==5.14.3
trezor==0.13.8
trie==3.0.1
trove-classifiers==2024.7.2
types-python-dateutil==2.9.0.20240316
types-pytz==2024.1.0.20240417
types-PyYAML==6.0.12.20240311
types-requests==2.31.0.20240406
types-setuptools==69.5.0.20240513
types-SQLAlchemy==1.4.53.38
types-toml==0.10.8.20240310
typing_extensions==4.11.0
tzdata==2024.1
uc-micro-py==1.0.3
urllib3==2.2.2
varint==1.0.2
virtualenv==20.26.2
vvm==0.2.0
vyper==0.3.10
watchdog==3.0.0
wcwidth==0.2.13
web3==6.20.1
websocket-client==1.8.0
websockets==12.0
wheel==0.43.0
wrapt==1.16.0
xattr==1.1.0
yarl==1.9.4
zipp==3.18.2
antazoey commented 3 months ago

btw, non-urgent, as I don't get use this issue when I use EthereumTester class directly rather than evm backend