Skip to content
Verified contractPartialMIT

OPContractsManagerStandardValidator

Address0xae6153ec750dfb0871b3e2287caacc0c19f9e809
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.15

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.15+commit.e14f2714
Language
solidity
Optimization
Yes, 200 runs
EVM version
london
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,480,487
Creation transaction
0xddd9a4984f…b14dee3220

50 files

The source code is large: one file is shown at a time. Choose a file in the list.

src/L1/OPContractsManagerStandardValidator.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

// Libraries
import { LibString } from "@solady/utils/LibString.sol";
import { GameType, Claim, GameTypes, Hash } from "src/dispute/lib/Types.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
import { Features } from "src/libraries/Features.sol";
import { DevFeatures } from "src/libraries/DevFeatures.sol";
import { LibGameArgs } from "src/dispute/lib/LibGameArgs.sol";
import { IStandardValidatorUtils } from "interfaces/L1/opcm/IStandardValidatorUtils.sol";
import {
    DisputeGameImplementation,
    DisputeGameValidationArgs,
    DisputeGameImpls,
    DisputeGameConfig,
    SuperPermissionedDisputeGameImplementation,
    SuperPermissionedDisputeGameImpls,
    SuperPermissionedDisputeGameValidationArgs
} from "src/L1/opcm/StandardValidatorUtils.sol";

// Interfaces
import { IOPContractsManagerMigrationValidator } from "interfaces/L1/opcm/IOPContractsManagerMigrationValidator.sol";
import { IOPContractsManagerStandardValidator } from "interfaces/L1/IOPContractsManagerStandardValidator.sol";
import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol";
import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol";
import { IL1CrossDomainMessenger } from "interfaces/L1/IL1CrossDomainMessenger.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { IL1StandardBridge } from "interfaces/L1/IL1StandardBridge.sol";
import { IL1ERC721Bridge } from "interfaces/L1/IL1ERC721Bridge.sol";
import { IETHLockbox } from "interfaces/L1/IETHLockbox.sol";
import { IPermissionedDisputeGame } from "interfaces/dispute/IPermissionedDisputeGame.sol";
import { IProxyAdmin } from "interfaces/universal/IProxyAdmin.sol";
import { IDelayedWETH } from "interfaces/dispute/IDelayedWETH.sol";
import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
import { ISemver } from "interfaces/universal/ISemver.sol";
import { IProxyAdminOwnedBase } from "interfaces/universal/IProxyAdminOwnedBase.sol";
import { IBigStepper } from "interfaces/dispute/IBigStepper.sol";

