-
Notifications
You must be signed in to change notification settings - Fork 240
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
feat: check class & transaction hashes #2349
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.
LGTM, nice work!
|
||
#[derive(Debug)] | ||
pub struct ClassDefinitionWithHash<'a> { | ||
pub cls_def: ClassDefinition<'a>, |
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.
Just a small nit: can we maybe call this definition
instead?
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.
Upon reflection, I don't like the whole ClassDefinitionWithHash
- now that I've finally fit the carpet, :-) it isn't really used that much...
}) | ||
if hash != layout.hash { | ||
tracing::debug!(input_hash=%layout.hash, actual_hash=%hash, "Class hash mismatch"); | ||
Err(SyncError2::ClassHashComputationError.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.
nit: I wonder if we should differentiate between a mismatch (ie. proper layout, bad values) and hash computation error (which means bad layout).
So for the former: ClassHashMismatch (maybe we need to add this variant)
and for the latter: ClassHashComputationError (which really is an InvalidDto but at a higher level)
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.
Well, I wasn't keen on extending SyncError / SyncError2, b/c
- I don't really understand why there's 2 of them, and
- the type isn't used here anyway,
but yes, it can be done...
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.
Re 1. Don't worry, there will be one error type soon.
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 🙇
A small nit - maybe we should use 2 variants there to differentiate between utter garbage (invalid dto, resulting in class computation error) and a mismatch (valid dto, the values dont match).
711d68f
to
3705dec
Compare
for equality with locally-computed hashes (and fail on mismatch).
Fixes #2346.