mirror of
https://github.com/codex-storage/das-research.git
synced 2025-02-23 16:28:27 +00:00
generate row/column interest locally in validator
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
4a5d410f6a
commit
dc7a4d3c03
@ -15,6 +15,7 @@ class Simulator:
|
|||||||
def __init__(self, shape, config):
|
def __init__(self, shape, config):
|
||||||
"""It initializes the simulation with a set of parameters (shape)."""
|
"""It initializes the simulation with a set of parameters (shape)."""
|
||||||
self.shape = shape
|
self.shape = shape
|
||||||
|
self.config = config
|
||||||
self.format = {"entity": "Simulator"}
|
self.format = {"entity": "Simulator"}
|
||||||
self.result = Result(self.shape)
|
self.result = Result(self.shape)
|
||||||
self.validators = []
|
self.validators = []
|
||||||
@ -28,12 +29,18 @@ class Simulator:
|
|||||||
self.glob = Observer(self.logger, self.shape)
|
self.glob = Observer(self.logger, self.shape)
|
||||||
self.glob.reset()
|
self.glob.reset()
|
||||||
self.validators = []
|
self.validators = []
|
||||||
rows = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberValidators/self.shape.blockSize)
|
if self.config.evenLineDistribution:
|
||||||
columns = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberValidators/self.shape.blockSize)
|
rows = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberValidators/self.shape.blockSize)
|
||||||
random.shuffle(rows)
|
columns = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberValidators/self.shape.blockSize)
|
||||||
random.shuffle(columns)
|
random.shuffle(rows)
|
||||||
|
random.shuffle(columns)
|
||||||
for i in range(self.shape.numberValidators):
|
for i in range(self.shape.numberValidators):
|
||||||
val = Validator(i, int(not i!=0), self.logger, self.shape, rows, columns)
|
if self.config.evenLineDistribution:
|
||||||
|
val = Validator(i, int(not i!=0), self.logger, self.shape,
|
||||||
|
rows[(i*self.shape.chi):((i+1)*self.shape.chi)],
|
||||||
|
columns[(i*self.shape.chi):((i+1)*self.shape.chi)])
|
||||||
|
else:
|
||||||
|
val = Validator(i, int(not i!=0), self.logger, self.shape)
|
||||||
if i == self.proposerID:
|
if i == self.proposerID:
|
||||||
val.initBlock()
|
val.initBlock()
|
||||||
self.glob.setGoldenData(val.block)
|
self.glob.setGoldenData(val.block)
|
||||||
|
@ -38,8 +38,13 @@ class Validator:
|
|||||||
"""It returns the validator ID."""
|
"""It returns the validator ID."""
|
||||||
return str(self.ID)
|
return str(self.ID)
|
||||||
|
|
||||||
def __init__(self, ID, amIproposer, logger, shape, rows, columns):
|
def __init__(self, ID, amIproposer, logger, shape, rows = None, columns = None):
|
||||||
"""It initializes the validator with the logger, shape and assigned rows/columns."""
|
"""It initializes the validator with the logger shape and rows/columns.
|
||||||
|
|
||||||
|
If rows/columns are specified these are observed, otherwise (default)
|
||||||
|
chi rows and columns are selected randomly.
|
||||||
|
"""
|
||||||
|
|
||||||
self.shape = shape
|
self.shape = shape
|
||||||
FORMAT = "%(levelname)s : %(entity)s : %(message)s"
|
FORMAT = "%(levelname)s : %(entity)s : %(message)s"
|
||||||
self.ID = ID
|
self.ID = ID
|
||||||
@ -59,12 +64,16 @@ class Validator:
|
|||||||
self.rowIDs = range(shape.blockSize)
|
self.rowIDs = range(shape.blockSize)
|
||||||
self.columnIDs = range(shape.blockSize)
|
self.columnIDs = range(shape.blockSize)
|
||||||
else:
|
else:
|
||||||
self.rowIDs = rows[(self.ID*self.shape.chi):(self.ID*self.shape.chi + self.shape.chi)]
|
|
||||||
self.columnIDs = columns[(self.ID*self.shape.chi):(self.ID*self.shape.chi + self.shape.chi)]
|
|
||||||
#if shape.deterministic:
|
#if shape.deterministic:
|
||||||
# random.seed(self.ID)
|
# random.seed(self.ID)
|
||||||
#self.rowIDs = random.sample(range(self.shape.blockSize), self.shape.chi)
|
if rows:
|
||||||
#self.columnIDs = random.sample(range(self.shape.blockSize), self.shape.chi)
|
self.rowIDs = rows
|
||||||
|
else:
|
||||||
|
self.rowIDs = random.sample(range(self.shape.blockSize), self.shape.chi)
|
||||||
|
if columns:
|
||||||
|
self.columnIDs = columns
|
||||||
|
else:
|
||||||
|
self.columnIDs = random.sample(range(self.shape.blockSize), self.shape.chi)
|
||||||
self.rowNeighbors = collections.defaultdict(dict)
|
self.rowNeighbors = collections.defaultdict(dict)
|
||||||
self.columnNeighbors = collections.defaultdict(dict)
|
self.columnNeighbors = collections.defaultdict(dict)
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ logLevel = logging.INFO
|
|||||||
# for more details, see joblib.Parallel
|
# for more details, see joblib.Parallel
|
||||||
numJobs = 3
|
numJobs = 3
|
||||||
|
|
||||||
|
# distribute rows/columns evenly between validators (True)
|
||||||
|
# or generate it using local randomness (False)
|
||||||
|
evenLineDistribution = False
|
||||||
|
|
||||||
# Number of simulation runs with the same parameters for statistical relevance
|
# Number of simulation runs with the same parameters for statistical relevance
|
||||||
runs = range(10)
|
runs = range(10)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user