Update pending deposits tests
This commit is contained in:
parent
7afe8e0742
commit
ad8f54ff7d
|
@ -334,6 +334,7 @@ def test_apply_pending_deposit_incorrect_withdrawal_credentials_top_up(spec, sta
|
|||
|
||||
@with_electra_and_later
|
||||
@spec_state_test
|
||||
@always_bls
|
||||
def test_apply_pending_deposit_key_validate_invalid_subgroup(spec, state):
|
||||
validator_index = len(state.validators)
|
||||
amount = spec.MIN_ACTIVATION_BALANCE
|
||||
|
@ -348,6 +349,7 @@ def test_apply_pending_deposit_key_validate_invalid_subgroup(spec, state):
|
|||
|
||||
@with_electra_and_later
|
||||
@spec_state_test
|
||||
@always_bls
|
||||
def test_apply_pending_deposit_key_validate_invalid_decompression(spec, state):
|
||||
validator_index = len(state.validators)
|
||||
amount = spec.MIN_ACTIVATION_BALANCE
|
||||
|
@ -425,12 +427,12 @@ def test_apply_pending_deposit_effective_deposit_with_genesis_fork_version(spec,
|
|||
assert spec.config.GENESIS_FORK_VERSION not in (state.fork.previous_version, state.fork.current_version)
|
||||
|
||||
validator_index = len(state.validators)
|
||||
fork_version=state.fork.previous_version
|
||||
fork_version = spec.config.GENESIS_FORK_VERSION
|
||||
pending_deposit = prepare_pending_deposit(
|
||||
spec,
|
||||
validator_index=validator_index,
|
||||
amount=spec.MIN_ACTIVATION_BALANCE,
|
||||
fork_version=spec.config.GENESIS_FORK_VERSION,
|
||||
fork_version=fork_version,
|
||||
signed=True
|
||||
)
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,7 +35,7 @@ def build_deposit_data(spec, pubkey, privkey, amount, withdrawal_credentials, fo
|
|||
return deposit_data
|
||||
|
||||
|
||||
def sign_deposit_data(spec, deposit_data, privkey, fork_version):
|
||||
def sign_deposit_data(spec, deposit_data, privkey, fork_version=None):
|
||||
deposit_message = spec.DepositMessage(
|
||||
pubkey=deposit_data.pubkey,
|
||||
withdrawal_credentials=deposit_data.withdrawal_credentials,
|
||||
|
@ -175,22 +175,6 @@ def prepare_state_and_deposit(spec, state, validator_index, amount,
|
|||
return deposit
|
||||
|
||||
|
||||
def build_deposit_request(spec,
|
||||
index,
|
||||
pubkey,
|
||||
privkey,
|
||||
amount,
|
||||
withdrawal_credentials,
|
||||
signed):
|
||||
deposit_data = build_deposit_data(spec, pubkey, privkey, amount, withdrawal_credentials, signed=signed)
|
||||
return spec.DepositRequest(
|
||||
pubkey=deposit_data.pubkey,
|
||||
withdrawal_credentials=deposit_data.withdrawal_credentials,
|
||||
amount=deposit_data.amount,
|
||||
signature=deposit_data.signature,
|
||||
index=index)
|
||||
|
||||
|
||||
def prepare_deposit_request(spec, validator_index, amount,
|
||||
index=None,
|
||||
pubkey=None,
|
||||
|
@ -213,71 +197,16 @@ def prepare_deposit_request(spec, validator_index, amount,
|
|||
if withdrawal_credentials is None:
|
||||
withdrawal_credentials = spec.BLS_WITHDRAWAL_PREFIX + spec.hash(pubkey)[1:]
|
||||
|
||||
return build_deposit_request(
|
||||
spec,
|
||||
index,
|
||||
pubkey,
|
||||
privkey,
|
||||
amount,
|
||||
withdrawal_credentials,
|
||||
signed,
|
||||
deposit_data = build_deposit_data(spec, pubkey, privkey, amount, withdrawal_credentials, signed=signed)
|
||||
return spec.DepositRequest(
|
||||
pubkey=deposit_data.pubkey,
|
||||
withdrawal_credentials=deposit_data.withdrawal_credentials,
|
||||
amount=deposit_data.amount,
|
||||
signature=deposit_data.signature,
|
||||
index=index
|
||||
)
|
||||
|
||||
|
||||
def build_pending_deposit_top_up(spec, state, validator_index, amount, slot=None):
|
||||
"""
|
||||
Create a pending deposit which is a top up to an existing validator
|
||||
"""
|
||||
if slot is None:
|
||||
slot = spec.GENESIS_SLOT
|
||||
|
||||
return spec.PendingDeposit(
|
||||
pubkey=state.validators[validator_index].pubkey,
|
||||
withdrawal_credentials=state.validators[validator_index].withdrawal_credentials,
|
||||
amount=amount,
|
||||
signature=bls.G2_POINT_AT_INFINITY,
|
||||
slot=slot,
|
||||
)
|
||||
|
||||
|
||||
def build_pending_deposit(spec, validator_index, amount,
|
||||
index=None,
|
||||
pubkey=None,
|
||||
privkey=None,
|
||||
withdrawal_credentials=None,
|
||||
fork_version=None,
|
||||
slot=None,
|
||||
signed=False):
|
||||
if index is None:
|
||||
index = validator_index
|
||||
|
||||
if pubkey is None:
|
||||
pubkey = pubkeys[validator_index]
|
||||
|
||||
if privkey is None:
|
||||
privkey = privkeys[validator_index]
|
||||
|
||||
if slot is None:
|
||||
slot = spec.GENESIS_SLOT
|
||||
|
||||
pending_deposit = spec.PendingDeposit(
|
||||
pubkey=pubkeys[index],
|
||||
withdrawal_credentials=withdrawal_credentials,
|
||||
amount=amount,
|
||||
slot=slot,
|
||||
)
|
||||
if signed:
|
||||
deposit_data = build_deposit_data(spec,
|
||||
pubkeys[index],
|
||||
privkeys[index],
|
||||
amount,
|
||||
withdrawal_credentials,
|
||||
fork_version,
|
||||
signed=True)
|
||||
pending_deposit.signature = deposit_data.signature
|
||||
return pending_deposit
|
||||
|
||||
|
||||
def prepare_pending_deposit(spec, validator_index, amount,
|
||||
pubkey=None,
|
||||
privkey=None,
|
||||
|
@ -450,8 +379,6 @@ def run_deposit_request_processing(
|
|||
pre_balance = get_balance(state, validator_index)
|
||||
pre_effective_balance = state.validators[validator_index].effective_balance
|
||||
|
||||
pre_pending_deposits = len(state.pending_deposits)
|
||||
|
||||
yield 'pre', state
|
||||
yield 'deposit_request', deposit_request
|
||||
|
||||
|
|
|
@ -179,3 +179,8 @@ def has_active_balance_differential(spec, state):
|
|||
def get_validator_index_by_pubkey(state, pubkey):
|
||||
index = next((i for i, validator in enumerate(state.validators) if validator.pubkey == pubkey), None)
|
||||
return index
|
||||
|
||||
|
||||
def advance_finality_to(spec, state, epoch):
|
||||
while state.finalized_checkpoint.epoch < epoch:
|
||||
next_epoch_with_full_participation(spec, state)
|
||||
|
|
Loading…
Reference in New Issue