-
Notifications
You must be signed in to change notification settings - Fork 10
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
EIP-2935 get() fails to revert on out-of-bounds input #34
Comments
Although not directly related to this issue, it's worth noting that the Patch: daejunpark@a6af555 |
The EIP says to return zero outside the range. https://eips.ethereum.org/EIPS/eip-2935#block-hash-history-contract
It seems @lightclient changed this in the code but didn't update the EIP. |
I agree with your point, but please note that this issue is a different thing. The current implementation neither returns zero nor reverts for the specific out-of-range input, (Additionally, this is unrelated to the edge case of |
This was fixed in 6cae17b |
Problem
According to the EIP-2935 spec, the valid input range for the get() operation is
[block.number - HISTORY_SERVE_WINDOW, block.number - 1]
. Additionally, as per #19, the get() operation should revert if the input falls outside this valid range.However, when get() is called with an input of
block.number - HISTORY_SERVE_WINDOW - 1
, which is outside the valid range, it currently does NOT revert; instead it returns the blockhash ofblock.number - 1
, which I believe is incorrect behavior.How to reproduce
The issue can be reproduced by adding the following test to
test/ExecutionHash.t.sol.in
:Test output:
(Note that the returned
data
is0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6
, which is the blockhash set earlier for the last block.)Suggested fix
The root cause of this issue is the following line:
sys-asm/src/execution_hash/main.eas
Line 70 in b5b9f33
This issue can be fixed by changing it to
push BUFLEN
(removing+1
).Once this issue is fixed, the existing
testHistoricalReads()
test will also need to be adjusted, e.g., by addingvm.roll(buflen);
before the secondfor
loop.Patch: daejunpark@2a11c29
The text was updated successfully, but these errors were encountered: