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 additional pre-checks to the DisputeGameUpgade #442

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
59 changes: 58 additions & 1 deletion script/verification/DisputeGameUpgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,34 @@ interface IASR {
function superchainConfig() external view returns (address superchainConfig_);
}

interface IMIPS is ISemver {
function oracle() external view returns (address oracle_);
}

abstract contract DisputeGameUpgrade is VerificationBase, SuperchainRegistry {
using LibString for string;

bytes32 immutable expAbsolutePrestate;
address immutable expFaultDisputeGame;
address immutable expPermissionedDisputeGame;
DisputeGameFactory immutable dgfProxy;

constructor(bytes32 _absolutePrestate, address _faultDisputeGame, address _permissionedDisputeGame) {
expAbsolutePrestate = _absolutePrestate;
expFaultDisputeGame = _faultDisputeGame;
expPermissionedDisputeGame = _permissionedDisputeGame;

dgfProxy = DisputeGameFactory(proxies.DisputeGameFactory);

addAllowedStorageAccess(proxies.DisputeGameFactory);

precheckDisputeGames();
}

/// @notice Public function that must be called by the verification script.
function checkDisputeGameUpgrade() public view {
console.log("check dispute game implementations");

DisputeGameFactory dgfProxy = DisputeGameFactory(proxies.DisputeGameFactory);
FaultDisputeGame faultDisputeGame = FaultDisputeGame(address(dgfProxy.gameImpls(GameTypes.CANNON)));
PermissionedDisputeGame permissionedDisputeGame =
PermissionedDisputeGame(address(dgfProxy.gameImpls(GameTypes.PERMISSIONED_CANNON)));
Expand Down Expand Up @@ -86,4 +94,53 @@ abstract contract DisputeGameUpgrade is VerificationBase, SuperchainRegistry {

require(address(faultDisputeGame.weth()) != address(permissionedDisputeGame.weth()), "weth-200");
}

function precheckDisputeGames() internal view {
mbaxter marked this conversation as resolved.
Show resolved Hide resolved
_precheckDisputeGameImplementation(GameType.wrap(0), expFaultDisputeGame);
_precheckDisputeGameImplementation(GameType.wrap(1), expPermissionedDisputeGame);
}

// _precheckDisputeGameImplementation checks that the new game being set has the same
// configuration as the existing implementation.
function _precheckDisputeGameImplementation(GameType _targetGameType, address _newImpl) internal view {
console.log("pre-check new game implementation", _targetGameType.raw());

FaultDisputeGame currentGame = FaultDisputeGame(address(dgfProxy.gameImpls(GameType(_targetGameType))));
FaultDisputeGame newGame = FaultDisputeGame(_newImpl);

if (vm.envOr("DISPUTE_GAME_CHANGE_WETH", false)) {
Ethnical marked this conversation as resolved.
Show resolved Hide resolved
console.log("Expecting DelayedWETH to change");
require(address(currentGame.weth()) != address(newGame.weth()), "pre-10");
} else {
console.log("Expecting DelayedWETH to stay the same");
require(address(currentGame.weth()) == address(newGame.weth()), "pre-10");
}

require(_targetGameType.raw() == newGame.gameType().raw(), "pre-20");
require(address(currentGame.anchorStateRegistry()) == address(newGame.anchorStateRegistry()), "pre-30");
require(currentGame.l2ChainId() == newGame.l2ChainId(), "pre-40");
require(currentGame.splitDepth() == newGame.splitDepth(), "pre-50");
require(currentGame.maxGameDepth() == newGame.maxGameDepth(), "pre-60");
require(currentGame.maxClockDuration().raw() == newGame.maxClockDuration().raw(), "pre-70");
require(currentGame.clockExtension().raw() == newGame.clockExtension().raw(), "pre-80");

if (_targetGameType.raw() == GameTypes.PERMISSIONED_CANNON.raw()) {
PermissionedDisputeGame currentPDG = PermissionedDisputeGame(address(currentGame));
PermissionedDisputeGame newPDG = PermissionedDisputeGame(address(newGame));
require(address(currentPDG.proposer()) == address(newPDG.proposer()), "pre-90");
require(address(currentPDG.challenger()) == address(newPDG.challenger()), "pre-100");
}

_precheckVm(newGame, currentGame);
}

// _precheckVm checks that the new VM has the same oracle as the old VM.
function _precheckVm(FaultDisputeGame _newGame, FaultDisputeGame _currentGame) internal view {
console.log("pre-check VM implementation", _newGame.gameType().raw());

IMIPS newVm = IMIPS(address(_newGame.vm()));
IMIPS currentVm = IMIPS(address(_currentGame.vm()));

require(newVm.oracle() == currentVm.oracle(), "vm-10");
}
}
3 changes: 3 additions & 0 deletions tasks/eth/022-holocene-fp-upgrade/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ SAFE_NONCE_0XC2819DC788505AAC350142A7A707BF9D03E3BD03=8 # noop
SAFE_NONCE_0X847B5C174615B1B7FDF770882256E2D3E95B9D92=11 # +1, task 021

SIMULATE_WITHOUT_LEDGER=0 # 1
Ethnical marked this conversation as resolved.
Show resolved Hide resolved

# we change the WETH in this task, which is non-standard
DISPUTE_GAME_CHANGE_WETH=true
mbaxter marked this conversation as resolved.
Show resolved Hide resolved