You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR makes a small modification the `simulate` function such that it
ensures its inner `simulateAndRevert` reverts as expected. This is to
prevent calls to the `CompatibilityFallbackHandler` from making
unexpected state changes when not called by a Safe.
While using the `CompatibilityFallbackHandler` for something other than
a Safe fallback handler is explictely not supported, it makes sense to
ensure the inner call inverts and prevent unintended behaviours.
* @dev Performs a delegatecall on a targetContract in the context of self.
85
-
* Internally reverts execution to avoid side effects (making it static). Catches revert and returns encoded result as bytes.
86
-
* @dev Inspired by https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol
94
+
* @notice Performs a `DELEGATECALL` to a `targetContract` in the context of self.
95
+
* @dev Internally reverts execution to avoid side effects (making it effectively static).
96
+
* Catches the internal revert and returns encoded result as bytes.
97
+
* Inspired by <https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol>.
87
98
* @param targetContract Address of the contract containing the code to execute.
88
99
* @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).
89
100
*/
90
101
function simulate(addresstargetContract, bytescalldatacalldataPayload) externalreturns (bytesmemoryresponse) {
91
-
/**
92
-
* Suppress compiler warnings about not using parameters, while allowing
93
-
* parameters to keep names for documentation purposes. This does not
94
-
* generate code.
95
-
*/
102
+
// Suppress compiler warnings about not using parameters, while allowing
103
+
// parameters to keep names for documentation purposes. This does not
104
+
// generate code.
96
105
targetContract;
97
106
calldataPayload;
98
107
99
108
/* solhint-disable no-inline-assembly */
100
109
/// @solidity memory-safe-assembly
101
110
assembly {
102
111
let ptr :=mload(0x40)
103
-
/**
104
-
* Store `simulateAndRevert.selector`.
105
-
* String representation is used to force right padding
106
-
*/
112
+
// Store `simulateAndRevert.selector`.
113
+
// String representation is used to force right padding.
107
114
mstore(ptr, "\xb4\xfa\xba\x09")
108
115
109
-
/**
110
-
* Abuse the fact that both this and the internal methods have the
111
-
* same signature, and differ only in symbol name (and therefore,
112
-
* selector) and copy calldata directly. This saves us approximately
113
-
* 250 bytes of code and 300 gas at runtime over the
114
-
* `abi.encodeWithSelector` builtin.
115
-
*/
116
+
// Abuse the fact that both this and the internal methods have the
117
+
// same signature, and differ only in symbol name (and therefore,
118
+
// selector) and copy calldata directly. This saves us approximately
119
+
// 250 bytes of code and 300 gas at runtime over the
0 commit comments