mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-05 22:53:11 +00:00
Make da verification indempotent (#118)
This commit is contained in:
parent
44af97f493
commit
3a8f8167a9
@ -69,4 +69,4 @@ class TestVerifier(TestCase):
|
||||
encoded_data.row_commitments,
|
||||
[row[i] for row in encoded_data.row_proofs],
|
||||
)
|
||||
self.assertFalse(self.verifier.verify(da_blob))
|
||||
self.assertTrue(self.verifier.verify(da_blob))
|
||||
|
||||
@ -33,9 +33,6 @@ class DABlob:
|
||||
|
||||
|
||||
class DAVerifier:
|
||||
def __init__(self):
|
||||
self.attested_blobs: Set[BlobId] = set()
|
||||
|
||||
@staticmethod
|
||||
def _verify_column(
|
||||
column: Column,
|
||||
@ -77,11 +74,18 @@ class DAVerifier:
|
||||
return True
|
||||
|
||||
def verify(self, blob: DABlob) -> bool:
|
||||
blob_id = blob.blob_id()
|
||||
if blob_id in self.attested_blobs:
|
||||
# we already attested and they are asking us to attest again
|
||||
# skip
|
||||
return False
|
||||
"""
|
||||
Verify the integrity of the given blob.
|
||||
|
||||
This function must be idempotent. The implementer should ensure that
|
||||
repeated verification attempts do not result in inconsistent states.
|
||||
|
||||
Args:
|
||||
blob (DABlob): The blob to verify.
|
||||
|
||||
Returns:
|
||||
bool: True if the blob is verified successfully, False otherwise.
|
||||
"""
|
||||
is_column_verified = DAVerifier._verify_column(
|
||||
blob.column,
|
||||
blob.column_idx,
|
||||
@ -91,10 +95,12 @@ class DAVerifier:
|
||||
)
|
||||
if not is_column_verified:
|
||||
return False
|
||||
|
||||
are_chunks_verified = DAVerifier._verify_chunks(
|
||||
blob.column, blob.rows_commitments, blob.rows_proofs, blob.column_idx
|
||||
)
|
||||
if not are_chunks_verified:
|
||||
return False
|
||||
self.attested_blobs.add(blob_id)
|
||||
|
||||
# Ensure idempotency: Implementers should define how to avoid redundant verification.
|
||||
return True
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user