Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions packages/contracts-bedrock/scripts/DevnetAddTeeGame.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ contract DevnetAddTeeGame is Script {
IDisputeGameFactory(cfg.existingDgf),
ITeeProofVerifier(verifier),
cfg.challengerBond,
IAnchorStateRegistry(tzAsr),
cfg.proposer,
cfg.challenger
IAnchorStateRegistry(tzAsr)
)
);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts-bedrock/src/dispute/tee/TeeDisputeGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ contract TeeDisputeGame is Clone, ISemver, IDisputeGame {
return startingOutputRoot.root;
}

function rootClaimByChainId(uint256) public pure returns (Claim rootClaim_) {
rootClaim_ = rootClaim();
}

function extraData() public pure returns (bytes memory extraData_) {
extraData_ = _getArgBytes(0x54, 0x64);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ contract AnchorStateRegistryCompatibilityTest is TeeTestUtils {
);
anchorStateRegistry = IAnchorStateRegistry(address(anchorStateRegistryProxy));

teeProofVerifier.setAllowedProposer(proposer, true);
teeProofVerifier.setAllowedChallenger(challenger, true);

implementation = new TeeDisputeGame(
Duration.wrap(MAX_CHALLENGE_DURATION),
Duration.wrap(MAX_PROVE_DURATION),
IDisputeGameFactory(address(factory)),
ITeeProofVerifier(address(teeProofVerifier)),
CHALLENGER_BOND,
anchorStateRegistry,
proposer,
challenger
anchorStateRegistry
);

factory.setImplementation(GameType.wrap(TEE_DISPUTE_GAME_TYPE), implementation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ contract TeeDisputeGameTest is TeeTestUtils {
anchorStateRegistry = new MockAnchorStateRegistry();
teeProofVerifier = new MockTeeProofVerifier();

teeProofVerifier.setAllowedProposer(proposer, true);
teeProofVerifier.setAllowedChallenger(challenger, true);

implementation = new TeeDisputeGame(
Duration.wrap(MAX_CHALLENGE_DURATION),
Duration.wrap(MAX_PROVE_DURATION),
IDisputeGameFactory(address(factory)),
ITeeProofVerifier(address(teeProofVerifier)),
CHALLENGER_BOND,
IAnchorStateRegistry(address(anchorStateRegistry)),
proposer,
challenger
IAnchorStateRegistry(address(anchorStateRegistry))
);

factory.setImplementation(GameType.wrap(TEE_DISPUTE_GAME_TYPE), implementation);
Expand All @@ -80,7 +81,6 @@ contract TeeDisputeGameTest is TeeTestUtils {
(Hash startingRoot, uint256 startingBlockNumber) = game.startingOutputRoot();
assertEq(startingRoot.raw(), computeRootClaim(ANCHOR_BLOCK_HASH, ANCHOR_STATE_HASH).raw());
assertEq(startingBlockNumber, ANCHOR_L2_BLOCK);
assertEq(game.PROPOSER(), proposer);
assertEq(game.refundModeCredit(proposer), DEFENDER_BOND);
assertTrue(game.wasRespectedGameTypeWhenCreated());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@ contract TeeDisputeGameIntegrationTest is TeeTestUtils {
// --- Deploy real TeeProofVerifier (with MockRiscZeroVerifier) ---
teeProofVerifier = _deployTeeProofVerifier();

// --- Register proposer/challenger in the whitelist ---
teeProofVerifier.addProposer(proposer);
teeProofVerifier.addChallenger(challenger);

// --- Deploy TeeDisputeGame implementation ---
implementation = new TeeDisputeGame(
Duration.wrap(MAX_CHALLENGE_DURATION),
Duration.wrap(MAX_PROVE_DURATION),
IDisputeGameFactory(address(factory)),
ITeeProofVerifier(address(teeProofVerifier)),
CHALLENGER_BOND,
IAnchorStateRegistry(address(anchorStateRegistry)),
proposer,
challenger
IAnchorStateRegistry(address(anchorStateRegistry))
);

factory.setImplementation(TEE_GAME_TYPE, IDisputeGame(address(implementation)), bytes(""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,16 @@ contract TeeDisputeGameInvariantTest is TeeTestUtils {
anchorStateRegistry = new MockAnchorStateRegistry();
teeProofVerifier = new MockTeeProofVerifier();

teeProofVerifier.setAllowedProposer(proposer, true);
teeProofVerifier.setAllowedChallenger(challenger, true);

implementation = new TeeDisputeGame(
Duration.wrap(MAX_CHALLENGE_DURATION),
Duration.wrap(MAX_PROVE_DURATION),
IDisputeGameFactory(address(factory)),
ITeeProofVerifier(address(teeProofVerifier)),
CHALLENGER_BOND,
IAnchorStateRegistry(address(anchorStateRegistry)),
proposer,
challenger
IAnchorStateRegistry(address(anchorStateRegistry))
);

factory.setImplementation(GameType.wrap(TEE_DISPUTE_GAME_TYPE), implementation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.15;
import {IAnchorStateRegistry} from "interfaces/dispute/IAnchorStateRegistry.sol";
import {IDisputeGameFactory} from "interfaces/dispute/IDisputeGameFactory.sol";
import {IDisputeGame} from "interfaces/dispute/IDisputeGame.sol";
import {IFaultDisputeGame} from "interfaces/dispute/IFaultDisputeGame.sol";
import {ISystemConfig} from "interfaces/L1/ISystemConfig.sol";
import {ISuperchainConfig} from "interfaces/L1/ISuperchainConfig.sol";
import {IProxyAdmin} from "interfaces/universal/IProxyAdmin.sol";
Expand All @@ -24,7 +23,7 @@ contract MockAnchorStateRegistry is IAnchorStateRegistry {
uint8 public initVersion = 1;
ISystemConfig public systemConfig;
IDisputeGameFactory public disputeGameFactory;
IFaultDisputeGame public anchorGame;
IDisputeGame public anchorGame;
Proposal internal anchorRoot;
mapping(IDisputeGame => bool) public disputeGameBlacklist;
mapping(address => Flags) internal flags;
Expand Down Expand Up @@ -135,10 +134,14 @@ contract MockAnchorStateRegistry is IAnchorStateRegistry {

function setAnchorState(IDisputeGame game) external {
if (revertOnSetAnchorState) revert AnchorStateRegistry_InvalidAnchorGame();
anchorGame = IFaultDisputeGame(address(game));
anchorGame = game;
lastSetAnchorState = game;
}

function getStartingAnchorRoot() external view returns (Proposal memory) {
return anchorRoot;
}

function getAnchorRoot() external view returns (Hash, uint256) {
return (anchorRoot.root, anchorRoot.l2SequenceNumber);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ contract MockTeeProofVerifier is ITeeProofVerifier {
error InvalidSignature();

mapping(address => bool) public registered;
mapping(address => bool) public allowedProposers;
mapping(address => bool) public allowedChallengers;
bytes32 public lastDigest;
bytes public lastSignature;

function setRegistered(address enclave, bool value) external {
registered[enclave] = value;
}

function setAllowedProposer(address proposer, bool value) external {
allowedProposers[proposer] = value;
}

function setAllowedChallenger(address challenger, bool value) external {
allowedChallengers[challenger] = value;
}

function verifyBatch(bytes32 digest, bytes calldata signature) external view returns (address signer) {
(address recovered, ECDSA.RecoverError err) = ECDSA.tryRecover(digest, signature);
if (err != ECDSA.RecoverError.NoError || recovered == address(0)) revert InvalidSignature();
Expand Down