Skip to content

Commit

Permalink
feat: AnchorStateRegistry as source of truth
Browse files Browse the repository at this point in the history
Updates the OptimismPortal to use the AnchorStateRegistry as the
source of truth for the validity of Dispute Game contracts.
  • Loading branch information
smartcontracts committed Jan 17, 2025
1 parent 003d648 commit a54f238
Show file tree
Hide file tree
Showing 37 changed files with 1,228 additions and 1,085 deletions.
2 changes: 1 addition & 1 deletion op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func TestProofParamOverrides(t *testing.T) {
{
"disputeGameFinalityDelaySeconds",
uint64Caster,
st.ImplementationsDeployment.OptimismPortalImplAddress,
st.ImplementationsDeployment.AnchorStateRegistryImplAddress,
},
{
"faultGameAbsolutePrestate",
Expand Down
1 change: 0 additions & 1 deletion op-deployer/pkg/deployer/opcm/dispute_game_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
type SetDisputeGameImplInput struct {
Factory common.Address
Impl common.Address
Portal common.Address
AnchorStateRegistry common.Address
GameType uint32
}
Expand Down
9 changes: 4 additions & 5 deletions op-deployer/pkg/deployer/pipeline/dispute_games.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,12 @@ func deployDisputeGame(

lgr.Info("setting dispute game impl on factory", "respected", game.MakeRespected)
sdgiInput := opcm.SetDisputeGameImplInput{
Factory: thisState.DisputeGameFactoryProxyAddress,
Impl: out.DisputeGameImpl,
GameType: game.DisputeGameType,
AnchorStateRegistry: thisState.AnchorStateRegistryProxyAddress,
Factory: thisState.DisputeGameFactoryProxyAddress,
Impl: out.DisputeGameImpl,
GameType: game.DisputeGameType,
}
if game.MakeRespected {
sdgiInput.Portal = thisState.OptimismPortalProxyAddress
sdgiInput.AnchorStateRegistry = thisState.AnchorStateRegistryProxyAddress
}
if err := opcm.SetDisputeGameImpl(
env.L1ScriptHost,
Expand Down
46 changes: 21 additions & 25 deletions packages/contracts-bedrock/interfaces/L1/IOptimismPortal2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,46 @@
pragma solidity ^0.8.0;

import { Types } from "src/libraries/Types.sol";
import { GameType, Timestamp } from "src/dispute/lib/LibUDT.sol";
import { GameType } from "src/dispute/lib/LibUDT.sol";
import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol";
import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol";

interface IOptimismPortal2 {
error AlreadyFinalized();
error BadTarget();
error Blacklisted();
error CallPaused();
error ContentLengthMismatch();
error EmptyItem();
error GasEstimation();
error InvalidDataRemainder();
error InvalidDisputeGame();
error InvalidGameType();
error InvalidHeader();
error InvalidMerkleProof();
error InvalidProof();
error LargeCalldata();
error NonReentrant();
error OptimismPortal_AlreadyFinalized();
error OptimismPortal_BadTarget();
error OptimismPortal_CallPaused();
error OptimismPortal_CalldataTooLarge();
error OptimismPortal_GasEstimation();
error OptimismPortal_GasLimitTooLow();
error OptimismPortal_ImproperDisputeGame();
error OptimismPortal_InvalidDisputeGame();
error OptimismPortal_InvalidMerkleProof();
error OptimismPortal_InvalidOutputRootProof();
error OptimismPortal_InvalidProofTimestamp();
error OptimismPortal_InvalidRootClaim();
error OptimismPortal_NoReentrancy();
error OptimismPortal_ProofNotOldEnough();
error OptimismPortal_Unproven();
error OutOfGas();
error ProposalNotValidated();
error SmallGasLimit();
error Unauthorized();
error UnexpectedList();
error UnexpectedString();
error Unproven();
error LegacyGame();

event DisputeGameBlacklisted(IDisputeGame indexed disputeGame);
event Initialized(uint8 version);
event RespectedGameTypeSet(GameType indexed newGameType, Timestamp indexed updatedAt);
event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData);
event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);
event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter);

receive() external payable;

function blacklistDisputeGame(IDisputeGame _disputeGame) external;
function anchorStateRegistry() external view returns (IAnchorStateRegistry);
function checkWithdrawal(bytes32 _withdrawalHash, address _proofSubmitter) external view;
function depositTransaction(
address _to,
Expand All @@ -54,7 +52,6 @@ interface IOptimismPortal2 {
)
external
payable;
function disputeGameBlacklist(IDisputeGame) external view returns (bool);
function disputeGameFactory() external view returns (IDisputeGameFactory);
function disputeGameFinalityDelaySeconds() external view returns (uint256);
function donateETH() external payable;
Expand All @@ -70,7 +67,7 @@ interface IOptimismPortal2 {
IDisputeGameFactory _disputeGameFactory,
ISystemConfig _systemConfig,
ISuperchainConfig _superchainConfig,
GameType _initialRespectedGameType
IAnchorStateRegistry _anchorStateRegistry
)
external;
function l2Sender() external view returns (address);
Expand All @@ -93,13 +90,12 @@ interface IOptimismPortal2 {
)
external
view
returns (IDisputeGame disputeGameProxy, uint64 timestamp); // nosemgrep
returns (IDisputeGame disputeGameProxy, uint64 timestamp);
function respectedGameType() external view returns (GameType);
function respectedGameTypeUpdatedAt() external view returns (uint64);
function setRespectedGameType(GameType _gameType) external;
function superchainConfig() external view returns (ISuperchainConfig);
function systemConfig() external view returns (ISystemConfig);
function version() external pure returns (string memory);

function __constructor__(uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds) external;
function __constructor__(uint256 _proofMaturityDelaySeconds) external;
}
47 changes: 22 additions & 25 deletions packages/contracts-bedrock/interfaces/L1/IOptimismPortalInterop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,49 @@
pragma solidity ^0.8.0;

import { Types } from "src/libraries/Types.sol";
import { GameType, Timestamp } from "src/dispute/lib/LibUDT.sol";
import { GameType } from "src/dispute/lib/LibUDT.sol";
import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol";
import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { ConfigType } from "interfaces/L2/IL1BlockInterop.sol";
import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol";

interface IOptimismPortalInterop {
error CustomGasTokenNotSupported();
error AlreadyFinalized();
error BadTarget();
error Blacklisted();
error CallPaused();
error ContentLengthMismatch();
error CustomGasTokenNotSupported();
error EmptyItem();
error GasEstimation();
error InvalidDataRemainder();
error InvalidDisputeGame();
error InvalidGameType();
error InvalidHeader();
error InvalidMerkleProof();
error InvalidProof();
error LargeCalldata();
error NonReentrant();
error OptimismPortal_AlreadyFinalized();
error OptimismPortal_BadTarget();
error OptimismPortal_CallPaused();
error OptimismPortal_CalldataTooLarge();
error OptimismPortal_GasEstimation();
error OptimismPortal_GasLimitTooLow();
error OptimismPortal_ImproperDisputeGame();
error OptimismPortal_InvalidDisputeGame();
error OptimismPortal_InvalidMerkleProof();
error OptimismPortal_InvalidOutputRootProof();
error OptimismPortal_InvalidProofTimestamp();
error OptimismPortal_InvalidRootClaim();
error OptimismPortal_NoReentrancy();
error OptimismPortal_ProofNotOldEnough();
error OptimismPortal_Unauthorized();
error OptimismPortal_Unproven();
error OutOfGas();
error ProposalNotValidated();
error SmallGasLimit();
error Unauthorized();
error UnexpectedList();
error UnexpectedString();
error Unproven();
error LegacyGame();

event DisputeGameBlacklisted(IDisputeGame indexed disputeGame);
event Initialized(uint8 version);
event RespectedGameTypeSet(GameType indexed newGameType, Timestamp indexed updatedAt);
event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData);
event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);
event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter);

