yools icon indicating copy to clipboard operation
yools copied to clipboard

Evaluator

Open chriseth opened this issue 3 years ago • 2 comments
trafficstars

chriseth avatar Oct 28 '22 08:10 chriseth

This now uses the evaluator to determine if some branches cannot be reached at all (and then it does not encode them). This is a trace of the encoded opcodes filtered to mstore, datacopy, create, sload, sstore and call, executed on two transactions: First a call to "setUp()" and then "proveA()" (i.e. calldata is set accordingly). You can see that it does not encode any of the panics in the abi decoder and properly re-retrieves the address of the contract under test from storage:

=========== SETUP ===================
mstore(64, 128)
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 65)
datacopy(128, dataoffset("oTest_15"), datasize("oTest_15"))
_54 := create(0, 128, $_53)
   - _54 = address<oTest_15,0>
_75 := sload(0)
sstore(0, address<oTest_15,0>)
=========== CALL ===================
mstore(64, 128)
_68 := sload(0)
   - _68 = address<oTest_15,0>
mstore(128, 8964389696657244788749362684448106728022753484683927377131620019041577467904)
mstore(132, 0)
mstore(164, 0)
_110 := call($_106, address<oTest_15,0>, 0, 128, 68, 128, 32)
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 65)
mstore(64, $newFreePtr_113_1)
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 17)
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 1)

chriseth avatar Nov 01 '22 16:11 chriseth

Got this working now without the hack:

=========== SETUP ===================
mstore(40, 80)
mstore(0, 4e487b7100000000000000000000000000000000000000000000000000000000)
mstore(4, 41)
datacopy(80, dataoffset(dataref("oTest_15")), datasize(dataref("oTest_15")))
_54 := create(0, 80, sub(add(add(80, datasize(dataref("oTest_15"))), 0), 80))
   - _54 = address<oTest_15,0>
_75 := sload(0)
sstore(0, or(and($value_49_0, ffffffffffffffffffffffff0000000000000000000000000000000000000000), address<oTest_15,0>))
=========== CALL ===================
mstore(40, 80)
_70 := sload(0)
   - _70 = or(and($value_49_0, ffffffffffffffffffffffff0000000000000000000000000000000000000000), address<oTest_15,0>)
mstore(80, 13d1aa2e00000000000000000000000000000000000000000000000000000000)
mstore(84, 0)
mstore(a4, 0)
_112 := call($_108, address<oTest_15,0>, 0, 80, 44, 80, 20)
mstore(0, 4e487b7100000000000000000000000000000000000000000000000000000000)
mstore(4, 41)
mstore(40, add(80, and(add($value_108_0, 1f), ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0)))
mstore(0, 4e487b7100000000000000000000000000000000000000000000000000000000)
mstore(4, 11)
mstore(0, 4e487b7100000000000000000000000000000000000000000000000000000000)
mstore(4, 1)

chriseth avatar Nov 02 '22 14:11 chriseth