In the OpenZeppelin::MulticallUpgradeable
contract, there's a validation that checks msg.sender == _msgSender()
. Considering that msg.sender
and _msgSender()
typically return the same value, why is this validation necessary? Are there any scenarios where this equality might not hold? What's the non-canonical contexts (i.e. msg.sender
is not {_msgSender})?
function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
@> bytes memory context = msg.sender == _msgSender()
? new bytes(0)
: msg.data[msg.data.length - _contextSuffixLength():];
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = AddressUpgradeable.functionDelegateCall(address(this), bytes.concat(data[i], context));
}
return results;
}