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 IPersistencePlugin inconsistency #2576

Conversation

Qiao-Jin
Copy link
Contributor

Close #2570

Furthermore, we should regulate that IPersistencePlugin.OnCommit & IPersistencePlugin.OnPersist should never change the content of snapshot

}
}
}
if (commitExceptions != null) throw new AggregateException(commitExceptions);
snapshot.Commit();
Copy link
Contributor

Choose a reason for hiding this comment

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

If snapshot is the last to commit then #2570 (comment) is probably not relevant though, plugins won't ever have N-1 data, rather they could have some N+1, but they won't process it again because of plugin.CurrentHeight. So it should be fine.

{
plugin.OnCommit(system, block, snapshot);
plugin.OnPersist(system, block, snapshot, all_application_executed);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe OnPersist and OnCommit could be merged then? Previously they were done at different stages of processing, but now they're very similar and probably this separation is not really needed. It will change plugin interface though (but I doubt we have a lot of third-party plugins now).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is introduced in #568:

If there are multiple persistence plugins loaded and one of them throws an exception, then none of them should actually commit anything to a persistent store. To facilitate this behavior, I added an OnCommit method to be called after all plugins have had a chance to process results from OnPersist and throw if something was wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we should merge it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we'd better keep this strategy to make sure there is no dirty data stored in plugins once some error occurs

Copy link
Member

Choose a reason for hiding this comment

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

But it's better to revert if there is an error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once we merge these 2 functions, it will not be able to work correctly for such scenarios: i.e. there are 2 IPersistencePlugins installed. The first one persists without error but the second one throws some exception caused by dirty data. We can restart nodes again to re-persist data for neo-node and IPersistencePlugins, but the first plugin is already "polluted", I'm afraid the node can only be re-syncronized from 0 height again...

Copy link
Member

Choose a reason for hiding this comment

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

If there are two plugins, and one throw an exception the problem will be in the plugin, I still thinking that is better to merge it. What do you think @erikzhang ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ping

Copy link
Contributor Author

@Qiao-Jin Qiao-Jin Nov 9, 2021

Choose a reason for hiding this comment

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

@erikzhang Could you provide opinion upon this question?

@Qiao-Jin
Copy link
Contributor Author

Ping?

@cschuchardt88
Copy link
Member

cschuchardt88 commented Jan 4, 2024

Can we close this? This is so outdated.

@shargon
Copy link
Member

shargon commented Jan 4, 2024

Can we close this? This is so outdated.

This can be closed and open a issue related to https://github.com/neo-project/neo/pull/2576/files#r690242355

@cschuchardt88
Copy link
Member

cschuchardt88 commented Jan 4, 2024

But dont we use Blockchain.Committing event for that now?

@shargon
Copy link
Member

shargon commented Jan 6, 2024

But dont we use Blockchain.Committing event for that now?

Yes, seems that it was already merged

@shargon shargon closed this Jan 6, 2024
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.

Logic vulnerability when handling IPersistencePlugin during block persisting
4 participants