-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Events emitted from external
functions log different data than public
functions
#3493
Comments
Good catch.
|
Does this also happen with the new encoder? |
Nice catch. But its not bug its depends on memory allocation, In solidity all public functions immediately copies arguments to memory. In this process of copying values in to memory EVM will pad with 32 bytes.
As per EVM documentation
Now pointer will move to 33bytes to next 32 bytes is length so length is
Memory representation of any bytes is padded with multiples of 32 bytes. Thats a reason you are getting Where is case of external functions can read directly from calldata. What is values your passing it will send same thing to the network. So thats reason you able to see only Memory allocation is expensive, whereas reading from calldata is cheap. That means its not a bug. |
@jitenhub all you say is correct, but what is your point? |
@chriseth Its not bug |
external
functions log different data than public
functionsexternal
functions log different data than public
functions
@jitenhub I would still say we should properly ABI-encode calldata arrays with padding. |
The padding should be added at ArrayUtils.cpp:309. |
Finished work on this, but cannot push to github from this network. Hope I can push later today. |
Note that as soon as this is merged, it is not possible to forward bytes data anymore via call. We need #3955 for this, but that is a breaking change. |
Result of discussion: Add a warning for hash functions, and do the rest (including call*) with 0.5.0 proper. |
I posted full reproduction details on StackExchange
The short version is that calling these two functions produces different log output:
When I call both functions with "glitch" (in
geth --dev
), I get logs with two different data:0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006676c697463680000000000000000000000000000000000000000000000000000
0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006676c69746368
Note: "glitch" encoded with UTF-8, and then hex-encoded, is:
0x676c69746368
The text was updated successfully, but these errors were encountered: