Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nayduck) - fix flaky state_sync_routed test #12821

Merged
merged 5 commits into from
Jan 28, 2025
Merged

fix(nayduck) - fix flaky state_sync_routed test #12821

merged 5 commits into from
Jan 28, 2025

Conversation

wacban
Copy link
Contributor

@wacban wacban commented Jan 28, 2025

The test was failing when the node was slow to catch up and was still at height 0 when entering this loop:

if catch_up_height >= observed_height:
break

In this case the hash_ here would be the genesis block hash:

if ctx.get_balances() == ctx.expected_balances:
ctx.send_moar_txs(hash_, 3, False)
logger.info(f"Sending moar txs at height {boot_height}")

The ctx.send_moar_txs would send it to a node that is fully caught it and has already garbage collected the genesis block. In this case the transaction would be invalid and the balance check would fail. This would in turn lead to the test being stuck forever in the final loop:

while ctx.get_balances() != ctx.expected_balances:
assert time.time() - started < TIMEOUT
logger.info(
"Waiting for the old node to catch up. Current balances: %s; Expected balances: %s"
% (ctx.get_balances(), ctx.expected_balances))
time.sleep(1)
logger.info("Old node caught up to expected balances: %s" %
ctx.expected_balances)

This PR contains a few fixes and improvement:

  • Fixing the issue described above by using the boot_nodes head's block hash when creating transactions.
  • Decreasing the timeout of the test to 100s + 2s per block to make it fail faster (5min instead of 20min)
  • Always execute the "catch up" loop at least once to make the test more interesting.
  • More assertions and logs to fail faster
  • Removed the pool_time overwrite (now the default 0.25 is used). It doesn't make any difference but the code is nicer and shorter.
  • Random mini refactorings.

This reverts commit 6cc60da5ce2bd0d9a751929bcb8e333f1a912bbf.
@wacban wacban requested a review from a team as a code owner January 28, 2025 16:31
Copy link
Member

@Longarithm Longarithm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Let's also change timeout in pytest --timeout=600 sanity/state_sync_routed.py manytx 115, etc. to something more reasonable.

@wacban wacban enabled auto-merge January 28, 2025 16:54
@wacban wacban added this pull request to the merge queue Jan 28, 2025
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.46%. Comparing base (ba1ed9f) to head (383bd74).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12821      +/-   ##
==========================================
- Coverage   70.47%   70.46%   -0.02%     
==========================================
  Files         847      847              
  Lines      175003   175003              
  Branches   175003   175003              
==========================================
- Hits       123329   123311      -18     
- Misses      46426    46439      +13     
- Partials     5248     5253       +5     
Flag Coverage Δ
backward-compatibility 0.16% <ø> (ø)
db-migration 0.16% <ø> (ø)
genesis-check 1.41% <ø> (ø)
linux 70.07% <ø> (-0.01%) ⬇️
linux-nightly 70.09% <ø> (+0.01%) ⬆️
pytests 1.70% <ø> (ø)
sanity-checks 1.52% <ø> (ø)
unittests 70.29% <ø> (-0.02%) ⬇️
upgradability 0.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Merged via the queue into master with commit e6bb098 Jan 28, 2025
29 checks passed
@wacban wacban deleted the waclaw-nayduck branch January 28, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants