-
Notifications
You must be signed in to change notification settings - Fork 311
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
protobuf decode tx patch #583
protobuf decode tx patch #583
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.
Is it expected that CI fail?
types/tx.go
Outdated
func DecodeChildTx(tx Tx) (hash []byte, unwrapped Tx, has bool) { | ||
// attempt to unmarshal into a a child transaction | ||
var childTx tmproto.ChildTx | ||
err := proto.Unmarshal(tx, &childTx) | ||
if err != nil { | ||
return nil, nil, false | ||
} | ||
// this check isn't fool proof but it should work most of the time | ||
if len(childTx.ParentTxHash) != sha256.Size { |
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.
Isn't there like a constant in the code that references this already? Just in case we swap out the hash function in the future then we won't have to change many places.
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 idea, switched to using the hash size from tmhash
af691ce
Co-authored-by: John Adler <[email protected]>
* fix protobuf bug * clean up * mispelling * add more comments to a weird test * Update types/tx.go Co-authored-by: John Adler <[email protected]> * better comment w/ todo and use prexisting hash constant Co-authored-by: John Adler <[email protected]>
Description
I didn't know protobuf doesn't check types when unmarshalling, so there needs to be some check to prevent random stuff from being returned successfully from
DecodeChildTx