Skip to content

Changes to enable delegate calling to OPCM upgrade. #124

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions script/universal/MultisigBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,22 @@ import {Simulation} from "./Simulation.sol";

abstract contract MultisigBase is CommonBase {
bytes32 internal constant SAFE_NONCE_SLOT = bytes32(uint256(5));
address internal constant MULTI_DELEGATECALL_ADDRESS = 0x95b259eae68ba96edB128eF853fFbDffe47D2Db0;

event DataToSign(bytes);

function _ownerSafe() internal view virtual returns (address);

function _target(address _safe) internal view returns (address) {
// Always parse the env var as a string to avoid issues with boolean values. This lets
// us use "true" or "1" as the value to enable the multi-delegatecall.
bool useMultiDelegatecall = (vm.envOr("USE_MULTI_DELEGATECALL", false) || vm.envOr("USE_MULTI_DELEGATECALL", uint256(0)) == 1);
if (_safe == _ownerSafe() && useMultiDelegatecall) {
return MULTI_DELEGATECALL_ADDRESS;
}
return MULTICALL3_ADDRESS;
}

// Subclasses that use nested safes should return `false` to force use of the
// explicit SAFE_NONCE_{UPPERCASE_SAFE_ADDRESS} env var.
function _readFrom_SAFE_NONCE() internal pure virtual returns (bool);
Expand Down Expand Up @@ -134,7 +147,7 @@ abstract contract MultisigBase is CommonBase {

function _encodeTransactionData(address _safe, bytes memory _data) internal view returns (bytes memory) {
return IGnosisSafe(_safe).encodeTransactionData({
to: MULTICALL3_ADDRESS,
to: _target(_safe),
value: 0,
data: _data,
operation: Enum.Operation.DelegateCall,
Expand All @@ -149,35 +162,25 @@ abstract contract MultisigBase is CommonBase {

function _execTransationCalldata(address _safe, bytes memory _data, bytes memory _signatures)
internal
pure
view
returns (bytes memory)
{
return abi.encodeCall(
IGnosisSafe(_safe).execTransaction,
(
MULTICALL3_ADDRESS,
0,
_data,
Enum.Operation.DelegateCall,
0,
0,
0,
address(0),
payable(address(0)),
_signatures
)
(_target(_safe), 0, _data, Enum.Operation.DelegateCall, 0, 0, 0, address(0), payable(address(0)), _signatures)
);
}

function _execTransaction(address _safe, bytes memory _data, bytes memory _signatures, bool _broadcast)
internal
returns (bool)
{
address target = _target(_safe);
if (_broadcast) {
vm.broadcast();
}
return IGnosisSafe(_safe).execTransaction({
to: MULTICALL3_ADDRESS,
to: target,
value: 0,
data: _data,
operation: Enum.Operation.DelegateCall,
Expand Down
5 changes: 0 additions & 5 deletions script/universal/MultisigBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ abstract contract MultisigBuilder is MultisigBase {
* -----------------------------------------------------------
*/

/**
* @notice Returns the safe address to execute the transaction from
*/
function _ownerSafe() internal view virtual returns (address);

/**
* @notice Creates the calldata for both signatures (`sign`) and execution (`run`)
*/
Expand Down
5 changes: 0 additions & 5 deletions script/universal/NestedMultisigBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ abstract contract NestedMultisigBase is MultisigBase {
* -----------------------------------------------------------
*/

/**
* @notice Returns the nested safe address to execute the final transaction from
*/
function _ownerSafe() internal view virtual returns (address);

/**
* @notice Creates the calldata for both signatures (`sign`) and execution (`run`)
*/
Expand Down
3 changes: 3 additions & 0 deletions script/universal/Simulation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ library Simulation {
"&stateOverrides=",
stateOverrides
);
if (vm.envOr("TENDERLY_GAS", uint256(0)) > 0) {
str = string.concat(str, "&gas=", vm.toString(vm.envOr("TENDERLY_GAS", uint256(0))));
}
if (bytes(str).length + _data.length * 2 > 7980) {
// tenderly's nginx has issues with long URLs, so print the raw input data separately
str = string.concat(str, "\nInsert the following hex into the 'Raw input data' field:");
Expand Down
Loading