receive() external payable;

function blacklistDisputeGame(IDisputeGame _disputeGame) external;
function anchorStateRegistry() external view returns (IAnchorStateRegistry);
function checkWithdrawal(bytes32 _withdrawalHash, address _proofSubmitter) external view;
function depositTransaction(
address _to,
Expand All @@ -56,7 +55,6 @@ interface IOptimismPortalInterop {
)
external
payable;
function disputeGameBlacklist(IDisputeGame) external view returns (bool);
function disputeGameFactory() external view returns (IDisputeGameFactory);
function disputeGameFinalityDelaySeconds() external view returns (uint256);
function donateETH() external payable;
Expand All @@ -72,7 +70,7 @@ interface IOptimismPortalInterop {
IDisputeGameFactory _disputeGameFactory,
ISystemConfig _systemConfig,
ISuperchainConfig _superchainConfig,
GameType _initialRespectedGameType
IAnchorStateRegistry _anchorStateRegistry
)
external;
function l2Sender() external view returns (address);
Expand All @@ -99,10 +97,9 @@ interface IOptimismPortalInterop {
function respectedGameType() external view returns (GameType);
function respectedGameTypeUpdatedAt() external view returns (uint64);
function setConfig(ConfigType _type, bytes memory _value) external;
function setRespectedGameType(GameType _gameType) external;
function superchainConfig() external view returns (ISuperchainConfig);
function systemConfig() external view returns (ISystemConfig);
function version() external pure returns (string memory);

function __constructor__(uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds) external;
function __constructor__(uint256 _proofMaturityDelaySeconds) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,34 @@ import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
import { IFaultDisputeGame } from "interfaces/dispute/IFaultDisputeGame.sol";
import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
import { GameType, Hash, OutputRoot } from "src/dispute/lib/Types.sol";

interface IAnchorStateRegistry {
error AnchorStateRegistry_Unauthorized();
error AnchorStateRegistry_InvalidAnchorGame();
error AnchorStateRegistry_AnchorGameBlacklisted();
error AnchorStateRegistry_InvalidAnchorGame();
error AnchorStateRegistry_Unauthorized();

event AnchorNotUpdated(IFaultDisputeGame indexed game);
event AnchorUpdated(IFaultDisputeGame indexed game);
event DisputeGameBlacklisted(IDisputeGame indexed disputeGame);
event Initialized(uint8 version);
event RespectedGameTypeSet(GameType gameType);
event RetirementTimestampSet(uint256 timestamp);

function anchorGame() external view returns (IFaultDisputeGame);
function anchors(GameType) external view returns (Hash, uint256);
function blacklistDisputeGame(IDisputeGame _disputeGame) external;
function disputeGameBlacklist(IDisputeGame) external view returns (bool);
function getAnchorRoot() external view returns (Hash, uint256);
function disputeGameFinalityDelaySeconds() external view returns (uint256);
function disputeGameFactory() external view returns (IDisputeGameFactory);
function initialize(
ISuperchainConfig _superchainConfig,
IDisputeGameFactory _disputeGameFactory,
IOptimismPortal2 _portal,
OutputRoot memory _startingAnchorRoot
OutputRoot memory _startingAnchorRoot,
GameType _startingRespectedGameType
)
external;

function isGameAirgapped(IDisputeGame _game) external view returns (bool);
function isGameBlacklisted(IDisputeGame _game) external view returns (bool);
function isGameProper(IDisputeGame _game) external view returns (bool);
Expand All @@ -38,11 +42,15 @@ interface IAnchorStateRegistry {
function isGameRetired(IDisputeGame _game) external view returns (bool);
function isGameFinalized(IDisputeGame _game) external view returns (bool);
function isGameClaimValid(IDisputeGame _game) external view returns (bool);
function portal() external view returns (IOptimismPortal2);
function respectedGameType() external view returns (GameType);
function retirementTimestamp() external view returns (uint64);
function setAnchorState(IDisputeGame _game) external;
function setRespectedGameType(GameType _gameType) external;
function superchainConfig() external view returns (ISuperchainConfig);
function updateRetirementTimestamp() external;
function version() external view returns (string memory);

function __constructor__() external;
function __constructor__(
uint256 _disputeGameFinalityDelaySeconds
) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
pragma solidity ^0.8.0;

import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol";
import { IFaultDisputeGame } from "interfaces/dispute/IFaultDisputeGame.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
import { ISemver } from "interfaces/universal/ISemver.sol";
import { GameType, Timestamp } from "src/dispute/lib/Types.sol";
import { GnosisSafe as Safe } from "safe-contracts/GnosisSafe.sol";

interface IDeputyGuardianModule is ISemver {
error ExecutionFailed(string);
error Unauthorized();
error DeputyGuardianModule_ExecutionFailed(string);
error DeputyGuardianModule_Unauthorized();

event Paused(string identifier);
event Unpaused();
event DisputeGameBlacklisted(IDisputeGame indexed game);
event RespectedGameTypeSet(GameType indexed gameType, Timestamp indexed updatedAt);
event RetirementTimestampUpdated(Timestamp indexed updatedAt);

function version() external view returns (string memory);
function __constructor__(Safe _safe, ISuperchainConfig _superchainConfig, address _deputyGuardian) external;
Expand All @@ -26,7 +25,7 @@ interface IDeputyGuardianModule is ISemver {
function deputyGuardian() external view returns (address deputyGuardian_);
function pause() external;
function unpause() external;
function setAnchorState(IAnchorStateRegistry _registry, IFaultDisputeGame _game) external;
function blacklistDisputeGame(IOptimismPortal2 _portal, IDisputeGame _game) external;
function setRespectedGameType(IOptimismPortal2 _portal, GameType _gameType) external;
function blacklistDisputeGame(IAnchorStateRegistry _anchorStateRegistry, IDisputeGame _game) external;
function setRespectedGameType(IAnchorStateRegistry _anchorStateRegistry, GameType _gameType) external;
function updateRetirementTimestamp(IAnchorStateRegistry _anchorStateRegistry) external;
}
3 changes: 1 addition & 2 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { GameType, Claim, GameTypes, OutputRoot, Hash } from "src/dispute/lib/Ty
// Interfaces
import { IProxy } from "interfaces/universal/IProxy.sol";
import { IProxyAdmin } from "interfaces/universal/IProxyAdmin.sol";
import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { IDataAvailabilityChallenge } from "interfaces/L1/IDataAvailabilityChallenge.sol";
Expand Down Expand Up @@ -207,7 +206,7 @@ contract Deploy is Deployer {

// Set the respected game type according to the deploy config
vm.startPrank(ISuperchainConfig(artifacts.mustGetAddress("SuperchainConfigProxy")).guardian());
IOptimismPortal2(artifacts.mustGetAddress("OptimismPortalProxy")).setRespectedGameType(
IAnchorStateRegistry(artifacts.mustGetAddress("AnchorStateRegistryProxy")).setRespectedGameType(
GameType.wrap(uint32(cfg.respectedGameType()))
);
vm.stopPrank();
Expand Down
Loading

0 comments on commit a54f238

Please sign in to comment.