-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrrevert.sol
61 lines (44 loc) · 995 Bytes
/
errrevert.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
contract CErr {
error errGas();
function i0i0(uint i) external {
require(i == 0, "err");
}
function i1i1(uint i) external {
if (i != 0) {
revert errGas();
}
}
}
contract errrevert {
uint public g0;
uint public g1;
uint public g2;
uint public gas01;
uint public gas12;
event errGet();
CErr cerr = new CErr();
function err() public {
g0 = gasleft();
for (uint i; i < 100; ) {
try cerr.i0i0(i) {
} catch {
emit errGet();
}
unchecked { ++i; }
}
g1 = gasleft();
gas01 = g0 - g1;
g1 = gasleft();
for (uint i; i < 100; ) {
try cerr.i1i1(i) {
} catch {
emit errGet();
}
unchecked { ++i; }
}
g2 = gasleft();
gas12 = g1 - g2;
}
}