Clean up `is_data_available`. Remove the stub `retrieve_blobs_and_proofs` responses.

This commit is contained in:
Hsiao-Wei Wang 2023-07-25 23:32:55 +08:00
parent d2d351f7c9
commit e79caff2f7
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
3 changed files with 9 additions and 7 deletions

View File

@ -21,9 +21,9 @@ T = TypeVar('T') # For generic function
@classmethod
def sundry_functions(cls) -> str:
return '''
def retrieve_blobs_and_proofs(beacon_block_root: Root) -> PyUnion[Tuple[Blob, KZGProof], Tuple[str, str]]:
def retrieve_blobs_and_proofs(beacon_block_root: Root) -> Tuple[Sequence[Blob], Sequence[KZGProof]]:
# pylint: disable=unused-argument
return ("TEST", "TEST")'''
return [], []'''
@classmethod
def execution_engine_cls(cls) -> str:

View File

@ -55,11 +55,6 @@ def is_data_available(beacon_block_root: Root, blob_kzg_commitments: Sequence[KZ
# `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS`
blobs, proofs = retrieve_blobs_and_proofs(beacon_block_root)
# For testing, `retrieve_blobs_and_proofs` returns ("TEST", "TEST").
# TODO: Remove it once we have a way to inject `BlobSidecar` into tests.
if isinstance(blobs, str) or isinstance(proofs, str):
return True
return verify_blob_kzg_proof_batch(blobs, blob_kzg_commitments, proofs)
```

View File

@ -10,11 +10,18 @@ from eth2spec.test.helpers.attestations import (
class BlobData(NamedTuple):
"""
The return values of ``retrieve_blobs_and_proofs`` helper.
"""
blobs: Sequence[Any]
proofs: Sequence[bytes]
def with_blob_data(spec, blob_data, func):
"""
This helper runs the given ``func`` with monkeypatched ``retrieve_blobs_and_proofs``
that returns ``blob_data.blobs, blob_data.proofs``.
"""
def retrieve_blobs_and_proofs(beacon_block_root):
return blob_data.blobs, blob_data.proofs