Skip to content
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

Transient storage write within entryContext makes staticcalls revert #267

Open
vdrg opened this issue Oct 18, 2024 · 3 comments
Open

Transient storage write within entryContext makes staticcalls revert #267

vdrg opened this issue Oct 18, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@vdrg
Copy link

vdrg commented Oct 18, 2024

📃 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 no initialMsgSender 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 the initialMsgSender 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

@ccp-tezza
Copy link
Collaborator

ccp-tezza commented Oct 25, 2024

@vdrg Thanks for bringing this to attention. We have a fix in the pipeline for this coming with our V2 rollout in the near future! I will close this ticket as resolved once that happens, cheers!

@tapticc
Copy link

tapticc commented Dec 6, 2024

Any updates on this please i.e. when will V2 be released?

@0xxlegolas
Copy link
Collaborator

@tapticc its going to be released in Q1 next year

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants