ethereum-optimism / ethereum-optimism/optimism

DisputeGameFactory: Find gameIndex that updated AnchorStateRegistry

Open
#11,269 4 comments 0 reactions 0 assignees View on GitHub
T-proofs
Dominant language
Go
Stars
6.5k
Forks
4k
Avg merge
2d 38m
Merged PRs (30d)
164

Description

**Is your feature request related to a problem? Please describe.**

* I'd like to be able to figure out the `gameIndex` of the latest anchor before some time bound.
* Currently, this requires a lot of RPC calls.
* This is useful for finding the latest finalized `rootClaim` that's visible across the network.

**Describe the solution you'd like**

This is just an sketch:

```Solidity
// DisputeGameFactory.sol
function findLatestVisibleDefendedGameIndexPlusOne(
GameType gt, // typically DisputeGameFactory.respectedGameType()
uint64 t1 // latest timestamp to consider
) external view returns (uint256) {
i = _disputeGameList.length;
while (i > 0) {
GameId id = _disputeGameList[--i];
(GameType gameType, , address proxy) = id.unpack();
if (gameType.raw() != gt.raw()) continue; // wrong type
if (IDisputeGame(proxy).status() != GameStatus.DEFENDER_WINS) continue; // not resolved
if (IDisputeGame(proxy).resolvedAt().raw() > t1) continue; // not visible
return i + 1;
}
// 0 = not found
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.