Update casper_sharding_v2.1.md

This commit is contained in:
vbuterin 2018-09-30 14:38:51 -04:00 committed by GitHub
parent 4cb9790ea8
commit 2f9b8b2f08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -298,15 +298,18 @@ def get_block_hash(active_state, curblock, slot):
`get_block_hash(*, *, h)` should always return the block in the chain at slot `h`, and `get_shards_and_committees_for_slot(*, h)` should not change unless the dynasty changes.
Finally, we abstractly define `integer_sqrt` for use in reward/penalty calculations:
Finally, we abstractly define `integer_sqrt(x)` for use in reward/penalty calculations as the largest integer `n` such that `n**2 <= x`. Here is one possible implementation, though clients are free to use their own including standard libraries if available.
```python
def integer_sqrt(n):
return max(n in Z: n**2 <= x)
x = n
y = (x + 1) // 2
while y < x:
x = y
y = (x + n // x) // 2
return x
```
We leave `integer_sqrt` implementation details to each particular language/framework.
### On startup
* Let `x = get_new_shuffling(bytes([0] * 32), validators, 1, 0)` and set `crystallized_state.shard_and_committee_for_slots` to `x + x`