/// @title OPContractsManagerStandardValidator
/// @notice This contract is used to validate the configuration of the L1 contracts of an OP Stack chain.
/// It is a stateless contract that can be used to ensure that the L1 contracts are configured correctly.
/// It is intended to be used by the L1 PAO multisig to validate the configuration of the L1 contracts
/// after an upgrade. It expects the chain to already run this release's contracts.
contract OPContractsManagerStandardValidator is ISemver {
    /// @notice The semantic version of the OPContractsManagerStandardValidator contract.
    /// @custom:semver 6.0.0
    string public constant version = "6.0.0";

    /// @notice The SuperchainConfig contract.
    ISuperchainConfig public superchainConfig;

    /// @notice The L1 PAO multisig address.
    address public l1PAOMultisig;

    /// @notice The challenger address for permissioned dispute games.
    address public challenger;

    // Implementation addresses as state variables

    /// @notice The L1ERC721Bridge implementation address.
    address public l1ERC721BridgeImpl;

    /// @notice The OptimismPortal implementation address.
    address public optimismPortalImpl;

    /// @notice The ETHLockbox implementation address.
    address public ethLockboxImpl;

    /// @notice The SystemConfig implementation address.
    address public systemConfigImpl;

    /// @notice The OptimismMintableERC20Factory implementation address.
    address public optimismMintableERC20FactoryImpl;

    /// @notice The L1CrossDomainMessenger implementation address.
    address public l1CrossDomainMessengerImpl;

    /// @notice The L1StandardBridge implementation address.
    address public l1StandardBridgeImpl;

    /// @notice The DisputeGameFactory implementation address.
    address public disputeGameFactoryImpl;

    /// @notice The AnchorStateRegistry implementation address.
    address public anchorStateRegistryImpl;

    /// @notice The DelayedWETH implementation address.
    address public delayedWETHImpl;

    /// @notice The MIPS implementation address.
    address public mipsImpl;

    /// @notice The FaultDisputeGame implementation address.
    address public faultDisputeGameImpl;

    /// @notice The PermissionedFaultDisputeGame implementation address.
    address public permissionedDisputeGameImpl;

    /// @notice The SuperFaultDisputeGame implementation address.
    address public superFaultDisputeGameImpl;

    /// @notice The SuperPermissionedDisputeGame implementation address.
    address public superPermissionedDisputeGameImpl;

    /// @notice The ZKDisputeGame implementation address.
    address public zkDisputeGameImpl;

    /// @notice Bitmap of development features, verification may depend on these features.
    bytes32 public devFeatureBitmap;

    /// @notice Helper contract providing validation utilities (split for EIP-170 bytecode size).
    IStandardValidatorUtils public standardValidatorUtils;

    /// @notice The migration validator contract for post-interop-migration validation.
    IOPContractsManagerMigrationValidator public migrationValidator;

    /// @notice The release-approved SP1 PLONK adapter address.
    address public sp1PlonkAdapterImpl;

    /// @notice Struct containing the implementation addresses of the L1 contracts.
    struct Implementations {
        address l1ERC721BridgeImpl;
        address optimismPortalImpl;
        address ethLockboxImpl;
        address systemConfigImpl;
        address optimismMintableERC20FactoryImpl;
        address l1CrossDomainMessengerImpl;
        address l1StandardBridgeImpl;
        address disputeGameFactoryImpl;
        address anchorStateRegistryImpl;
        address delayedWETHImpl;
        address mipsImpl;
        address faultDisputeGameImpl;
        address permissionedDisputeGameImpl;
        address superFaultDisputeGameImpl;
        address superPermissionedDisputeGameImpl;
        address zkDisputeGameImpl;
        address sp1PlonkAdapterImpl;
    }

    /// @notice Struct containing the input parameters for the validation process.
    struct ValidationInput {
        ISystemConfig sysCfg;
        bytes32 absolutePrestate;
        uint256 l2ChainID;
        address proposer;
    }

    /// @notice Validation input carrying the expected Cannon, Cannon-Kona and ZK prestates.
    struct ValidationInputDev {
        ISystemConfig sysCfg;
        bytes32 cannonPrestate;
        bytes32 cannonKonaPrestate;
        bytes32 zkPrestate;
        uint256 l2ChainID;
        address proposer;
    }

    /// @notice Struct containing override parameters for the validation process.
    struct ValidationOverrides {
        address l1PAOMultisig;
        address challenger;
    }

    /// @notice Constructor for the OPContractsManagerStandardValidator contract.
    constructor(
        IStandardValidatorUtils _standardValidatorUtils,
        IOPContractsManagerMigrationValidator _migrationValidator,
        Implementations memory _implementations,
        ISuperchainConfig _superchainConfig,
        address _l1PAOMultisig,
        address _challenger,
        bytes32 _devFeatureBitmap
    ) {
        superchainConfig = _superchainConfig;
        l1PAOMultisig = _l1PAOMultisig;
        challenger = _challenger;
        devFeatureBitmap = _devFeatureBitmap;
        standardValidatorUtils = _standardValidatorUtils;
        migrationValidator = _migrationValidator;

        // Set implementation addresses from struct
        l1ERC721BridgeImpl = _implementations.l1ERC721BridgeImpl;
        optimismPortalImpl = _implementations.optimismPortalImpl;
        ethLockboxImpl = _implementations.ethLockboxImpl;
        systemConfigImpl = _implementations.systemConfigImpl;
        optimismMintableERC20FactoryImpl = _implementations.optimismMintableERC20FactoryImpl;
        l1CrossDomainMessengerImpl = _implementations.l1CrossDomainMessengerImpl;
        l1StandardBridgeImpl = _implementations.l1StandardBridgeImpl;
        disputeGameFactoryImpl = _implementations.disputeGameFactoryImpl;
        anchorStateRegistryImpl = _implementations.anchorStateRegistryImpl;
        delayedWETHImpl = _implementations.delayedWETHImpl;
        mipsImpl = _implementations.mipsImpl;
        faultDisputeGameImpl = _implementations.faultDisputeGameImpl;
        permissionedDisputeGameImpl = _implementations.permissionedDisputeGameImpl;
        superFaultDisputeGameImpl = _implementations.superFaultDisputeGameImpl;
        superPermissionedDisputeGameImpl = _implementations.superPermissionedDisputeGameImpl;
        zkDisputeGameImpl = _implementations.zkDisputeGameImpl;
        sp1PlonkAdapterImpl = _implementations.sp1PlonkAdapterImpl;
    }

    /// @notice Returns a string representing the overrides that are set.
    function getOverridesString(ValidationOverrides memory _overrides) private pure returns (string memory) {
        string memory overridesError;

        if (_overrides.l1PAOMultisig != address(0)) {
            overridesError = string.concat(overridesError, "OVERRIDES-L1PAOMULTISIG");
        }

        if (_overrides.challenger != address(0)) {
            if (bytes(overridesError).length > 0) overridesError = string.concat(overridesError, ",");
            overridesError = string.concat(overridesError, "OVERRIDES-CHALLENGER");
        }

        return overridesError;
    }

    /// @notice Returns the expected L1 PAO multisig address.
    function expectedL1PAOMultisig(ValidationOverrides memory _overrides) internal view returns (address) {
        if (_overrides.l1PAOMultisig != address(0)) {
            return _overrides.l1PAOMultisig;
        }
        return l1PAOMultisig;
    }

    /// @notice Returns the expected challenger address.
    function expectedChallenger(ValidationOverrides memory _overrides) internal view returns (address) {
        if (_overrides.challenger != address(0)) {
            return _overrides.challenger;
        }
        return challenger;
    }

    /// @notice Returns the expected PreimageOracle version.
    function preimageOracleVersion() public pure returns (string memory) {
        return "1.1.5";
    }

    /// @notice Internal function to get version from any contract implementing ISemver.
    function getVersion(address _contract) private view returns (string memory) {
        return ISemver(_contract).version();
    }

    /// @notice Internal function to get the ProxyAdmin contract from any contract implementing IProxyAdminOwnedBase.
    function getProxyAdmin(address _contract) private view returns (IProxyAdmin) {
        return IProxyAdminOwnedBase(_contract).proxyAdmin();
    }

    /// @notice Internal function to get the implementation address of any contract via the ProxyAdmin contract.
    function getProxyImplementation(IProxyAdmin _admin, address _contract) private view returns (address) {
        return _admin.getProxyImplementation(_contract);
    }

    /// @notice Asserts that the SuperchainConfig contract is valid.
    function assertValidSuperchainConfig(string memory _errors) internal view returns (string memory) {
        return standardValidatorUtils.assertValidSuperchainConfig(_errors, superchainConfig);
    }

    /// @notice Asserts that the ProxyAdmin contract is valid.
    function assertValidProxyAdmin(
        string memory _errors,
        IProxyAdmin _admin,
        ValidationOverrides memory _overrides
    )
        internal
        view
        returns (string memory)
    {
        return standardValidatorUtils.assertValidProxyAdmin(_errors, _admin, expectedL1PAOMultisig(_overrides));
    }

    /// @notice Asserts that the SystemConfig contract is valid.
    function assertValidSystemConfig(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin,
        uint256 _l2ChainID
    )
        internal
        view
        virtual
        returns (string memory)
    {
        _errors = internalRequire(
            LibString.eq(getVersion(address(_sysCfg)), getVersion(systemConfigImpl)), "SYSCON-10", _errors
        );
        _errors = internalRequire(_sysCfg.gasLimit() <= uint64(500_000_000), "SYSCON-20", _errors);
        _errors = internalRequire(_sysCfg.scalar() != 0, "SYSCON-30", _errors);
        _errors =
            internalRequire(getProxyImplementation(_admin, address(_sysCfg)) == systemConfigImpl, "SYSCON-40", _errors);

        IResourceMetering.ResourceConfig memory outputConfig = _sysCfg.resourceConfig();
        _errors = internalRequire(outputConfig.maxResourceLimit == 20_000_000, "SYSCON-50", _errors);
        _errors = internalRequire(outputConfig.elasticityMultiplier == 10, "SYSCON-60", _errors);
        _errors = internalRequire(outputConfig.baseFeeMaxChangeDenominator == 8, "SYSCON-70", _errors);
        _errors = internalRequire(outputConfig.systemTxMaxGas == 1_000_000, "SYSCON-80", _errors);
        _errors = internalRequire(outputConfig.minimumBaseFee == 1 gwei, "SYSCON-90", _errors);
        _errors = internalRequire(outputConfig.maximumBaseFee == type(uint128).max, "SYSCON-100", _errors);
        _errors = internalRequire(_sysCfg.operatorFeeScalar() == 0, "SYSCON-110", _errors);
        _errors = internalRequire(_sysCfg.operatorFeeConstant() == 0, "SYSCON-120", _errors);
        _errors = internalRequire(_sysCfg.superchainConfig() == superchainConfig, "SYSCON-130", _errors);
        _errors = internalRequire(_sysCfg.l2ChainId() == _l2ChainID, "SYSCON-140", _errors);
        return _errors;
    }

    /// @notice Asserts that the L1CrossDomainMessenger contract is valid.
    function assertValidL1CrossDomainMessenger(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin
    )
        internal
        view
        returns (string memory)
    {
        IL1CrossDomainMessenger _messenger = IL1CrossDomainMessenger(_sysCfg.l1CrossDomainMessenger());
        _errors = internalRequire(
            LibString.eq(getVersion(address(_messenger)), getVersion(l1CrossDomainMessengerImpl)), "L1xDM-10", _errors
        );
        _errors = internalRequire(
            getProxyImplementation(_admin, address(_messenger)) == l1CrossDomainMessengerImpl, "L1xDM-20", _errors
        );

        IOptimismPortal2 _portal = IOptimismPortal2(payable(_sysCfg.optimismPortal()));

        _errors = internalRequire(
            address(_messenger.OTHER_MESSENGER()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER, "L1xDM-30", _errors
        );
        _errors = internalRequire(
            address(_messenger.otherMessenger()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER, "L1xDM-40", _errors
        );
        _errors = internalRequire(address(_messenger.PORTAL()) == address(_portal), "L1xDM-50", _errors);
        _errors = internalRequire(address(_messenger.portal()) == address(_portal), "L1xDM-60", _errors);
        _errors = internalRequire(address(_messenger.systemConfig()) == address(_sysCfg), "L1xDM-70", _errors);
        _errors = internalRequire(getProxyAdmin(address(_messenger)) == _admin, "L1xDM-80", _errors);
        return _errors;
    }

    /// @notice Asserts that the L1StandardBridge contract is valid.
    function assertValidL1StandardBridge(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin
    )
        internal
        view
        returns (string memory)
    {
        IL1StandardBridge _bridge = IL1StandardBridge(payable(_sysCfg.l1StandardBridge()));
        _errors = internalRequire(
            LibString.eq(getVersion(address(_bridge)), getVersion(l1StandardBridgeImpl)), "L1SB-10", _errors
        );
        _errors = internalRequire(
            getProxyImplementation(_admin, address(_bridge)) == l1StandardBridgeImpl, "L1SB-20", _errors
        );

        IL1CrossDomainMessenger _messenger = IL1CrossDomainMessenger(_sysCfg.l1CrossDomainMessenger());

        _errors = internalRequire(address(_bridge.MESSENGER()) == address(_messenger), "L1SB-30", _errors);
        _errors = internalRequire(address(_bridge.messenger()) == address(_messenger), "L1SB-40", _errors);
        _errors = internalRequire(address(_bridge.OTHER_BRIDGE()) == Predeploys.L2_STANDARD_BRIDGE, "L1SB-50", _errors);
        _errors = internalRequire(address(_bridge.otherBridge()) == Predeploys.L2_STANDARD_BRIDGE, "L1SB-60", _errors);
        _errors = internalRequire(address(_bridge.systemConfig()) == address(_sysCfg), "L1SB-70", _errors);
        _errors = internalRequire(getProxyAdmin(address(_bridge)) == _admin, "L1SB-80", _errors);
        return _errors;
    }

    /// @notice Asserts that the OptimismMintableERC20Factory contract is valid.
    function assertValidOptimismMintableERC20Factory(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin
    )
        internal
        view
        returns (string memory)
    {
        return standardValidatorUtils.assertValidOptimismMintableERC20Factory(
            _errors, _sysCfg, _admin, optimismMintableERC20FactoryImpl
        );
    }

    /// @notice Asserts that the L1ERC721Bridge contract is valid.
    function assertValidL1ERC721Bridge(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin
    )
        internal
        view
        returns (string memory)
    {
        IL1ERC721Bridge _bridge = IL1ERC721Bridge(_sysCfg.l1ERC721Bridge());
        _errors = internalRequire(
            LibString.eq(getVersion(address(_bridge)), getVersion(l1ERC721BridgeImpl)), "L721B-10", _errors
        );
        _errors = internalRequire(
            getProxyImplementation(_admin, address(_bridge)) == l1ERC721BridgeImpl, "L721B-20", _errors
        );

        IL1CrossDomainMessenger _l1XDM = IL1CrossDomainMessenger(_sysCfg.l1CrossDomainMessenger());
        _errors = internalRequire(address(_bridge.OTHER_BRIDGE()) == Predeploys.L2_ERC721_BRIDGE, "L721B-30", _errors);
        _errors = internalRequire(address(_bridge.otherBridge()) == Predeploys.L2_ERC721_BRIDGE, "L721B-40", _errors);
        _errors = internalRequire(address(_bridge.MESSENGER()) == address(_l1XDM), "L721B-50", _errors);
        _errors = internalRequire(address(_bridge.messenger()) == address(_l1XDM), "L721B-60", _errors);
        _errors = internalRequire(address(_bridge.systemConfig()) == address(_sysCfg), "L721B-70", _errors);
        _errors = internalRequire(getProxyAdmin(address(_bridge)) == _admin, "L721B-80", _errors);
        return _errors;
    }

    /// @notice Asserts that the OptimismPortal contract is valid.
    function assertValidOptimismPortal(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin
    )
        internal
        view
        returns (string memory)
    {
        return standardValidatorUtils.assertValidOptimismPortal(_errors, _sysCfg, _admin, optimismPortalImpl);
    }

    /// @notice Asserts that the ETHLockbox contract is valid.
    function assertValidETHLockbox(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin
    )
        internal
        view
        returns (string memory)
    {
        IOptimismPortal2 _portal = IOptimismPortal2(payable(_sysCfg.optimismPortal()));
        IETHLockbox _lockbox = IETHLockbox(_portal.ethLockbox());

        // Validate the chain's ETHLockbox configuration.
        _errors = internalRequire(_sysCfg.isFeatureEnabled(Features.ETH_LOCKBOX), "LOCKBOX-00", _errors);
        _errors = internalRequire(address(_lockbox) != address(0), "LOCKBOX-05", _errors);
        if (address(_lockbox) == address(0)) {
            return _errors;
        }

        _errors = internalRequire(
            LibString.eq(getVersion(address(_lockbox)), getVersion(ethLockboxImpl)), "LOCKBOX-10", _errors
        );
        _errors =
            internalRequire(getProxyImplementation(_admin, address(_lockbox)) == ethLockboxImpl, "LOCKBOX-20", _errors);
        _errors = internalRequire(getProxyAdmin(address(_lockbox)) == _admin, "LOCKBOX-30", _errors);
        _errors = internalRequire(_lockbox.superchainConfig() == _sysCfg.superchainConfig(), "LOCKBOX-40", _errors);
        _errors = internalRequire(_lockbox.authorizedPortals(_portal), "LOCKBOX-50", _errors);
        return _errors;
    }

    /// @notice Asserts that the DisputeGameFactory contract is valid.
    function assertValidDisputeGameFactory(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin,
        ValidationOverrides memory _overrides
    )
        internal
        view
        returns (string memory)
    {
        return standardValidatorUtils.assertValidDisputeGameFactory(
            _errors, _sysCfg, _admin, disputeGameFactoryImpl, expectedL1PAOMultisig(_overrides)
        );
    }

    /// @notice Asserts that dispute games are correctly configured for super root mode.
    ///         Checks that legacy game types and SUPER_CANNON are unregistered, SUPER_PERMISSIONED is
    ///         registered, and SUPER_CANNON_KONA or ZK_DISPUTE_GAME is registered.
    ///         This only validates system shape, not full game configuration. State transition
    ///         checks (e.g., "was this chain already migrated?") belong in Superchain Ops scripts.
    function assertValidSuperRootDisputeGames(
        string memory _errors,
        ISystemConfig _sysCfg
    )
        internal
        view
        returns (string memory)
    {
        return standardValidatorUtils.assertValidSuperRootDisputeGames(_errors, _sysCfg);
    }

    /// @notice Asserts that super game types are NOT registered in non-super-root mode.
    ///         Mirrors assertValidSuperRootDisputeGames for the opposite direction.
    function assertValidNonSuperRootDisputeGames(
        string memory _errors,
        ISystemConfig _sysCfg
    )
        internal
        view
        returns (string memory)
    {
        return standardValidatorUtils.assertValidNonSuperRootDisputeGames(_errors, _sysCfg);
    }

    /// @notice Asserts that a permissioned dispute game contract is valid.
    function assertValidPermissionedDisputeGame(
        string memory _errors,
        ISystemConfig _sysCfg,
        GameType _gameType,
        bytes32 _absolutePrestate,
        uint256 _l2ChainID,
        IProxyAdmin _admin,
        address _proposer,
        ValidationOverrides memory _overrides,
        string memory _errorPrefix
    )
        internal
        view
        returns (string memory)
    {
        if (_gameType.raw() == GameTypes.SUPER_PERMISSIONED.raw()) {
            return assertValidSuperPermissionedDisputeGame(_errors, _sysCfg, _admin, _proposer, _errorPrefix);
        }

        // Collect game implementation parameters
        DisputeGameImplementation memory gameImpl;
        bool failedToGetImpl = false;
        (gameImpl, _errors, failedToGetImpl) = getGameImplementation(_errors, _gameType, _sysCfg, _errorPrefix);
        if (failedToGetImpl) {
            // Return early on failure to avoid trying to validate an invalid dispute game
            return _errors;
        }

        _errors = assertValidDisputeGame(
            DisputeGameValidationArgs({
                errors: _errors,
                sysCfg: _sysCfg,
                game: gameImpl,
                absolutePrestate: _absolutePrestate,
                l2ChainID: _l2ChainID,
                admin: _admin,
                gameType: _gameType,
                errorPrefix: _errorPrefix
            }),
            _buildDisputeGameImpls(_gameType),
            _buildDisputeGameConfig(_overrides)
        );

        // Challenger is specific to legacy permissioned dispute game contracts.
        address _challenger = expectedChallenger(_overrides);
        _errors = internalRequire(gameImpl.challenger == _challenger, string.concat(_errorPrefix, "-130"), _errors);
        _errors = internalRequire(gameImpl.proposer == _proposer, string.concat(_errorPrefix, "-140"), _errors);

        return _errors;
    }

    /// @notice Asserts that the SuperPermissionedDisputeGame contract is valid.
    function assertValidSuperPermissionedDisputeGame(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin,
        address _proposer,
        string memory _errorPrefix
    )
        internal
        view
        returns (string memory)
    {
        SuperPermissionedDisputeGameImplementation memory gameImpl;
        bool failedToGetImpl = false;
        (gameImpl, _errors, failedToGetImpl) = getSuperPermissionedGameImplementation(_errors, _sysCfg, _errorPrefix);
        if (failedToGetImpl) {
            return _errors;
        }

        _errors = standardValidatorUtils.assertValidSuperPermissionedDisputeGame(
            SuperPermissionedDisputeGameValidationArgs({
                errors: _errors,
                sysCfg: _sysCfg,
                game: gameImpl,
                admin: _admin,
                expectedProposer: _proposer,
                errorPrefix: _errorPrefix
            }),
            _buildSuperPermissionedDisputeGameImpls()
        );

        return _errors;
    }

    /// @notice Asserts that the PermissionlessDisputeGame contract is valid.
    function assertValidPermissionlessDisputeGame(
        string memory _errors,
        ISystemConfig _sysCfg,
        GameType _gameType,
        bytes32 _absolutePrestate,
        uint256 _l2ChainID,
        IProxyAdmin _admin,
        ValidationOverrides memory _overrides,
        string memory _errorPrefix
    )
        internal
        view
        returns (string memory)
    {
        require(
            _gameType.raw() != GameTypes.SUPER_PERMISSIONED.raw(),
            "OPContractsManagerStandardValidator: SPDG is not permissionless"
        );

        // Collect game implementation parameters
        DisputeGameImplementation memory gameImpl;
        bool failedToGetImpl = false;
        (gameImpl, _errors, failedToGetImpl) = getGameImplementation(_errors, _gameType, _sysCfg, _errorPrefix);
        if (failedToGetImpl) {
            // Return early on failure to avoid trying to validate an invalid dispute game
            return _errors;
        }

        _errors = assertValidDisputeGame(
            DisputeGameValidationArgs({
                errors: _errors,
                sysCfg: _sysCfg,
                game: gameImpl,
                absolutePrestate: _absolutePrestate,
                l2ChainID: _l2ChainID,
                admin: _admin,
                gameType: _gameType,
                errorPrefix: _errorPrefix
            }),
            _buildDisputeGameImpls(_gameType),
            _buildDisputeGameConfig(_overrides)
        );

        _errors = internalRequire(
            IDisputeGameFactory(_sysCfg.disputeGameFactory()).initBonds(_gameType) > 0,
            string.concat(_errorPrefix, "-160"),
            _errors
        );

        return _errors;
    }

    /// @notice Internal function to get the game implementation and decode game args for a given game type.
    ///        Returns a boolean indicating whether the retrieval and decoding of the game implementation failed
    function getGameImplementation(
        string memory _initialErrors,
        GameType _gameType,
        ISystemConfig _sysCfg,
        string memory _errorPrefix
    )
        internal
        view
        returns (DisputeGameImplementation memory gameImpl_, string memory errors_, bool failed_)
    {
        errors_ = _initialErrors;
        IDisputeGameFactory _factory = IDisputeGameFactory(_sysCfg.disputeGameFactory());
        IPermissionedDisputeGame _game = IPermissionedDisputeGame(address(_factory.gameImpls(_gameType)));

        if (address(_game) == address(0)) {
            errors_ = internalRequire(false, string.concat(_errorPrefix, "-10"), errors_);
            // Return early to avoid reverting, since this means that there is no valid game impl
            // for this game type.
            failed_ = true;
            return (gameImpl_, errors_, failed_);
        }

        bytes memory _gameArgs = _factory.gameArgs(_gameType);
        bool lenCheckFailed;
        (errors_, lenCheckFailed) = assertGameArgsLength(errors_, _gameArgs, _gameType, _errorPrefix);
        if (lenCheckFailed) {
            // Return early to avoid decoding invalid game args
            failed_ = true;
            return (gameImpl_, errors_, failed_);
        }
        gameImpl_ = _decodeDisputeGameImpl(_game, _gameArgs, _gameType);

        return (gameImpl_, errors_, failed_);
    }

    /// @notice Internal function to get the game implementation and decode game args for a super permissioned game.
    ///        Returns a boolean indicating whether the length check failed, since this is used as a guard
    function getSuperPermissionedGameImplementation(
        string memory _initialErrors,
        ISystemConfig _sysCfg,
        string memory _errorPrefix
    )
        internal
        view
        returns (SuperPermissionedDisputeGameImplementation memory gameImpl_, string memory errors_, bool failed_)
    {
        errors_ = _initialErrors;
        IDisputeGameFactory _factory = IDisputeGameFactory(_sysCfg.disputeGameFactory());
        address gameAddress = address(_factory.gameImpls(GameTypes.SUPER_PERMISSIONED));

        if (gameAddress == address(0)) {
            errors_ = internalRequire(false, string.concat(_errorPrefix, "-10"), errors_);
            failed_ = true;
            return (gameImpl_, errors_, failed_);
        }

        bytes memory gameArgsBytes = _factory.gameArgs(GameTypes.SUPER_PERMISSIONED);
        bool lenCheckFailed;
        (errors_, lenCheckFailed) =
            assertGameArgsLength(errors_, gameArgsBytes, GameTypes.SUPER_PERMISSIONED, _errorPrefix);
        if (lenCheckFailed) {
            failed_ = true;
            return (gameImpl_, errors_, failed_);
        }

        LibGameArgs.SuperPermissionedGameArgs memory gameArgs = LibGameArgs.decodeSuperPermissioned(gameArgsBytes);
        gameImpl_ = SuperPermissionedDisputeGameImplementation({
            gameAddress: gameAddress,
            asr: IAnchorStateRegistry(gameArgs.anchorStateRegistry),
            proposer: gameArgs.proposer
        });

        return (gameImpl_, errors_, failed_);
    }

    /// @notice Asserts that a DisputeGame contract is valid. Delegates to the shared utility.
    function assertValidDisputeGame(
        DisputeGameValidationArgs memory _args,
        DisputeGameImpls memory _impls,
        DisputeGameConfig memory _cfg
    )
        internal
        view
        returns (string memory)
    {
        return standardValidatorUtils.assertValidDisputeGame(_args, _impls, _cfg);
    }

    /// @notice Returns the expected implementation address for a given game type.
    function expectedGameImpl(GameType _gameType) internal view returns (address) {
        uint32 raw = _gameType.raw();
        if (raw == GameTypes.PERMISSIONED_CANNON.raw()) return permissionedDisputeGameImpl;
        if (raw == GameTypes.SUPER_PERMISSIONED.raw()) return superPermissionedDisputeGameImpl;
        if (raw == GameTypes.SUPER_CANNON.raw()) return superFaultDisputeGameImpl;
        if (raw == GameTypes.SUPER_CANNON_KONA.raw()) return superFaultDisputeGameImpl;
        if (raw == GameTypes.ZK_DISPUTE_GAME.raw()) return zkDisputeGameImpl;
        return faultDisputeGameImpl;
    }

    /// @notice Builds the `DisputeGameImpls` struct from this validator's storage for the given game type.
    function _buildDisputeGameImpls(GameType _gameType) internal view returns (DisputeGameImpls memory) {
        return DisputeGameImpls({
            expectedGameImpl: expectedGameImpl(_gameType),
            mipsImpl: mipsImpl,
            delayedWETHImpl: delayedWETHImpl,
            anchorStateRegistryImpl: anchorStateRegistryImpl
        });
    }

    /// @notice Builds the SPDG implementation references from this validator's storage.
    function _buildSuperPermissionedDisputeGameImpls()
        internal
        view
        returns (SuperPermissionedDisputeGameImpls memory)
    {
        return SuperPermissionedDisputeGameImpls({
            expectedGameImpl: superPermissionedDisputeGameImpl, anchorStateRegistryImpl: anchorStateRegistryImpl
        });
    }

    /// @notice Builds the `DisputeGameConfig` struct, resolving overrides against storage.
    function _buildDisputeGameConfig(ValidationOverrides memory _overrides)
        internal
        view
        returns (DisputeGameConfig memory)
    {
        return DisputeGameConfig({ l1PAOMultisig: expectedL1PAOMultisig(_overrides) });
    }

    /// @notice Internal function to require a condition to be true, otherwise append an error message.
    function internalRequire(
        bool _condition,
        string memory _message,
        string memory _errors
    )
        internal
        pure
        returns (string memory)
    {
        if (_condition) {
            return _errors;
        }
        if (bytes(_errors).length == 0) {
            _errors = _message;
        } else {
            _errors = string.concat(_errors, ",", _message);
        }
        return _errors;
    }

    /// @notice Validates the configuration of all L1 contracts after an interop migration.
    function validateMigratedChain(
        IOPContractsManagerMigrationValidator.MigrationValidationInput memory _input,
        bool _allowFailure
    )
        external
        view
        returns (string memory)
    {
        return migrationValidator.validateMigration(
            _input, _allowFailure, _buildSharedImplementations(), _buildSharedConfig()
        );
    }

    /// @notice Validates the configuration of all L1 contracts after an interop migration.
    ///         Supports overrides of certain storage values denoted in the ValidationOverrides struct.
    function validateMigratedChainWithOverrides(
        IOPContractsManagerMigrationValidator.MigrationValidationInput memory _input,
        bool _allowFailure,
        ValidationOverrides memory _overrides
    )
        external
        view
        returns (string memory)
    {
        return migrationValidator.validateMigrationWithOverrides(
            _input,
            _allowFailure,
            IOPContractsManagerStandardValidator.ValidationOverrides({
                l1PAOMultisig: _overrides.l1PAOMultisig, challenger: _overrides.challenger
            }),
            _buildSharedImplementations(),
            _buildSharedConfig()
        );
    }

    /// @notice Builds the SharedImplementations struct from this validator's state.
    function _buildSharedImplementations()
        private
        view
        returns (IOPContractsManagerMigrationValidator.SharedImplementations memory)
    {
        return IOPContractsManagerMigrationValidator.SharedImplementations({
            disputeGameFactoryImpl: disputeGameFactoryImpl,
            anchorStateRegistryImpl: anchorStateRegistryImpl,
            ethLockboxImpl: ethLockboxImpl,
            delayedWETHImpl: delayedWETHImpl,
            mipsImpl: mipsImpl,
            superFaultDisputeGameImpl: superFaultDisputeGameImpl,
            superPermissionedDisputeGameImpl: superPermissionedDisputeGameImpl,
            standardValidatorUtils: standardValidatorUtils
        });
    }

    /// @notice Builds the SharedConfig struct from this validator's state.
    function _buildSharedConfig() private view returns (IOPContractsManagerMigrationValidator.SharedConfig memory) {
        return IOPContractsManagerMigrationValidator.SharedConfig({
            l1PAOMultisig: l1PAOMultisig, superchainConfig: superchainConfig
        });
    }

    /// @notice Returns whether the selected validation branch validates the respected game type.
    ///         SUPER_CANNON_KONA and ZK_DISPUTE_GAME count only when the factory registers them;
    ///         the SHAPE checks require every other accepted type.
    function isRespectedGameTypeValidated(
        GameType _gameType,
        bool _isSuperMode,
        ISystemConfig _sysCfg
    )
        internal
        view
        returns (bool)
    {
        uint32 raw = _gameType.raw();
        if (!_isSuperMode) {
            return raw == GameTypes.PERMISSIONED_CANNON.raw() || raw == GameTypes.CANNON_KONA.raw();
        }
        if (raw == GameTypes.SUPER_PERMISSIONED.raw()) return true;
        if (raw != GameTypes.SUPER_CANNON_KONA.raw() && raw != GameTypes.ZK_DISPUTE_GAME.raw()) return false;
        return address(IDisputeGameFactory(_sysCfg.disputeGameFactory()).gameImpls(_gameType)) != address(0);
    }

    /// @notice Validates the configuration of the L1 contracts. Passes zero Cannon-Kona and ZK
    ///         prestates, so chains registering those games report their prestate errors.
    function validate(ValidationInput memory _input, bool _allowFailure) external view returns (string memory) {
        ValidationInputDev memory devInput = _toValidationInputDev(_input);
        return validate(devInput, _allowFailure);
    }

    /// @notice Validates the configuration of the L1 contracts against the given prestates.
    function validate(ValidationInputDev memory _input, bool _allowFailure) public view returns (string memory) {
        return validateWithOverrides(
            _input, _allowFailure, ValidationOverrides({ l1PAOMultisig: address(0), challenger: address(0) })
        );
    }

    /// @notice Validates the configuration of the L1 contracts. Supports overrides of certain storage values denoted in
    /// the ValidationOverrides struct. Passes zero Cannon-Kona and ZK prestates.
    function validateWithOverrides(
        ValidationInput memory _input,
        bool _allowFailure,
        ValidationOverrides memory _overrides
    )
        public
        view
        returns (string memory)
    {
        ValidationInputDev memory devInput = _toValidationInputDev(_input);
        return validateWithOverrides(devInput, _allowFailure, _overrides);
    }

    /// @notice Validates the configuration of the L1 contracts. Supports overrides of certain storage values denoted in
    /// the ValidationOverrides struct.
    function validateWithOverrides(
        ValidationInputDev memory _input,
        bool _allowFailure,
        ValidationOverrides memory _overrides
    )
        public
        view
        returns (string memory)
    {
        string memory _errors = "";

        IProxyAdmin _proxyAdmin = _input.sysCfg.proxyAdmin();

        _errors = assertValidSuperchainConfig(_errors);
        _errors = assertValidProxyAdmin(_errors, _proxyAdmin, _overrides);
        _errors = assertValidSystemConfig(_errors, _input.sysCfg, _proxyAdmin, _input.l2ChainID);
        _errors = assertValidL1CrossDomainMessenger(_errors, _input.sysCfg, _proxyAdmin);
        _errors = assertValidL1StandardBridge(_errors, _input.sysCfg, _proxyAdmin);
        _errors = assertValidOptimismMintableERC20Factory(_errors, _input.sysCfg, _proxyAdmin);
        _errors = assertValidL1ERC721Bridge(_errors, _input.sysCfg, _proxyAdmin);
        _errors = assertValidOptimismPortal(_errors, _input.sysCfg, _proxyAdmin);

        // Migrated interop chains retain their own ProxyAdmins, while the shared contracts use
        // the first member's ProxyAdmin. Use the factory's admin for the shared contract checks,
        // preserving both their common admin and the expected PAO owner.
        IProxyAdmin _sharedProxyAdmin = _proxyAdmin;
        if (_input.sysCfg.isFeatureEnabled(Features.INTEROP)) {
            _sharedProxyAdmin = getProxyAdmin(_input.sysCfg.disputeGameFactory());
            _errors = internalRequire(
                _sharedProxyAdmin.owner() == expectedL1PAOMultisig(_overrides), "SHARED-PROXYA-10", _errors
            );
        }
        // Under INTEROP, DF-40 compares the factory's admin with itself. SHARED-PROXYA-10
        // checks its PAO owner; the ASR, WETH and lockbox checks enforce the same shared admin.
        _errors = assertValidDisputeGameFactory(_errors, _input.sysCfg, _sharedProxyAdmin, _overrides);

        GameType rgt =
            IOptimismPortal2(payable(_input.sysCfg.optimismPortal())).anchorStateRegistry().respectedGameType();
        bool isSuperMode = DevFeatures.isDevFeatureEnabled(devFeatureBitmap, DevFeatures.SUPER_ROOT_GAMES_MIGRATION)
            && GameTypes.isSuperGame(rgt);

        _errors = internalRequire(isRespectedGameTypeValidated(rgt, isSuperMode, _input.sysCfg), "ASR-RGT", _errors);

        if (isSuperMode) {
            _errors = assertValidSuperRootDisputeGames(_errors, _input.sysCfg);
            _errors = assertValidPermissionedDisputeGame(
                _errors,
                _input.sysCfg,
                GameTypes.SUPER_PERMISSIONED,
                _input.cannonPrestate,
                _input.l2ChainID,
                _sharedProxyAdmin,
                _input.proposer,
                _overrides,
                "SPDG"
            );
            // Optional: DF-60 requires SUPER_CANNON_KONA or ZK_DISPUTE_GAME.
            if (
                address(IDisputeGameFactory(_input.sysCfg.disputeGameFactory()).gameImpls(GameTypes.SUPER_CANNON_KONA))
                    != address(0)
            ) {
                _errors = assertValidPermissionlessDisputeGame(
                    _errors,
                    _input.sysCfg,
                    GameTypes.SUPER_CANNON_KONA,
                    _input.cannonKonaPrestate,
                    _input.l2ChainID,
                    _sharedProxyAdmin,
                    _overrides,
                    "SCKDG"
                );
            }
            _errors = assertValidZKDisputeGame(_errors, _input.sysCfg, _sharedProxyAdmin, _overrides, _input.zkPrestate);
        } else {
            // Super game types must not be registered in non-super mode.
            _errors = assertValidNonSuperRootDisputeGames(_errors, _input.sysCfg);
            _errors = assertValidPermissionedDisputeGame(
                _errors,
                _input.sysCfg,
                GameTypes.PERMISSIONED_CANNON,
                _input.cannonPrestate,
                _input.l2ChainID,
                _sharedProxyAdmin,
                _input.proposer,
                _overrides,
                "PDDG"
            );
            _errors = assertValidPermissionlessDisputeGame(
                _errors,
                _input.sysCfg,
                GameTypes.CANNON_KONA,
                _input.cannonKonaPrestate,
                _input.l2ChainID,
                _sharedProxyAdmin,
                _overrides,
                "CKDG"
            );
        }

        _errors = assertValidETHLockbox(_errors, _input.sysCfg, _sharedProxyAdmin);

        string memory overridesString = getOverridesString(_overrides);
        string memory finalErrors = _errors;

        // Handle overrides if present
        if (bytes(overridesString).length > 0) {
            // If we have both overrides and errors, combine them
            if (bytes(_errors).length > 0) {
                finalErrors = string.concat(overridesString, ",", _errors);
            } else {
                // If we only have overrides, use them as the final message
                finalErrors = overridesString;
            }
        }

        // Handle validation failure
        if (bytes(_errors).length > 0 && !_allowFailure) {
            revert(string.concat("OPContractsManagerStandardValidator: ", finalErrors));
        }

        return finalErrors;
    }

    /// @notice Converts a ValidationInput into a ValidationInputDev with zero Cannon-Kona and ZK
    ///         prestates.
    function _toValidationInputDev(ValidationInput memory _input) internal pure returns (ValidationInputDev memory) {
        return ValidationInputDev({
            sysCfg: _input.sysCfg,
            cannonPrestate: _input.absolutePrestate,
            cannonKonaPrestate: bytes32(0),
            zkPrestate: bytes32(0),
            l2ChainID: _input.l2ChainID,
            proposer: _input.proposer
        });
    }

    function assertGameArgsLength(
        string memory _errors,
        bytes memory _gameArgsBytes,
        GameType _gameType,
        string memory _errorPrefix
    )
        internal
        pure
        returns (string memory errors_, bool failed_)
    {
        _errorPrefix = string.concat(_errorPrefix, "-GARGS");
        uint32 rawGameType = _gameType.raw();
        if (rawGameType == GameTypes.ZK_DISPUTE_GAME.raw()) {
            bool ok = LibGameArgs.isValidZKArgs(_gameArgsBytes);
            _errors = internalRequire(ok, string.concat(_errorPrefix, "-10"), _errors);
            return (_errors, !ok);
        } else if (rawGameType == GameTypes.SUPER_PERMISSIONED.raw()) {
            bool ok = LibGameArgs.isValidSuperPermissionedArgs(_gameArgsBytes);
            _errors = internalRequire(ok, string.concat(_errorPrefix, "-10"), _errors);
            return (_errors, !ok);
        } else if (rawGameType == GameTypes.PERMISSIONED_CANNON.raw()) {
            bool ok = LibGameArgs.isValidPermissionedArgs(_gameArgsBytes);
            _errors = internalRequire(ok, string.concat(_errorPrefix, "-10"), _errors);
            return (_errors, !ok);
        } else {
            bool ok = LibGameArgs.isValidPermissionlessArgs(_gameArgsBytes);
            _errors = internalRequire(ok, string.concat(_errorPrefix, "-10"), _errors);
            return (_errors, !ok);
        }
    }

    /// @notice Validates the decoded ZK game args against the chain config and the expected ZK
    ///         prestate.
    function _assertValidZKGameArgs(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin,
        ValidationOverrides memory _overrides,
        bytes32 _zkPrestate,
        string memory _errorPrefix
    )
        private
        view
        returns (string memory)
    {
        IDisputeGameFactory factory = IDisputeGameFactory(_sysCfg.disputeGameFactory());
        LibGameArgs.ZKGameArgs memory args = LibGameArgs.decodeZK(factory.gameArgs(GameTypes.ZK_DISPUTE_GAME));
        _errors = internalRequire(
            _zkPrestate != bytes32(0) && args.absolutePrestate == _zkPrestate,
            string.concat(_errorPrefix, "-70"),
            _errors
        );
        _errors = internalRequire(
            args.verifier == sp1PlonkAdapterImpl && sp1PlonkAdapterImpl.code.length > 0,
            string.concat(_errorPrefix, "-80"),
            _errors
        );
        // Durations are capped at uint32 max so that `block.timestamp + duration` cannot overflow
        // the uint64 deadline cast in ZKDisputeGame, which would place the deadline in the past.
        _errors = internalRequire(
            args.maxChallengeDuration > 0 && args.maxChallengeDuration <= type(uint32).max,
            string.concat(_errorPrefix, "-90"),
            _errors
        );
        _errors = internalRequire(
            args.maxProveDuration > 0 && args.maxProveDuration <= type(uint32).max,
            string.concat(_errorPrefix, "-100"),
            _errors
        );
        _errors = internalRequire(args.challengerBond > 0, string.concat(_errorPrefix, "-110"), _errors);
        (Hash anchorRoot,) = IAnchorStateRegistry(args.anchorStateRegistry).getAnchorRoot();
        _errors = internalRequire(Hash.unwrap(anchorRoot) != bytes32(0), string.concat(_errorPrefix, "-120"), _errors);
        _errors = standardValidatorUtils.assertValidDelayedWETH(
            _errors,
            _sysCfg,
            IDelayedWETH(payable(args.weth)),
            _admin,
            expectedL1PAOMultisig(_overrides),
            delayedWETHImpl,
            _errorPrefix
        );
        _errors = standardValidatorUtils.assertValidAnchorStateRegistry(
            _errors,
            _sysCfg,
            factory,
            IAnchorStateRegistry(args.anchorStateRegistry),
            _admin,
            anchorStateRegistryImpl,
            _errorPrefix
        );
        return _errors;
    }

    /// @notice Asserts that the ZKDisputeGame contract registered in the factory is valid.
    function assertValidZKDisputeGame(
        string memory _errors,
        ISystemConfig _sysCfg,
        IProxyAdmin _admin,
        ValidationOverrides memory _overrides,
        bytes32 _zkPrestate
    )
        internal
        view
        returns (string memory)
    {
        // ZK_DISPUTE_GAME is optional; there is nothing to validate when it is not registered.
        // TODO(#21529): once SUPER_CANNON_KONA is removed, drop this early return so chains without a ZK game
        // fail validation.
        IDisputeGameFactory _factory = IDisputeGameFactory(_sysCfg.disputeGameFactory());
        if (address(_factory.gameImpls(GameTypes.ZK_DISPUTE_GAME)) == address(0)) {
            return _errors;
        }

        string memory errorPrefix = "ZKDG";
        DisputeGameImplementation memory gameImpl;
        bool failedToGetImpl;
        (gameImpl, _errors, failedToGetImpl) =
            getGameImplementation(_errors, GameTypes.ZK_DISPUTE_GAME, _sysCfg, errorPrefix);
        if (failedToGetImpl) return _errors;
        _errors = internalRequire(
            LibString.eq(getVersion(gameImpl.gameAddress), getVersion(zkDisputeGameImpl)),
            string.concat(errorPrefix, "-20"),
            _errors
        );
        _errors =
            internalRequire(gameImpl.gameAddress == zkDisputeGameImpl, string.concat(errorPrefix, "-150"), _errors);
        _errors = _assertValidZKGameArgs(_errors, _sysCfg, _admin, _overrides, _zkPrestate, errorPrefix);
        // ZK game creation is permissionless, so a zero init bond leaves root claims free to spam.
        return internalRequire(
            _factory.initBonds(GameTypes.ZK_DISPUTE_GAME) > 0, string.concat(errorPrefix, "-160"), _errors
        );
    }

    /// @notice Internal function to read all information from a dispute game.
    function _decodeDisputeGameImpl(
        IPermissionedDisputeGame _game,
        bytes memory _gameArgsBytes,
        GameType _gameType
    )
        internal
        view
        returns (DisputeGameImplementation memory gameImpl_)
    {
        if (_gameType.raw() == GameTypes.ZK_DISPUTE_GAME.raw()) {
            gameImpl_.gameAddress = address(_game);
            gameImpl_.gameType = _gameType;
            return gameImpl_;
        }

        LibGameArgs.GameArgs memory gameArgs = LibGameArgs.decode(_gameArgsBytes);

        gameImpl_ = DisputeGameImplementation({
            gameAddress: address(_game),
            maxGameDepth: _game.maxGameDepth(),
            splitDepth: _game.splitDepth(),
            maxClockDuration: _game.maxClockDuration(),
            clockExtension: _game.clockExtension(),
            gameType: _gameType,
            l2SequenceNumber: _game.l2SequenceNumber(),
            absolutePrestate: Claim.wrap(gameArgs.absolutePrestate),
            vm: IBigStepper(gameArgs.vm),
            asr: IAnchorStateRegistry(gameArgs.anchorStateRegistry),
            weth: IDelayedWETH(payable(gameArgs.weth)),
            l2ChainId: gameArgs.l2ChainId,
            challenger: gameArgs.challenger,
            proposer: gameArgs.proposer
        });
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "london",
  "remappings": [
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-v5/=lib/openzeppelin-contracts-v5/contracts/",
    "@rari-capital/solmate/=lib/solmate/",
    "@lib-keccak/=lib/lib-keccak/contracts/lib/",
    "@solady/=lib/solady/src/",
    "forge-std/=lib/forge-std/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "safe-contracts/=lib/safe-contracts/contracts/",
    "kontrol-cheatcodes/=lib/kontrol-cheatcodes/src/",
    "interfaces/=interfaces/",
    "lib/lib-keccak/:solady/=lib/lib-keccak/lib/solady/",
    "lib/lib-keccak/:solady/=lib/lib-keccak/lib/solady/",
    "@solady-test/=lib/lib-keccak/lib/solady/test/",
    "erc4626-tests/=lib/openzeppelin-contracts-v5/lib/erc4626-tests/",
    "lib-keccak/=lib/lib-keccak/contracts/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts-v5/=lib/openzeppelin-contracts-v5/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solady/=lib/solady/",
    "solmate/=lib/solmate/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.