Skip to content

Instantly share code, notes, and snippets.

@nikkolasg
Last active September 21, 2020 09:44
Show Gist options
  • Save nikkolasg/43403ee732f1acd8f2b517494d558d9f to your computer and use it in GitHub Desktop.
Save nikkolasg/43403ee732f1acd8f2b517494d558d9f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
precommitGas = 9000000
provecommitGas = 40000000
windowpostGas = 512265727
sectorsInPartition = 2349
maxSectorsPerWindowPost = 10000
sectorSize = 32
blockLimitGas = 10e9
tipset = 5
## rate at which the network grows in size each day in Gb
## 10 Pb
growthRateDay = 20 * 1024 * 1024
## rate for each block in GB
growthRateBlock = growthRateDay / 24 / 60 / 2
## number of precommit for 32GB sectors
growthPreCommit = growthRateBlock / sectorSize
growthProveCommit = growthPreCommit
maxdeadline = 48
roundsInDeadline = 30 * 2
## fillingPerc assumes that all the blocks in the tipset contains transactions
## that uses only this percentage of the maximum gas available.
## If you take 1/tipset, it means you only use one block worth of gas for example
fillingPerc = 0.30
print("Filling percentage of tipset: ", fillingPerc*100, "%")
print("Daily growth rate of",growthRateDay, "GB")
print("Number of pre + prove commit per block: ",2 * int(growthPreCommit))
bb = 1024
def gbToEB(gb):
return gb/bb/bb/bb
def ebToGB(eb):
return eb * bb * bb * bb
def windowPostToSectors(nbWindowPost):
return nbWindowPost * maxSectorsPerWindowPost
def sectorsToWindowPost(nbSectors):
return max(1, nbSectors / maxSectorsPerWindowPost)
totalSectors = 0
rounds = 0
deadline = 0
## contains the number of sectors to prove at each deadline
toProve = dict.fromkeys(range(0,maxdeadline),0)
while True:
## since we have the growthPreCommit = growthProveCommit
growthGas = growthPreCommit * (precommitGas + provecommitGas)
## how many gas can we use in the tipset
gasLeft = blockLimitGas * fillingPerc * tipset - growthGas
## we prove sectors spreaded over all the rounds in the deadline
nbWindowPost = sectorsToWindowPost(toProve[deadline]) / roundsInDeadline
gasWindow = windowpostGas * nbWindowPost
## we don't have enough place to prove all sectors anymore
if gasWindow > gasLeft:
break
totalSectors += growthPreCommit
rounds += 1
## register the new sectors for proving in 24h
toProve[(deadline - 1) % maxdeadline] += growthProveCommit
## we increase the deadline when we have passed 60 rounds
if rounds % roundsInDeadline == 0:
deadline = (deadline + 1) % maxdeadline
print("How many rounds until full of windowpost: ",rounds)
print("How much time this takes (years): %.2f" % (rounds / 2 / 60 / 24 / 365))
print("How many sectors emboarded: ", int(totalSectors))
print("How much storage this means (EB): %.2f" % gbToEB(totalSectors * 32))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment