Created
September 17, 2020 12:42
-
-
Save nikkolasg/ad4ee94fb53b2fd4aaa105d7e3ccd1cf to your computer and use it in GitHub Desktop.
Simulation of pre/provecommit + window post evolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
precommitGas = 9000000 | |
provecommitGas = 40000000 | |
windowpostGas = 512265727 | |
maxSectorsPerWindowPost = 10000 | |
sectorSize = 32 | |
blockLimitGas = 10e9 | |
tipset = 5 | |
def howManyTx(gasTx,available): | |
return available / gasTx | |
bb = 1000 | |
def gbToEB(gb): | |
return gb/bb/bb/bb | |
def ebToGB(eb): | |
return eb * bb * bb * bb | |
def sectorsToWindowPost(nbSectors): | |
return max(1, nbSectors / maxSectorsPerWindowPost) | |
# we initially fill the block only with precommit and provecommit and gradually | |
# put window post in it | |
nbPreCommit = howManyTx(precommitGas, blockLimitGas/2) | |
nbProveCommit = howManyTx(provecommitGas, blockLimitGas/2) | |
nbWindowPost = 0 | |
nbSectorsEmboarded = 0 | |
deadline=0 | |
maxdeadline= 48 | |
roundsInDeadline= 30 * 2 | |
toProve = {} | |
rounds = 0 | |
for i in range(0,maxdeadline): | |
toProve[i] = 0 | |
## We continue as long as we can still put some precommit / provecommit | |
while True: | |
## keep track of how many prove commit we have seen thus far | |
nbSectorsEmboarded += nbProveCommit | |
## howmany window post should I prove at this deadline | |
## we spread out the windowpost to do over all blocks of the deadline | |
nbWindowPost = sectorsToWindowPost(toProve[deadline] / roundsInDeadline) | |
gasWindow = windowpostGas * nbWindowPost | |
gasLeft = tipset * blockLimitGas - gasWindow | |
if gasLeft < 0: | |
break | |
# we put as many pre/prove commit as we can with the gas that's left | |
nbPreCommit = howManyTx(precommitGas, gasLeft/2) | |
nbProveCommit = howManyTx(provecommitGas, gasLeft/2) | |
# in 24h - a deadline we start proving those (easier to shift by one dl) | |
toProve[(deadline-1) % maxdeadline] += nbProveCommit | |
rounds += 1 | |
## we are changing of deadline now | |
if rounds % roundsInDeadline == 0: | |
deadline = (deadline + 1) % maxdeadline | |
print("how many rounds until full of windowpost: ",rounds) | |
print("how much time does this represents (years): ", rounds / 2 / 60 / 24 / 365) | |
print("how many sectors emboarded: ", nbSectorsEmboarded) | |
print("how much storage in EB being proven: ",gbToEB(nbSectorsEmboarded*32)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment