Skip to content

Commit 207633c

Browse files
committed
feat(Verifier): add contract for post-attack storage verification
Adds a minimal Verifier contract that checks if a target contract's deepest storage slot was updated to the expected attack value. This enables the test to verify attack success without expensive post-state checks on all attacked contracts. The verify() function calls getDeepest() on the target and compares the returned value against the expected attack value.
1 parent 04d54fa commit 207633c

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • tests/benchmark/stateful/bloatnet/depth_benchmarks
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
* @title Verifier
6+
* @dev Minimal contract to verify that an attacked contract's deep storage slot was updated.
7+
* Called at the end of the attack execution to confirm the attack succeeded.
8+
*/
9+
contract Verifier {
10+
/**
11+
* @dev Verifies that the target contract's deepest storage slot contains the expected value.
12+
* @param target The address of the attacked contract
13+
* @param expectedValue The expected value in the deep storage slot
14+
* @return success True if the value matches, false otherwise
15+
*/
16+
function verify(address target, uint256 expectedValue) external view returns (bool success) {
17+
// Call getDeepest() on target - selector is 0x77b5b7e6
18+
// bytes4(keccak256("getDeepest()")) = 0x77b5b7e6
19+
(bool callSuccess, bytes memory data) = target.staticcall(
20+
abi.encodeWithSelector(0x77b5b7e6)
21+
);
22+
23+
if (!callSuccess || data.length != 32) {
24+
return false;
25+
}
26+
27+
uint256 actualValue = abi.decode(data, (uint256));
28+
return actualValue == expectedValue;
29+
}
30+
}

0 commit comments

Comments
 (0)