Skip to content

Commit 2e14273

Browse files
author
Antoni Nowakowski
committed
Made the replicas track the total amount of sequences
1 parent dac415c commit 2e14273

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

simulator/src/main/java/byzzbench/simulator/protocols/tendermint/TendermintReplica.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class TendermintReplica extends LeaderBasedProtocolReplica {
2828
// Sequence: the current sequence within the height, where multiple sequences might be needed to finalize a block
2929
private long sequence;
3030

31+
private long totalSequences;
32+
3133
// Step: the current step within the sequence (PROPOSE, PREVOTE, PRECOMMIT)
3234
private Step step;
3335

@@ -68,6 +70,7 @@ public TendermintReplica(String nodeId, SortedSet<String> nodeIds, Scenario scen
6870
super(nodeId, scenario, new TotalOrderCommitLog());
6971
this.height = 0;
7072
this.sequence = 0;
73+
this.totalSequences = 0;
7174
this.step = Step.PROPOSE;
7275
this.lockedValue = null;
7376
this.lockedSequence = -1;
@@ -293,6 +296,7 @@ private void executeProposalPrecommitRule(Block block) {
293296
//53: reset lockedRoundp, lockedV aluep, validRoundp and validV aluep to initial values and empty message log
294297
//54: StartRound(0)
295298
commitOperation(block);
299+
this.totalSequences += this.sequence + 1;
296300
ReplyMessage replyMessage = new ReplyMessage(
297301
this.height,
298302
block.getRequestMessage().getTimestamp(),
@@ -315,7 +319,7 @@ protected void broadcastProposal(long height, long sequence, Block proposal, lon
315319
if(hasBroadcasted.contains(Pair.of(height, sequence))) {
316320
return;
317321
}
318-
ProposalMessage proposalMessage = new ProposalMessage(getId(), height, sequence, validSequence, proposal);
322+
ProposalMessage proposalMessage = new ProposalMessage(getId(), height, sequence, totalSequences, validSequence, proposal);
319323
broadcastMessageIncludingSelf(proposalMessage);
320324
hasBroadcasted.add(Pair.of(height, sequence));
321325

@@ -488,7 +492,7 @@ private void broadcastGossipPrevote(PrevoteMessage prevoteMessage) {
488492

489493
private void broadcastPrevote(long height, long sequence, Block block) {
490494
// messageLog.sentPrevote();
491-
PrevoteMessage prevoteMessage = new PrevoteMessage(height, sequence, this.getId(), block);
495+
PrevoteMessage prevoteMessage = new PrevoteMessage(height, sequence, totalSequences, this.getId(), block);
492496
broadcastMessageIncludingSelf(prevoteMessage);
493497
}
494498

@@ -609,7 +613,7 @@ private void broadcastGossipPrecommit(PrecommitMessage precommitMessage) {
609613
}
610614

611615
protected void broadcastPrecommit(long height, long sequence, Block block) {
612-
PrecommitMessage precommitMessage = new PrecommitMessage(height, sequence, this.getId(), block);
616+
PrecommitMessage precommitMessage = new PrecommitMessage(height, sequence, totalSequences, this.getId(), block);
613617
broadcastMessageIncludingSelf(precommitMessage);
614618
}
615619

simulator/src/main/java/byzzbench/simulator/protocols/tendermint/message/GossipMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public String getType() {
2121

2222
@Override
2323
public long getRound() {
24-
return gossipMessage.getRound();
24+
return 0;
2525
}
2626
}

simulator/src/main/java/byzzbench/simulator/protocols/tendermint/message/PrecommitMessage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public class PrecommitMessage extends GenericMessage {
1111
private final long height; // Current blockchain height
1212
private final long sequence; // Current round in the consensus process
13+
private final long totalSeq;
1314
private final String replicaId; // ID of the validator sending the precommit
1415
private final Block block;
1516

@@ -25,6 +26,6 @@ public String getAuthor() {
2526

2627
@Override
2728
public long getRound() {
28-
return sequence * 3 + 3;
29+
return totalSeq + 3;
2930
}
3031
}

simulator/src/main/java/byzzbench/simulator/protocols/tendermint/message/PrevoteMessage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public class PrevoteMessage extends GenericMessage {
1111
private final long height; // Current blockchain height
1212
private final long sequence; // Current round in the consensus process
13+
private final long totalSeq;
1314
private final String replicaId; // ID of the validator sending the prevote
1415
private final Block block; // Block being prevoted
1516

@@ -24,7 +25,7 @@ public String getAuthor() {
2425
}
2526

2627
@Override
27-
public long getRound(){
28-
return sequence * 3 + 2;
28+
public long getRound() {
29+
return totalSeq + 2;
2930
}
3031
}

simulator/src/main/java/byzzbench/simulator/protocols/tendermint/message/ProposalMessage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class ProposalMessage extends GenericMessage {
1111
private final String replicaId; // ID of the proposer
1212
private final long height; // Current blockchain height
1313
private final long sequence; // Current round in the consensus process
14+
private final long totalSeq;
1415
private final long validSequence; // Round in which the value is valid
1516
private final Block block; // Block being proposed\
1617

@@ -26,6 +27,6 @@ public String getAuthor() {
2627

2728
@Override
2829
public long getRound() {
29-
return sequence * 3 + 1;
30+
return totalSeq + 1;
3031
}
3132
}

0 commit comments

Comments
 (0)