diff --git a/op-challenger/cmd/create_game.go b/op-challenger/cmd/create_game.go index 4a7e6493a7a7..a41e78e5bb22 100644 --- a/op-challenger/cmd/create_game.go +++ b/op-challenger/cmd/create_game.go @@ -76,6 +76,6 @@ var CreateGameCommand = &cli.Command{ Name: "create-game", Usage: "Creates a dispute game via the factory", Description: "Creates a dispute game via the factory", - Action: CreateGame, + Action: Interruptible(CreateGame), Flags: createGameFlags(), } diff --git a/op-challenger/cmd/credits.go b/op-challenger/cmd/credits.go index 19b650e669a7..6c9aa3e5b914 100644 --- a/op-challenger/cmd/credits.go +++ b/op-challenger/cmd/credits.go @@ -112,6 +112,6 @@ var ListCreditsCommand = &cli.Command{ Name: "list-credits", Usage: "List the credits in a dispute game", Description: "Lists the credits in a dispute game", - Action: ListCredits, + Action: Interruptible(ListCredits), Flags: listCreditsFlags(), } diff --git a/op-challenger/cmd/list_claims.go b/op-challenger/cmd/list_claims.go index 26a09a47cd02..440db293f588 100644 --- a/op-challenger/cmd/list_claims.go +++ b/op-challenger/cmd/list_claims.go @@ -198,6 +198,6 @@ var ListClaimsCommand = &cli.Command{ Name: "list-claims", Usage: "List the claims in a dispute game", Description: "Lists the claims in a dispute game", - Action: ListClaims, + Action: Interruptible(ListClaims), Flags: listClaimsFlags(), } diff --git a/op-challenger/cmd/list_games.go b/op-challenger/cmd/list_games.go index 330474dbd9c6..0e0ce1880a8e 100644 --- a/op-challenger/cmd/list_games.go +++ b/op-challenger/cmd/list_games.go @@ -183,6 +183,6 @@ var ListGamesCommand = &cli.Command{ Name: "list-games", Usage: "List the games created by a dispute game factory", Description: "Lists the games created by a dispute game factory", - Action: ListGames, + Action: Interruptible(ListGames), Flags: listGamesFlags(), } diff --git a/op-challenger/cmd/move.go b/op-challenger/cmd/move.go index fb6a417fc360..3bc80ae1882a 100644 --- a/op-challenger/cmd/move.go +++ b/op-challenger/cmd/move.go @@ -97,6 +97,6 @@ var MoveCommand = &cli.Command{ Name: "move", Usage: "Creates and sends a move transaction to the dispute game", Description: "Creates and sends a move transaction to the dispute game", - Action: Move, + Action: Interruptible(Move), Flags: moveFlags(), } diff --git a/op-challenger/cmd/resolve.go b/op-challenger/cmd/resolve.go index 8489edbe9004..1e4ac214dfc6 100644 --- a/op-challenger/cmd/resolve.go +++ b/op-challenger/cmd/resolve.go @@ -46,6 +46,6 @@ var ResolveCommand = &cli.Command{ Name: "resolve", Usage: "Resolves the specified dispute game if possible", Description: "Resolves the specified dispute game if possible", - Action: Resolve, + Action: Interruptible(Resolve), Flags: resolveFlags(), } diff --git a/op-challenger/cmd/resolve_claim.go b/op-challenger/cmd/resolve_claim.go index f4079f121709..7e564123073d 100644 --- a/op-challenger/cmd/resolve_claim.go +++ b/op-challenger/cmd/resolve_claim.go @@ -66,6 +66,6 @@ var ResolveClaimCommand = &cli.Command{ Name: "resolve-claim", Usage: "Resolves the specified claim if possible", Description: "Resolves the specified claim if possible", - Action: ResolveClaim, + Action: Interruptible(ResolveClaim), Flags: resolveClaimFlags(), } diff --git a/op-challenger/cmd/utils.go b/op-challenger/cmd/utils.go index a62ffa44df30..110f1dddd641 100644 --- a/op-challenger/cmd/utils.go +++ b/op-challenger/cmd/utils.go @@ -8,6 +8,7 @@ import ( contractMetrics "github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts/metrics" opservice "github.com/ethereum-optimism/optimism/op-service" "github.com/ethereum-optimism/optimism/op-service/dial" + "github.com/ethereum-optimism/optimism/op-service/opio" "github.com/ethereum-optimism/optimism/op-service/sources/batching" "github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum-optimism/optimism/op-service/txmgr/metrics" @@ -17,6 +18,12 @@ import ( type ContractCreator[T any] func(context.Context, contractMetrics.ContractMetricer, common.Address, *batching.MultiCaller) (T, error) +func Interruptible(action cli.ActionFunc) cli.ActionFunc { + return func(ctx *cli.Context) error { + ctx.Context = opio.CancelOnInterrupt(ctx.Context) + return action(ctx) + } +} func AddrFromFlag(flagName string) func(ctx *cli.Context) (common.Address, error) { return func(ctx *cli.Context) (common.Address, error) { gameAddr, err := opservice.ParseAddress(ctx.String(flagName))