Merge pull request #58 from codex-storage/published-copies

Allow setting number of published copies in config file
This commit is contained in:
Csaba Kiraly 2024-03-04 17:30:31 +01:00 committed by GitHub
commit a2d6fd2deb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 3 deletions

View File

@ -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)})

View File

@ -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