diff --git a/DAS/simulator.py b/DAS/simulator.py index c76aff0..7d4b341 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -41,7 +41,8 @@ class Simulator: # pushed out by the proposer. # 1: the data is sent out exactly once on rows and once on columns (2 copies in total) # self.shape.netDegree: default behavior similar (but not same) to previous code - self.proposerPublishTo = self.shape.netDegree # TODO: make this an external parameter + self.proposerPublishToR = config.evalConf(self, config.proposerPublishToR, shape) + self.proposerPublishToC = config.evalConf(self, config.proposerPublishToR, shape) def initValidators(self): """It initializes all the validators in the network.""" @@ -202,12 +203,12 @@ class Simulator: for v in self.validators: if (self.proposerPublishOnly and v.amIproposer): for id in v.rowIDs: - count = min(self.proposerPublishTo, len(rowChannels[id])) + count = min(self.proposerPublishToR, len(rowChannels[id])) publishTo = random.sample(rowChannels[id], count) for vi in publishTo: v.rowNeighbors[id].update({vi.ID : Neighbor(vi, 0, self.shape.nbCols)}) for id in v.columnIDs: - count = min(self.proposerPublishTo, len(columnChannels[id])) + count = min(self.proposerPublishToC, len(columnChannels[id])) publishTo = random.sample(columnChannels[id], count) for vi in publishTo: v.columnNeighbors[id].update({vi.ID : Neighbor(vi, 1, self.shape.nbRows)}) diff --git a/smallConf.py b/smallConf.py index 8938dc1..685c2b1 100644 --- a/smallConf.py +++ b/smallConf.py @@ -62,6 +62,11 @@ randomizeMaliciousNodes = True # Per-topic mesh neighborhood size netDegrees = range(8, 9, 2) +# How many copies are sent out by the block producer +# Note, previously this was set to match netDegree +proposerPublishToR = "shape.netDegree" +proposerPublishToC = "shape.netDegree" + # the overall number of row/columns taken into custody by a node is determined by # a base number (custody) and a class specific multiplier (validatorsPerNode). # We support two models: @@ -120,3 +125,18 @@ def nextShape(): if netDegree % 2 == 0: shape = Shape(nbCols, nbColsK, nbRows, nbRowsK, nn, fm, fr, mn, class1ratio, chR, chC, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run) yield shape + +def evalConf(self, param, shape = None): + '''Allow lazy evaluation of params in various forms + + Examples: + sendLineUntilR = "shape.blockSizeRK" + sendLineUntilC = lambda shape : shape.blockSizeCK + perNodeQueue = "self.amIproposer" + ''' + if callable(param): + return param(shape) + elif isinstance(param, str): + return eval(param) + else: + return param