From 96b71a19de3c67091b241cdd077e5e50270e6d43 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 30 Jun 2020 16:58:56 +0800 Subject: [PATCH] Avoid Python-specific negative operation --- specs/phase0/validator.md | 2 +- specs/phase1/custody-game.md | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/specs/phase0/validator.md b/specs/phase0/validator.md index e325f75f6..a3bbcac32 100644 --- a/specs/phase0/validator.md +++ b/specs/phase0/validator.md @@ -307,7 +307,7 @@ def get_eth1_vote(state: BeaconState, eth1_chain: Sequence[Eth1Block]) -> Eth1Da valid_votes = [vote for vote in state.eth1_data_votes if vote in votes_to_consider] # Default vote on latest eth1 block data in the period range unless eth1 chain is not live - default_vote = votes_to_consider[-1] if any(votes_to_consider) else state.eth1_data + default_vote = votes_to_consider[len(votes_to_consider) - 1] if any(votes_to_consider) else state.eth1_data return max( valid_votes, diff --git a/specs/phase1/custody-game.md b/specs/phase1/custody-game.md index 6b767193a..e454e28c0 100644 --- a/specs/phase1/custody-game.md +++ b/specs/phase1/custody-game.md @@ -229,9 +229,11 @@ Given one set of data, return the custody atoms: each atom will be combined with ```python def get_custody_atoms(bytez: bytes) -> Sequence[bytes]: - bytez += b'\x00' * (-len(bytez) % BYTES_PER_CUSTODY_ATOM) # right-padding - return [bytez[i:i + BYTES_PER_CUSTODY_ATOM] - for i in range(0, len(bytez), BYTES_PER_CUSTODY_ATOM)] + bytez += b'\x00' * ((BYTES_PER_CUSTODY_ATOM - len(bytez)) % BYTES_PER_CUSTODY_ATOM) # right-padding + return [ + bytez[i:i + BYTES_PER_CUSTODY_ATOM] + for i in range(0, len(bytez), BYTES_PER_CUSTODY_ATOM) + ] ``` ### `get_custody_secrets`