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

App::Commit competes with App::CheckTx for a lock over a cache + bad caching behaviour #1104

Open
raulk opened this issue Aug 12, 2024 · 0 comments

Comments

@raulk
Copy link
Contributor

raulk commented Aug 12, 2024

Concurrency issues

This is poor concurrency design. Under certain lock starvation scenarios, it can prevent us from making consensus/chain progress.

Key principle in blockchain client design: never ever allow your consensus to be conditioned by untrusted external requests (mpool, sendRawTransaction, which invoke CheckTx); let alone for just a cache.

Instead, we should track the height of the FvmExecState we've cached, and in CheckTx, we should compare the consensus height with our cached height. If they diverged, the first CheckTx thread to notice must recycle the FvmExecState; all other threads can wait.

Logic issues

FvmExecState must be Clone, and every thread must clone it before executing, and later dispose of their instance. Today, if exec_in_check is enabled, CheckTx will execute the transaction and the resulting state tree will be the start state tree of the next CheckTx request, thus causing us to diverge from the chain state when checking transactions, until the next block is committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant