fix: add get_shares_commitments to da

This commit is contained in:
Roman 2025-04-08 14:05:33 +08:00
parent 19d4b04a55
commit 6af92fa449
No known key found for this signature in database
GPG Key ID: 583BDF43C238B83E
3 changed files with 34 additions and 0 deletions

View File

@ -43,6 +43,12 @@ def to_app_id(n: int) -> list:
return list(n.to_bytes(32, byteorder="big"))
def to_blob_id(n: int) -> list:
if n < 0:
raise ValueError("Input must be an unsigned integer (non-negative)")
return list(n.to_bytes(32, byteorder="big"))
def random_divide_k(n, k):
if n < k:
raise ValueError(f"n={n} must be at least k={k} to split into {k} parts")

View File

@ -157,3 +157,6 @@ class NomosNode:
def send_get_data_range_request(self, data):
return self._api.da_get_range(data)
def send_get_commitments_request(self, data):
return self._api.da_get_commitments(data)

View File

@ -28,6 +28,11 @@ def prepare_get_range_request(app_id, start_index, end_index):
return query_data
def prepare_get_shares_commitments_request(blob_id):
query_data = {"blob_id": blob_id}
return query_data
def response_contains_data(response):
if response is None:
return False
@ -101,3 +106,23 @@ class StepsDataAvailability(StepsCommon):
return response
return get_range()
@allure.step
def get_shares_commitments(self, node, blob_id, **kwargs):
timeout_duration = kwargs.get("timeout_duration", 65)
interval = kwargs.get("interval", 0.1)
query = prepare_get_shares_commitments_request(blob_id)
@retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(interval), reraise=True)
def get_commitments():
try:
response = node.send_get_commitments_request(query)
except Exception as ex:
logger.error(f"Exception while retrieving commitments: {ex}")
raise
return response
return get_commitments()