提交 8551cb7e 编写于 作者: J João Sousa

Fixed bug in the state transfer caused by the addition of an ACK field in the requests

上级 d387bdbe
无法预览此类型文件
......@@ -120,7 +120,7 @@ system.totalordermulticast.invoketimeout = 40000
############################################
#Enable/disable control flow mechanism
system.controlflow.controlflow = true
system.controlflow.controlflow = false
#Maximum number of total pending requests that each replica can hold. Set to -1 to disable.
system.controlflow.maxpendingreqs = 500000
......
......@@ -194,7 +194,7 @@ public final class Acceptor {
tomLayer.setInExec(cid);
}
epoch.deserializedPropValue = tomLayer.checkProposedValue(value, true);
if (epoch.deserializedPropValue != null && !epoch.isWriteSent()) {
if(epoch.getConsensus().getDecision().firstMessageProposed == null) {
epoch.getConsensus().getDecision().firstMessageProposed = epoch.deserializedPropValue[0];
......
......@@ -41,6 +41,7 @@ public class MessageContext implements Serializable {
private final int sequence;
private final int operationId;
private final int replyServer;
private final int ackSeq;
private final byte[] signature;
// Consensus info
......@@ -70,6 +71,7 @@ public class MessageContext implements Serializable {
* @param sequence Request's sequence number
* @param operationId The operation ID
* @param replyServer ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.
* @param ackSeq ACK sequence for the request
* @param signature Client's signature.
* @param timestamp The timestamp as generated by the leader
* @param numOfNonces The nonces as generated by the leader
......@@ -82,7 +84,7 @@ public class MessageContext implements Serializable {
* @param noOp true if the consensus instance has no operations to deliver to the application
*/
public MessageContext(int sender, int viewID, TOMMessageType type,
int session, int sequence, int operationId, int replyServer, byte[] signature,
int session, int sequence, int operationId, int replyServer, int ackSeq, byte[] signature,
long timestamp, int numOfNonces, long seed, int regency, int leader, int consensusId,
Set<ConsensusMessage> proof, TOMMessage firstInBatch, boolean noOp) {
......@@ -95,6 +97,7 @@ public class MessageContext implements Serializable {
this.sequence = sequence;
this.operationId = operationId;
this.replyServer = replyServer;
this.ackSeq = ackSeq;
this.signature = signature;
this.timestamp = timestamp;
......@@ -157,6 +160,13 @@ public class MessageContext implements Serializable {
return replyServer;
}
/**
* Returns the ACK sequence for the request.
* @return ACK sequence for the request.
*/
public int getAckSeq() {
return ackSeq;
}
/**
* Returns the client's signature.
......@@ -295,6 +305,7 @@ public class MessageContext implements Serializable {
TOMMessage ret = new TOMMessage(sender, session, sequence, operationId, content, viewID, type);
ret.setReplyServer(replyServer);
ret.setAckSeq(ackSeq);
ret.serializedMessageSignature = signature;
ret.serializedMessage = TOMMessage.messageToBytes(ret);
......
......@@ -301,7 +301,7 @@ public class ServiceReplica {
numRequests++;
MessageContext msgCtx = new MessageContext(request.getSender(), request.getViewID(),
request.getReqType(), request.getSession(), request.getSequence(), request.getOperationId(),
request.getReplyServer(), request.serializedMessageSignature, firstRequest.timestamp,
request.getReplyServer(), request.getAckSeq(), request.serializedMessageSignature, firstRequest.timestamp,
request.numOfNonces, request.seed, regencies[consensusCount], leaders[consensusCount],
consId[consensusCount], cDecs[consensusCount].getConsMessages(), firstRequest, false);
if (requestCount + 1 == requestsFromConsensus.length) {
......@@ -384,7 +384,7 @@ public class ServiceReplica {
msgCtx[line] = new MessageContext(m.getSender(), m.getViewID(),
m.getReqType(), m.getSession(), m.getSequence(), m.getOperationId(),
m.getReplyServer(), m.serializedMessageSignature, firstRequest.timestamp,
m.getReplyServer(), m.getAckSeq(), m.serializedMessageSignature, firstRequest.timestamp,
m.numOfNonces, m.seed, regencies[consensusCount], leaders[consensusCount],
consId[consensusCount], cDecs[consensusCount].getConsMessages(), firstRequest, true);
msgCtx[line].setLastInBatch();
......
......@@ -319,7 +319,7 @@ public final class DeliveryThread extends Thread {
protected void deliverUnordered(TOMMessage request, int regency) {
MessageContext msgCtx = new MessageContext(request.getSender(), request.getViewID(), request.getReqType(),
request.getSession(), request.getSequence(), request.getOperationId(), request.getReplyServer(), request.serializedMessageSignature,
request.getSession(), request.getSequence(), request.getOperationId(), request.getReplyServer(), request.getAckSeq(), request.serializedMessageSignature,
System.currentTimeMillis(), 0, 0, regency, -1, -1, null, null, false); // Since the request is unordered,
// there is no consensus info to pass
......
......@@ -15,7 +15,6 @@ limitations under the License.
*/
package bftsmart.tom.leaderchange;
import bftsmart.communication.server.ServerConnection;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.SignedObject;
......
......@@ -47,11 +47,12 @@ public class CommandsInfo implements Serializable {
msgCtx[i].getViewID(), msgCtx[i].getType(),
msgCtx[i].getSession(), msgCtx[i].getSequence(),
msgCtx[i].getOperationId(), msgCtx[i].getReplyServer(),
msgCtx[i].getSignature(), msgCtx[i].getTimestamp(),
msgCtx[i].getNumOfNonces(), msgCtx[i].getSeed(),
msgCtx[i].getRegency(), msgCtx[i].getLeader(),
msgCtx[i].getConsensusId(), msgCtx[i].getProof(),
msgCtx[i].getFirstInBatch(), msgCtx[i].isNoOp());
msgCtx[i].getAckSeq(), msgCtx[i].getSignature(),
msgCtx[i].getTimestamp(), msgCtx[i].getNumOfNonces(),
msgCtx[i].getSeed(), msgCtx[i].getRegency(),
msgCtx[i].getLeader(), msgCtx[i].getConsensusId(),
msgCtx[i].getProof(), msgCtx[i].getFirstInBatch(),
msgCtx[i].isNoOp());
onlyNeeded[i] = msg;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册