From ea63c949531f55e0e83c993d916d24b1fc1acd40 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Tue, 23 Apr 2024 13:11:22 -0400 Subject: [PATCH 1/2] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d7804fc1..a5ba2b5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "titanoboa" -version = "0.1.9" +version = "0.1.10b1" description = "A Vyper interpreter" #authors = [] license = { file = "LICENSE" } From 78ff3d23c2f10bb1a8754d0df6f39d96ac1ded97 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Wed, 24 Apr 2024 16:06:46 -0400 Subject: [PATCH 2/2] feat: validate time travel bail out if negative --- boa/environment.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/boa/environment.py b/boa/environment.py index d0656274..fdc48186 100644 --- a/boa/environment.py +++ b/boa/environment.py @@ -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: + 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