MCPcopy
hub / github.com/ethereum/research / test_deposit_in_block

Function test_deposit_in_block

spec_pythonizer/sanity_check.py:338–369  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

336
337# @timeit
338def test_deposit_in_block(state):
339 pre_state = deepcopy(state)
340 test_deposit_data_leaves = deepcopy(all_deposit_data_leaves)
341
342 index = len(test_deposit_data_leaves)
343 pubkey = pubkeys[index]
344 deposit_data = create_deposit_data(pre_state, pubkey, spec.MAX_DEPOSIT_AMOUNT)
345
346 item = hash(deposit_data.serialize())
347 test_deposit_data_leaves.append(item)
348 tree = calc_merkle_tree_from_leaves(tuple(test_deposit_data_leaves))
349 root = get_merkle_root((tuple(test_deposit_data_leaves)))
350 proof = list(get_merkle_proof(tree, item_index=index))
351 assert verify_merkle_branch(item, proof, spec.DEPOSIT_CONTRACT_TREE_DEPTH, index, root)
352
353 deposit = Deposit(
354 proof=list(proof),
355 index=index,
356 deposit_data=deposit_data,
357 )
358
359 pre_state.latest_eth1_data.deposit_root = root
360 post_state = deepcopy(pre_state)
361 block = construct_empty_block_for_next_slot(post_state)
362 block.body.deposits.append(deposit)
363
364 state_transition(post_state, block)
365 assert len(post_state.validator_registry) == len(state.validator_registry) + 1
366 assert len(post_state.validator_balances) == len(state.validator_balances) + 1
367 assert post_state.validator_registry[index].pubkey == pubkeys[index]
368
369 return pre_state, [block], post_state
370
371
372# @timeit

Callers

nothing calls this directly

Calls 10

hashFunction · 0.90
get_merkle_rootFunction · 0.90
get_merkle_proofFunction · 0.90
state_transitionFunction · 0.90
deepcopyFunction · 0.85
create_deposit_dataFunction · 0.85
serializeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected