Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cardano_node_tests/utils/custom_clusterlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def cli(
"""
# Set a default timeout. This is a change of behavior compared to the base class!
if timeout is None:
timeout = 120
timeout = 300

cli_args_strs_all = [str(arg) for arg in cli_args]
if add_default_args:
Expand Down
38 changes: 20 additions & 18 deletions cardano_node_tests/utils/submit_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Utilities for `cardano-submit-api` REST service."""

import binascii
import contextlib
import dataclasses
import json
import logging
Expand Down Expand Up @@ -68,20 +67,16 @@ def post_cbor(*, cbor_file: clusterlib.FileType, url: str) -> requests.Response:
if r > 1:
LOGGER.warning(f"Resubmitting transaction to submit-api. Attempt {r}/{attempts}.")

response = None
with contextlib.suppress(requests.exceptions.ReadTimeout):
response = http_client.get_session().post(
url, headers=headers, data=cbor_binary, timeout=60
)
response = http_client.get_session().post(
url, headers=headers, data=cbor_binary, timeout=300
)
Comment thread
mkoura marked this conversation as resolved.

if response is not None and not response and "MempoolTxTooSlow" in response.text:
# Repeat the request as the transaction didn't make it to mempool
pass
elif response is not None:
break
if not response and "MempoolTxTooSlow" in response.text:
if r < attempts:
time.sleep(random.uniform(0, r))
continue

if r < attempts:
time.sleep(random.uniform(0, r))
break
else:
err = f"Failed to submit the tx after {attempts} attempts."
raise SubmitApiError(err)
Comment thread
mkoura marked this conversation as resolved.
Expand Down Expand Up @@ -132,20 +127,21 @@ def submit_tx(
wait_blocks: A number of new blocks to wait for (default = 2).
"""
txid = ""
err = None
err: Exception | None = None
attempts = 20
for r in range(1, attempts + 1):
if r == 1:
txid = submit_tx_bare(tx_file=tx_file).txid
try:
txid = submit_tx_bare(tx_file=tx_file).txid
except requests.exceptions.ReadTimeout as exc:
Comment thread
mkoura marked this conversation as resolved.
err = exc
else:
if not txid:
msg = "The TxId is not known."
raise SubmitApiError(msg)
LOGGER.warning(
f"Resubmitting transaction '{txid}' (from '{tx_file}'). Attempt {r}/{attempts}."
)
try:
submit_tx_bare(tx_file=tx_file)
Comment thread
mkoura marked this conversation as resolved.
err = None
except SubmitApiError as exc:
# Check if resubmitting failed because an input UTxO was already spent
exc_str = str(exc)
Expand All @@ -157,6 +153,12 @@ def submit_tx(
raise
err = exc
# If here, the TX is likely still in mempool and we need to wait
except requests.exceptions.ReadTimeout as exc:
# If here, the TX might have been successfully submitted, but
# the timeout occurred before we got response.
err = exc

txid = txid or cluster_obj.g_transaction.get_txid(tx_file=tx_file)

cluster_obj.wait_for_new_block(wait_blocks)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
]
dependencies = [
"allure-pytest (>=2.15.2,<3.0.0)",
"cardano-clusterlib (>=0.10.1,<0.11.0)",
"cardano-clusterlib (>=0.10.2,<0.11.0)",
"cardonnay (>=0.3.4,<0.4.0)",
"cbor2 (>=5.7.1,<6.0.0)",
"filelock (>=3.20.0,<4.0.0)",
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading