Skip to content

Commit

Permalink
Update ice age
Browse files Browse the repository at this point in the history
  • Loading branch information
vbuterin committed May 30, 2017
1 parent ac89506 commit 43ebb25
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
12 changes: 6 additions & 6 deletions iceage.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import random
import datetime

diffs = [343.14 * 10**12]
hashpower = diffs[0] / 15
times = [1493974999]
diffs = [453.71 * 10**12]
hashpower = diffs[0] / 15.73
times = [1495425834]


for i in range(3653829, 6010000):
for i in range(3746966, 6010000):
blocktime = random.expovariate(hashpower / diffs[-1])
adjfac = max(1 - int(blocktime / 10), -99) / 2048.
newdiff = diffs[-1] * (1 + adjfac)
Expand All @@ -15,6 +15,6 @@
diffs.append(newdiff)
times.append(times[-1] + blocktime)
if i % 10000 == 0:
print 'Block %d, approx ETH supply %d, time %r blocktime %.2f' % \
(i, 60102216 * 1.199 + 5.3 * i, datetime.datetime.utcfromtimestamp(times[-1]).isoformat().replace('T',' '), diffs[-1] / hashpower)
print('Block %d, approx ETH supply %d, time %r blocktime %.2f' % \
(i, 60102216 * 1.199 + 5.3 * i, datetime.datetime.utcfromtimestamp(times[-1]).isoformat().replace('T',' '), diffs[-1] / hashpower))
# print int(adjfac * 2048)
18 changes: 12 additions & 6 deletions selfish_mining_strats.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def test_strat(strat, hashpower, gamma, reward, fees, uncle_rewards=1, uncle_coe
if me_blocks >= len(strat) or them_blocks >= len(strat[me_blocks]) or strat[me_blocks][them_blocks] == 1:
# Override
if me_blocks > them_blocks or (me_blocks == them_blocks and random.random() < gamma):
me_reward += me_blocks * reward - (reward if me_blocks and them_blocks else 0)
# me_reward += me_blocks * reward - (reward if me_blocks and them_blocks else 0)
me_reward += me_blocks * reward
me_fees += time_elapsed * fees
divisor += me_blocks - (1 if me_blocks and them_blocks else 0)
# divisor += me_blocks - (1 if me_blocks and them_blocks else 0)
divisor += me_blocks
me_totblocks += me_blocks
# Add uncles
while me_blocks < 7 and them_blocks > 0:
Expand All @@ -55,9 +57,11 @@ def test_strat(strat, hashpower, gamma, reward, fees, uncle_rewards=1, uncle_coe
me_blocks += 1
# Adopt
else:
them_reward += them_blocks * reward - (reward if me_blocks and them_blocks else 0)
# them_reward += them_blocks * reward - (reward if me_blocks and them_blocks else 0)
them_reward += them_blocks * reward
them_fees += time_elapsed * fees
divisor += them_blocks - (1 if me_blocks and them_blocks else 0)
# divisor += them_blocks - (1 if me_blocks and them_blocks else 0)
divisor += them_blocks
them_totblocks += them_blocks
# Add uncles
while them_blocks < 7 and me_blocks > 0:
Expand All @@ -73,9 +77,11 @@ def test_strat(strat, hashpower, gamma, reward, fees, uncle_rewards=1, uncle_coe
# Match
elif strat[me_blocks][them_blocks] == 2 and not last_is_me:
if random.random() < gamma:
me_reward += me_blocks * reward + time_elapsed * fees - (reward if me_blocks and them_blocks else 0)
# me_reward += me_blocks * reward + time_elapsed * fees - (reward if me_blocks and them_blocks else 0)
me_reward += me_blocks * reward
me_totblocks += me_blocks
divisor += me_blocks - (1 if me_blocks and them_blocks else 0)
# divisor += me_blocks - (1 if me_blocks and them_blocks else 0)
divisor += me_blocks
time_elapsed = 0
# Add uncles
while me_blocks < 7 and them_blocks > 0:
Expand Down

0 comments on commit 43ebb25

Please sign in to comment.