diff --git a/DAS/simulator.py b/DAS/simulator.py index 0bdbfd6..a6788b8 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -25,6 +25,18 @@ class Simulator: self.proposerID = 0 self.glob = [] + # In GossipSub the initiator might push messages without participating in the mesh. + # proposerPublishOnly regulates this behavior. If set to true, the proposer is not + # part of the p2p distribution graph, only pushes segments to it. If false, the proposer + # might get back segments from other peers since links are symmetric. + self.proposerPublishOnly = True + + # If proposerPublishOnly == True, this regulates how many copies of each segment are + # 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 + def initValidators(self): """It initializes all the validators in the network.""" self.glob = Observer(self.logger, self.shape) @@ -150,29 +162,6 @@ class Simulator: logger.addHandler(ch) self.logger = logger - def resetShape(self, shape): - """It resets the parameters of the simulation.""" - self.shape = shape - self.result = Result(self.shape) - for val in self.validators: - val.shape.failureRate = shape.failureRate - val.shape.chi = shape.chi - val.shape.vpn1 = shape.vpn1 - val.shape.vpn2 = shape.vpn2 - - # In GossipSub the initiator might push messages without participating in the mesh. - # proposerPublishOnly regulates this behavior. If set to true, the proposer is not - # part of the p2p distribution graph, only pushes segments to it. If false, the proposer - # might get back segments from other peers since links are symmetric. - self.proposerPublishOnly = True - - # If proposerPublishOnly == True, this regulates how many copies of each segment are - # 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 - - def run(self): """It runs the main simulation until the block is available or it gets stucked.""" self.glob.checkRowsColumns(self.validators) diff --git a/study.py b/study.py index 3b956e8..e7e6ce6 100644 --- a/study.py +++ b/study.py @@ -24,14 +24,12 @@ def initLogger(config): def runOnce(config, shape): - sim = Simulator(shape, config) - if config.deterministic: shape.setSeed(config.randomSeed+"-"+str(shape)) random.seed(shape.randomSeed) + sim = Simulator(shape, config) sim.initLogger() - sim.resetShape(shape) sim.initValidators() sim.initNetwork() result = sim.run()