Commit 671d08bb authored by clabby's avatar clabby Committed by GitHub

feat(ctb): Extra monitoring events in `OptimismPortal2` (#10423)

Adds extra monitoring events into the `OptimismPortal2` for a dispute
game being blacklisted and the resepected game type being set.
parent 80afbbdc
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
"sourceCodeHash": "0x3d0e9dc8ed75b6f2e59444e9204341b18d343af02d6e37ecd9f759da2c8c118b" "sourceCodeHash": "0x3d0e9dc8ed75b6f2e59444e9204341b18d343af02d6e37ecd9f759da2c8c118b"
}, },
"src/L1/OptimismPortal2.sol": { "src/L1/OptimismPortal2.sol": {
"initCodeHash": "0xea32d79e8297956d4f9a4c7985bb53ff8bb3735e5b307d4e118fea71f503a38e", "initCodeHash": "0x6bc8659932ab7eed221880a1d606704a0446d80cf4826f13623fc6cc57053751",
"sourceCodeHash": "0x209d7e9ffa97a54c060f5d30e5d88684a50a7b4610336cf03880bfbc80ca669e" "sourceCodeHash": "0x411ad7aea4d36d7a89ecb2f0dc2c6c200e5fb022b528b3beb1e1b37c557bc7dc"
}, },
"src/L1/ProtocolVersions.sol": { "src/L1/ProtocolVersions.sol": {
"initCodeHash": "0x72cd467e8bcf019c02675d72ab762e088bcc9cc0f1a4e9f587fa4589f7fdd1b8", "initCodeHash": "0x72cd467e8bcf019c02675d72ab762e088bcc9cc0f1a4e9f587fa4589f7fdd1b8",
...@@ -100,8 +100,8 @@ ...@@ -100,8 +100,8 @@
"sourceCodeHash": "0xa304b4b556162323d69662b4dd9a1d073d55ec661494465489bb67f1e465e7b3" "sourceCodeHash": "0xa304b4b556162323d69662b4dd9a1d073d55ec661494465489bb67f1e465e7b3"
}, },
"src/Safe/DeputyGuardianModule.sol": { "src/Safe/DeputyGuardianModule.sol": {
"initCodeHash": "0x533a9dfab7fa1f7f5e8796f0ad78b4a16f93cd8ff3cddcce946691944f6416c0", "initCodeHash": "0x433eb7488e613a51c7ff05a76bbecf47f5beac8b8614f5c50001f99e39ae7ed2",
"sourceCodeHash": "0x82c7ea737cefeb2fda38a75c7165cbad9c902a0f22a13dd46f56050223e308ce" "sourceCodeHash": "0x2919835fc15c166a027b2ff1cf801c847f139948baf2df0db3d02ac3017c09d9"
}, },
"src/Safe/LivenessGuard.sol": { "src/Safe/LivenessGuard.sol": {
"initCodeHash": "0x16ec47f0888391638814047a1735dbac849b48e256b2e20182bbb3186d950a3c", "initCodeHash": "0x16ec47f0888391638814047a1735dbac849b48e256b2e20182bbb3186d950a3c",
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
{ {
"indexed": false, "indexed": true,
"internalType": "contract IDisputeGame", "internalType": "contract IDisputeGame",
"name": "game", "name": "game",
"type": "address" "type": "address"
...@@ -152,10 +152,16 @@ ...@@ -152,10 +152,16 @@
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
{ {
"indexed": false, "indexed": true,
"internalType": "GameType", "internalType": "GameType",
"name": "gameType", "name": "gameType",
"type": "uint32" "type": "uint32"
},
{
"indexed": true,
"internalType": "Timestamp",
"name": "updatedAt",
"type": "uint64"
} }
], ],
"name": "RespectedGameTypeSet", "name": "RespectedGameTypeSet",
......
...@@ -603,6 +603,19 @@ ...@@ -603,6 +603,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "contract IDisputeGame",
"name": "disputeGame",
"type": "address"
}
],
"name": "DisputeGameBlacklisted",
"type": "event"
},
{ {
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
...@@ -616,6 +629,25 @@ ...@@ -616,6 +629,25 @@
"name": "Initialized", "name": "Initialized",
"type": "event" "type": "event"
}, },
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "GameType",
"name": "newGameType",
"type": "uint32"
},
{
"indexed": true,
"internalType": "Timestamp",
"name": "updatedAt",
"type": "uint64"
}
],
"name": "RespectedGameTypeSet",
"type": "event"
},
{ {
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
......
...@@ -124,6 +124,15 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -124,6 +124,15 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
/// @param success Whether the withdrawal transaction was successful. /// @param success Whether the withdrawal transaction was successful.
event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success); event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
/// @notice Emitted when a dispute game is blacklisted by the Guardian.
/// @param disputeGame Address of the dispute game that was blacklisted.
event DisputeGameBlacklisted(IDisputeGame indexed disputeGame);
/// @notice Emitted when the Guardian changes the respected game type in the portal.
/// @param newGameType The new respected game type.
/// @param updatedAt The timestamp at which the respected game type was updated.
event RespectedGameTypeSet(GameType indexed newGameType, Timestamp indexed updatedAt);
/// @notice Reverts when paused. /// @notice Reverts when paused.
modifier whenNotPaused() { modifier whenNotPaused() {
if (paused()) revert CallPaused(); if (paused()) revert CallPaused();
...@@ -131,8 +140,8 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -131,8 +140,8 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
} }
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 3.8.0 /// @custom:semver 3.9.0
string public constant version = "3.8.0"; string public constant version = "3.9.0";
/// @notice Constructs the OptimismPortal contract. /// @notice Constructs the OptimismPortal contract.
constructor(uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds) { constructor(uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds) {
...@@ -432,6 +441,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -432,6 +441,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
function blacklistDisputeGame(IDisputeGame _disputeGame) external { function blacklistDisputeGame(IDisputeGame _disputeGame) external {
if (msg.sender != guardian()) revert Unauthorized(); if (msg.sender != guardian()) revert Unauthorized();
disputeGameBlacklist[_disputeGame] = true; disputeGameBlacklist[_disputeGame] = true;
emit DisputeGameBlacklisted(_disputeGame);
} }
/// @notice Sets the respected game type. Changing this value can alter the security properties of the system, /// @notice Sets the respected game type. Changing this value can alter the security properties of the system,
...@@ -441,6 +451,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -441,6 +451,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
if (msg.sender != guardian()) revert Unauthorized(); if (msg.sender != guardian()) revert Unauthorized();
respectedGameType = _gameType; respectedGameType = _gameType;
respectedGameTypeUpdatedAt = uint64(block.timestamp); respectedGameTypeUpdatedAt = uint64(block.timestamp);
emit RespectedGameTypeSet(_gameType, Timestamp.wrap(respectedGameTypeUpdatedAt));
} }
/// @notice Checks if a withdrawal can be finalized. This function will revert if the withdrawal cannot be /// @notice Checks if a withdrawal can be finalized. This function will revert if the withdrawal cannot be
......
...@@ -28,10 +28,10 @@ contract DeputyGuardianModule is ISemver { ...@@ -28,10 +28,10 @@ contract DeputyGuardianModule is ISemver {
event Unpaused(); event Unpaused();
/// @notice Emitted when a DisputeGame is blacklisted /// @notice Emitted when a DisputeGame is blacklisted
event DisputeGameBlacklisted(IDisputeGame game); event DisputeGameBlacklisted(IDisputeGame indexed game);
/// @notice Emitted when the respected game type is set /// @notice Emitted when the respected game type is set
event RespectedGameTypeSet(GameType gameType); event RespectedGameTypeSet(GameType indexed gameType, Timestamp indexed updatedAt);
/// @notice The Safe contract instance /// @notice The Safe contract instance
Safe internal immutable SAFE; Safe internal immutable SAFE;
...@@ -43,8 +43,8 @@ contract DeputyGuardianModule is ISemver { ...@@ -43,8 +43,8 @@ contract DeputyGuardianModule is ISemver {
address internal immutable DEPUTY_GUARDIAN; address internal immutable DEPUTY_GUARDIAN;
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 1.0.1 /// @custom:semver 1.1.0
string public constant version = "1.0.1"; string public constant version = "1.1.0";
// Constructor to initialize the Safe and baseModule instances // Constructor to initialize the Safe and baseModule instances
constructor(Safe _safe, SuperchainConfig _superchainConfig, address _deputyGuardian) { constructor(Safe _safe, SuperchainConfig _superchainConfig, address _deputyGuardian) {
...@@ -139,6 +139,6 @@ contract DeputyGuardianModule is ISemver { ...@@ -139,6 +139,6 @@ contract DeputyGuardianModule is ISemver {
if (!success) { if (!success) {
revert ExecutionFailed(string(returnData)); revert ExecutionFailed(string(returnData));
} }
emit RespectedGameTypeSet(_gameType); emit RespectedGameTypeSet(_gameType, Timestamp.wrap(uint64(block.timestamp)));
} }
} }
...@@ -368,11 +368,14 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest { ...@@ -368,11 +368,14 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
} }
/// @dev Tests that the guardian role can blacklist any dispute game. /// @dev Tests that the guardian role can blacklist any dispute game.
function testFuzz_blacklist_guardian_succeeds(address _addr) external { function testFuzz_blacklist_guardian_succeeds(IDisputeGame _addr) external {
vm.expectEmit(address(optimismPortal2));
emit DisputeGameBlacklisted(_addr);
vm.prank(optimismPortal2.guardian()); vm.prank(optimismPortal2.guardian());
optimismPortal2.blacklistDisputeGame(IDisputeGame(_addr)); optimismPortal2.blacklistDisputeGame(_addr);
assertTrue(optimismPortal2.disputeGameBlacklist(IDisputeGame(_addr))); assertTrue(optimismPortal2.disputeGameBlacklist(_addr));
} }
/// @dev Tests that `setRespectedGameType` reverts when called by a non-guardian. /// @dev Tests that `setRespectedGameType` reverts when called by a non-guardian.
...@@ -386,6 +389,8 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest { ...@@ -386,6 +389,8 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
/// @dev Tests that the guardian role can set the respected game type to anything they want. /// @dev Tests that the guardian role can set the respected game type to anything they want.
function testFuzz_setRespectedGameType_guardian_succeeds(GameType _ty) external { function testFuzz_setRespectedGameType_guardian_succeeds(GameType _ty) external {
vm.expectEmit(address(optimismPortal2));
emit RespectedGameTypeSet(_ty, Timestamp.wrap(uint64(block.timestamp)));
vm.prank(optimismPortal2.guardian()); vm.prank(optimismPortal2.guardian());
optimismPortal2.setRespectedGameType(_ty); optimismPortal2.setRespectedGameType(_ty);
......
...@@ -9,7 +9,7 @@ import "test/safe-tools/SafeTestTools.sol"; ...@@ -9,7 +9,7 @@ import "test/safe-tools/SafeTestTools.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { DeputyGuardianModule } from "src/Safe/DeputyGuardianModule.sol"; import { DeputyGuardianModule } from "src/Safe/DeputyGuardianModule.sol";
import { GameType } from "src/dispute/lib/Types.sol"; import "src/dispute/lib/Types.sol";
contract DeputyGuardianModule_TestInit is CommonTest, SafeTestTools { contract DeputyGuardianModule_TestInit is CommonTest, SafeTestTools {
using SafeTestLib for SafeInstance; using SafeTestLib for SafeInstance;
...@@ -17,8 +17,6 @@ contract DeputyGuardianModule_TestInit is CommonTest, SafeTestTools { ...@@ -17,8 +17,6 @@ contract DeputyGuardianModule_TestInit is CommonTest, SafeTestTools {
error Unauthorized(); error Unauthorized();
error ExecutionFailed(string); error ExecutionFailed(string);
event DisputeGameBlacklisted(IDisputeGame);
event RespectedGameTypeSet(GameType);
event ExecutionFromModuleSuccess(address indexed); event ExecutionFromModuleSuccess(address indexed);
DeputyGuardianModule deputyGuardianModule; DeputyGuardianModule deputyGuardianModule;
...@@ -202,7 +200,7 @@ contract DeputyGuardianModule_setRespectedGameType_Test is DeputyGuardianModule_ ...@@ -202,7 +200,7 @@ contract DeputyGuardianModule_setRespectedGameType_Test is DeputyGuardianModule_
emit ExecutionFromModuleSuccess(address(deputyGuardianModule)); emit ExecutionFromModuleSuccess(address(deputyGuardianModule));
vm.expectEmit(address(deputyGuardianModule)); vm.expectEmit(address(deputyGuardianModule));
emit RespectedGameTypeSet(_gameType); emit RespectedGameTypeSet(_gameType, Timestamp.wrap(uint64(block.timestamp)));
vm.prank(address(deputyGuardian)); vm.prank(address(deputyGuardian));
deputyGuardianModule.setRespectedGameType(optimismPortal2, _gameType); deputyGuardianModule.setRespectedGameType(optimismPortal2, _gameType);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
import { FeeVault } from "src/universal/FeeVault.sol"; import { FeeVault } from "src/universal/FeeVault.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import "src/dispute/lib/Types.sol";
/// @title Events /// @title Events
/// @dev Contains various events that are tested against. This contract needs to /// @dev Contains various events that are tested against. This contract needs to
...@@ -15,6 +17,8 @@ contract Events { ...@@ -15,6 +17,8 @@ contract Events {
event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success); event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to); event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);
event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter); event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter);
event DisputeGameBlacklisted(IDisputeGame indexed disputeGame);
event RespectedGameTypeSet(GameType indexed newGameType, Timestamp indexed updatedAt);
event SentMessage(address indexed target, address sender, bytes message, uint256 messageNonce, uint256 gasLimit); event SentMessage(address indexed target, address sender, bytes message, uint256 messageNonce, uint256 gasLimit);
event SentMessageExtension1(address indexed sender, uint256 value); event SentMessageExtension1(address indexed sender, uint256 value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment