mirror of
https://github.com/logos-storage/das-research.git
synced 2026-05-23 09:49:29 +00:00
Merge pull request #26 from status-im/fix-uniformDistribution
Fixing the global random uniform distribution
This commit is contained in:
commit
c7a3fb1c52
@ -30,15 +30,27 @@ class Simulator:
|
|||||||
self.glob.reset()
|
self.glob.reset()
|
||||||
self.validators = []
|
self.validators = []
|
||||||
if self.config.evenLineDistribution:
|
if self.config.evenLineDistribution:
|
||||||
rows = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberNodes/self.shape.blockSize)
|
|
||||||
columns = list(range(self.shape.blockSize)) * int(self.shape.chi*self.shape.numberNodes/self.shape.blockSize)
|
lightVal = int(self.shape.numberNodes * self.shape.class1ratio * self.shape.vpn1)
|
||||||
|
heavyVal = int(self.shape.numberNodes * (1-self.shape.class1ratio) * self.shape.vpn2)
|
||||||
|
totalValidators = lightVal + heavyVal
|
||||||
|
rows = list(range(self.shape.blockSize)) * (int(totalValidators/self.shape.blockSize)+1)
|
||||||
|
columns = list(range(self.shape.blockSize)) * (int(totalValidators/self.shape.blockSize)+1)
|
||||||
|
offset = heavyVal*self.shape.chi
|
||||||
random.shuffle(rows)
|
random.shuffle(rows)
|
||||||
random.shuffle(columns)
|
random.shuffle(columns)
|
||||||
for i in range(self.shape.numberNodes):
|
for i in range(self.shape.numberNodes):
|
||||||
if self.config.evenLineDistribution:
|
if self.config.evenLineDistribution:
|
||||||
val = Validator(i, int(not i!=0), self.logger, self.shape,
|
if i < int(heavyVal/self.shape.vpn2): # First start with the heavy nodes
|
||||||
rows[(i*self.shape.chi):((i+1)*self.shape.chi)],
|
start = i *self.shape.chi*self.shape.vpn2
|
||||||
columns[(i*self.shape.chi):((i+1)*self.shape.chi)])
|
end = (i+1)*self.shape.chi*self.shape.vpn2
|
||||||
|
else: # Then the solo stakers
|
||||||
|
j = i - int(heavyVal/self.shape.vpn2)
|
||||||
|
start = offset+( j *self.shape.chi)
|
||||||
|
end = offset+((j+1)*self.shape.chi)
|
||||||
|
r = rows[start:end]
|
||||||
|
c = columns[start:end]
|
||||||
|
val = Validator(i, int(not i!=0), self.logger, self.shape, r, c)
|
||||||
else:
|
else:
|
||||||
val = Validator(i, int(not i!=0), self.logger, self.shape)
|
val = Validator(i, int(not i!=0), self.logger, self.shape)
|
||||||
if i == self.proposerID:
|
if i == self.proposerID:
|
||||||
@ -47,6 +59,7 @@ class Simulator:
|
|||||||
else:
|
else:
|
||||||
val.logIDs()
|
val.logIDs()
|
||||||
self.validators.append(val)
|
self.validators.append(val)
|
||||||
|
self.logger.debug("Validators initialized.", extra=self.format)
|
||||||
|
|
||||||
def initNetwork(self):
|
def initNetwork(self):
|
||||||
"""It initializes the simulated network."""
|
"""It initializes the simulated network."""
|
||||||
@ -59,6 +72,14 @@ class Simulator:
|
|||||||
for id in v.columnIDs:
|
for id in v.columnIDs:
|
||||||
columnChannels[id].append(v)
|
columnChannels[id].append(v)
|
||||||
|
|
||||||
|
# Check rows/columns distribution
|
||||||
|
#totalR = 0
|
||||||
|
#totalC = 0
|
||||||
|
#for r in rowChannels:
|
||||||
|
# totalR += len(r)
|
||||||
|
#for c in columnChannels:
|
||||||
|
# totalC += len(c)
|
||||||
|
|
||||||
for id in range(self.shape.blockSize):
|
for id in range(self.shape.blockSize):
|
||||||
|
|
||||||
# If the number of nodes in a channel is smaller or equal to the
|
# If the number of nodes in a channel is smaller or equal to the
|
||||||
|
|||||||
@ -28,7 +28,7 @@ numJobs = 3
|
|||||||
|
|
||||||
# distribute rows/columns evenly between validators (True)
|
# distribute rows/columns evenly between validators (True)
|
||||||
# or generate it using local randomness (False)
|
# or generate it using local randomness (False)
|
||||||
evenLineDistribution = False
|
evenLineDistribution = True
|
||||||
|
|
||||||
# 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