Skip to content
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

Add Rollback template to setup templates #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions setup-templates/template-incident/script/RollbackPause.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "@base-contracts/script/universal/MultisigBuilder.sol";
import "@eth-optimism-bedrock/contracts/L1/OptimismPortal.sol";

contract RollbackUnpausePortal is MultisigBuilder {
address constant internal OPTIMISM_PORTAL_PROXY = vm.envAddress("OPTIMISM_PORTAL_PROXY"); // TODO: define OPTIMISM_PORTAL_PROXY=xxx in the .env file
address constant internal GUARDIAN = vm.envAddress("GUARDIAN"); // TODO: define GUARDIAN=xxx in the .env file

function _postCheck() internal override view {
OptimismPortal optimismPortal = OptimismPortal(payable(OPTIMISM_PORTAL_PROXY));
require(optimismPortal.paused() == false, "UnpausePortal: Portal did not get unpaused");
}

function _buildCalls() internal override view returns (IMulticall3.Call3[] memory) {
IMulticall3.Call3[] memory calls = new IMulticall3.Call3[](1);

calls[0] = IMulticall3.Call3({
target: OPTIMISM_PORTAL_PROXY,
allowFailure: false,
callData: abi.encodeCall(
OptimismPortal.unpause, ()
)
});

return calls;
}

function _ownerSafe() internal override view returns (address) {
return GUARDIAN;
}

function _addOverrides(address _safe) internal override view returns (SimulationStateOverride memory) {
IGnosisSafe safe = IGnosisSafe(payable(_safe));
uint256 _nonce = _getNonce(safe);
return overrideSafeThresholdOwnerAndNonce(_safe, DEFAULT_SENDER, _nonce);
}

// This transaction expects that there will be a `Pause` transaction before this one
// but both txs will be signed ahead of time. Need to explicitly override the nonce to
// ensure that the correct nonce is used in the sign, simulate and execution steps.
Comment on lines +40 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This transaction expects that there will be a `Pause` transaction before this one
// but both txs will be signed ahead of time. Need to explicitly override the nonce to
// ensure that the correct nonce is used in the sign, simulate and execution steps.
// This transaction expects that there will be a `Pause` transaction before this one
// but both txs will be signed ahead of time. Need to explicitly override the nonce to
// ensure that the correct nonce is used in the sign, simulate and execution steps.
// Note that dynamically calculating the nonce will lead to errors in signature sorting,
// hence the use of an envvar to fix the nonce to a static value.

function _getNonce(IGnosisSafe) internal override view returns (uint256 nonce) {
nonce = vm.envUint("ROLLBACK_NONCE");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nonce = vm.envUint("ROLLBACK_NONCE");
nonce = vm.envUint("EXPECTED_NONCE");

}
}