Skip to content

Commit

Permalink
Stronger bounds on symbolic block.timestamp and block.number (#2583)
Browse files Browse the repository at this point in the history
* stronger bounds on symbolic block.timestamp

* add comment

* bound block.number

* formatting

* update block.number bounds
  • Loading branch information
anvacaru authored Aug 20, 2024
1 parent 7519a78 commit 414742d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions kevm-pyk/src/kevm_pyk/kevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pyk.ktool.krun import KRun
from pyk.prelude.bytes import BYTES, pretty_bytes
from pyk.prelude.kbool import notBool
from pyk.prelude.kint import INT, eqInt, intToken, ltInt
from pyk.prelude.kint import INT, eqInt, gtInt, intToken, ltInt
from pyk.prelude.ml import mlEqualsFalse, mlEqualsTrue
from pyk.prelude.string import stringToken
from pyk.prelude.utils import token
Expand Down Expand Up @@ -368,9 +368,12 @@ def _add_account_invariant(account: KApply) -> list[KApply]:
mlEqualsFalse(KEVM.is_precompiled_account(cterm.cell('ORIGIN_CELL'), cterm.cell('SCHEDULE_CELL')))
)

constraints.append(mlEqualsTrue(KEVM.range_blocknum(cterm.cell('NUMBER_CELL'))))
constraints.append(mlEqualsTrue(KEVM.range_uint(256, cterm.cell('TIMESTAMP_CELL'))))

# Setting the timestamp range from January 2004 to October 3058
constraints.append(mlEqualsTrue(gtInt(cterm.cell('TIMESTAMP_CELL'), intToken(2**30))))
constraints.append(mlEqualsTrue(ltInt(cterm.cell('TIMESTAMP_CELL'), intToken(2**35))))
# Setting the block number range conservatively to match the timestamp range
constraints.append(mlEqualsTrue(gtInt(cterm.cell('NUMBER_CELL'), intToken(2**24))))
constraints.append(mlEqualsTrue(ltInt(cterm.cell('NUMBER_CELL'), intToken(2**32))))
for c in constraints:
cterm = cterm.add_constraint(c)
return cterm
Expand Down

0 comments on commit 414742d

Please sign in to comment.