Changelog and test for the KeccakCaching bug

This commit is contained in:
hrkrshnn
2021-03-23 11:09:00 +01:00
parent 2ecb20589b
commit 30e08ee3a5
7 changed files with 180 additions and 6 deletions
@@ -0,0 +1,21 @@
contract C {
uint[] data;
function val() public returns (bool) {
assembly {
sstore(0, 2)
mstore(0, 0)
sstore(keccak256(0, 32), 234)
// A bug in the caching mechanism previously caused keccak256(0, 23) to be the same as
// keccak256(0, 32), leading to `data[1] == 123` being true.
sstore(add(keccak256(0, 23), 1), 123)
}
assert(data[1] != 123);
assert(data[1] == 0);
return true;
}
}
// ====
// compileViaYul: also
// ----
// val() -> true