diff --git a/op-challenger/game/fault/contracts/faultdisputegame.go b/op-challenger/game/fault/contracts/faultdisputegame.go index b1f82da5e898..c0e371950f52 100644 --- a/op-challenger/game/fault/contracts/faultdisputegame.go +++ b/op-challenger/game/fault/contracts/faultdisputegame.go @@ -231,7 +231,16 @@ func (f *FaultDisputeGameContract) addGlobalDataTx(ctx context.Context, data *ty return oracle.AddGlobalDataTx(data) } -func (f *FaultDisputeGameContract) GetDelayedWETH(ctx context.Context) (*DelayedWETHContract, error) { +func (f *FaultDisputeGameContract) GetWithdrawals(ctx context.Context, block rpcblock.Block, gameAddr common.Address, recipients ...common.Address) ([]*WithdrawalRequest, error) { + defer f.metrics.StartContractRequest("GetWithdrawals")() + delayedWETH, err := f.getDelayedWETH(ctx) + if err != nil { + return nil, err + } + return delayedWETH.GetWithdrawals(ctx, block, gameAddr, recipients...) +} + +func (f *FaultDisputeGameContract) getDelayedWETH(ctx context.Context) (*DelayedWETHContract, error) { defer f.metrics.StartContractRequest("GetDelayedWETH")() result, err := f.multiCaller.SingleCall(ctx, rpcblock.Latest, f.contract.Call(methodWETH)) if err != nil { diff --git a/op-dispute-mon/mon/extract/caller.go b/op-dispute-mon/mon/extract/caller.go index 000e30a543fb..ab38bf50466e 100644 --- a/op-dispute-mon/mon/extract/caller.go +++ b/op-dispute-mon/mon/extract/caller.go @@ -22,7 +22,9 @@ type GameCallerMetrics interface { caching.Metrics contractMetrics.ContractMetricer } + type GameCaller interface { + GetWithdrawals(context.Context, rpcblock.Block, common.Address, ...common.Address) ([]*contracts.WithdrawalRequest, error) GetGameMetadata(context.Context, rpcblock.Block) (common.Hash, uint64, common.Hash, gameTypes.GameStatus, uint64, error) GetAllClaims(context.Context, rpcblock.Block) ([]faultTypes.Claim, error) BondCaller diff --git a/op-dispute-mon/mon/extract/extractor_test.go b/op-dispute-mon/mon/extract/extractor_test.go index 83264baa4b9e..2a0a3274721f 100644 --- a/op-dispute-mon/mon/extract/extractor_test.go +++ b/op-dispute-mon/mon/extract/extractor_test.go @@ -6,6 +6,7 @@ import ( "math/big" "testing" + "github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts" monTypes "github.com/ethereum-optimism/optimism/op-dispute-mon/mon/types" "github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock" "github.com/stretchr/testify/require" @@ -189,6 +190,21 @@ type mockGameCaller struct { balanceErr error balance *big.Int balanceAddr common.Address + withdrawalsCalls int + withdrawalsErr error +} + +func (m *mockGameCaller) GetWithdrawals(_ context.Context, _ rpcblock.Block, _ common.Address, _ ...common.Address) ([]*contracts.WithdrawalRequest, error) { + m.withdrawalsCalls++ + if m.withdrawalsErr != nil { + return nil, m.withdrawalsErr + } + return []*contracts.WithdrawalRequest{ + { + Timestamp: big.NewInt(1), + Amount: big.NewInt(2), + }, + }, nil } func (m *mockGameCaller) GetGameMetadata(_ context.Context, _ rpcblock.Block) (common.Hash, uint64, common.Hash, types.GameStatus, uint64, error) { diff --git a/op-dispute-mon/mon/types/types.go b/op-dispute-mon/mon/types/types.go index c97376f108ad..605c7d5f24c5 100644 --- a/op-dispute-mon/mon/types/types.go +++ b/op-dispute-mon/mon/types/types.go @@ -3,6 +3,7 @@ package types import ( "math/big" + "github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts" faultTypes "github.com/ethereum-optimism/optimism/op-challenger/game/fault/types" "github.com/ethereum-optimism/optimism/op-challenger/game/types" "github.com/ethereum/go-ethereum/common" @@ -27,6 +28,9 @@ type EnrichedGameData struct { // Credits records the paid out bonds for the game, keyed by recipient. Credits map[common.Address]*big.Int + // WithdrawalRequests maps recipients with withdrawal requests in DelayedWETH for this game. + WithdrawalRequests map[common.Address]*contracts.WithdrawalRequest + // WETHContract is the address of the DelayedWETH contract used by this game // The contract is potentially shared by multiple games. WETHContract common.Address