Parameter tweaks

This commit is contained in:
Vitalik Buterin 2015-08-28 06:23:03 -04:00
parent 04bcd31ea3
commit 02ac09a8d0
2 changed files with 7 additions and 6 deletions

View File

@ -61,7 +61,7 @@ class Validator():
# The validator's ID, and its position in the queue # The validator's ID, and its position in the queue
self.pos = self.id = pos self.pos = self.id = pos
# This validator's offset from the clock # This validator's offset from the clock
self.time_offset = max(normal_distribution(200, 100)(), 0) self.time_offset = normal_distribution(0, 100)()
# The highest height that this validator has seen # The highest height that this validator has seen
self.max_height = 0 self.max_height = 0
self.head = None self.head = None
@ -90,10 +90,11 @@ class Validator():
for i, b in list(enumerate(self.received_blocks))[sign_from:]: for i, b in list(enumerate(self.received_blocks))[sign_from:]:
if self.received_blocks[i] is None: if self.received_blocks[i] is None:
time_delta = self.get_time() - BLKTIME * i time_delta = self.get_time() - BLKTIME * i
my_opinion = 0.35 / (1 + max(0, time_delta) * 0.3 / BLKTIME) + 0.14 my_opinion = 0.35 / (1 + max(0, time_delta) * 0.2 / BLKTIME) + 0.14
else: else:
time_delta = self.time_received[b.hash] - BLKTIME * i time_delta = self.time_received[b.hash] - BLKTIME * i
my_opinion = 0.7 / (1 + abs(time_delta) * 0.3 / BLKTIME) + 0.15 my_opinion = 0.7 / (1 + abs(time_delta) * 0.2 / BLKTIME) + 0.15
# print 'tdpost', time_delta, my_opinion
if my_opinion == 0.5: if my_opinion == 0.5:
my_opinion = 0.5001 my_opinion = 0.5001
votes = self.received_signatures[i].values() if i < len(self.received_signatures) else [] votes = self.received_signatures[i].values() if i < len(self.received_signatures) else []
@ -253,7 +254,7 @@ def run(steps=4000):
del discarded[x] del discarded[x]
for i in range(steps): for i in range(steps):
n.tick() n.tick()
if i % 250 == 0: if i % 500 == 0:
print get_opinions(n)[-60:] print get_opinions(n)[-60:]
finalized0 = [(v.max_finalized_height, v.finalized_hashes) for v in n.agents] finalized0 = [(v.max_finalized_height, v.finalized_hashes) for v in n.agents]
finalized = sorted(finalized0, key=lambda x: len(x[1])) finalized = sorted(finalized0, key=lambda x: len(x[1]))
@ -281,4 +282,4 @@ def run(steps=4000):
print "Network health back to normal!" print "Network health back to normal!"
print "###########################################################" print "###########################################################"
n.generate_peers() n.generate_peers()
calibrate(n.agents[0].finalized_hashes) calibrate(n.agents[0].finalized_hashes[:n.agents[0].max_finalized_height + 1])

View File

@ -2,4 +2,4 @@ import casper
import sys import sys
casper.logging_level = int(sys.argv[1]) if len(sys.argv) > 1 else 0 casper.logging_level = int(sys.argv[1]) if len(sys.argv) > 1 else 0
casper.run(40000) casper.run(100000)