Skip to content
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

Validate timetravel #201

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions boa/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,10 @@ def time_travel(
assert blocks is not None # mypy hint
seconds = blocks * block_delta

self.evm.patch.timestamp += seconds
self.evm.patch.block_number += blocks
if (new_blknum := self.evm.patch.block_number + blocks) < 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to abbreviate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no 🤓 but i think abbreviations are fine for variables with small scope! when i read code, i associate scope with size of the variable name, if the variable name is too long i start hunting for references to it outside of its actual scope.

raise ValueError(f"negative blocknumber: to set to {new_blknum}")
if (new_ts := self.evm.patch.timestamp + seconds) < 0:
raise ValueError(f"negative timestamp: to set to {new_ts}")

self.evm.patch.timestamp = new_ts
self.evm.patch.block_number = new_blknum
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "titanoboa"
version = "0.1.9"
version = "0.1.10b1"
description = "A Vyper interpreter"
#authors = []
license = { file = "LICENSE" }
Expand Down
Loading