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
5199c4a0
Unverified
Commit
5199c4a0
authored
Jul 24, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Carefully rearrange modules to avoid cycles.
parent
c14c1725
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
63 deletions
+58
-63
main_test.go
op-challenger/cmd/main_test.go
+5
-5
config.go
op-challenger/config/config.go
+5
-6
config_test.go
op-challenger/config/config_test.go
+8
-8
cannon_provider.go
op-challenger/fault/cannon/cannon_provider.go
+0
-3
service.go
op-challenger/fault/service.go
+3
-2
types.go
op-challenger/fault/types.go
+0
-31
flags.go
op-challenger/flags/flags.go
+37
-8
No files found.
op-challenger/cmd/main_test.go
View file @
5199c4a0
...
@@ -6,7 +6,7 @@ import (
...
@@ -6,7 +6,7 @@ import (
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/f
ault
"
"github.com/ethereum-optimism/optimism/op-challenger/f
lags
"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
...
@@ -39,12 +39,12 @@ func TestLogLevel(t *testing.T) {
...
@@ -39,12 +39,12 @@ func TestLogLevel(t *testing.T) {
func
TestDefaultCLIOptionsMatchDefaultConfig
(
t
*
testing
.
T
)
{
func
TestDefaultCLIOptionsMatchDefaultConfig
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
())
cfg
:=
configForArgs
(
t
,
addRequiredArgs
())
defaultCfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
f
ault
.
TraceTypeAlphabet
,
alphabetTrace
,
cannonDatadir
,
true
,
4
)
defaultCfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
f
lags
.
TraceTypeAlphabet
,
alphabetTrace
,
cannonDatadir
,
true
,
4
)
require
.
Equal
(
t
,
defaultCfg
,
cfg
)
require
.
Equal
(
t
,
defaultCfg
,
cfg
)
}
}
func
TestDefaultConfigIsValid
(
t
*
testing
.
T
)
{
func
TestDefaultConfigIsValid
(
t
*
testing
.
T
)
{
cfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
f
ault
.
TraceTypeAlphabet
,
alphabetTrace
,
cannonDatadir
,
true
,
4
)
cfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
f
lags
.
TraceTypeAlphabet
,
alphabetTrace
,
cannonDatadir
,
true
,
4
)
require
.
NoError
(
t
,
cfg
.
Check
())
require
.
NoError
(
t
,
cfg
.
Check
())
}
}
...
@@ -66,7 +66,7 @@ func TestTraceType(t *testing.T) {
...
@@ -66,7 +66,7 @@ func TestTraceType(t *testing.T) {
verifyArgsInvalid
(
t
,
"flag trace-type is required"
,
addRequiredArgsExcept
(
"--trace-type"
))
verifyArgsInvalid
(
t
,
"flag trace-type is required"
,
addRequiredArgsExcept
(
"--trace-type"
))
})
})
for
_
,
traceType
:=
range
f
ault
.
TraceTypes
{
for
_
,
traceType
:=
range
f
lags
.
TraceTypes
{
traceType
:=
traceType
traceType
:=
traceType
t
.
Run
(
"Valid_"
+
traceType
.
String
(),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Valid_"
+
traceType
.
String
(),
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgsExcept
(
"--trace-type"
,
"--trace-type"
,
traceType
.
String
()))
cfg
:=
configForArgs
(
t
,
addRequiredArgsExcept
(
"--trace-type"
,
"--trace-type"
,
traceType
.
String
()))
...
@@ -172,7 +172,7 @@ func requiredArgs() map[string]string {
...
@@ -172,7 +172,7 @@ func requiredArgs() map[string]string {
"--agree-with-proposed-output"
:
agreeWithProposedOutput
,
"--agree-with-proposed-output"
:
agreeWithProposedOutput
,
"--l1-eth-rpc"
:
l1EthRpc
,
"--l1-eth-rpc"
:
l1EthRpc
,
"--game-address"
:
gameAddressValue
,
"--game-address"
:
gameAddressValue
,
"--trace-type"
:
f
ault
.
TraceTypeAlphabet
.
String
(),
"--trace-type"
:
f
lags
.
TraceTypeAlphabet
.
String
(),
"--alphabet"
:
alphabetTrace
,
"--alphabet"
:
alphabetTrace
,
"--cannon-datadir"
:
cannonDatadir
,
"--cannon-datadir"
:
cannonDatadir
,
}
}
...
...
op-challenger/config/config.go
View file @
5199c4a0
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"errors"
"errors"
"strings"
"strings"
"github.com/ethereum-optimism/optimism/op-challenger/fault"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
...
@@ -30,7 +29,7 @@ type Config struct {
...
@@ -30,7 +29,7 @@ type Config struct {
AgreeWithProposedOutput
bool
// Temporary config if we agree or disagree with the posted output
AgreeWithProposedOutput
bool
// Temporary config if we agree or disagree with the posted output
GameDepth
int
// Depth of the game tree
GameDepth
int
// Depth of the game tree
TraceType
f
ault
.
TraceType
// Type of trace
TraceType
f
lags
.
TraceType
// Type of trace
AlphabetTrace
string
// String for the AlphabetTraceProvider
AlphabetTrace
string
// String for the AlphabetTraceProvider
CannonDatadir
string
// Cannon Data Directory for the CannonTraceProvider
CannonDatadir
string
// Cannon Data Directory for the CannonTraceProvider
...
@@ -40,7 +39,7 @@ type Config struct {
...
@@ -40,7 +39,7 @@ type Config struct {
func
NewConfig
(
func
NewConfig
(
l1EthRpc
string
,
l1EthRpc
string
,
gameAddress
common
.
Address
,
gameAddress
common
.
Address
,
traceType
f
ault
.
TraceType
,
traceType
f
lags
.
TraceType
,
alphabetTrace
string
,
alphabetTrace
string
,
cannonDatadir
string
,
cannonDatadir
string
,
agreeWithProposedOutput
bool
,
agreeWithProposedOutput
bool
,
...
@@ -71,10 +70,10 @@ func (c Config) Check() error {
...
@@ -71,10 +70,10 @@ func (c Config) Check() error {
if
c
.
TraceType
==
""
{
if
c
.
TraceType
==
""
{
return
ErrMissingTraceType
return
ErrMissingTraceType
}
}
if
c
.
TraceType
==
f
ault
.
TraceTypeCannon
&&
c
.
CannonDatadir
==
""
{
if
c
.
TraceType
==
f
lags
.
TraceTypeCannon
&&
c
.
CannonDatadir
==
""
{
return
ErrMissingCannonDatadir
return
ErrMissingCannonDatadir
}
}
if
c
.
TraceType
==
f
ault
.
TraceTypeAlphabet
&&
c
.
AlphabetTrace
==
""
{
if
c
.
TraceType
==
f
lags
.
TraceTypeAlphabet
&&
c
.
AlphabetTrace
==
""
{
return
ErrMissingAlphabetTrace
return
ErrMissingAlphabetTrace
}
}
if
err
:=
c
.
TxMgrConfig
.
Check
();
err
!=
nil
{
if
err
:=
c
.
TxMgrConfig
.
Check
();
err
!=
nil
{
...
@@ -95,7 +94,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*Config, error) {
...
@@ -95,7 +94,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*Config, error) {
txMgrConfig
:=
txmgr
.
ReadCLIConfig
(
ctx
)
txMgrConfig
:=
txmgr
.
ReadCLIConfig
(
ctx
)
traceTypeFlag
:=
f
ault
.
TraceType
(
strings
.
ToLower
(
ctx
.
String
(
flags
.
TraceTypeFlag
.
Name
)))
traceTypeFlag
:=
f
lags
.
TraceType
(
strings
.
ToLower
(
ctx
.
String
(
flags
.
TraceTypeFlag
.
Name
)))
return
&
Config
{
return
&
Config
{
// Required Flags
// Required Flags
...
...
op-challenger/config/config_test.go
View file @
5199c4a0
...
@@ -3,7 +3,7 @@ package config
...
@@ -3,7 +3,7 @@ package config
import
(
import
(
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/f
ault
"
"github.com/ethereum-optimism/optimism/op-challenger/f
lags
"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -18,27 +18,27 @@ var (
...
@@ -18,27 +18,27 @@ var (
gameDepth
=
4
gameDepth
=
4
)
)
func
validConfig
(
traceType
f
ault
.
TraceType
)
Config
{
func
validConfig
(
traceType
f
lags
.
TraceType
)
Config
{
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
traceType
,
validAlphabetTrace
,
validCannonDatadir
,
agreeWithProposedOutput
,
gameDepth
)
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
traceType
,
validAlphabetTrace
,
validCannonDatadir
,
agreeWithProposedOutput
,
gameDepth
)
return
cfg
return
cfg
}
}
// TestValidConfigIsValid checks that the config provided by validConfig is actually valid
// TestValidConfigIsValid checks that the config provided by validConfig is actually valid
func
TestValidConfigIsValid
(
t
*
testing
.
T
)
{
func
TestValidConfigIsValid
(
t
*
testing
.
T
)
{
err
:=
validConfig
(
f
ault
.
TraceTypeCannon
)
.
Check
()
err
:=
validConfig
(
f
lags
.
TraceTypeCannon
)
.
Check
()
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
}
}
func
TestTxMgrConfig
(
t
*
testing
.
T
)
{
func
TestTxMgrConfig
(
t
*
testing
.
T
)
{
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
f
ault
.
TraceTypeCannon
)
config
:=
validConfig
(
f
lags
.
TraceTypeCannon
)
config
.
TxMgrConfig
=
txmgr
.
CLIConfig
{}
config
.
TxMgrConfig
=
txmgr
.
CLIConfig
{}
require
.
Equal
(
t
,
config
.
Check
()
.
Error
(),
"must provide a L1 RPC url"
)
require
.
Equal
(
t
,
config
.
Check
()
.
Error
(),
"must provide a L1 RPC url"
)
})
})
}
}
func
TestL1EthRpcRequired
(
t
*
testing
.
T
)
{
func
TestL1EthRpcRequired
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
f
ault
.
TraceTypeCannon
)
config
:=
validConfig
(
f
lags
.
TraceTypeCannon
)
config
.
L1EthRpc
=
""
config
.
L1EthRpc
=
""
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingL1EthRPC
)
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingL1EthRPC
)
config
.
L1EthRpc
=
validL1EthRpc
config
.
L1EthRpc
=
validL1EthRpc
...
@@ -46,7 +46,7 @@ func TestL1EthRpcRequired(t *testing.T) {
...
@@ -46,7 +46,7 @@ func TestL1EthRpcRequired(t *testing.T) {
}
}
func
TestGameAddressRequired
(
t
*
testing
.
T
)
{
func
TestGameAddressRequired
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
f
ault
.
TraceTypeCannon
)
config
:=
validConfig
(
f
lags
.
TraceTypeCannon
)
config
.
GameAddress
=
common
.
Address
{}
config
.
GameAddress
=
common
.
Address
{}
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingGameAddress
)
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingGameAddress
)
config
.
GameAddress
=
validGameAddress
config
.
GameAddress
=
validGameAddress
...
@@ -54,7 +54,7 @@ func TestGameAddressRequired(t *testing.T) {
...
@@ -54,7 +54,7 @@ func TestGameAddressRequired(t *testing.T) {
}
}
func
TestAlphabetTraceRequired
(
t
*
testing
.
T
)
{
func
TestAlphabetTraceRequired
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
f
ault
.
TraceTypeAlphabet
)
config
:=
validConfig
(
f
lags
.
TraceTypeAlphabet
)
config
.
AlphabetTrace
=
""
config
.
AlphabetTrace
=
""
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingAlphabetTrace
)
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingAlphabetTrace
)
config
.
AlphabetTrace
=
validAlphabetTrace
config
.
AlphabetTrace
=
validAlphabetTrace
...
@@ -62,7 +62,7 @@ func TestAlphabetTraceRequired(t *testing.T) {
...
@@ -62,7 +62,7 @@ func TestAlphabetTraceRequired(t *testing.T) {
}
}
func
TestCannonTraceRequired
(
t
*
testing
.
T
)
{
func
TestCannonTraceRequired
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
f
ault
.
TraceTypeCannon
)
config
:=
validConfig
(
f
lags
.
TraceTypeCannon
)
config
.
CannonDatadir
=
""
config
.
CannonDatadir
=
""
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingCannonDatadir
)
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingCannonDatadir
)
config
.
CannonDatadir
=
validCannonDatadir
config
.
CannonDatadir
=
validCannonDatadir
...
...
op-challenger/fault/cannon/cannon_provider.go
View file @
5199c4a0
...
@@ -7,7 +7,6 @@ import (
...
@@ -7,7 +7,6 @@ import (
"os"
"os"
"path/filepath"
"path/filepath"
"github.com/ethereum-optimism/optimism/op-challenger/fault"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
)
)
...
@@ -77,5 +76,3 @@ func (p *CannonTraceProvider) loadProof(i uint64) (*proofData, error) {
...
@@ -77,5 +76,3 @@ func (p *CannonTraceProvider) loadProof(i uint64) (*proofData, error) {
}
}
return
&
proof
,
nil
return
&
proof
,
nil
}
}
var
_
fault
.
TraceProvider
=
(
*
CannonTraceProvider
)(
nil
)
op-challenger/fault/service.go
View file @
5199c4a0
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/fault/cannon"
"github.com/ethereum-optimism/optimism/op-challenger/fault/cannon"
"github.com/ethereum-optimism/optimism/op-challenger/flags"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
...
@@ -53,9 +54,9 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
...
@@ -53,9 +54,9 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
var
trace
TraceProvider
var
trace
TraceProvider
switch
cfg
.
TraceType
{
switch
cfg
.
TraceType
{
case
TraceTypeCannon
:
case
flags
.
TraceTypeCannon
:
trace
=
cannon
.
NewCannonTraceProvider
(
cfg
.
CannonDatadir
)
trace
=
cannon
.
NewCannonTraceProvider
(
cfg
.
CannonDatadir
)
case
TraceTypeAlphabet
:
case
flags
.
TraceTypeAlphabet
:
trace
=
NewAlphabetProvider
(
cfg
.
AlphabetTrace
,
uint64
(
cfg
.
GameDepth
))
trace
=
NewAlphabetProvider
(
cfg
.
AlphabetTrace
,
uint64
(
cfg
.
GameDepth
))
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported trace type: %v"
,
cfg
.
TraceType
)
return
nil
,
fmt
.
Errorf
(
"unsupported trace type: %v"
,
cfg
.
TraceType
)
...
...
op-challenger/fault/types.go
View file @
5199c4a0
...
@@ -3,7 +3,6 @@ package fault
...
@@ -3,7 +3,6 @@ package fault
import
(
import
(
"context"
"context"
"errors"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
)
)
...
@@ -20,36 +19,6 @@ const (
...
@@ -20,36 +19,6 @@ const (
GameStatusDefenderWon
GameStatusDefenderWon
)
)
type
TraceType
string
const
(
TraceTypeAlphabet
TraceType
=
"alphabet"
TraceTypeCannon
TraceType
=
"cannon"
)
var
TraceTypes
=
[]
TraceType
{
TraceTypeAlphabet
,
TraceTypeCannon
}
func
(
t
TraceType
)
String
()
string
{
return
string
(
t
)
}
func
(
t
*
TraceType
)
Set
(
value
string
)
error
{
if
!
ValidTraceType
(
TraceType
(
value
))
{
return
fmt
.
Errorf
(
"unknown trace type: %q"
,
value
)
}
*
t
=
TraceType
(
value
)
return
nil
}
func
ValidTraceType
(
value
TraceType
)
bool
{
for
_
,
t
:=
range
TraceTypes
{
if
t
==
value
{
return
true
}
}
return
false
}
// StepCallData encapsulates the data needed to perform a step.
// StepCallData encapsulates the data needed to perform a step.
type
StepCallData
struct
{
type
StepCallData
struct
{
ClaimIndex
uint64
ClaimIndex
uint64
...
...
op-challenger/flags/flags.go
View file @
5199c4a0
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"fmt"
"fmt"
"strings"
"strings"
"github.com/ethereum-optimism/optimism/op-challenger/fault"
openum
"github.com/ethereum-optimism/optimism/op-service/enum"
openum
"github.com/ethereum-optimism/optimism/op-service/enum"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
...
@@ -21,6 +20,36 @@ func prefixEnvVars(name string) []string {
...
@@ -21,6 +20,36 @@ func prefixEnvVars(name string) []string {
return
opservice
.
PrefixEnvVar
(
envVarPrefix
,
name
)
return
opservice
.
PrefixEnvVar
(
envVarPrefix
,
name
)
}
}
type
TraceType
string
const
(
TraceTypeAlphabet
TraceType
=
"alphabet"
TraceTypeCannon
TraceType
=
"cannon"
)
var
TraceTypes
=
[]
TraceType
{
TraceTypeAlphabet
,
TraceTypeCannon
}
func
(
t
TraceType
)
String
()
string
{
return
string
(
t
)
}
func
(
t
*
TraceType
)
Set
(
value
string
)
error
{
if
!
ValidTraceType
(
TraceType
(
value
))
{
return
fmt
.
Errorf
(
"unknown trace type: %q"
,
value
)
}
*
t
=
TraceType
(
value
)
return
nil
}
func
ValidTraceType
(
value
TraceType
)
bool
{
for
_
,
t
:=
range
TraceTypes
{
if
t
==
value
{
return
true
}
}
return
false
}
var
(
var
(
// Required Flags
// Required Flags
L1EthRpcFlag
=
&
cli
.
StringFlag
{
L1EthRpcFlag
=
&
cli
.
StringFlag
{
...
@@ -35,10 +64,10 @@ var (
...
@@ -35,10 +64,10 @@ var (
}
}
TraceTypeFlag
=
&
cli
.
GenericFlag
{
TraceTypeFlag
=
&
cli
.
GenericFlag
{
Name
:
"trace-type"
,
Name
:
"trace-type"
,
Usage
:
"The trace type. Valid options: "
+
openum
.
EnumString
(
fault
.
TraceTypes
),
Usage
:
"The trace type. Valid options: "
+
openum
.
EnumString
(
TraceTypes
),
EnvVars
:
prefixEnvVars
(
"TRACE_TYPE"
),
EnvVars
:
prefixEnvVars
(
"TRACE_TYPE"
),
Value
:
func
()
*
fault
.
TraceType
{
Value
:
func
()
*
TraceType
{
out
:=
fault
.
TraceType
(
""
)
// No default value
out
:=
TraceType
(
""
)
// No default value
return
&
out
return
&
out
}(),
}(),
}
}
...
@@ -96,18 +125,18 @@ func CheckRequired(ctx *cli.Context) error {
...
@@ -96,18 +125,18 @@ func CheckRequired(ctx *cli.Context) error {
return
fmt
.
Errorf
(
"flag %s is required"
,
f
.
Names
()[
0
])
return
fmt
.
Errorf
(
"flag %s is required"
,
f
.
Names
()[
0
])
}
}
}
}
gameType
:=
fault
.
TraceType
(
strings
.
ToLower
(
ctx
.
String
(
TraceTypeFlag
.
Name
)))
gameType
:=
TraceType
(
strings
.
ToLower
(
ctx
.
String
(
TraceTypeFlag
.
Name
)))
switch
gameType
{
switch
gameType
{
case
fault
.
TraceTypeCannon
:
case
TraceTypeCannon
:
if
!
ctx
.
IsSet
(
CannonDatadirFlag
.
Name
)
{
if
!
ctx
.
IsSet
(
CannonDatadirFlag
.
Name
)
{
return
fmt
.
Errorf
(
"flag %s is required"
,
"cannon-datadir"
)
return
fmt
.
Errorf
(
"flag %s is required"
,
"cannon-datadir"
)
}
}
case
fault
.
TraceTypeAlphabet
:
case
TraceTypeAlphabet
:
if
!
ctx
.
IsSet
(
AlphabetFlag
.
Name
)
{
if
!
ctx
.
IsSet
(
AlphabetFlag
.
Name
)
{
return
fmt
.
Errorf
(
"flag %s is required"
,
"alphabet"
)
return
fmt
.
Errorf
(
"flag %s is required"
,
"alphabet"
)
}
}
default
:
default
:
return
fmt
.
Errorf
(
"invalid trace type. must be one of %v"
,
fault
.
TraceTypes
)
return
fmt
.
Errorf
(
"invalid trace type. must be one of %v"
,
TraceTypes
)
}
}
return
nil
return
nil
}
}
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