commit
1eebbf545b
|
@ -13,9 +13,17 @@ from typing import (
|
||||||
NewType,
|
NewType,
|
||||||
Tuple,
|
Tuple,
|
||||||
)
|
)
|
||||||
from eth2spec.utils.minimal_ssz import *
|
from eth2spec.utils.minimal_ssz import (
|
||||||
|
SSZType,
|
||||||
|
hash_tree_root,
|
||||||
|
signing_root,
|
||||||
|
)
|
||||||
from eth2spec.utils.hash_function import hash
|
from eth2spec.utils.hash_function import hash
|
||||||
from eth2spec.utils.bls import *
|
from eth2spec.utils.bls import (
|
||||||
|
bls_aggregate_pubkeys,
|
||||||
|
bls_verify,
|
||||||
|
bls_verify_multiple,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# stub, will get overwritten by real var
|
# stub, will get overwritten by real var
|
||||||
|
|
|
@ -1776,7 +1776,8 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
|
||||||
validator_pubkeys = [v.pubkey for v in state.validator_registry]
|
validator_pubkeys = [v.pubkey for v in state.validator_registry]
|
||||||
if pubkey not in validator_pubkeys:
|
if pubkey not in validator_pubkeys:
|
||||||
# Verify the deposit signature (proof of possession).
|
# Verify the deposit signature (proof of possession).
|
||||||
# Invalid signatures are allowed by the deposit contract, and hence included on-chain, but must not be processed.
|
# Invalid signatures are allowed by the deposit contract,
|
||||||
|
# and hence included on-chain, but must not be processed.
|
||||||
# Note: deposits are valid across forks, hence the deposit domain is retrieved directly from `bls_domain`
|
# Note: deposits are valid across forks, hence the deposit domain is retrieved directly from `bls_domain`
|
||||||
if not bls_verify(
|
if not bls_verify(
|
||||||
pubkey, signing_root(deposit.data), deposit.data.signature, bls_domain(DOMAIN_DEPOSIT)
|
pubkey, signing_root(deposit.data), deposit.data.signature, bls_domain(DOMAIN_DEPOSIT)
|
||||||
|
|
|
@ -89,7 +89,7 @@ def test_invalid_signature(state):
|
||||||
transfer = get_valid_transfer(state)
|
transfer = get_valid_transfer(state)
|
||||||
# un-activate so validator can transfer
|
# un-activate so validator can transfer
|
||||||
state.validator_registry[transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH
|
state.validator_registry[transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH
|
||||||
|
|
||||||
yield from run_transfer_processing(state, transfer, False)
|
yield from run_transfer_processing(state, transfer, False)
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,7 +140,13 @@ def test_insufficient_balance(state):
|
||||||
def test_no_dust_sender(state):
|
def test_no_dust_sender(state):
|
||||||
sender_index = get_active_validator_indices(state, get_current_epoch(state))[-1]
|
sender_index = get_active_validator_indices(state, get_current_epoch(state))[-1]
|
||||||
balance = state.balances[sender_index]
|
balance = state.balances[sender_index]
|
||||||
transfer = get_valid_transfer(state, sender_index=sender_index, amount=balance - spec.MIN_DEPOSIT_AMOUNT + 1, fee=0, signed=True)
|
transfer = get_valid_transfer(
|
||||||
|
state,
|
||||||
|
sender_index=sender_index,
|
||||||
|
amount=balance - spec.MIN_DEPOSIT_AMOUNT + 1,
|
||||||
|
fee=0,
|
||||||
|
signed=True,
|
||||||
|
)
|
||||||
|
|
||||||
# un-activate so validator can transfer
|
# un-activate so validator can transfer
|
||||||
state.validator_registry[transfer.sender].activation_epoch = spec.FAR_FUTURE_EPOCH
|
state.validator_registry[transfer.sender].activation_epoch = spec.FAR_FUTURE_EPOCH
|
||||||
|
|
|
@ -3,6 +3,7 @@ from eth2spec.phase0 import spec
|
||||||
# We import pytest only when it's present, i.e. when we are running tests.
|
# We import pytest only when it's present, i.e. when we are running tests.
|
||||||
# The test-cases themselves can be generated without installing pytest.
|
# The test-cases themselves can be generated without installing pytest.
|
||||||
|
|
||||||
|
|
||||||
def module_exists(module_name):
|
def module_exists(module_name):
|
||||||
try:
|
try:
|
||||||
__import__(module_name)
|
__import__(module_name)
|
||||||
|
|
|
@ -77,4 +77,3 @@ def build_empty_block(state, slot=None, signed=False):
|
||||||
|
|
||||||
def build_empty_block_for_next_slot(state, signed=False):
|
def build_empty_block_for_next_slot(state, signed=False):
|
||||||
return build_empty_block(state, state.slot + 1, signed=signed)
|
return build_empty_block(state, state.slot + 1, signed=signed)
|
||||||
|
|
||||||
|
|
|
@ -55,4 +55,3 @@ def test_over_epoch_boundary(state):
|
||||||
yield 'slots', slots
|
yield 'slots', slots
|
||||||
process_slots(state, state.slot + slots)
|
process_slots(state, state.slot + slots)
|
||||||
yield 'post', state
|
yield 'post', state
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue