Commit 78f40a3e authored by refcell's avatar refcell Committed by GitHub

feat(op-dispute-mon): GetWithdrawals GameCaller Method (#9939)

* feat(op-challenger): Delayed Weth Withdrawal Request Caller

* fix(op-challenger): withdrawal request field ordering

* fix(op-challenger): encapsulate delayed weth behind the fault dispute game contract binding

* feat(op-dispute-mon): get withdrawals game caller method

* fix(op-dispute-mon): revert service name changes

* fix(op-dispute-mon): revert extractor test name

* fix(op-dispute-mon): revert extractor changes

* fix(op-dispute-mon): revert newline add

* fix(op-dispute-mon): revert caller field reordering

* fix(op-challenger): make contract method private
parent 873bc000
...@@ -231,7 +231,16 @@ func (f *FaultDisputeGameContract) addGlobalDataTx(ctx context.Context, data *ty ...@@ -231,7 +231,16 @@ func (f *FaultDisputeGameContract) addGlobalDataTx(ctx context.Context, data *ty
return oracle.AddGlobalDataTx(data) 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")() defer f.metrics.StartContractRequest("GetDelayedWETH")()
result, err := f.multiCaller.SingleCall(ctx, rpcblock.Latest, f.contract.Call(methodWETH)) result, err := f.multiCaller.SingleCall(ctx, rpcblock.Latest, f.contract.Call(methodWETH))
if err != nil { if err != nil {
......
...@@ -22,7 +22,9 @@ type GameCallerMetrics interface { ...@@ -22,7 +22,9 @@ type GameCallerMetrics interface {
caching.Metrics caching.Metrics
contractMetrics.ContractMetricer contractMetrics.ContractMetricer
} }
type GameCaller interface { 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) GetGameMetadata(context.Context, rpcblock.Block) (common.Hash, uint64, common.Hash, gameTypes.GameStatus, uint64, error)
GetAllClaims(context.Context, rpcblock.Block) ([]faultTypes.Claim, error) GetAllClaims(context.Context, rpcblock.Block) ([]faultTypes.Claim, error)
BondCaller BondCaller
......
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"math/big" "math/big"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
monTypes "github.com/ethereum-optimism/optimism/op-dispute-mon/mon/types" monTypes "github.com/ethereum-optimism/optimism/op-dispute-mon/mon/types"
"github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock" "github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
...@@ -189,6 +190,21 @@ type mockGameCaller struct { ...@@ -189,6 +190,21 @@ type mockGameCaller struct {
balanceErr error balanceErr error
balance *big.Int balance *big.Int
balanceAddr common.Address 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) { func (m *mockGameCaller) GetGameMetadata(_ context.Context, _ rpcblock.Block) (common.Hash, uint64, common.Hash, types.GameStatus, uint64, error) {
......
...@@ -3,6 +3,7 @@ package types ...@@ -3,6 +3,7 @@ package types
import ( import (
"math/big" "math/big"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
faultTypes "github.com/ethereum-optimism/optimism/op-challenger/game/fault/types" faultTypes "github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger/game/types" "github.com/ethereum-optimism/optimism/op-challenger/game/types"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -27,6 +28,9 @@ type EnrichedGameData struct { ...@@ -27,6 +28,9 @@ type EnrichedGameData struct {
// Credits records the paid out bonds for the game, keyed by recipient. // Credits records the paid out bonds for the game, keyed by recipient.
Credits map[common.Address]*big.Int 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 // WETHContract is the address of the DelayedWETH contract used by this game
// The contract is potentially shared by multiple games. // The contract is potentially shared by multiple games.
WETHContract common.Address WETHContract common.Address
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment