Skip to content

refactor(state): CoreAccessor restricts writes on fraud #1258

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

Closed
wants to merge 3 commits into from

Conversation

renaynay
Copy link
Member

This PR refactors CoreAccessor such that it contains a field that determines whether CoreAccessor is read-only:

  • implements RestrictWrites() method on core accessor (and state module) that gets called from fraud lifecycle in the case of fraud instead of calling stop
  • middleware now calls ReadOnly() on state module to check if state is read-only, and if so, restricts POST endpoints
  • CoreAccessor Stop method now returns an error if stop is called twice (as it is now no longer expected).

Resolves #1235

Tagging as a bug-fix as this is technically fixing a bug in specified behaviour.

@renaynay renaynay added area:state Related to fetching state and state execution area:fraud kind:fix Attached to bug-fixing PRs labels Oct 20, 2022
@renaynay renaynay self-assigned this Oct 20, 2022
@renaynay renaynay changed the title refactor(state): CoreAccessor restricts writes on fraud refactor(state): CoreAccessor restricts writes on fraud Oct 20, 2022
Comment on lines +20 to +21
// ReadOnly checks if the Module has disabled write access
ReadOnly() bool
Copy link
Member

@Wondertan Wondertan Oct 20, 2022

Choose a reason for hiding this comment

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

Our module interfaces are soon to be used by the RPC. This means that all the methods are exposed over RPC. This type of hack is not aligned with that. Also, note that this ReadOnly is only used by the middleware, but not in the case we use the module interface directly as a lib, which we defined as the main use case.

I recommend closing this PR and revisiting this issue later once the RPC work is done(edit: preventing users from sending PFDs during a fraud is not a biggest security concern and thus is not the biggest priority)

Also note that current "RPC/API" endpoints will become a gateway soon, which means all the endpoints should become read-only by default, and sending tx transactions from the node's key through the key must be forbidden. (We should thought allow sending already signed transactions later through gateway)

@renaynay renaynay marked this pull request as draft October 21, 2022 11:45
@renaynay
Copy link
Member Author

renaynay commented Nov 9, 2022

New solution is needed for new RPC design.

@renaynay renaynay closed this Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:fraud area:state Related to fetching state and state execution kind:fix Attached to bug-fixing PRs
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

nodebuilder/state: CoreAccessor should only restrict state writes, not reads, on fraud
2 participants