Debugged to ensure accurate results
Signed-off-by: Arunima Chaudhuri <arunimachaudhuri2020@gmail.com>
This commit is contained in:
parent
2fc4a963fb
commit
7ed3d8c690
|
@ -241,7 +241,8 @@ class Simulator:
|
|||
self.glob.checkRowsColumns(self.validators)
|
||||
for i in range(0,self.shape.numberNodes):
|
||||
if i == self.proposerID:
|
||||
self.validators[i].initBlock()
|
||||
# self.validators[i].initBlock()
|
||||
self.logger.warning("I am a block proposer.", extra=self.format)
|
||||
else:
|
||||
self.validators[i].logIDs()
|
||||
arrived, expected, ready, validatedall, validated = self.glob.checkStatus(self.validators)
|
||||
|
@ -256,6 +257,7 @@ class Simulator:
|
|||
oldMissingSamples = missingSamples
|
||||
self.logger.debug("PHASE SEND %d" % steps, extra=self.format)
|
||||
for i in range(0,self.shape.numberNodes):
|
||||
if not self.validators[i].amImalicious:
|
||||
self.validators[i].send()
|
||||
self.logger.debug("PHASE RECEIVE %d" % steps, extra=self.format)
|
||||
for i in range(1,self.shape.numberNodes):
|
||||
|
@ -323,6 +325,17 @@ class Simulator:
|
|||
if not self.validators[i].amIaddedToQueue :
|
||||
malicious_nodes_not_added_count += 1
|
||||
|
||||
for i in range(0,self.shape.numberNodes):
|
||||
column_ids = []
|
||||
row_ids = []
|
||||
for rID in self.validators[i].rowIDs:
|
||||
row_ids.append(rID)
|
||||
for cID in self.validators[i].columnIDs:
|
||||
column_ids.append(cID)
|
||||
|
||||
self.logger.debug("List of columnIDs for %d node: %s", i, column_ids, extra=self.format)
|
||||
self.logger.debug("List of rowIDs for %d node: %s", i, row_ids, extra=self.format)
|
||||
|
||||
self.logger.debug("Number of malicious nodes not added to the send queue: %d" % malicious_nodes_not_added_count, extra=self.format)
|
||||
malicious_nodes_not_added_percentage = (malicious_nodes_not_added_count * 100)/(self.shape.numberNodes)
|
||||
self.logger.debug("Percentage of malicious nodes not added to the send queue: %d" % malicious_nodes_not_added_percentage, extra=self.format)
|
||||
|
|
|
@ -305,7 +305,7 @@ class Validator:
|
|||
while self.sendQueue:
|
||||
(rID, cID) = self.sendQueue[0]
|
||||
|
||||
if rID in self.rowIDs:
|
||||
if rID in self.rowIDs and not self.amImalicious:
|
||||
for _, neigh in shuffledDict(self.rowNeighbors[rID], self.shuffleNeighbors):
|
||||
if not self.amImalicious:
|
||||
self.checkSendSegmentToNeigh(rID, cID, neigh)
|
||||
|
@ -313,7 +313,7 @@ class Validator:
|
|||
if self.statsTxInSlot >= self.bwUplink:
|
||||
return
|
||||
|
||||
if cID in self.columnIDs:
|
||||
if cID in self.columnIDs and not self.amImalicious:
|
||||
for _, neigh in shuffledDict(self.columnNeighbors[cID], self.shuffleNeighbors):
|
||||
if not self.amImalicious:
|
||||
self.checkSendSegmentToNeigh(rID, cID, neigh)
|
||||
|
@ -370,6 +370,7 @@ class Validator:
|
|||
def collectSegmentsToSend():
|
||||
# yields list of segments to send as (dim, lineID, id)
|
||||
segmentsToSend = []
|
||||
if not self.amImalicious:
|
||||
for rID, neighs in self.rowNeighbors.items():
|
||||
line = self.getRow(rID)
|
||||
needed = zeros(self.shape.blockSize)
|
||||
|
@ -405,12 +406,12 @@ class Validator:
|
|||
for dim, lineID, id in self.segmentShuffleGen:
|
||||
if dim == 0:
|
||||
for _, neigh in shuffledDict(self.rowNeighbors[lineID], self.shuffleNeighbors):
|
||||
if self.checkSegmentToNeigh(lineID, id, neigh):
|
||||
if self.checkSegmentToNeigh(lineID, id, neigh) and not self.amImalicious:
|
||||
yield((lineID, id, neigh))
|
||||
break
|
||||
else:
|
||||
for _, neigh in shuffledDict(self.columnNeighbors[lineID], self.shuffleNeighbors):
|
||||
if self.checkSegmentToNeigh(id, lineID, neigh):
|
||||
if self.checkSegmentToNeigh(id, lineID, neigh) and not self.amImalicious:
|
||||
yield((id, lineID, neigh))
|
||||
break
|
||||
|
||||
|
@ -425,6 +426,7 @@ class Validator:
|
|||
|
||||
for rid, cid, neigh in nextSegment():
|
||||
# segments are checked just before yield, so we can send directly
|
||||
if not self.amImalicious:
|
||||
self.sendSegmentToNeigh(rid, cid, neigh)
|
||||
|
||||
if self.statsTxInSlot >= self.bwUplink:
|
||||
|
@ -450,7 +452,7 @@ class Validator:
|
|||
cID = random.randrange(0, self.shape.blockSize)
|
||||
if self.block.getSegment(rID, cID) :
|
||||
neigh = random.choice(list(self.rowNeighbors[rID].values()))
|
||||
if self.checkSegmentToNeigh(rID, cID, neigh):
|
||||
if self.checkSegmentToNeigh(rID, cID, neigh) and not self.amImalicious:
|
||||
yield(rID, cID, neigh)
|
||||
t = tries
|
||||
if self.columnIDs:
|
||||
|
@ -458,13 +460,14 @@ class Validator:
|
|||
rID = random.randrange(0, self.shape.blockSize)
|
||||
if self.block.getSegment(rID, cID) :
|
||||
neigh = random.choice(list(self.columnNeighbors[cID].values()))
|
||||
if self.checkSegmentToNeigh(rID, cID, neigh):
|
||||
if self.checkSegmentToNeigh(rID, cID, neigh) and not self.amImalicious:
|
||||
yield(rID, cID, neigh)
|
||||
t = tries
|
||||
t -= 1
|
||||
|
||||
for rid, cid, neigh in nextSegment():
|
||||
# segments are checked just before yield, so we can send directly
|
||||
if not self.amImalicious:
|
||||
self.sendSegmentToNeigh(rid, cid, neigh)
|
||||
|
||||
if self.statsTxInSlot >= self.bwUplink:
|
||||
|
|
Loading…
Reference in New Issue