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(grpc): return bool if mempool is out of sync instead of returning… #6728

Merged

Conversation

stringhandler
Copy link
Collaborator

@stringhandler stringhandler commented Dec 19, 2024

… an error

Removed the error "Mempool out of sync, blockchain db advanced passed current tip in mempool storage;" when getting a block template and instead return a bool that indicates such.

The clients that are worried about this can check the flag and request a new template, while clients that are not worried about this can accept the data for what it is

@stringhandler stringhandler requested a review from a team as a code owner December 19, 2024 14:49
Copy link

github-actions bot commented Dec 19, 2024

Test Results (Integration tests)

36 tests  +36   36 ✅ +36   15m 23s ⏱️ + 15m 23s
11 suites +11    0 💤 ± 0 
 2 files   + 2    0 ❌ ± 0 

Results for commit 144637d. ± Comparison against base commit 71efa03.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 19, 2024

Test Results (CI)

    3 files    129 suites   36m 36s ⏱️
1 349 tests 1 349 ✅ 0 💤 0 ❌
4 045 runs  4 045 ✅ 0 💤 0 ❌

Results for commit 144637d.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

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

I don't like this. It super dangerous and if there are transactions flowing in the network, 9/10 I think it will provide the miner with a template it cannot use to submit a block.

If the mempool is not in sync with the node, it means it has not processed the new block yet. This means it may and probably will include transactions that are already mined in the block that it has not processed yet and thus the miner will mine a block that contains an already spent output/duplicate tx. This means the base node will reject the mined block.

We added in this error specifically because we where seeing miners submitting invalid blocks and we want the miner to request a new template and not think the template is valid.

@stringhandler
Copy link
Collaborator Author

I have added the check to mmproxy to treat a false in this case as an error. I have started adding it to the gpu miner, but it needs the updated field to compile properly.

@stringhandler
Copy link
Collaborator Author

There are no transactions in the mempool on nextnet, yet we see this error all the time, so it leads me to believe the error is a false positive

@SWvheerden
Copy link
Collaborator

The reason we see this, is a race condition between the read write locks of the base node adding a block and miner asking for a template. If the miner's read requests come in first, it gets an error. Its its very likely that you will see this, and because we have no real transactions on nextnet, we wont see the invalid mined blocks, but we do ask for a lot of templates, so we will see this error a lot.

@SWvheerden
Copy link
Collaborator

SWvheerden commented Dec 19, 2024

Why dont we rather change the template request of the mempool, to release the lock and try again. That way we don't propagate the out of sync outside of the base node,
Its very much a temporary state, but during that temporary state, the templates are almost guaranteed to be bad

@stringhandler
Copy link
Collaborator Author

The problem is that Tari Universe is using this call because it is the only one that returns the current block reward. It would be best to create a method that returns all the data for tari universe instead.

However, the merge mining proxy already has been changed to treat this data the same as an error, and GPU miner can also be updated.

At a later stage you can fix this properly if you wish, but I need this fix more urgently

@stringhandler stringhandler merged commit 5164a38 into tari-project:development Dec 19, 2024
17 checks passed
@stringhandler stringhandler deleted the st-reduce-error-to-bool branch December 19, 2024 16:18
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