Transient storage write within entryContext
makes staticcall
s revert
#267
Labels
bug
Something isn't working
entryContext
makes staticcall
s revert
#267
📃 Description
Hi folks, we noticed some users were encountering issues when trying to call system functions marked as view (thus a staticcall is used). The error they are getting is
StateChangeDuringStaticCall
.Original issue in MUD repo: latticexyz/mud#3306
📝 Details
I believe the revert happens within the
entryContext
modifier, as it tries to write to transient storage if there is noinitialMsgSender
set. Unfortunately, writing to transient storage is not allowed within a staticcall context.🔢 How to reproduce
Try to call (from another system or contract) any view function through the world:
world.app__someGetter()
. Note that this will not revert if within the same transaction there is previous (non static) call to the world, as in that case theinitialMsgSender
will be set so no write will be made.☀️ Expected behavior
It should always be possible to call view system functions through the world.
One option to solve this would be to check if the call is within a staticcall context. This can be done by calling an external contract that just tries to modify transient storage, and if that call reverts then it means we are within a staticcall.
💻 Environment
Reproduced using projectawakening/world-chain-deployer-image:0.0.16
The text was updated successfully, but these errors were encountered: