accounts/abi: Index inputs are not present in output#15568
Conversation
|
Thank you for your contribution! Your commits seem to not adhere to the repository coding standards
Please check the contribution guidelines for more details. This message was auto-generated by https://gitcop.com |
1095a29 to
e3bca64
Compare
|
@VoR0220 Would you mind taking a look at this? I find that code a bit difficult to follow, and don't understand why the fix works, and if there are any other sideeffects of it. |
|
Because of this if an event has 3 fields, and 2 of them are indexed - following function will expect that data for 3rd field will be in 2*32:96 range of the output. But the encoded output doesn't contain fields that are indexed and following error is returned: maybe it would be better to have all the fields in log.Data, but then this condition won't be needed https://github.com/ethereum/go-ethereum/pull/15568/files#diff-7af5eed2bdda4c04119f5dba36a637b4R71 |
|
Yup, this is my bad. While I took into account that indexed types should be skipped, it doesn't appear I did so in terms of how long the bytecode should be. This appears to correct that, however the tests are a little confusing to read. |
| input := e.Inputs[i] | ||
| if input.Indexed { | ||
| // indexed inputs are not available in log output | ||
| j-- |
There was a problem hiding this comment.
This seems fairly elegant. Works for me.
There was a problem hiding this comment.
Second thought, I'm not sure this plays nicely with a static array element insofar as indexing is concerned.
There was a problem hiding this comment.
thanks for review, i added required test, but i think that i spotted another issue with array types. please see my comment below
VoR0220
left a comment
There was a problem hiding this comment.
Needs to take into account static array indexing and how that interacts with the changes prescribed.
| { | ||
| definition: `[{"anonymous":false,"inputs":[{"indexed":false,"name":"value1","type":"uint256"},{"indexed":true,"name":"value2","type":"uint256"}],"name":"transfer","type":"event"}]`, | ||
| want: testResult{Value1: big.NewInt(100)}, | ||
| }, |
There was a problem hiding this comment.
A test that should be added for the sake of sanity would be in the case of a indexed static array type. Say for example I'm passing in an indexed uint[2], and a non indexed string, this should take into account the length of the static array and ignore it...perhaps this should be handled by another variable in the events.go file above to best handle this.
|
Thank you for your contribution! Your commits seem to not adhere to the repository coding standards
Please check the contribution guidelines for more details. This message was auto-generated by https://gitcop.com |
362fb00 to
3fd0350
Compare
There was a problem hiding this comment.
In current codebase array fields are counted before unpacking output.
So, if we have array with 2 fields: toGoType function will try to unpack
values from 64 till 64 + 2*32 which is not correct in my opinion.
Counting will be done after processing array, so in case array is the first
field, and it has 2 elements: we will read it from 0 till 2*32, and next element will start at 64.
There was a problem hiding this comment.
I was using this contract for test:
contract Test {
event Echo(uint8[2] message, address from);
function emit() {
uint8[2] memory r = [1,2];
Echo(r, msg.sender);
}
}
Error message:
2017/11/30 12:37:46 abi: cannot marshal in to go array: offset 96 would go over slice boundary (len=128)
There was a problem hiding this comment.
Why would that be incorrect? Sounds right at the beginning.
There was a problem hiding this comment.
how is that correct? example that i provided actually fails on current master
let's say we will try to unpack an event with ([7,8], 9) all simple integers,
it will be encoded as
0000000000000000000000000000000000000000000000000000000000000007
0000000000000000000000000000000000000000000000000000000000000008
0000000000000000000000000000000000000000000000000000000000000009
without this change we will try to read array from 64 till 128, and integer from 96 till 128, and actually will fail with this error 2017/12/07 16:04:29 abi: cannot marshal in to go array: offset 96 would go over slice boundary (len=128)
with this change first read will be done from 0 till 64 (array), and for integer from 64 till 96
There was a problem hiding this comment.
Ah. Okay. Yea I'm sorry for the wait, I've reviewed the code, it looks fairly good, but I would just add a comment about the j += input.Type.Size - 1...specifically why you're subtracting the 1. Just leave a comment on that and I'll approve this...for whatever that's worth.
3fd0350 to
b11eecb
Compare
|
@VoR0220 would you mind taking a look again? |
In current codebase array fields are counted before unpacking output. So, if we have array with 2 fields: toGoType function will try to unpack values from 64 till 64 + 2*32 which is not correct in my opinion. I shifted counting to be done after processing array, so in case array is the first field, and it has 2 elements: we will read it from 0 till 2*32. Additionally array doesnt require length prefix, so field that follows array should be read from 64 byte. This is why i made additional substitution in this change.
b11eecb to
4fc2aa3
Compare
|
@gballet perhaps you can help with review? |
|
Thank you for your contribution! Your commits seem to not adhere to the repository coding standards
Please check the contribution guidelines for more details. This message was auto-generated by https://gitcop.com |
9b8e320 to
6a9ed4c
Compare
b959674 to
10c4590
Compare
10c4590 to
2191706
Compare
solves: #15567 #15617