Skip to content

Instantly share code, notes, and snippets.

@nikkolasg
Created September 16, 2020 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikkolasg/4a2199c0814708e15f01d3583ef8e36f to your computer and use it in GitHub Desktop.
Save nikkolasg/4a2199c0814708e15f01d3583ef8e36f to your computer and use it in GitHub Desktop.
Compute the maximum storage size given some conditions and the time to reach it
#!/usr/bin/env python3
precommitGas = 9000000
provecommitGas = 40000000
windowpostGas = 512265727
windowPostInPartition = 2349
sectorSize = 32
blockLimitGas = 10e9
percPreCommit = 0.33
percProveCommit = 0.33
percWindowPost = 0.33
tipset = 5
def howManyTx(gasTx,proportion):
return blockLimitGas * proportion / gasTx
def gbToEB(gb):
return gb/1024/1024/1024
def ebToGB(eb):
return eb * 1024 * 1024 * 1024
## how many windowpost in a day
nbWindowPost = howManyTx(windowpostGas, percWindowPost) * tipset * 2 * 60 * 24
## how much storage does this represents in EB
storageWPost = gbToEB(nbWindowPost * windowPostInPartition * sectorSize)
## how many precommit in a block
nbPreCommit = howManyTx(precommitGas, percPreCommit)
## how many provecommit in a block
nbProveCommit = howManyTx(provecommitGas, percProveCommit)
## we take the min to be able to determine the soonest the amount of storage is
## fully emboarded. For example if we can put 133 PreCommit but 150 ProveCommit,
## we still need to wait to emboard 133 PreCommit each time, so it's longer
nbEmboardTx = min(nbPreCommit,nbProveCommit)
## how many rounds do we need to reach the size representable with window posts
rounds = ebToGB(storageWPost) / (nbEmboardTx * sectorSize * tipset)
## how much time does this represents
timeMonths = rounds / (2 * 60 * 24 * 30)
print("Number of window posts in a day: ",nbWindowPost)
print("Can reach max storage: ",storageWPost, "(EB)")
print("Number of rounds to to reach that storage: ",rounds)
print("In months: ",timeMonths)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment