Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AnchorStateRegistry: remove blacklist check in getAnchorRoot #14232

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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: 2 additions & 2 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@
"sourceCodeHash": "0xb7b0a06cd971c4647247dc19ce997d0c64a73e87c81d30731da9cf9efa1b952a"
},
"src/dispute/AnchorStateRegistry.sol": {
"initCodeHash": "0x378970d3613b8cf0202cc660afd8b0447988a22c18fdb9e7096a5dedbb389ad8",
"sourceCodeHash": "0x95cd2860ee20ed54615da02f53c87ca836aa15af20e3164ae6ef5a9b9cfd3983"
"initCodeHash": "0xc845f8e6694d43a881c2a65d4bbc35027070945cb8a6fef4d2353ab33f05ba0b",
"sourceCodeHash": "0xc3cd021bf768aab8a2f5c2007688bd9f04cb5857ebb37036d06fcf695c6a120e"
},
"src/dispute/DelayedWETH.sol": {
"initCodeHash": "0xdd0b5e523f3b53563fe0b6e6165fb73605b14910ffa32a7cbed855cdebab47c6",
Expand Down
16 changes: 4 additions & 12 deletions packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
/// be initialized with a more recent starting state which reduces the amount of required offchain computation.
contract AnchorStateRegistry is Initializable, ISemver {
/// @notice Semantic version.
/// @custom:semver 2.2.0
string public constant version = "2.2.0";
/// @custom:semver 2.2.1
string public constant version = "2.2.1";

/// @notice Address of the SuperchainConfig contract.
ISuperchainConfig public superchainConfig;
Expand Down Expand Up @@ -106,10 +106,6 @@ contract AnchorStateRegistry is Initializable, ISemver {
return (startingAnchorRoot.root, startingAnchorRoot.l2BlockNumber);
}

if (isGameBlacklisted(anchorGame)) {
smartcontracts marked this conversation as resolved.
Show resolved Hide resolved
revert AnchorStateRegistry_AnchorGameBlacklisted();
}

// Otherwise, return the anchor root.
return (Hash.wrap(anchorGame.rootClaim().raw()), anchorGame.l2BlockNumber());
}
Expand Down Expand Up @@ -257,16 +253,12 @@ contract AnchorStateRegistry is Initializable, ISemver {
// version of IDisputeGame in the future.
IFaultDisputeGame game = IFaultDisputeGame(address(_game));

// Check if the candidate game is valid.
bool valid = isGameClaimValid(game);
if (!valid) {
// Check if the candidate game claim is valid.
if (!isGameClaimValid(game)) {
revert AnchorStateRegistry_InvalidAnchorGame();
}
smartcontracts marked this conversation as resolved.
Show resolved Hide resolved

// Must be newer than the current anchor game.
// Note that this WILL block/brick if getAnchorRoot() ever reverts because the current
// anchor game is blacklisted. A blacklisted anchor game is *very* bad and we deliberately
// want to force the situation to be handled manually.
(, uint256 anchorL2BlockNumber) = getAnchorRoot();
if (game.l2BlockNumber() <= anchorL2BlockNumber) {
revert AnchorStateRegistry_InvalidAnchorGame();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ contract AnchorStateRegistry_GetAnchorRoot_Test is AnchorStateRegistry_Init {
assertEq(root.raw(), gameProxy.rootClaim().raw());
assertEq(l2BlockNumber, gameProxy.l2BlockNumber());
}
}

contract AnchorStateRegistry_GetAnchorRoot_TestFail is AnchorStateRegistry_Init {
/// @notice Tests that getAnchorRoot will revert if the anchor game is blacklisted.
function test_getAnchorRoot_blacklistedGame_fails() public {
/// @notice Tests that getAnchorRoot returns even if the anchor game is blacklisted.
function test_getAnchorRoot_blacklistedGame_succeeds() public {
// Mock the game to be resolved.
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.resolvedAt, ()), abi.encode(block.timestamp));
vm.warp(block.timestamp + optimismPortal2.disputeGameFinalityDelaySeconds() + 1);
Expand All @@ -116,8 +114,11 @@ contract AnchorStateRegistry_GetAnchorRoot_TestFail is AnchorStateRegistry_Init
abi.encodeCall(optimismPortal2.disputeGameBlacklist, (gameProxy)),
abi.encode(true)
);
vm.expectRevert(IAnchorStateRegistry.AnchorStateRegistry_AnchorGameBlacklisted.selector);
anchorStateRegistry.getAnchorRoot();

// Get the anchor root.
(Hash root, uint256 l2BlockNumber) = anchorStateRegistry.getAnchorRoot();
assertEq(root.raw(), gameProxy.rootClaim().raw());
assertEq(l2BlockNumber, gameProxy.l2BlockNumber());
}
}

Expand Down