-
Notifications
You must be signed in to change notification settings - Fork 20
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 undefined behavior on simultaneous write in daemon state file #326
Conversation
It also can corrupt state, in such cases: {
"juno": {
"juno-1": {
"code_ids": {},
"test": {
"test0": "test-0", } "te}
:
"test-3"
}
}
}
} |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
This is particularly crucial when using daemons that interact with different chains ! |
This is also needed when interacting with 1 chain |
Update: seems like it was because of mid-way aborted thread. |
@Kayanski wrote a quick proof of concept implementation, that don't break any existing test as well as succeeds the new multi-threaded ones |
I'm a bit confused by the global |
Updated PR description! This PR originally had only failing tests with missleading error "EOF while parsing a value", which you can find in |
See clippy err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I understand this PR correctly the JSON state file will be locked when the Daemon
is constructed? Any other threads that attempt to construct a Daemon
will be blocked until this original Daemon is dropped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure about moving the channel into the Sender.
IMO it would make more sense to rename Sender -> Signer and then have the Daemon do all the transmitting. That way we can also more easily update the signing logic (like adding multisig or MPC support)
Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>
Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
(This is a breaking change)
@Kayanski @CyberHoward On poisoned Mutex state should we allow saving state in case user called manually |
Let's fail if there's a poison, we can develop the feature if someone asks later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes to clarify things and nitify others
Simultaneous daemon state file writes currently are not handled. This PR aims to handle such cases.
So there are 2 scenarios when simultaneous write can happen:
How this PR tries to fix it:
For the 1.
file-lock
, which ensures another program won't be able to write in this file (We don't lock read-only daemonstates)For the 2.
once_cell::sync::Lazy
.Beyond safety this PR adds few optimizations:
Closes ORC-75, Closes ORC-84 Closes ORC-140