Closed
Description
System information
Geth version:
$ geth version
Geth
Version: 1.9.6-stable
Git Commit: bd05968077f27f7eb083404dd8448157996a8788
Architecture: amd64
Protocol Versions: [63]
Network Id: 1
Go Version: go1.13.1
Operating System: darwin
OS & Version: macOS 10.14.6
Expected behaviour
Events which emit negative signed integers with size >64 bits are decoded correctly.
Actual behaviour
They are treated as unsigned integers and not decoded correctly.
Steps to reproduce the behaviour
The problem is here:
go-ethereum/accounts/abi/bind/topics.go
Lines 214 to 215 in de2259d
For integers with size >64 bits, negative values will be encoded by the EVM with a size larger than max(int256)
. For example, -1 for an int256
(or int192
, etc.) is 2^256-1
, -2 is 2^256-2
, etc.
Non-indexed inputs are decoded correctly via readInteger()
in accounts/abi/unpack.go
:
go-ethereum/accounts/abi/unpack.go
Lines 56 to 71 in de2259d
To reproduce:
- Deploy the following smart contract:
pragma solidity >=0.0.0;
contract TestIntEvents {
event Int192Event(int192 x);
event Int192EventIndexed(int192 indexed x);
function send192(int192 x) public {
emit Int192Event(x);
}
function send192Indexed(int192 x) public {
emit Int192EventIndexed(x);
}
}
- Try calling
send192(-1)
andsend192Indexed(-1)
. - Observe the values returned from both events via go-ethereum:
Int192Event(-1)
// Ok
Int192EventIndexed(115792089237316195423570985008687907853269984665640564039457584007913129639935)
// Not Ok! Expected -1
Metadata
Assignees
Labels
No labels
Activity