Skip to content

Commit d10fece

Browse files
committed
Spearated integrity from agreement.
1 parent 9a2b439 commit d10fece

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

simulator/src/main/java/byzzbench/simulator/BaseScenario.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import byzzbench.simulator.schedule.Schedule;
1010
import byzzbench.simulator.scheduler.Scheduler;
1111
import byzzbench.simulator.state.AgreementPredicate;
12+
import byzzbench.simulator.state.IntegrityPredicate;
1213
import byzzbench.simulator.state.LivenessPredicate;
1314
import byzzbench.simulator.state.adob.AdobDistributedState;
1415
import byzzbench.simulator.transport.Transport;
@@ -55,7 +56,7 @@ public abstract class BaseScenario implements Scenario {
5556
/**
5657
* The invariants that must be satisfied by the scenario at all times.
5758
*/
58-
private final List<ScenarioPredicate> invariants = List.of(new AgreementPredicate(), new LivenessPredicate());
59+
private final List<ScenarioPredicate> invariants = List.of(new AgreementPredicate(), new IntegrityPredicate(), new LivenessPredicate());
5960
/**
6061
* The schedule of events in order of delivery.
6162
*/

simulator/src/main/java/byzzbench/simulator/state/AgreementPredicate.java

-17
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import byzzbench.simulator.Scenario;
55
import byzzbench.simulator.ScenarioPredicate;
66

7-
import java.util.ArrayList;
87
import java.util.Collection;
98
import java.util.List;
109
import java.util.Objects;
@@ -31,22 +30,6 @@ public boolean test(Scenario scenarioExecutor) {
3130
.max(Long::compareTo)
3231
.orElse(0L);
3332

34-
// check for duplicate entries in each replica's commit log
35-
for (Replica replica : replicas) {
36-
CommitLog commitLog = replica.getCommitLog();
37-
for (int i = 0; i < commitLog.getLength(); i++) {
38-
for (int j = i + 1; j < commitLog.getLength(); j++) {
39-
if (commitLog.get(i) == null || commitLog.get(j) == null) {
40-
continue;
41-
}
42-
if (commitLog.get(i).equals(commitLog.get(j))) {
43-
System.out.println("Replica " + replica.getId() + " has duplicate entries at indices " + i + " and " + j);
44-
return false;
45-
}
46-
}
47-
}
48-
}
49-
5033
// check if the Nth entry in the commit log of each replica is the same
5134
for (long i = lowestSequenceNumber; i <= highestSequenceNumber; i++) {
5235
final long index = i;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package byzzbench.simulator.state;
2+
3+
import byzzbench.simulator.Replica;
4+
import byzzbench.simulator.Scenario;
5+
import byzzbench.simulator.ScenarioPredicate;
6+
7+
import java.util.Collection;
8+
9+
public class IntegrityPredicate implements ScenarioPredicate {
10+
@Override
11+
public String getId() {
12+
return "Integrity";
13+
}
14+
15+
@Override
16+
public boolean test(Scenario scenarioExecutor) {
17+
Collection<Replica> replicas = scenarioExecutor.getReplicas().values().stream()
18+
.filter(node -> !scenarioExecutor.isFaultyReplica(node.getId()))
19+
.toList();
20+
21+
22+
// check for duplicate entries in each replica's commit log
23+
for (Replica replica : replicas) {
24+
CommitLog commitLog = replica.getCommitLog();
25+
for (int i = 0; i < commitLog.getLength(); i++) {
26+
for (int j = i + 1; j < commitLog.getLength(); j++) {
27+
if (commitLog.get(i) == null || commitLog.get(j) == null) {
28+
continue;
29+
}
30+
if (commitLog.get(i).equals(commitLog.get(j))) {
31+
System.out.println("IntegrityPredicate: Duplicate vote!");
32+
System.out.println("Replica " + replica.getId() + " has duplicate entries at indices " + i + " and " + j);
33+
return false;
34+
}
35+
}
36+
}
37+
}
38+
39+
return true;
40+
}
41+
}

simulator/src/main/resources/application.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ springdoc:
1616

1717
# ByzzBench configuration
1818
byzzbench:
19-
autostart: true # Whether to start running scenarios automatically on startup
19+
autostart: false # Whether to start running scenarios automatically on startup
2020
numScenarios: 4000
2121
#outputPath: /tmp/byzzbench # The path to write the output to
2222
outputSchedules: buggy # which schedules to write to file? one of 'all', 'buggy' or 'none'

0 commit comments

Comments
 (0)