-
Notifications
You must be signed in to change notification settings - Fork 21.9k
accounts/abi: Index inputs are not present in output #15568
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,16 +69,20 @@ func (e Event) tupleUnpack(v interface{}, output []byte) error { | |
| for i := 0; i < len(e.Inputs); i++ { | ||
| input := e.Inputs[i] | ||
| if input.Indexed { | ||
| // indexed inputs are not available in log output | ||
| j-- | ||
| // can't read, continue | ||
| continue | ||
| } else if input.Type.T == ArrayTy { | ||
| // need to move this up because they read sequentially | ||
| j += input.Type.Size | ||
| } | ||
| marshalledValue, err := toGoType((i+j)*32, input.Type, output) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if input.Type.T == ArrayTy { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In current codebase array fields are counted before unpacking output. Counting will be done after processing array, so in case array is the first
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was using this contract for test: Error message:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would that be incorrect? Sounds right at the beginning.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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, 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 with this change first read will be done from 0 till 64 (array), and for integer from 64 till 96
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @VoR0220 added a comment |
||
| // combined index ('i' + 'j') need to be adjusted only by size of array, thus | ||
| // we need to decrement 'j' because 'i' was incremented | ||
| j += input.Type.Size - 1 | ||
| } | ||
| reflectValue := reflect.ValueOf(marshalledValue) | ||
|
|
||
| switch value.Kind() { | ||
|
|
||
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.
This seems fairly elegant. Works for me.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for review, i added required test, but i think that i spotted another issue with array types. please see my comment below