File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
35
35
- Dumping of END states (.prop) files is now default for ` --debug `
36
36
- When cheatcode is missing, we produce a partial execution warning
37
37
- Size of calldata can be up to 2** 64, not 256. This is now reflected in the documentation
38
+ - Zero-length buffers actually imply all-zero buffer, and vica-versa. This
39
+ was assumed but not encoded. Fixed.
38
40
39
41
## Changed
40
42
- Warnings now lead printing FAIL. This way, users don't accidentally think that
Original file line number Diff line number Diff line change @@ -420,12 +420,20 @@ discoverMaxReads props benv senv = bufMap
420
420
421
421
-- | Returns an SMT2 object with all buffers referenced from the input props declared, and with the appropriate cex extraction metadata attached
422
422
declareBufs :: [Prop ] -> BufEnv -> StoreEnv -> SMT2
423
- declareBufs props bufEnv storeEnv = SMT2 (" ; buffers" : fmap declareBuf allBufs <> (" ; buffer lengths" : fmap declareLength allBufs)) cexvars mempty
423
+ declareBufs props bufEnv storeEnv =
424
+ SMT2 (smtBufNames <> smtBufLengths <> smtEmptyRelations) cexvars mempty
424
425
where
426
+ smtBufNames = " ; buffers" : fmap declareBuf allBufs
427
+ smtBufLengths = " ; buffer lengths" : fmap declareLength allBufs
428
+ smtEmptyRelations = " ; empty buffer relations" : concatMap emptyRelation allBufs
425
429
cexvars = (mempty :: CexVars ){ buffers = discoverMaxReads props bufEnv storeEnv }
426
430
allBufs = fmap fromLazyText $ Map. keys cexvars. buffers
427
431
declareBuf n = " (declare-fun " <> n <> " () (Array (_ BitVec 256) (_ BitVec 8)))"
428
432
declareLength n = " (declare-fun " <> n <> " _length" <> " () (_ BitVec 256))"
433
+ emptyRelation buf =
434
+ let bufLen = buf <> " _length"
435
+ in [" (assert (=> (= " <> bufLen <> " (_ bv0 256)) (= " <> buf <> " ((as const Buf) #b00000000)) ))"
436
+ , " (assert (=> (= " <> buf <> " ((as const Buf) #b00000000)) (= " <> bufLen <> " (_ bv0 256)) ))" ]
429
437
430
438
-- Given a list of variable names, create an SMT2 object with the variables declared
431
439
declareVars :: [Builder ] -> SMT2
Original file line number Diff line number Diff line change @@ -545,6 +545,13 @@ tests = testGroup "hevm"
545
545
simp = Expr. simplify e
546
546
res <- checkEquiv e simp
547
547
assertEqualM " readWord simplification" res True
548
+ , test " simp-empty-buflength" $ do
549
+ let e = PEq (BufLength (AbstractBuf " mybuf" )) (Lit 0 )
550
+ let simp = Expr. simplifyProp e
551
+ let simpExpected = PEq (AbstractBuf " mybuf" ) (ConcreteBuf " " )
552
+ assertEqualM " buflen-to-empty" simp simpExpected
553
+ ret <- checkEquivPropAndLHS e simpExpected
554
+ assertBoolM " Must be equivalent" ret
548
555
, test " simp-max-buflength" $ do
549
556
let simp = Expr. simplify $ Max (Lit 0 ) (BufLength (AbstractBuf " txdata" ))
550
557
assertEqualM " max-buflength rules" simp $ BufLength (AbstractBuf " txdata" )
You can’t perform that action at this time.
0 commit comments