aptos-labs / aptos-python-sdk

Aptos Python SDK
20 stars 17 forks source link

[Bug] Examples are flaky #31

Open gregnazario opened 2 months ago

gregnazario commented 2 months ago

🐛 Bug Description

In CI, it seems like the builds fail periodically because of sequence number synchronization issues (usually because we aren't waiting on the sequence number), or it may be possible we don't use cookie stickiness on backends.

Example: https://github.com/aptos-labs/aptos-python-sdk/actions/runs/10567843264/job/29277642966?pr=30

Rotation to MultiPublicKey complete, new authkey: 0xf24cd6264990e79b343ee05d39d847672240c20d63498a7bc6e3ce4ee444ab49
poetry run python -m examples.read_aggregator
Total circulating APT: 18457257503516241927
poetry run python -m examples.secp256k1_ecdsa_transfer_coin
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 1[96](https://github.com/aptos-labs/aptos-python-sdk/actions/runs/10567843264/job/29277642966?pr=30#step:4:97), in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/work/aptos-python-sdk/aptos-python-sdk/examples/secp256k1_ecdsa_transfer_coin.py", line 68, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/runner/work/aptos-python-sdk/aptos-python-sdk/examples/secp256k1_ecdsa_transfer_coin.py", line 28, in main
    await asyncio.gather(*[alice_fund, bob_fund])
  File "/home/runner/work/aptos-python-sdk/aptos-python-sdk/aptos_sdk/async_client.py", line 920, in fund_account
    raise ApiError(response.text, response.status_code)
aptos_sdk.async_client.ApiError: API error Error(VmError): Invalid transaction: Type: Validation Code: SEQUENCE_NUMBER_TOO_OLD

Second example, also from the faucet https://github.com/aptos-labs/aptos-python-sdk/actions/runs/10567843264/job/29278249030?pr=30

poetry run python -m examples.aptos_token
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/work/aptos-python-sdk/aptos-python-sdk/examples/aptos_token.py", line 125, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/runner/work/aptos-python-sdk/aptos-python-sdk/examples/aptos_token.py", line 30, in main
    await asyncio.gather(*[bob_fund, alice_fund])
  File "/home/runner/work/aptos-python-sdk/aptos-python-sdk/aptos_sdk/async_client.py", line 9[20](https://github.com/aptos-labs/aptos-python-sdk/actions/runs/10567843264/job/29278249030?pr=30#step:4:21), in fund_account
    raise ApiError(response.text, response.status_code)
aptos_sdk.async_client.ApiError: API error Error(VmError): Invalid transaction: Type: Validation Code: SEQUENCE_NUMBER_TOO_OLD
gregnazario commented 2 months ago

This seems to be derived from the devnet faucet. I'm not sure there was a behavior change. I'm going to bypass the CI for devnet for right now.

gregnazario commented 2 months ago

Now there's a different flakiness, where indexer requests fail, because we don't wait for the indexer to update first.