-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfault_proof_detection_child.gate
57 lines (48 loc) · 1.96 KB
/
fault_proof_detection_child.gate
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
use Call, Calls, Events, Contains, Len, Range from hexagate;
// Parameters to be passed
param cbChallenger: address;
param disputeGame: address;
// Source to retrieve `Move` events from the specified dispute game contract
source moveEvents: list<tuple<integer, bytes, address>> = Events {
contract: disputeGame,
signature: "event Move(uint256 indexed parentIndex, bytes32 indexed claim, address indexed claimant)"
};
// Retrieve the number of claims
source claimCount: integer = Call {
contract: disputeGame,
signature: "function claimDataLen() view returns (uint256)"
};
// Create a list of even parent indices (indicating challenge moves)
source evenParentIndices: list<integer> = Range {
start: 0,
stop: claimCount,
step: 2
};
// Create a list of odd parent indices (indicating defense moves)
source oddParentIndices: list<integer> = Range {
start: 1,
stop: claimCount,
step: 2
};
// Filter the events where the claimant is cbChallenger and the parentIndex is even (challenge move)
source challengeMoves: list<tuple<integer, bytes, address>> = [
event
for event in moveEvents
if (event[2] == cbChallenger) and Contains { sequence: evenParentIndices, item: event[0] }
];
// Filter the events where parentIndex is odd (defense move) and attacker defending
source defenseMoves: list<tuple<integer, bytes, address>> = [
event
for event in moveEvents
if Contains { sequence: oddParentIndices, item: event[0] }
];
// Invariant to trigger an alert if attacker is defending a invalid output root
invariant {
description: "Attacker is defending the output root",
condition: Len { sequence: moveEvents } == 0 ? true : Len { sequence: challengeMoves } > 0
};
// Invariant to trigger an alert if cbChallenger is challenging the invalid output root
invariant {
description: "CB challenger is challenging the invalid output root submitted",
condition: Len { sequence: moveEvents } == 0 ? true : Len { sequence: defenseMoves } > 0
};