0

Does anyone knows what happens to the stack and memory of the EVM when an external contract is invoked?

Do the stack and memory get "cleaned" in order for the external contract to execute its code or are the new variables added on top of the previous ones (which in my opinion could be potentially dangerous since the external contract could manipulate the original contract variable values...)?

I know that the context changes when an external contract gets invoked, I would only assume that the same happens to the stack and memory (basically, I thought that the stack and memory were part of the context that gets swapped between calls) but I could not find a confirmation anywhere...

1 Answer 1

1

You can find the answer in another question: Does stack persist through external calls?

The recipient contract doesn't have access to the caller contract's stack.

There are two separate stacks: a local stack where variables are pushed and removed (accessible only to the contract instance being executed); a global call stack where the calls are stored (it is not accessible to the contract).

The same happens for memory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.