Caller Contexts

delegatecall allows us to use a single contract context to retrieve global state such as msg.sender. However with Extendable, there are situations where msg.sender does not return us the data that we are interested in.

It might be required for an Extension to be able to understand where the true caller of a function originated from, but due to the use of delegatecall, msg.sender always returns us the most recent external caller even if the caller was another Extension.

In order to support a more expressive record of callers, we use Caller Contexts to track and view during any function call who the last true caller was and who the last external caller was.

We achieve this using a FIFO queue:

Function calls in an Extendable record the caller upon entry, allowing easy read access to the caller context during the call. Once a call is finished, the caller at the current context is popped from the queue as a final step.

The functions lastCaller() and lastExternalCaller() are available under all Extensions.

Last updated