@@ -6,8 +6,6 @@ import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable
66
77// Libraries
88import { GameType, OutputRoot, Claim, GameStatus, Hash } from "src/dispute/lib/Types.sol " ;
9- import { Unauthorized } from "src/libraries/errors/CommonErrors.sol " ;
10- import { InvalidAnchorGame } from "src/dispute/lib/Errors.sol " ;
119
1210// Interfaces
1311import { ISemver } from "interfaces/universal/ISemver.sol " ;
@@ -44,11 +42,22 @@ contract AnchorStateRegistry is Initializable, ISemver {
4442 OutputRoot internal startingAnchorRoot;
4543
4644 /// @notice Emitted when an anchor state is not updated.
47- event AnchorNotUpdated (IFaultDisputeGame indexed game , string reason );
45+ /// @param game Game that was not used as the new anchor game.
46+ event AnchorNotUpdated (IFaultDisputeGame indexed game );
4847
4948 /// @notice Emitted when an anchor state is updated.
49+ /// @param game Game that was used as the new anchor game.
5050 event AnchorUpdated (IFaultDisputeGame indexed game );
5151
52+ /// @notice Thrown when an unauthorized caller attempts to set the anchor state.
53+ error AnchorStateRegistry_Unauthorized ();
54+
55+ /// @notice Thrown when an improper anchor game is provided.
56+ error AnchorStateRegistry_ImproperAnchorGame ();
57+
58+ /// @notice Thrown when an invalid anchor game is provided.
59+ error AnchorStateRegistry_InvalidAnchorGame ();
60+
5261 /// @notice Constructor to disable initializers.
5362 constructor () {
5463 _disableInitializers ();
@@ -138,28 +147,28 @@ contract AnchorStateRegistry is Initializable, ISemver {
138147 /// DO NOT USE THIS FUNCTION ALONE TO DETERMINE IF A ROOT CLAIM IS VALID.
139148 /// @param _game The game to check.
140149 /// @return Whether the game is a proper game.
141- /// @return Reason why the game is not a proper game.
142- function isGameProper (IDisputeGame _game ) public view returns ( bool , string memory ) {
150+ function isGameProper (IDisputeGame _game ) public view returns ( bool ) {
151+ // Must be registered in the DisputeGameFactory.
143152 if (! isGameRegistered (_game)) {
144- return ( false , " game not factory registered " ) ;
153+ return false ;
145154 }
146155
147156 // Must be respected game type.
148157 if (! isGameRespected (_game)) {
149- return ( false , " game type not respected " ) ;
158+ return false ;
150159 }
151160
152161 // Must not be blacklisted.
153162 if (isGameBlacklisted (_game)) {
154- return ( false , " game blacklisted " ) ;
163+ return false ;
155164 }
156165
157166 // Must be created at or after the respectedGameTypeUpdatedAt timestamp.
158167 if (isGameRetired (_game)) {
159- return ( false , " game retired " ) ;
168+ return false ;
160169 }
161170
162- return ( true , "" ) ;
171+ return true ;
163172 }
164173
165174 /// @notice Callable by FaultDisputeGame contracts to update the anchor state. Pulls the anchor state directly from
@@ -170,22 +179,21 @@ contract AnchorStateRegistry is Initializable, ISemver {
170179 IFaultDisputeGame game = IFaultDisputeGame (msg .sender );
171180
172181 // Check if the game is a proper game.
173- (bool isProper , string memory reason ) = isGameProper (game);
174- if (! isProper) {
175- emit AnchorNotUpdated (game, reason);
182+ if (! isGameProper (game)) {
183+ emit AnchorNotUpdated (game);
176184 return ;
177185 }
178186
179187 // Must be a game that resolved in favor of the state.
180188 if (game.status () != GameStatus.DEFENDER_WINS) {
181- emit AnchorNotUpdated (game, " game not defender wins " );
189+ emit AnchorNotUpdated (game);
182190 return ;
183191 }
184192
185193 // No need to update anything if the anchor state is already newer.
186194 (, uint256 anchorL2BlockNumber ) = getAnchorRoot ();
187195 if (game.l2BlockNumber () <= anchorL2BlockNumber) {
188- emit AnchorNotUpdated (game, " game not newer than anchor state " );
196+ emit AnchorNotUpdated (game);
189197 return ;
190198 }
191199
@@ -197,17 +205,19 @@ contract AnchorStateRegistry is Initializable, ISemver {
197205 /// @notice Sets the anchor state given the game.
198206 /// @param _game The game to set the anchor state for.
199207 function setAnchorState (IFaultDisputeGame _game ) external {
200- if (msg .sender != superchainConfig.guardian ()) revert Unauthorized ();
208+ // Function can only be triggered by the guardian.
209+ if (msg .sender != superchainConfig.guardian ()) {
210+ revert AnchorStateRegistry_Unauthorized ();
211+ }
201212
202213 // Check if the game is a proper game.
203- (bool isProper , string memory reason ) = isGameProper (_game);
204- if (! isProper) {
205- revert InvalidAnchorGame (reason);
214+ if (! isGameProper (_game)) {
215+ revert AnchorStateRegistry_ImproperAnchorGame ();
206216 }
207217
208218 // The game must have resolved in favor of the root claim.
209219 if (_game.status () != GameStatus.DEFENDER_WINS) {
210- revert InvalidAnchorGame ( " game not defender wins " );
220+ revert AnchorStateRegistry_InvalidAnchorGame ( );
211221 }
212222
213223 // Update the anchor game.
0 commit comments