-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Logic vulnerability when handling IPersistencePlugin during block persisting #2570
Comments
I think that it's not a bad idea |
Looks like I'm not familiar enough with this part of C# codebase. I've never thought it's possible to persist new blocks until |
BTW, maybe there is a more generic problem here in that some plugins keep their own DBs and we can't atomically flush to disk all of them, so there always is a chance for inconsistency (when one DB syncs its data to disk and another doesn't). |
Adding a Height parameter whose value is got from DB should solve this problem |
It will allow to detect inconsistency, but what can we do with it? Say we have block N persisted and NEP-17 tracker didn't make it before something killed the process, so it only has data for N-1, now on node start we can see this mismatch, but I don't think we can get data plugin needs for block N again, so probably the only thing we could do is to ask user to resync. |
We can change the order so that snapshot in neo-core is committed in the last, please refer to #2576 |
Describe the bug
IPersistencePlugins have DBs themselves, which is used to store specified data. This design, however, can bring data inconsistency in case that node closes or crashes within these lines:
neo/src/neo/Ledger/Blockchain.cs
Lines 418 to 427 in a4d2edd
Data can be writen mutiple times or missing from DBs of IPersistencePlugins.
To Reproduce
Close nodes while persisting blocks.
Solution
Height
parameter inIPersistencePlugin
, which is recorded in its DBOnCommit
andOnPersist
of missing blocks if needed, in the constructor ofIPersistencePlugin
OnPersist
andOnCommit
directly.The 3rd can also be replaced by this logic: don't persist new blocks until all IPersistencePlugins finished all
OnPersist
andOnCommit
, similiar to logic of Neo2.The text was updated successfully, but these errors were encountered: