Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
5669b83f
Commit
5669b83f
authored
Aug 24, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deletes the redundant fault dispute game caller component.
parent
aac273a9
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
212 additions
and
298 deletions
+212
-298
agent.go
op-challenger/fault/agent.go
+6
-2
caller.go
op-challenger/fault/caller.go
+0
-54
caller_test.go
op-challenger/fault/caller_test.go
+0
-108
factory_test.go
op-challenger/fault/factory_test.go
+5
-2
loader.go
op-challenger/fault/loader.go
+28
-7
loader_test.go
op-challenger/fault/loader_test.go
+163
-113
player.go
op-challenger/fault/player.go
+4
-9
player_test.go
op-challenger/fault/player_test.go
+1
-1
service.go
op-challenger/fault/service.go
+5
-2
No files found.
op-challenger/fault/agent.go
View file @
5669b83f
...
...
@@ -19,9 +19,13 @@ type Responder interface {
Step
(
ctx
context
.
Context
,
stepData
types
.
StepCallData
)
error
}
type
ClaimLoader
interface
{
FetchClaims
(
ctx
context
.
Context
)
([]
types
.
Claim
,
error
)
}
type
Agent
struct
{
solver
*
solver
.
Solver
loader
Loader
loader
Claim
Loader
responder
Responder
updater
types
.
OracleUpdater
maxDepth
int
...
...
@@ -29,7 +33,7 @@ type Agent struct {
log
log
.
Logger
}
func
NewAgent
(
loader
Loader
,
maxDepth
int
,
trace
types
.
TraceProvider
,
responder
Responder
,
updater
types
.
OracleUpdater
,
agreeWithProposedOutput
bool
,
log
log
.
Logger
)
*
Agent
{
func
NewAgent
(
loader
Claim
Loader
,
maxDepth
int
,
trace
types
.
TraceProvider
,
responder
Responder
,
updater
types
.
OracleUpdater
,
agreeWithProposedOutput
bool
,
log
log
.
Logger
)
*
Agent
{
return
&
Agent
{
solver
:
solver
.
NewSolver
(
maxDepth
,
trace
),
loader
:
loader
,
...
...
op-challenger/fault/caller.go
deleted
100644 → 0
View file @
aac273a9
package
fault
import
(
"context"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
)
type
FaultDisputeGameCaller
interface
{
Status
(
opts
*
bind
.
CallOpts
)
(
uint8
,
error
)
ClaimDataLen
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
}
type
FaultCaller
struct
{
contract
FaultDisputeGameCaller
}
func
NewFaultCaller
(
caller
FaultDisputeGameCaller
)
*
FaultCaller
{
return
&
FaultCaller
{
caller
,
}
}
func
NewFaultCallerFromBindings
(
fdgAddr
common
.
Address
,
client
bind
.
ContractCaller
)
(
*
FaultCaller
,
error
)
{
caller
,
err
:=
bindings
.
NewFaultDisputeGameCaller
(
fdgAddr
,
client
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
FaultCaller
{
caller
,
},
nil
}
// GetGameStatus returns the current game status.
// 0: In Progress
// 1: Challenger Won
// 2: Defender Won
func
(
fc
*
FaultCaller
)
GetGameStatus
(
ctx
context
.
Context
)
(
types
.
GameStatus
,
error
)
{
status
,
err
:=
fc
.
contract
.
Status
(
&
bind
.
CallOpts
{
Context
:
ctx
})
return
types
.
GameStatus
(
status
),
err
}
// GetClaimCount returns the number of claims in the game.
func
(
fc
*
FaultCaller
)
GetClaimCount
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
count
,
err
:=
fc
.
contract
.
ClaimDataLen
(
&
bind
.
CallOpts
{
Context
:
ctx
})
if
err
!=
nil
{
return
0
,
err
}
return
count
.
Uint64
(),
nil
}
op-challenger/fault/caller_test.go
deleted
100644 → 0
View file @
aac273a9
package
fault
import
(
"context"
"errors"
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/stretchr/testify/require"
)
var
(
errMock
=
errors
.
New
(
"mock error"
)
)
type
mockFaultDisputeGameCaller
struct
{
status
uint8
errStatus
bool
claimDataLen
*
big
.
Int
errClaimDataLen
bool
}
func
(
m
*
mockFaultDisputeGameCaller
)
Status
(
opts
*
bind
.
CallOpts
)
(
uint8
,
error
)
{
if
m
.
errStatus
{
return
0
,
errMock
}
return
m
.
status
,
nil
}
func
(
m
*
mockFaultDisputeGameCaller
)
ClaimDataLen
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
{
if
m
.
errClaimDataLen
{
return
nil
,
errMock
}
return
m
.
claimDataLen
,
nil
}
func
TestFaultCaller_GetGameStatus
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
caller
FaultDisputeGameCaller
expectedStatus
types
.
GameStatus
expectedErr
error
}{
{
name
:
"success"
,
caller
:
&
mockFaultDisputeGameCaller
{
status
:
1
,
},
expectedStatus
:
types
.
GameStatusChallengerWon
,
expectedErr
:
nil
,
},
{
name
:
"error"
,
caller
:
&
mockFaultDisputeGameCaller
{
errStatus
:
true
,
},
expectedStatus
:
0
,
expectedErr
:
errMock
,
},
}
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
fc
:=
NewFaultCaller
(
test
.
caller
)
status
,
err
:=
fc
.
GetGameStatus
(
context
.
Background
())
require
.
Equal
(
t
,
test
.
expectedStatus
,
status
)
require
.
Equal
(
t
,
test
.
expectedErr
,
err
)
})
}
}
func
TestFaultCaller_GetClaimCount
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
caller
FaultDisputeGameCaller
expectedClaimDataLen
uint64
expectedErr
error
}{
{
name
:
"success"
,
caller
:
&
mockFaultDisputeGameCaller
{
claimDataLen
:
big
.
NewInt
(
1
),
},
expectedClaimDataLen
:
1
,
expectedErr
:
nil
,
},
{
name
:
"error"
,
caller
:
&
mockFaultDisputeGameCaller
{
errClaimDataLen
:
true
,
},
expectedClaimDataLen
:
0
,
expectedErr
:
errMock
,
},
}
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
fc
:=
NewFaultCaller
(
test
.
caller
)
claimDataLen
,
err
:=
fc
.
GetClaimCount
(
context
.
Background
())
require
.
Equal
(
t
,
test
.
expectedClaimDataLen
,
claimDataLen
)
require
.
Equal
(
t
,
test
.
expectedErr
,
err
)
})
}
}
op-challenger/fault/factory_test.go
View file @
5669b83f
...
...
@@ -6,10 +6,10 @@ import (
"math/big"
"testing"
"github.com/ethereum
/go-ethereum/accounts/abi/bind
"
"github.com/ethereum
-optimism/optimism/op-challenger/fault/types
"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)
...
...
@@ -144,6 +144,9 @@ func newMockMinimalDisputeGameFactoryCaller(count uint64, gameCountErr bool, ind
games
:
generateMockGames
(
count
),
}
}
func
(
m
*
mockMinimalDisputeGameFactoryCaller
)
Status
(
opts
*
bind
.
CallOpts
)
(
uint8
,
error
)
{
return
uint8
(
types
.
GameStatusInProgress
),
nil
}
func
(
m
*
mockMinimalDisputeGameFactoryCaller
)
GameCount
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
{
if
m
.
gameCountErr
{
...
...
op-challenger/fault/loader.go
View file @
5669b83f
...
...
@@ -4,8 +4,11 @@ import (
"context"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
)
// MinimalFaultDisputeGameCaller is a minimal interface around [bindings.FaultDisputeGameCaller].
...
...
@@ -18,18 +21,12 @@ type MinimalFaultDisputeGameCaller interface {
Position
*
big
.
Int
Clock
*
big
.
Int
},
error
)
Status
(
opts
*
bind
.
CallOpts
)
(
uint8
,
error
)
ClaimDataLen
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
MAXGAMEDEPTH
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
ABSOLUTEPRESTATE
(
opts
*
bind
.
CallOpts
)
([
32
]
byte
,
error
)
}
// Loader is a minimal interface for loading onchain [Claim] data.
type
Loader
interface
{
FetchClaims
(
ctx
context
.
Context
)
([]
types
.
Claim
,
error
)
FetchGameDepth
(
ctx
context
.
Context
)
(
uint64
,
error
)
FetchAbsolutePrestateHash
(
ctx
context
.
Context
)
([]
byte
,
error
)
}
// loader pulls in fault dispute game claim data periodically and over subscriptions.
type
loader
struct
{
caller
MinimalFaultDisputeGameCaller
...
...
@@ -42,6 +39,30 @@ func NewLoader(caller MinimalFaultDisputeGameCaller) *loader {
}
}
// NewLoaderFromBindings creates a new [loader] from a [bindings.FaultDisputeGameCaller].
func
NewLoaderFromBindings
(
fdgAddr
common
.
Address
,
client
bind
.
ContractCaller
)
(
*
loader
,
error
)
{
caller
,
err
:=
bindings
.
NewFaultDisputeGameCaller
(
fdgAddr
,
client
)
if
err
!=
nil
{
return
nil
,
err
}
return
NewLoader
(
caller
),
nil
}
// GetGameStatus returns the current game status.
func
(
l
*
loader
)
GetGameStatus
(
ctx
context
.
Context
)
(
types
.
GameStatus
,
error
)
{
status
,
err
:=
l
.
caller
.
Status
(
&
bind
.
CallOpts
{
Context
:
ctx
})
return
types
.
GameStatus
(
status
),
err
}
// GetClaimCount returns the number of claims in the game.
func
(
l
*
loader
)
GetClaimCount
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
count
,
err
:=
l
.
caller
.
ClaimDataLen
(
&
bind
.
CallOpts
{
Context
:
ctx
})
if
err
!=
nil
{
return
0
,
err
}
return
count
.
Uint64
(),
nil
}
// FetchGameDepth fetches the game depth from the fault dispute game.
func
(
l
*
loader
)
FetchGameDepth
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
callOpts
:=
bind
.
CallOpts
{
...
...
op-challenger/fault/loader_test.go
View file @
5669b83f
...
...
@@ -18,98 +18,52 @@ var (
mockClaimLenError
=
fmt
.
Errorf
(
"claim len errored"
)
mockMaxGameDepthError
=
fmt
.
Errorf
(
"max game depth errored"
)
mockPrestateError
=
fmt
.
Errorf
(
"prestate errored"
)
mockStatusError
=
fmt
.
Errorf
(
"status errored"
)
)
type
mockCaller
struct
{
claimDataError
bool
claimLenError
bool
maxGameDepthError
bool
prestateError
bool
maxGameDepth
uint64
currentIndex
uint64
returnClaims
[]
struct
{
ParentIndex
uint32
Countered
bool
Claim
[
32
]
byte
Position
*
big
.
Int
Clock
*
big
.
Int
}
}
func
newMockCaller
()
*
mockCaller
{
return
&
mockCaller
{
returnClaims
:
[]
struct
{
ParentIndex
uint32
Countered
bool
Claim
[
32
]
byte
Position
*
big
.
Int
Clock
*
big
.
Int
// TestLoader_GetGameStatus tests fetching the game status.
func
TestLoader_GetGameStatus
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
status
uint8
expectedError
bool
}{
{
Claim
:
[
32
]
byte
{
0x00
},
Position
:
big
.
NewInt
(
0
),
Countered
:
false
,
Clock
:
big
.
NewInt
(
0
),
name
:
"challenger won status"
,
status
:
uint8
(
types
.
GameStatusChallengerWon
),
},
{
Claim
:
[
32
]
byte
{
0x01
},
Position
:
big
.
NewInt
(
0
),
Countered
:
false
,
Clock
:
big
.
NewInt
(
0
),
name
:
"defender won status"
,
status
:
uint8
(
types
.
GameStatusDefenderWon
),
},
{
Claim
:
[
32
]
byte
{
0x02
},
Position
:
big
.
NewInt
(
0
),
Countered
:
false
,
Clock
:
big
.
NewInt
(
0
),
name
:
"in progress status"
,
status
:
uint8
(
types
.
GameStatusInProgress
),
},
{
name
:
"error bubbled up"
,
expectedError
:
true
,
},
}
}
func
(
m
*
mockCaller
)
ClaimData
(
opts
*
bind
.
CallOpts
,
arg0
*
big
.
Int
)
(
struct
{
ParentIndex
uint32
Countered
bool
Claim
[
32
]
byte
Position
*
big
.
Int
Clock
*
big
.
Int
},
error
)
{
if
m
.
claimDataError
{
return
struct
{
ParentIndex
uint32
Countered
bool
Claim
[
32
]
byte
Position
*
big
.
Int
Clock
*
big
.
Int
}{},
mockClaimDataError
}
returnClaim
:=
m
.
returnClaims
[
m
.
currentIndex
]
m
.
currentIndex
++
return
returnClaim
,
nil
}
func
(
m
*
mockCaller
)
ClaimDataLen
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
{
if
m
.
claimLenError
{
return
big
.
NewInt
(
0
),
mockClaimLenError
}
return
big
.
NewInt
(
int64
(
len
(
m
.
returnClaims
))),
nil
}
func
(
m
*
mockCaller
)
MAXGAMEDEPTH
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
{
if
m
.
maxGameDepthError
{
return
nil
,
mockMaxGameDepthError
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
mockCaller
:=
newMockCaller
()
mockCaller
.
status
=
test
.
status
mockCaller
.
statusError
=
test
.
expectedError
loader
:=
NewLoader
(
mockCaller
)
status
,
err
:=
loader
.
GetGameStatus
(
context
.
Background
())
if
test
.
expectedError
{
require
.
ErrorIs
(
t
,
err
,
mockStatusError
)
}
else
{
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
types
.
GameStatus
(
test
.
status
),
status
)
}
return
big
.
NewInt
(
int64
(
m
.
maxGameDepth
)),
nil
}
func
(
m
*
mockCaller
)
ABSOLUTEPRESTATE
(
opts
*
bind
.
CallOpts
)
([
32
]
byte
,
error
)
{
if
m
.
prestateError
{
return
[
32
]
byte
{},
mockPrestateError
})
}
return
common
.
HexToHash
(
"0xdEad"
),
nil
}
// TestLoader_FetchGameDepth tests
[loader.FetchGameDepth]
.
// TestLoader_FetchGameDepth tests
fetching the game depth
.
func
TestLoader_FetchGameDepth
(
t
*
testing
.
T
)
{
t
.
Run
(
"Succeeds"
,
func
(
t
*
testing
.
T
)
{
mockCaller
:=
newMockCaller
()
...
...
@@ -130,7 +84,7 @@ func TestLoader_FetchGameDepth(t *testing.T) {
})
}
// TestLoader_FetchAbsolutePrestateHash tests
the [loader.FetchAbsolutePrestateHash] function
.
// TestLoader_FetchAbsolutePrestateHash tests
fetching the absolute prestate hash
.
func
TestLoader_FetchAbsolutePrestateHash
(
t
*
testing
.
T
)
{
t
.
Run
(
"Succeeds"
,
func
(
t
*
testing
.
T
)
{
mockCaller
:=
newMockCaller
()
...
...
@@ -150,8 +104,9 @@ func TestLoader_FetchAbsolutePrestateHash(t *testing.T) {
})
}
// TestLoader_FetchClaims_Succeeds tests [loader.FetchClaims].
func
TestLoader_FetchClaims_Succeeds
(
t
*
testing
.
T
)
{
// TestLoader_FetchClaims tests fetching claims.
func
TestLoader_FetchClaims
(
t
*
testing
.
T
)
{
t
.
Run
(
"Succeeds"
,
func
(
t
*
testing
.
T
)
{
mockCaller
:=
newMockCaller
()
expectedClaims
:=
mockCaller
.
returnClaims
loader
:=
NewLoader
(
mockCaller
)
...
...
@@ -198,26 +153,121 @@ func TestLoader_FetchClaims_Succeeds(t *testing.T) {
ContractIndex
:
2
,
},
},
claims
)
}
})
// TestLoader_FetchClaims_ClaimDataErrors tests [loader.FetchClaims]
// when the claim fetcher [ClaimData] function call errors.
func
TestLoader_FetchClaims_ClaimDataErrors
(
t
*
testing
.
T
)
{
t
.
Run
(
"Claim Data Errors"
,
func
(
t
*
testing
.
T
)
{
mockCaller
:=
newMockCaller
()
mockCaller
.
claimDataError
=
true
loader
:=
NewLoader
(
mockCaller
)
claims
,
err
:=
loader
.
FetchClaims
(
context
.
Background
())
require
.
ErrorIs
(
t
,
err
,
mockClaimDataError
)
require
.
Empty
(
t
,
claims
)
}
})
// TestLoader_FetchClaims_ClaimLenErrors tests [loader.FetchClaims]
// when the claim fetcher [ClaimDataLen] function call errors.
func
TestLoader_FetchClaims_ClaimLenErrors
(
t
*
testing
.
T
)
{
t
.
Run
(
"Claim Len Errors"
,
func
(
t
*
testing
.
T
)
{
mockCaller
:=
newMockCaller
()
mockCaller
.
claimLenError
=
true
loader
:=
NewLoader
(
mockCaller
)
claims
,
err
:=
loader
.
FetchClaims
(
context
.
Background
())
require
.
ErrorIs
(
t
,
err
,
mockClaimLenError
)
require
.
Empty
(
t
,
claims
)
})
}
type
mockCaller
struct
{
claimDataError
bool
claimLenError
bool
maxGameDepthError
bool
prestateError
bool
statusError
bool
maxGameDepth
uint64
currentIndex
uint64
status
uint8
returnClaims
[]
struct
{
ParentIndex
uint32
Countered
bool
Claim
[
32
]
byte
Position
*
big
.
Int
Clock
*
big
.
Int
}
}
func
newMockCaller
()
*
mockCaller
{
return
&
mockCaller
{
returnClaims
:
[]
struct
{
ParentIndex
uint32
Countered
bool
Claim
[
32
]
byte
Position
*
big
.
Int
Clock
*
big
.
Int
}{
{
Claim
:
[
32
]
byte
{
0x00
},
Position
:
big
.
NewInt
(
0
),
Countered
:
false
,
Clock
:
big
.
NewInt
(
0
),
},
{
Claim
:
[
32
]
byte
{
0x01
},
Position
:
big
.
NewInt
(
0
),
Countered
:
false
,
Clock
:
big
.
NewInt
(
0
),
},
{
Claim
:
[
32
]
byte
{
0x02
},
Position
:
big
.
NewInt
(
0
),
Countered
:
false
,
Clock
:
big
.
NewInt
(
0
),
},
},
}
}
func
(
m
*
mockCaller
)
ClaimData
(
opts
*
bind
.
CallOpts
,
arg0
*
big
.
Int
)
(
struct
{
ParentIndex
uint32
Countered
bool
Claim
[
32
]
byte
Position
*
big
.
Int
Clock
*
big
.
Int
},
error
)
{
if
m
.
claimDataError
{
return
struct
{
ParentIndex
uint32
Countered
bool
Claim
[
32
]
byte
Position
*
big
.
Int
Clock
*
big
.
Int
}{},
mockClaimDataError
}
returnClaim
:=
m
.
returnClaims
[
m
.
currentIndex
]
m
.
currentIndex
++
return
returnClaim
,
nil
}
func
(
m
*
mockCaller
)
Status
(
opts
*
bind
.
CallOpts
)
(
uint8
,
error
)
{
if
m
.
statusError
{
return
0
,
mockStatusError
}
return
m
.
status
,
nil
}
func
(
m
*
mockCaller
)
ClaimDataLen
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
{
if
m
.
claimLenError
{
return
big
.
NewInt
(
0
),
mockClaimLenError
}
return
big
.
NewInt
(
int64
(
len
(
m
.
returnClaims
))),
nil
}
func
(
m
*
mockCaller
)
MAXGAMEDEPTH
(
opts
*
bind
.
CallOpts
)
(
*
big
.
Int
,
error
)
{
if
m
.
maxGameDepthError
{
return
nil
,
mockMaxGameDepthError
}
return
big
.
NewInt
(
int64
(
m
.
maxGameDepth
)),
nil
}
func
(
m
*
mockCaller
)
ABSOLUTEPRESTATE
(
opts
*
bind
.
CallOpts
)
([
32
]
byte
,
error
)
{
if
m
.
prestateError
{
return
[
32
]
byte
{},
mockPrestateError
}
return
common
.
HexToHash
(
"0xdEad"
),
nil
}
op-challenger/fault/player.go
View file @
5669b83f
...
...
@@ -27,7 +27,7 @@ type GameInfo interface {
type
GamePlayer
struct
{
agent
Actor
agreeWithProposedOutput
bool
call
er
GameInfo
load
er
GameInfo
logger
log
.
Logger
completed
bool
...
...
@@ -84,15 +84,10 @@ func NewGamePlayer(
return
nil
,
fmt
.
Errorf
(
"failed to create the responder: %w"
,
err
)
}
caller
,
err
:=
NewFaultCallerFromBindings
(
addr
,
client
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to bind the fault contract: %w"
,
err
)
}
return
&
GamePlayer
{
agent
:
NewAgent
(
loader
,
int
(
gameDepth
),
provider
,
responder
,
updater
,
cfg
.
AgreeWithProposedOutput
,
logger
),
agreeWithProposedOutput
:
cfg
.
AgreeWithProposedOutput
,
caller
:
call
er
,
loader
:
load
er
,
logger
:
logger
,
},
nil
}
...
...
@@ -107,7 +102,7 @@ func (g *GamePlayer) ProgressGame(ctx context.Context) bool {
if
err
:=
g
.
agent
.
Act
(
ctx
);
err
!=
nil
{
g
.
logger
.
Error
(
"Error when acting on game"
,
"err"
,
err
)
}
if
status
,
err
:=
g
.
call
er
.
GetGameStatus
(
ctx
);
err
!=
nil
{
if
status
,
err
:=
g
.
load
er
.
GetGameStatus
(
ctx
);
err
!=
nil
{
g
.
logger
.
Warn
(
"Unable to retrieve game status"
,
"err"
,
err
)
}
else
{
g
.
logGameStatus
(
ctx
,
status
)
...
...
@@ -119,7 +114,7 @@ func (g *GamePlayer) ProgressGame(ctx context.Context) bool {
func
(
g
*
GamePlayer
)
logGameStatus
(
ctx
context
.
Context
,
status
types
.
GameStatus
)
{
if
status
==
types
.
GameStatusInProgress
{
claimCount
,
err
:=
g
.
call
er
.
GetClaimCount
(
ctx
)
claimCount
,
err
:=
g
.
load
er
.
GetClaimCount
(
ctx
)
if
err
!=
nil
{
g
.
logger
.
Error
(
"Failed to get claim count for in progress game"
,
"err"
,
err
)
return
...
...
op-challenger/fault/player_test.go
View file @
5669b83f
...
...
@@ -115,7 +115,7 @@ func setupProgressGameTest(t *testing.T, agreeWithProposedRoot bool) (*testlog.C
game
:=
&
GamePlayer
{
agent
:
gameState
,
agreeWithProposedOutput
:
agreeWithProposedRoot
,
call
er
:
gameState
,
load
er
:
gameState
,
logger
:
logger
,
}
return
handler
,
game
,
gameState
...
...
op-challenger/fault/service.go
View file @
5669b83f
...
...
@@ -19,13 +19,16 @@ import (
"github.com/ethereum/go-ethereum/log"
)
// Service provides a clean interface for the challenger to interact
// with the fault package.
// Service exposes top-level fault dispute game challenger functionality.
type
Service
interface
{
// MonitorGame monitors the fault dispute game and attempts to progress it.
MonitorGame
(
context
.
Context
)
error
}
type
Loader
interface
{
FetchAbsolutePrestateHash
(
ctx
context
.
Context
)
([]
byte
,
error
)
}
type
service
struct
{
logger
log
.
Logger
metrics
metrics
.
Metricer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment