Skip to content

Commit

Permalink
Merge branch 'helperscleanup' of github.com:ethereum/eth2.0-specs int…
Browse files Browse the repository at this point in the history
…o helperscleanup
  • Loading branch information
JustinDrake committed Jun 30, 2019
2 parents d2ad809 + d1bc2f0 commit bb8eca6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class BeaconState(Container):
#### `integer_squareroot`

```python
def integer_squareroot(n: int) -> int:
def integer_squareroot(n: uint64) -> int:
"""
Return the largest integer ``x`` such that ``x**2 <= n``.
"""
Expand All @@ -564,7 +564,7 @@ def xor(bytes1: Bytes32, bytes2: Bytes32) -> Bytes32:
```

```python
def int_to_bytes(integer: int, length: int) -> bytes:
def int_to_bytes(integer: uint64, length: uint64) -> bytes:
"""
Return the ``length``-byte serialization of ``integer``.
"""
Expand Down Expand Up @@ -647,7 +647,7 @@ def is_slashable_attestation_data(data_1: AttestationData, data_2: AttestationDa
#### `is_valid_merkle_branch`

```python
def is_valid_merkle_branch(leaf: Hash, branch: Sequence[Hash], depth: int, index: int, root: Hash) -> bool:
def is_valid_merkle_branch(leaf: Hash, branch: Sequence[Hash], depth: uint64, index: uint64, root: Hash) -> bool:
"""
Check if ``leaf`` at ``index`` verifies against the Merkle ``root`` and ``branch``.
"""
Expand All @@ -665,7 +665,7 @@ def is_valid_merkle_branch(leaf: Hash, branch: Sequence[Hash], depth: int, index
#### `shuffle_index`

```python
def shuffle_index(index: ValidatorIndex, index_count: int, seed: Hash) -> ValidatorIndex:
def shuffle_index(index: ValidatorIndex, index_count: uint64, seed: Hash) -> ValidatorIndex:
"""
Return the shuffled validator index corresponding to ``seed`` (and ``index_count``).
"""
Expand All @@ -691,8 +691,8 @@ def shuffle_index(index: ValidatorIndex, index_count: int, seed: Hash) -> Valida
```python
def compute_committee(indices: Sequence[ValidatorIndex],
seed: Hash,
index: int,
count: int) -> Sequence[ValidatorIndex]:
index: uint64,
count: uint64) -> Sequence[ValidatorIndex]:
"""
Return the committee corresponding to ``indices``, ``seed``, ``index``, and committee ``count``.
"""
Expand Down Expand Up @@ -767,7 +767,7 @@ def delayed_activation_exit_epoch(epoch: Epoch) -> Epoch:
#### `bls_domain`

```python
def bls_domain(domain_type: int, fork_version: bytes=b'\x00' * 4) -> int:
def bls_domain(domain_type: uint64, fork_version: bytes=b'\x00' * 4) -> int:
"""
Return the BLS domain for the ``domain_type`` and ``fork_version``.
"""
Expand Down Expand Up @@ -997,7 +997,7 @@ def get_total_active_balance(state: BeaconState) -> Gwei:
#### `get_domain`

```python
def get_domain(state: BeaconState, domain_type: int, message_epoch: Epoch=None) -> int:
def get_domain(state: BeaconState, domain_type: uint64, message_epoch: Epoch=None) -> int:
"""
Return the signature domain (fork version concatenated with domain type) of a message.
"""
Expand Down
4 changes: 2 additions & 2 deletions specs/core/0_fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class LatestMessage(object):
```python
@dataclass
class Store(object):
time: int
time: uint64
justified_checkpoint: Checkpoint
finalized_checkpoint: Checkpoint
blocks: Dict[Hash, BeaconBlock] = field(default_factory=dict)
Expand Down Expand Up @@ -141,7 +141,7 @@ def get_head(store: Store) -> Hash:
#### `on_tick`

```python
def on_tick(store: Store, time: int) -> None:
def on_tick(store: Store, time: uint64) -> None:
store.time = time
```

Expand Down
6 changes: 3 additions & 3 deletions specs/core/1_custody-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class BeaconBlockBody(Container):
### `ceillog2`

```python
def ceillog2(x: int) -> int:
def ceillog2(x: uint64) -> int:
return x.bit_length()
```

Expand All @@ -275,7 +275,7 @@ def get_custody_chunk_count(crosslink: Crosslink) -> int:
### `get_bit`

```python
def get_bit(serialization: bytes, i: int) -> int:
def get_bit(serialization: bytes, i: uint64) -> int:
"""
Extract the bit in ``serialization`` at position ``i``.
"""
Expand Down Expand Up @@ -304,7 +304,7 @@ def get_chunk_bits_root(chunk_bits: bytes) -> Bytes32:
### `get_randao_epoch_for_custody_period`

