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
ab795dfd
Unverified
Commit
ab795dfd
authored
Aug 17, 2023
by
OptimismBot
Committed by
GitHub
Aug 17, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6827 from ethereum-optimism/refcell/game-status-string-fix
Cast GameStatusString onto Status Type
parents
317fcb6d
2fe0c069
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
29 deletions
+26
-29
caller.go
op-challenger/fault/caller.go
+4
-18
monitor.go
op-challenger/fault/monitor.go
+4
-3
monitor_test.go
op-challenger/fault/monitor_test.go
+4
-8
types.go
op-challenger/fault/types/types.go
+14
-0
No files found.
op-challenger/fault/caller.go
View file @
ab795dfd
...
@@ -4,13 +4,13 @@ import (
...
@@ -4,13 +4,13 @@ import (
"context"
"context"
"math/big"
"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/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
)
)
type
FaultDisputeGameCaller
interface
{
type
FaultDisputeGameCaller
interface
{
...
@@ -53,7 +53,7 @@ func (fc *FaultCaller) LogGameInfo(ctx context.Context) {
...
@@ -53,7 +53,7 @@ func (fc *FaultCaller) LogGameInfo(ctx context.Context) {
fc
.
log
.
Error
(
"failed to get claim count"
,
"err"
,
err
)
fc
.
log
.
Error
(
"failed to get claim count"
,
"err"
,
err
)
return
return
}
}
fc
.
log
.
Info
(
"Game info"
,
"claims"
,
claimLen
,
"status"
,
GameStatusString
(
status
)
)
fc
.
log
.
Info
(
"Game info"
,
"claims"
,
claimLen
,
"status"
,
status
)
}
}
// GetGameStatus returns the current game status.
// GetGameStatus returns the current game status.
...
@@ -78,17 +78,3 @@ func (fc *FaultCaller) LogClaimDataLength(ctx context.Context) {
...
@@ -78,17 +78,3 @@ func (fc *FaultCaller) LogClaimDataLength(ctx context.Context) {
}
}
fc
.
log
.
Info
(
"Number of claims"
,
"length"
,
claimLen
)
fc
.
log
.
Info
(
"Number of claims"
,
"length"
,
claimLen
)
}
}
// GameStatusString returns the current game status as a string.
func
GameStatusString
(
status
types
.
GameStatus
)
string
{
switch
status
{
case
types
.
GameStatusInProgress
:
return
"In Progress"
case
types
.
GameStatusChallengerWon
:
return
"Challenger Won"
case
types
.
GameStatusDefenderWon
:
return
"Defender Won"
default
:
return
"Unknown"
}
}
op-challenger/fault/monitor.go
View file @
ab795dfd
...
@@ -4,8 +4,9 @@ import (
...
@@ -4,8 +4,9 @@ import (
"context"
"context"
"time"
"time"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
)
)
type
GameInfo
interface
{
type
GameInfo
interface
{
...
@@ -51,9 +52,9 @@ func progressGame(ctx context.Context, logger log.Logger, agreeWithProposedOutpu
...
@@ -51,9 +52,9 @@ func progressGame(ctx context.Context, logger log.Logger, agreeWithProposedOutpu
expectedStatus
=
types
.
GameStatusDefenderWon
expectedStatus
=
types
.
GameStatusDefenderWon
}
}
if
expectedStatus
==
status
{
if
expectedStatus
==
status
{
logger
.
Info
(
"Game won"
,
"status"
,
GameStatusString
(
status
)
)
logger
.
Info
(
"Game won"
,
"status"
,
status
)
}
else
{
}
else
{
logger
.
Error
(
"Game lost"
,
"status"
,
GameStatusString
(
status
)
)
logger
.
Error
(
"Game lost"
,
"status"
,
status
)
}
}
return
true
return
true
}
else
{
}
else
{
...
...
op-challenger/fault/monitor_test.go
View file @
ab795dfd
...
@@ -5,10 +5,11 @@ import (
...
@@ -5,10 +5,11 @@ import (
"errors"
"errors"
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-node/testlog"
)
)
func
TestMonitorExitsWhenContextDone
(
t
*
testing
.
T
)
{
func
TestMonitorExitsWhenContextDone
(
t
*
testing
.
T
)
{
...
@@ -48,7 +49,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
...
@@ -48,7 +49,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
agreeWithOutput
bool
agreeWithOutput
bool
logLevel
log
.
Lvl
logLevel
log
.
Lvl
logMsg
string
logMsg
string
statusText
string
}{
}{
{
{
name
:
"GameLostAsDefender"
,
name
:
"GameLostAsDefender"
,
...
@@ -56,7 +56,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
...
@@ -56,7 +56,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
agreeWithOutput
:
false
,
agreeWithOutput
:
false
,
logLevel
:
log
.
LvlError
,
logLevel
:
log
.
LvlError
,
logMsg
:
"Game lost"
,
logMsg
:
"Game lost"
,
statusText
:
"Challenger Won"
,
},
},
{
{
name
:
"GameLostAsChallenger"
,
name
:
"GameLostAsChallenger"
,
...
@@ -64,7 +63,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
...
@@ -64,7 +63,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
agreeWithOutput
:
true
,
agreeWithOutput
:
true
,
logLevel
:
log
.
LvlError
,
logLevel
:
log
.
LvlError
,
logMsg
:
"Game lost"
,
logMsg
:
"Game lost"
,
statusText
:
"Defender Won"
,
},
},
{
{
name
:
"GameWonAsDefender"
,
name
:
"GameWonAsDefender"
,
...
@@ -72,7 +70,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
...
@@ -72,7 +70,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
agreeWithOutput
:
false
,
agreeWithOutput
:
false
,
logLevel
:
log
.
LvlInfo
,
logLevel
:
log
.
LvlInfo
,
logMsg
:
"Game won"
,
logMsg
:
"Game won"
,
statusText
:
"Defender Won"
,
},
},
{
{
name
:
"GameWonAsChallenger"
,
name
:
"GameWonAsChallenger"
,
...
@@ -80,7 +77,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
...
@@ -80,7 +77,6 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
agreeWithOutput
:
true
,
agreeWithOutput
:
true
,
logLevel
:
log
.
LvlInfo
,
logLevel
:
log
.
LvlInfo
,
logMsg
:
"Game won"
,
logMsg
:
"Game won"
,
statusText
:
"Challenger Won"
,
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
...
@@ -94,7 +90,7 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
...
@@ -94,7 +90,7 @@ func TestProgressGame_LogErrorWhenGameLost(t *testing.T) {
require
.
Equal
(
t
,
0
,
gameInfo
.
logCount
,
"should not log latest game state"
)
require
.
Equal
(
t
,
0
,
gameInfo
.
logCount
,
"should not log latest game state"
)
errLog
:=
handler
.
FindLog
(
test
.
logLevel
,
test
.
logMsg
)
errLog
:=
handler
.
FindLog
(
test
.
logLevel
,
test
.
logMsg
)
require
.
NotNil
(
t
,
errLog
,
"should log game result"
)
require
.
NotNil
(
t
,
errLog
,
"should log game result"
)
require
.
Equal
(
t
,
test
.
status
Text
,
errLog
.
GetContextValue
(
"status"
))
require
.
Equal
(
t
,
test
.
status
,
errLog
.
GetContextValue
(
"status"
))
})
})
}
}
}
}
...
...
op-challenger/fault/types/types.go
View file @
ab795dfd
...
@@ -20,6 +20,20 @@ const (
...
@@ -20,6 +20,20 @@ const (
GameStatusDefenderWon
GameStatusDefenderWon
)
)
// String returns the string representation of the game status.
func
(
s
GameStatus
)
String
()
string
{
switch
s
{
case
GameStatusInProgress
:
return
"In Progress"
case
GameStatusChallengerWon
:
return
"Challenger Won"
case
GameStatusDefenderWon
:
return
"Defender Won"
default
:
return
"Unknown"
}
}
// PreimageOracleData encapsulates the preimage oracle data
// PreimageOracleData encapsulates the preimage oracle data
// to load into the onchain oracle.
// to load into the onchain oracle.
type
PreimageOracleData
struct
{
type
PreimageOracleData
struct
{
...
...
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