make extracted byte uint8 for bitshift, do not use negative slice indexing, avoid negative comparison in test
This commit is contained in:
parent
3fb0257cbb
commit
3b7617f51a
2
setup.py
2
setup.py
|
@ -96,7 +96,7 @@ from lru import LRU
|
||||||
|
|
||||||
from eth2spec.utils.ssz.ssz_impl import hash_tree_root, copy
|
from eth2spec.utils.ssz.ssz_impl import hash_tree_root, copy
|
||||||
from eth2spec.utils.ssz.ssz_typing import (
|
from eth2spec.utils.ssz.ssz_typing import (
|
||||||
View, boolean, Container, List, Vector, uint64,
|
View, boolean, Container, List, Vector, uint64, uint8,
|
||||||
Bytes1, Bytes4, Bytes32, Bytes48, Bytes96, Bitlist, Bitvector,
|
Bytes1, Bytes4, Bytes32, Bytes48, Bytes96, Bitlist, Bitvector,
|
||||||
)
|
)
|
||||||
from eth2spec.utils import bls
|
from eth2spec.utils import bls
|
||||||
|
|
|
@ -737,7 +737,7 @@ def compute_shuffled_index(index: uint64, index_count: uint64, seed: Bytes32) ->
|
||||||
flip = (pivot + index_count - index) % index_count
|
flip = (pivot + index_count - index) % index_count
|
||||||
position = max(index, flip)
|
position = max(index, flip)
|
||||||
source = hash(seed + int_to_bytes(current_round, length=1) + int_to_bytes(position // 256, length=4))
|
source = hash(seed + int_to_bytes(current_round, length=1) + int_to_bytes(position // 256, length=4))
|
||||||
byte = source[(position % 256) // 8]
|
byte = uint8(source[(position % 256) // 8])
|
||||||
bit = (byte >> (position % 8)) % 2
|
bit = (byte >> (position % 8)) % 2
|
||||||
index = flip if bit else index
|
index = flip if bit else index
|
||||||
|
|
||||||
|
@ -1317,7 +1317,7 @@ def process_justification_and_finalization(state: BeaconState) -> None:
|
||||||
|
|
||||||
# Process justifications
|
# Process justifications
|
||||||
state.previous_justified_checkpoint = state.current_justified_checkpoint
|
state.previous_justified_checkpoint = state.current_justified_checkpoint
|
||||||
state.justification_bits[1:] = state.justification_bits[:-1]
|
state.justification_bits[1:] = state.justification_bits[:JUSTIFICATION_BITS_LENGTH - 1]
|
||||||
state.justification_bits[0] = 0b0
|
state.justification_bits[0] = 0b0
|
||||||
matching_target_attestations = get_matching_target_attestations(state, previous_epoch) # Previous epoch
|
matching_target_attestations = get_matching_target_attestations(state, previous_epoch) # Previous epoch
|
||||||
if get_attesting_balance(state, matching_target_attestations) * 3 >= get_total_active_balance(state) * 2:
|
if get_attesting_balance(state, matching_target_attestations) * 3 >= get_total_active_balance(state) * 2:
|
||||||
|
|
|
@ -48,7 +48,7 @@ def test_genesis_epoch_full_attestations_no_rewards(spec, state):
|
||||||
attestation = get_valid_attestation(spec, state, signed=True)
|
attestation = get_valid_attestation(spec, state, signed=True)
|
||||||
attestations.append(attestation)
|
attestations.append(attestation)
|
||||||
# fill each created slot in state after inclusion delay
|
# fill each created slot in state after inclusion delay
|
||||||
if slot - spec.MIN_ATTESTATION_INCLUSION_DELAY >= 0:
|
if slot >= spec.MIN_ATTESTATION_INCLUSION_DELAY:
|
||||||
include_att = attestations[slot - spec.MIN_ATTESTATION_INCLUSION_DELAY]
|
include_att = attestations[slot - spec.MIN_ATTESTATION_INCLUSION_DELAY]
|
||||||
add_attestations_to_state(spec, state, [include_att], state.slot)
|
add_attestations_to_state(spec, state, [include_att], state.slot)
|
||||||
next_slot(spec, state)
|
next_slot(spec, state)
|
||||||
|
|
Loading…
Reference in New Issue