-
Notifications
You must be signed in to change notification settings - Fork 12k
Refactor Blockhash lib #5702
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
Refactor Blockhash lib #5702
Conversation
|
Note: I was also thinking that doing return distance < 256 ? blockhash(blockNumber) : _historyStorageCall(blockNumber) Would be more future proof is the history is ever extended beyound 8192 blocks. That passes unit tests, but not fuzzing. Do we know why ? |
Should be
|
@ernestognw and I discussed this previously and found that this yul behaviour is pretty well documented and not just an implementation detail (documented here). Will defer to ernesto on this. |
Looking at #5642, I noticed that the if statement was quite complexe. It comes with an implicit expectation that the static call (right part of the if) is executed BEFORE the returndatasize (left part of the if). While that expectation might be correct today, I'm not sure the compiler garantees it will stay that way.
Considering that the if does not trigger a revert if the staticcall fails, I believe the proposed version is just as effective, and IMO easier to read. All tests (unit and fuzzing) pass just fine.
Given that an MSTORE is just 3 gas, this version is also cheaper !
PR Checklist
npx changeset add
)