From 2d636ddf5acff71808a044148095b28e8bf52522 Mon Sep 17 00:00:00 2001 From: protolambda Date: Tue, 11 Jun 2019 17:27:34 +0200 Subject: [PATCH] BLS withdrawal byte is formatted as int now, but still one byte. Justin changed spec, now fix tests + configs --- configs/constant_presets/mainnet.yaml | 2 +- configs/constant_presets/minimal.yaml | 2 +- test_libs/pyspec/eth2spec/test/helpers/deposits.py | 2 +- test_libs/pyspec/eth2spec/test/helpers/transfers.py | 2 +- .../test/phase_0/block_processing/test_process_deposit.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configs/constant_presets/mainnet.yaml b/configs/constant_presets/mainnet.yaml index bca7febc7..dca2a69ba 100644 --- a/configs/constant_presets/mainnet.yaml +++ b/configs/constant_presets/mainnet.yaml @@ -48,7 +48,7 @@ GENESIS_FORK_VERSION: 0x00000000 GENESIS_SLOT: 0 # 2**64 - 1 FAR_FUTURE_EPOCH: 18446744073709551615 -BLS_WITHDRAWAL_PREFIX: 0x00 +BLS_WITHDRAWAL_PREFIX: 0 # Time parameters diff --git a/configs/constant_presets/minimal.yaml b/configs/constant_presets/minimal.yaml index 23bc6e819..fa337cfbf 100644 --- a/configs/constant_presets/minimal.yaml +++ b/configs/constant_presets/minimal.yaml @@ -47,7 +47,7 @@ GENESIS_FORK_VERSION: 0x00000000 GENESIS_SLOT: 0 # 2**64 - 1 FAR_FUTURE_EPOCH: 18446744073709551615 -BLS_WITHDRAWAL_PREFIX: 0x00 +BLS_WITHDRAWAL_PREFIX: 0 # Time parameters diff --git a/test_libs/pyspec/eth2spec/test/helpers/deposits.py b/test_libs/pyspec/eth2spec/test/helpers/deposits.py index b84970044..1d4761753 100644 --- a/test_libs/pyspec/eth2spec/test/helpers/deposits.py +++ b/test_libs/pyspec/eth2spec/test/helpers/deposits.py @@ -67,7 +67,7 @@ def prepare_state_and_deposit(spec, state, validator_index, amount, withdrawal_c # insecurely use pubkey as withdrawal key if no credentials provided if withdrawal_credentials is None: - withdrawal_credentials = spec.BLS_WITHDRAWAL_PREFIX + spec.hash(pubkey)[1:] + withdrawal_credentials = spec.int_to_bytes(spec.BLS_WITHDRAWAL_PREFIX, length=1) + spec.hash(pubkey)[1:] deposit, root, deposit_data_leaves = build_deposit( spec, diff --git a/test_libs/pyspec/eth2spec/test/helpers/transfers.py b/test_libs/pyspec/eth2spec/test/helpers/transfers.py index eea12a36d..4d40deee7 100644 --- a/test_libs/pyspec/eth2spec/test/helpers/transfers.py +++ b/test_libs/pyspec/eth2spec/test/helpers/transfers.py @@ -32,7 +32,7 @@ def get_valid_transfer(spec, state, slot=None, sender_index=None, amount=None, f # ensure withdrawal_credentials reproducible state.validator_registry[transfer.sender].withdrawal_credentials = ( - spec.BLS_WITHDRAWAL_PREFIX + spec.hash(transfer.pubkey)[1:] + spec.int_to_bytes(spec.BLS_WITHDRAWAL_PREFIX, length=1) + spec.hash(transfer.pubkey)[1:] ) return transfer diff --git a/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_deposit.py b/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_deposit.py index 42de447ec..603a07c3d 100644 --- a/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_deposit.py +++ b/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_deposit.py @@ -101,7 +101,7 @@ def test_invalid_sig_top_up(spec, state): def test_invalid_withdrawal_credentials_top_up(spec, state): validator_index = 0 amount = spec.MAX_EFFECTIVE_BALANCE // 4 - withdrawal_credentials = spec.BLS_WITHDRAWAL_PREFIX + spec.hash(b"junk")[1:] + withdrawal_credentials = spec.int_to_bytes(spec.BLS_WITHDRAWAL_PREFIX, length=1) + spec.hash(b"junk")[1:] deposit = prepare_state_and_deposit( spec, state,