remove 'int' types from spec typehints. replace with uint64
This commit is contained in:
parent
3ae077a09b
commit
d1bc2f03ac
|
@ -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``.
|
||||
"""
|
||||
|
@ -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``.
|
||||
"""
|
||||
|
@ -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``.
|
||||
"""
|
||||
|
@ -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``).
|
||||
"""
|
||||
|
@ -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``.
|
||||
"""
|
||||
|
@ -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``.
|
||||
"""
|
||||
|
@ -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.
|
||||
"""
|
||||
|
|
|
@ -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)
|
||||
|
@ -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
|
||||
```
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ class BeaconBlockBody(Container):
|
|||
### `ceillog2`
|
||||
|
||||
```python
|
||||
def ceillog2(x: int) -> int:
|
||||
def ceillog2(x: uint64) -> int:
|
||||
return x.bit_length()
|
||||
```
|
||||
|
||||
|
@ -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``.
|
||||
"""
|
||||
|
@ -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)
|
||||
```
|
||||
|
|
|
@ -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.
|
||||
"""
|
||||
|
@ -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]:
|
||||
|
@ -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(
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue