Skip to content

Commit

Permalink
Merge branch 'dev' into remove-verify-cell-kzg-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored Jul 9, 2024
2 parents 0daa2ac + 5cce790 commit c402414
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 74 deletions.
3 changes: 1 addition & 2 deletions specs/_features/eip7594/polynomial-commitments-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def verify_cell_kzg_proof_batch_impl(row_commitments: Sequence[KZGCommitment],

# Step 4.2: Compute RLI = [sum_k r^k interpolation_poly_k(s)]
# Note: an efficient implementation would use the IDFT based method explained in the blog post
sum_interp_polys_coeff = [0]
sum_interp_polys_coeff = [0] * n
for k in range(num_cells):
interp_poly_coeff = interpolate_polynomialcoeff(coset_for_cell(column_indices[k]), cosets_evals[k])
interp_poly_scaled_coeff = multiply_polynomialcoeff([r_powers[k]], interp_poly_coeff)
Expand All @@ -526,7 +526,6 @@ def verify_cell_kzg_proof_batch_impl(row_commitments: Sequence[KZGCommitment],
]))
```


### Cell cosets

#### `coset_shift_for_cell`
Expand Down
2 changes: 1 addition & 1 deletion specs/deneb/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def is_valid_block_hash(self: ExecutionEngine,
def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
"""
Return ``True`` if and only if the version hashes computed by the blob transactions of
``new_payload_request.execution_payload`` matches ``new_payload_request.version_hashes``.
``new_payload_request.execution_payload`` matches ``new_payload_request.versioned_hashes``.
"""
...
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_bad_parent_hash_first_payload(spec, state):

execution_payload = build_empty_execution_payload(spec, state)
execution_payload.parent_hash = b'\x55' * 32
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload)

Expand All @@ -146,7 +146,7 @@ def test_invalid_bad_parent_hash_regular_payload(spec, state):

execution_payload = build_empty_execution_payload(spec, state)
execution_payload.parent_hash = spec.Hash32()
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)

Expand All @@ -156,7 +156,7 @@ def run_bad_prev_randao_test(spec, state):

execution_payload = build_empty_execution_payload(spec, state)
execution_payload.prev_randao = b'\x42' * 32
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)

Expand All @@ -182,7 +182,7 @@ def run_bad_everything_test(spec, state):
execution_payload.parent_hash = spec.Hash32()
execution_payload.prev_randao = spec.Bytes32()
execution_payload.timestamp = 0
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)

Expand Down Expand Up @@ -211,7 +211,7 @@ def run_bad_timestamp_test(spec, state, is_future):
else:
timestamp = execution_payload.timestamp - 1
execution_payload.timestamp = timestamp
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)

Expand Down Expand Up @@ -249,7 +249,7 @@ def run_non_empty_extra_data_test(spec, state):

execution_payload = build_empty_execution_payload(spec, state)
execution_payload.extra_data = b'\x45' * 12
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload)
assert state.latest_execution_payload_header.extra_data == execution_payload.extra_data
Expand Down Expand Up @@ -278,7 +278,7 @@ def run_non_empty_transactions_test(spec, state):
spec.Transaction(b'\x99' * 128)
for _ in range(num_transactions)
]
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload)
assert state.latest_execution_payload_header.transactions_root == execution_payload.transactions.hash_tree_root()
Expand All @@ -304,7 +304,7 @@ def run_zero_length_transaction_test(spec, state):
execution_payload = build_empty_execution_payload(spec, state)
execution_payload.transactions = [spec.Transaction(b'')]
assert len(execution_payload.transactions[0]) == 0
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload)
assert state.latest_execution_payload_header.transactions_root == execution_payload.transactions.hash_tree_root()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_all_valid(spec, state):
def run_func():
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_block.block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
signed_block = state_transition_and_sign_block(spec, state, block)
yield from tick_and_add_block(spec, store, signed_block, test_steps, merge_block=True)
# valid
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_block_lookup_failed(spec, state):
def run_func():
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_block.block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
signed_block = state_transition_and_sign_block(spec, state, block)
yield from tick_and_add_block(spec, store, signed_block, test_steps, valid=False, merge_block=True,
block_not_found=True)
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_too_early_for_merge(spec, state):
def run_func():
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_block.block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
signed_block = state_transition_and_sign_block(spec, state, block)
yield from tick_and_add_block(spec, store, signed_block, test_steps, valid=False, merge_block=True)

Expand Down Expand Up @@ -174,7 +174,7 @@ def test_too_late_for_merge(spec, state):
def run_func():
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_block.block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
signed_block = state_transition_and_sign_block(spec, state, block)
yield from tick_and_add_block(spec, store, signed_block, test_steps, valid=False, merge_block=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_from_syncing_to_invalid(spec, state):
block_hashes[f'chain_a_{i - 1}'] if i != 0 else block_hashes['block_0']
)
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_a_{i}', 'UTF-8'))
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
block_hashes[f'chain_a_{i}'] = block.body.execution_payload.block_hash

signed_block = state_transition_and_sign_block(spec, state, block)
Expand All @@ -82,7 +82,7 @@ def test_from_syncing_to_invalid(spec, state):
block_hashes[f'chain_b_{i - 1}'] if i != 0 else block_hashes['block_0']
)
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_b_{i}', 'UTF-8'))
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
block_hashes[f'chain_b_{i}'] = block.body.execution_payload.block_hash

signed_block = state_transition_with_full_block(spec, state, True, True, block=block)
Expand All @@ -95,7 +95,7 @@ def test_from_syncing_to_invalid(spec, state):
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = signed_blocks_b[-1].message.body.execution_payload.block_hash
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_b_{i}', 'UTF-8'))
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
block_hashes['chain_b_3'] = block.body.execution_payload.block_hash

# Ensure that no duplicate block hashes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_validate_merge_block_success(spec, state):
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
run_validate_merge_block(spec, pow_chain, block)


Expand All @@ -81,7 +81,7 @@ def test_validate_merge_block_fail_parent_block_lookup(spec, state):
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
run_validate_merge_block(spec, pow_chain, block, valid=False)


Expand All @@ -93,7 +93,7 @@ def test_validate_merge_block_fail_after_terminal(spec, state):
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY + uint256(1)
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
run_validate_merge_block(spec, pow_chain, block, valid=False)


Expand All @@ -110,7 +110,7 @@ def test_validate_merge_block_tbh_override_success(spec, state):
pow_chain.head().block_hash = TERMINAL_BLOCK_HASH
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
run_validate_merge_block(spec, pow_chain, block)


Expand All @@ -126,7 +126,7 @@ def test_validate_merge_block_fail_parent_hash_is_not_tbh(spec, state):
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
run_validate_merge_block(spec, pow_chain, block, valid=False)


Expand All @@ -143,7 +143,7 @@ def test_validate_merge_block_terminal_block_hash_fail_activation_not_reached(sp
pow_chain.head().block_hash = TERMINAL_BLOCK_HASH
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
run_validate_merge_block(spec, pow_chain, block, valid=False)


Expand All @@ -159,5 +159,5 @@ def test_validate_merge_block_fail_activation_not_reached_parent_hash_is_not_tbh
pow_chain.head().total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = pow_chain.head().block_hash
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
run_validate_merge_block(spec, pow_chain, block, valid=False)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ def test_invalid_bad_parent_hash_first_payload(spec, state):

execution_payload = build_empty_execution_payload(spec, state)
execution_payload.parent_hash = b'\x55' * 32
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload)
execution_payload.block_hash = compute_el_block_hash(spec, execution_payload, state)

yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
Loading

0 comments on commit c402414

Please sign in to comment.