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
Method of deciding amino overhead of tx in ReapMaxBytesMaxGas is wrong #2789
Comments
Thanks for raising this issue! Not sure I understand this correctly, but If you properly want to compute amino overhead, you would need to fill the underlying type with the largest possible data and encode it. The len of the resulting byte arrary is the max allowed size. See for example how we check against / compute the max. allowed header size here: tendermint/types/block_test.go Lines 238 to 274 in 6e9aee5
As transactions in general are arbitrary bytes, the above approach won't work though. The only way to compute the actual overhead of an arbitrary list of byte slices is to encode it and check its length. |
the below line calculate the amino overhead of one tx. but it's wrong and less than the real size. Line 485 in 6e9aee5
here is the error log I added for testing: I[11-09|09:00:14.917] Add block part error module=consensus err="Read overflow, maxSize is 512000 but this amino binary object is 513824 bytes." height=3272 csRound=112 blockRound=112 |
Thanks a lot! I'll have a look. |
You are right! Thanks again! It is a bit weird that amino encodes the array of transactions as if it was contained in a wrapping parent struct (which adds the fieldnumber & type). The fieldnumber is always 1 (as this is the default). When they are encoded in a Block this will also hold (as Tx is the 1st field in |
Yikes. Thanks for reporting this. Feel free to report this kind of thing to the bug bounty: https://hackerone.com/tendermint/ |
Oh I see you did that. Excellent!! |
I wrote a test for amino overhead of tx:
The underlying reason is
amino.UvarintSize
forgetencodeFieldNumberAndTyp3
which will be called in marshal list slice. So we add one extra byte in every tx when marshaling real txs and that's why we have a diff in the test.It will cause consensus failure because the actual block size exceeds the max block size for the error deciding amino overhead of txs.
The text was updated successfully, but these errors were encountered: