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

[#20266] Fix bugs decoding integers and fixed bytes in indexed event fields #20269

Merged
merged 8 commits into from
Dec 18, 2019
Merged

[#20266] Fix bugs decoding integers and fixed bytes in indexed event fields #20269

merged 8 commits into from
Dec 18, 2019

Conversation

shoenseiwaso
Copy link
Contributor

Resolves #20266

This PR fixes bugs in parseTopics() and parseTopicsIntoMap() which incorrectly decoded negative integer values and fixed bytes values.

Added tests, now passing, which fail on master:

--- FAIL: TestParseTopics (0.00s)
    --- PASS: TestParseTopics/support_fixed_byte_types,_right_padded_to_32_bytes (0.00s)
    --- FAIL: TestParseTopics/int8_with_negative_value (0.00s)
        topics_test.go:142: parseTopics() = &{115792089237316195423570985008687907853269984665640564039457584007913129639934}, want &{-1}
    --- FAIL: TestParseTopics/int256_with_negative_value (0.00s)
        topics_test.go:142: parseTopics() = &{115792089237316195423570985008687907853269984665640564039457584007913129639934}, want &{-1}
--- FAIL: TestParseTopicsIntoMap (0.00s)
    --- FAIL: TestParseTopicsIntoMap/support_fixed_byte_types,_right_padded_to_32_bytes (0.00s)
        topics_test.go:181: parseTopicsIntoMap() = map[staticBytes:[1 2 3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]], want map[staticBytes:[1 2 3 4 5]]
    --- FAIL: TestParseTopicsIntoMap/int8_with_negative_value (0.00s)
        topics_test.go:181: parseTopicsIntoMap() = map[int8Value:115792089237316195423570985008687907853269984665640564039457584007913129639935], want map[int8Value:-1]
    --- FAIL: TestParseTopicsIntoMap/int256_with_negative_value (0.00s)
        topics_test.go:181: parseTopicsIntoMap() = map[int256Value:115792089237316195423570985008687907853269984665640564039457584007913129639935], want map[int256Value:-1]

This PR promotes a few functions and variables to public, all inaccounts/abi/unpack.go, to help reduce duplication in decoding fields: MaxUint256, MaxInt256, ReadInteger() and ReadFixedBytes().

Future enhancement, not addressed in this PR, could further reduce the duplication of functionality between parseTopics(), parseTopicsIntoMap() and toGoType().

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@holiman
Copy link
Contributor

holiman commented Nov 12, 2019

Thanks! Please take a look at and fix the lint failures on travis

@shoenseiwaso
Copy link
Contributor Author

Thanks for the quick turnaround! Linter issues fixed and linting and tests passed in CI.

Copy link
Member

@gballet gballet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once updated

@gballet gballet merged commit 6ae9dc1 into ethereum:master Dec 18, 2019
@shoenseiwaso shoenseiwaso deleted the 20266-indexed-signed-integers branch December 18, 2019 15:23
enriquefynn pushed a commit to enriquefynn/go-ethereum that referenced this pull request Mar 10, 2021
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Jan 3, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 3, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 4, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 6, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 7, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 7, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 7, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 9, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 10, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 10, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 10, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 10, 2025
…d event fields (ethereum#20269)

* fix parseTopics() and add tests

* remove printf

* add ParseTopicsIntoMap() tests

* fix FixedBytesTy

* fix int and fixed bytes

* golint topics_test.go
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.

Negative signed integers as indexed event inputs are not decoded correctly
4 participants