Skip to content
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

Merged
merged 6 commits into from
Nov 21, 2021

Conversation

evan-forbes
Copy link
Member

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

@evan-forbes evan-forbes marked this pull request as ready for review November 19, 2021 16:46
Copy link
Member

@adlerjohn adlerjohn left a 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 {
Copy link
Member

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.

Copy link
Member Author

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

@evan-forbes evan-forbes removed the request for review from tac0turtle November 21, 2021 05:55
@evan-forbes evan-forbes merged commit 199a1e4 into v0.34.x-celestia Nov 21, 2021
@evan-forbes evan-forbes deleted the evan/mempool-decode-child-tx-fix branch November 21, 2021 09:35
evan-forbes added a commit that referenced this pull request Apr 26, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants