-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[storage] fix: used the typed_store error type #230
Conversation
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.
Good to go! Many thanks for doing this clean-up after the nice talk you gave on the subject!
@@ -151,7 +151,7 @@ pub enum FastPayError { | |||
#[error("Execution invariant violated")] | |||
ExecutionInvariantViolation, | |||
#[error("Storage error")] | |||
StorageError, | |||
StorageError(#[from] typed_store::rocks::TypedStoreError), |
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.
Weird question, I know: this may lead us to return to the client errors straight from the DB including detailed errors about encoding / decoding. Is there any case where this might leak security sensitive information through this error reporting?
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.
The question is perfectly valid for the whole FastPayError
hierarchy. One of the valid things to do here is to make sure your e.g. crypto signing lib doesn't share TMI, which is one of the things we should add as a TODO in #101 or similar. But there may be more scope of inspection here?
self.objects | ||
.multi_get(_objects) | ||
.map_err(|_| FastPayError::StorageError) | ||
self.objects.multi_get(_objects).map_err(|e| e.into()) |
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.
Is there no general Into() from Result<R,F> to Result<R',F'> if there is an R into R' and F into F'?
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.
But the idiom here is more probably :
let res = faillible()?;
Ok(res)
Very nice to see this in action |
This updates the typed_store version to one with a TypedStore error type, rather than using `eyre::Error`. As a consequence, it allows a more fine-grained conversion of store errors to `FastPay::StorageError`.
dff1695
to
8f9491f
Compare
This demonstrates the use of the following PR:
MystenLabs/mysten-infra#6
Please go and review the mysten-infra PR, once it's merged I'll update dependency pointers here.
This updates the
typed_store
version to one with a TypedStore error type, rather than usingeyre::Error
.As a consequence, it allows a more fine-grained conversion of store errors to
FastPay::StorageError
.