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

feat: improve txo validation logic #4689

Conversation

hansieodendaal
Copy link
Contributor

@hansieodendaal hansieodendaal commented Sep 16, 2022

Description

Fixed atomic mined height update error and implemented a recovery safety net for transaction output validation.

Motivation and Context

Transaction validation was failing in an endless loop under certain conditions. (See #4680, #4669, #4670)

Fixes #4669
Fixes #4670

How Has This Been Tested?

Passed unit tests.
Passed cucumber tests.
System level testing.

Co-Authored-By: SW van Heerden [email protected]

@hansieodendaal hansieodendaal force-pushed the fix_atomic_mined_height_update_error branch 6 times, most recently from 7fb78e7 to e41d7b5 Compare September 16, 2022 14:36
@hansieodendaal hansieodendaal changed the title [wip] feat: improve txo validation logic feat: improve txo validation logic Sep 16, 2022
@SWvheerden
Copy link
Collaborator

Fixes: #4669
Fixes: #4670

Copy link
Collaborator

@stringhandler stringhandler left a comment

Choose a reason for hiding this comment

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

It is not entirely clear how this solves the problem. I would also suggest using a semaphore instead, so that we could have X threads doing validation instead of just one.

There are a lot of warnings spread across the changes making it unclear where the actual fix is.

tokio::spawn(async move {
// Note: We do not want the validation task to be queued
let mut _lock = match validation_in_progress.try_lock() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is very difficult to understand the logic here, can it not be simplified?

@stringhandler stringhandler added P-controversial Process - This PR or Issue is controversial and/or requires more attention that simpler issues CR-insufficient_context Your PRs commit messages don't provide enough context to justify accepting the change. labels Sep 20, 2022
@stringhandler
Copy link
Collaborator

Reviewing again, perhaps a semaphore is not correct here. Mutex is fine, but please try simplify the code

hansieodendaal and others added 3 commits September 20, 2022 09:43
- Fixed atomic mined height update error and implemented a recovery safety net for
  transaction output validation.
- Stopped the TXO validation task from being executed in parallel as this will
  result in db operation on exactly the same data.
- Added error int to allow ffi to distinguish between internal and communication
  errors (#12).

Co-Authored-By: SW van Heerden [email protected]
* add specific already busy status, more comments
@hansieodendaal hansieodendaal force-pushed the fix_atomic_mined_height_update_error branch from 9da45e7 to 5111112 Compare September 20, 2022 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CR-insufficient_context Your PRs commit messages don't provide enough context to justify accepting the change. P-controversial Process - This PR or Issue is controversial and/or requires more attention that simpler issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wallet output table broken row Investigate wallet validation trigger
4 participants