diff --git a/specs/_features/eip7594/p2p-interface.md b/specs/_features/eip7594/p2p-interface.md index 712845c56..3dd199425 100644 --- a/specs/_features/eip7594/p2p-interface.md +++ b/specs/_features/eip7594/p2p-interface.md @@ -73,11 +73,16 @@ def verify_data_column_sidecar(sidecar: DataColumnSidecar) -> bool: Verify if the data column sidecar is valid. """ # The sidecar index must be within the valid range - assert sidecar.index < NUMBER_OF_COLUMNS + if sidecar.index >= NUMBER_OF_COLUMNS + return False + # A sidecar for zero blobs is invalid - assert len(sidecar.kzg_commitments) > 0 + if len(sidecar.kzg_commitments) == 0: + return False + # There should be an equal number of cells/commitments/proofs - assert len(sidecar.column) == len(sidecar.kzg_commitments) == len(sidecar.kzg_proofs) + if len(sidecar.column) != len(sidecar.kzg_commitments) or len(sidecar.column) != len(sidecar.kzg_proofs): + return False return True ``` diff --git a/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_networking.py b/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_networking.py index 3797a4ecd..a818c746f 100644 --- a/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_networking.py +++ b/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_networking.py @@ -1,6 +1,5 @@ import random from eth2spec.test.context import ( - expect_assertion_error, single_phase, spec_state_test, spec_test, @@ -62,7 +61,7 @@ def test_verify_data_column_sidecar__invalid_zero_blobs(spec, state): sidecar.column = [] sidecar.kzg_commitments = [] sidecar.kzg_proofs = [] - expect_assertion_error(lambda: spec.verify_data_column_sidecar(sidecar)) + assert not spec.verify_data_column_sidecar(sidecar) @with_eip7594_and_later @@ -71,7 +70,7 @@ def test_verify_data_column_sidecar__invalid_zero_blobs(spec, state): def test_verify_data_column_sidecar__invalid_index(spec, state): sidecar = compute_data_column_sidecar(spec, state) sidecar.index = 128 - expect_assertion_error(lambda: spec.verify_data_column_sidecar(sidecar)) + assert not spec.verify_data_column_sidecar(sidecar) @with_eip7594_and_later @@ -80,7 +79,7 @@ def test_verify_data_column_sidecar__invalid_index(spec, state): def test_verify_data_column_sidecar__invalid_mismatch_len_column(spec, state): sidecar = compute_data_column_sidecar(spec, state) sidecar.column = sidecar.column[1:] - expect_assertion_error(lambda: spec.verify_data_column_sidecar(sidecar)) + assert not spec.verify_data_column_sidecar(sidecar) @with_eip7594_and_later @@ -89,7 +88,7 @@ def test_verify_data_column_sidecar__invalid_mismatch_len_column(spec, state): def test_verify_data_column_sidecar__invalid_mismatch_len_kzg_commitments(spec, state): sidecar = compute_data_column_sidecar(spec, state) sidecar.kzg_commitments = sidecar.kzg_commitments[1:] - expect_assertion_error(lambda: spec.verify_data_column_sidecar_kzg_proofs(sidecar)) + assert not spec.verify_data_column_sidecar(sidecar) @with_eip7594_and_later @@ -98,7 +97,7 @@ def test_verify_data_column_sidecar__invalid_mismatch_len_kzg_commitments(spec, def test_verify_data_column_sidecars__invalid_mismatch_len_kzg_proofs(spec, state): sidecar = compute_data_column_sidecar(spec, state) sidecar.kzg_proofs = sidecar.kzg_proofs[1:] - expect_assertion_error(lambda: spec.verify_data_column_sidecar_kzg_proofs(sidecar)) + assert not spec.verify_data_column_sidecar(sidecar) # Tests for verify_data_column_sidecar_kzg_proofs