```python
def get_randao_epoch_for_custody_period(period: int, validator_index: ValidatorIndex) -> Epoch:
def get_randao_epoch_for_custody_period(period: uint64, validator_index: ValidatorIndex) -> Epoch:
next_period_start = (period + 1) * EPOCHS_PER_CUSTODY_PERIOD - validator_index % EPOCHS_PER_CUSTODY_PERIOD
return Epoch(next_period_start + CUSTODY_PERIOD_TO_RANDAO_PADDING)
```
Expand Down
8 changes: 4 additions & 4 deletions specs/core/1_shard-data-chains.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ class ShardBlockHeader(Container):
def get_period_committee(state: BeaconState,
epoch: Epoch,
shard: Shard,
index: int,
count: int) -> Sequence[ValidatorIndex]:
index: uint64,
count: uint64) -> Sequence[ValidatorIndex]:
"""
Return committee for a period. Used to construct persistent committees.
"""
Expand Down Expand Up @@ -248,7 +248,7 @@ def verify_shard_attestation_signature(state: BeaconState,

```python
def compute_crosslink_data_root(blocks: Sequence[ShardBlock]) -> Bytes32:
def is_power_of_two(value: int) -> bool:
def is_power_of_two(value: uint64) -> bool:
return (value > 0) and (value & (value - 1) == 0)

def pad_to_power_of_2(values: MutableSequence[bytes]) -> Sequence[bytes]:
Expand All @@ -259,7 +259,7 @@ def compute_crosslink_data_root(blocks: Sequence[ShardBlock]) -> Bytes32:
def hash_tree_root_of_bytes(data: bytes) -> bytes:
return hash_tree_root([data[i:i + 32] for i in range(0, len(data), 32)])

def zpad(data: bytes, length: int) -> bytes:
def zpad(data: bytes, length: uint64) -> bytes:
return data + b'\x00' * (length - len(data))

return hash(
Expand Down
2 changes: 1 addition & 1 deletion specs/validator/0_beacon-chain-validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ epoch_signature = bls_sign(

The `block.eth1_data` field is for block proposers to vote on recent Eth 1.0 data. This recent data contains an Eth 1.0 block hash as well as the associated deposit root (as calculated by the `get_hash_tree_root()` method of the deposit contract) and deposit count after execution of the corresponding Eth 1.0 block. If over half of the block proposers in the current Eth 1.0 voting period vote for the same `eth1_data` then `state.eth1_data` updates at the end of the voting period. Each deposit in `block.body.deposits` must verify against `state.eth1_data.eth1_deposit_root`.

Let `get_eth1_data(distance: int) -> Eth1Data` be the (subjective) function that returns the Eth 1.0 data at distance `distance` relative to the Eth 1.0 head at the start of the current Eth 1.0 voting period. Let `previous_eth1_distance` be the distance relative to the Eth 1.0 block corresponding to `state.eth1_data.block_hash` at the start of the current Eth 1.0 voting period. An honest block proposer sets `block.eth1_data = get_eth1_vote(state, previous_eth1_distance)` where:
Let `get_eth1_data(distance: uint64) -> Eth1Data` be the (subjective) function that returns the Eth 1.0 data at distance `distance` relative to the Eth 1.0 head at the start of the current Eth 1.0 voting period. Let `previous_eth1_distance` be the distance relative to the Eth 1.0 block corresponding to `state.eth1_data.block_hash` at the start of the current Eth 1.0 voting period. An honest block proposer sets `block.eth1_data = get_eth1_vote(state, previous_eth1_distance)` where:

```python
def get_eth1_vote(state: BeaconState, previous_eth1_distance: uint64) -> Eth1Data:
Expand Down

0 comments on commit bb8eca6

Please sign in to comment.