Skip to content

fix(sync-v2): compare to local bytes broke in some cases#747

Merged
jansegre merged 1 commit intomasterfrom
fix/compare-with-partial
Aug 8, 2023
Merged

fix(sync-v2): compare to local bytes broke in some cases#747
jansegre merged 1 commit intomasterfrom
fix/compare-with-partial

Conversation

@jansegre
Copy link
Member

@jansegre jansegre commented Aug 4, 2023

Motivation

When testing sync-v2 on v0.55.0, one of the nodes got stuck in a particular situation logging this exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/hathor/p2p/sync_v2/manager.py", line 746, in handle_blocks
    self.on_new_tx(blk, propagate_to_peers=False, quiet=True)
  File "/usr/local/lib/python3.10/site-packages/hathor/p2p/sync_v2/manager.py", line 1137, in on_new_tx
    if not self.manager.on_new_tx(tx):
  File "/usr/local/lib/python3.10/site-packages/hathor/profiler/cpu.py", line 207, in _wrapper
    ret = fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/hathor/manager.py", line 949, in on_new_tx
    self.tx_storage.compare_bytes_with_local_tx(tx)
  File "/usr/local/lib/python3.10/site-packages/hathor/transaction/storage/transaction_storage.py", line 517, in compare_bytes_with_local_tx
    local_tx = self.get_transaction(tx.hash)
  File "/usr/local/lib/python3.10/site-packages/hathor/transaction/storage/transaction_storage.py", line 569, in get_transaction
    self.post_get_validation(tx)
  File "/usr/local/lib/python3.10/site-packages/hathor/transaction/storage/transaction_storage.py", line 437, in post_get_validation
    self._validate_transaction_in_scope(tx)
  File "/usr/local/lib/python3.10/site-packages/hathor/transaction/storage/transaction_storage.py", line 451, in _validate_transaction_in_scope
    raise TransactionNotInAllowedScopeError(tx.hash_hex, self.get_allow_scope().name, tx_meta.validation.name)
hathor.transaction.storage.exceptions.TransactionNotInAllowedScopeError: ('00000000000000020737994b34fdd7f402641657e297d8bb364367bf3f775f08', 'VALID', 'BASIC')

It is not entirely clear what lead to the situation, but it is very possible that it is a normal case that can happen naturally depending on the timing of connections being closed and/or the node restarting. In any case the failure itself should not happen, at the higher level compare_bytes_with_local_tx was called and it failed because of the validation state of the transaction, but the method shouldn't depend on that.

Acceptance Criteria

  • Make compare_bytes_with_local_tx work regardless of the validation state of the transaction
  • Have tests that cover it

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@jansegre jansegre self-assigned this Aug 4, 2023
@jansegre jansegre force-pushed the fix/compare-with-partial branch from a718825 to f99d067 Compare August 4, 2023 02:00
@jansegre jansegre marked this pull request as ready for review August 4, 2023 02:05
@jansegre jansegre requested a review from msbrogli as a code owner August 4, 2023 02:05
@jansegre jansegre requested a review from glevco August 4, 2023 02:05
@jansegre jansegre force-pushed the fix/compare-with-partial branch from f99d067 to 21505bc Compare August 4, 2023 02:06
@jansegre jansegre merged commit a63ab5f into master Aug 8, 2023
@jansegre jansegre deleted the fix/compare-with-partial branch August 8, 2023 03:58
This was referenced Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants