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
051aa24d
Unverified
Commit
051aa24d
authored
Jul 14, 2023
by
OptimismBot
Committed by
GitHub
Jul 14, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6274 from ethereum-optimism/refcell/challenger-bool-flag
feat(op-challenger): Proposed Output Agreement Flag
parents
909554d0
1d6d77fd
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
138 additions
and
65 deletions
+138
-65
challenger.go
op-challenger/challenger.go
+1
-1
main_test.go
op-challenger/cmd/main_test.go
+31
-11
config.go
op-challenger/config/config.go
+17
-12
config_test.go
op-challenger/config/config_test.go
+5
-4
agent.go
op-challenger/fault/agent.go
+16
-14
full.go
op-challenger/fault/cmd/examples/full.go
+1
-1
game.go
op-challenger/fault/game.go
+23
-8
game_test.go
op-challenger/fault/game_test.go
+35
-11
orchestrator.go
op-challenger/fault/orchestrator.go
+2
-2
solver_test.go
op-challenger/fault/solver_test.go
+1
-1
flags.go
op-challenger/flags/flags.go
+6
-0
No files found.
op-challenger/challenger.go
View file @
051aa24d
...
@@ -38,7 +38,7 @@ func Main(logger log.Logger, cfg *config.Config) error {
...
@@ -38,7 +38,7 @@ func Main(logger log.Logger, cfg *config.Config) error {
gameDepth
:=
4
gameDepth
:=
4
trace
:=
fault
.
NewAlphabetProvider
(
cfg
.
AlphabetTrace
,
uint64
(
gameDepth
))
trace
:=
fault
.
NewAlphabetProvider
(
cfg
.
AlphabetTrace
,
uint64
(
gameDepth
))
agent
:=
fault
.
NewAgent
(
loader
,
gameDepth
,
trace
,
responder
,
logger
)
agent
:=
fault
.
NewAgent
(
loader
,
gameDepth
,
trace
,
responder
,
cfg
.
AgreeWithProposedOutput
,
logger
)
logger
.
Info
(
"Fault game started"
)
logger
.
Info
(
"Fault game started"
)
...
...
op-challenger/cmd/main_test.go
View file @
051aa24d
package
main
package
main
import
(
import
(
"fmt"
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/config"
...
@@ -11,9 +12,10 @@ import (
...
@@ -11,9 +12,10 @@ import (
)
)
var
(
var
(
l1EthRpc
=
"http://example.com:8545"
l1EthRpc
=
"http://example.com:8545"
gameAddressValue
=
"0xaa00000000000000000000000000000000000000"
gameAddressValue
=
"0xaa00000000000000000000000000000000000000"
alphabetTrace
=
"abcdefghijz"
alphabetTrace
=
"abcdefghijz"
agreeWithProposedOutput
=
"true"
)
)
func
TestLogLevel
(
t
*
testing
.
T
)
{
func
TestLogLevel
(
t
*
testing
.
T
)
{
...
@@ -33,12 +35,12 @@ func TestLogLevel(t *testing.T) {
...
@@ -33,12 +35,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
),
alphabetTrace
)
defaultCfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
alphabetTrace
,
true
)
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
),
alphabetTrace
)
cfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
alphabetTrace
,
true
)
require
.
NoError
(
t
,
cfg
.
Check
())
require
.
NoError
(
t
,
cfg
.
Check
())
}
}
...
@@ -89,6 +91,24 @@ func TestTxManagerFlagsSupported(t *testing.T) {
...
@@ -89,6 +91,24 @@ func TestTxManagerFlagsSupported(t *testing.T) {
require
.
Equal
(
t
,
uint64
(
7
),
cfg
.
TxMgrConfig
.
NumConfirmations
)
require
.
Equal
(
t
,
uint64
(
7
),
cfg
.
TxMgrConfig
.
NumConfirmations
)
}
}
func
TestAgreeWithProposedOutput
(
t
*
testing
.
T
)
{
t
.
Run
(
"MustBeProvided"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag agree-with-proposed-output is required"
,
addRequiredArgsExcept
(
"--agree-with-proposed-output"
))
})
t
.
Run
(
"Enabled"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
"--agree-with-proposed-output"
))
require
.
True
(
t
,
cfg
.
AgreeWithProposedOutput
)
})
t
.
Run
(
"EnabledWithArg"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
"--agree-with-proposed-output=true"
))
require
.
True
(
t
,
cfg
.
AgreeWithProposedOutput
)
})
t
.
Run
(
"Disabled"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
"--agree-with-proposed-output=false"
))
require
.
False
(
t
,
cfg
.
AgreeWithProposedOutput
)
})
}
func
verifyArgsInvalid
(
t
*
testing
.
T
,
messageContains
string
,
cliArgs
[]
string
)
{
func
verifyArgsInvalid
(
t
*
testing
.
T
,
messageContains
string
,
cliArgs
[]
string
)
{
_
,
_
,
err
:=
runWithArgs
(
cliArgs
)
_
,
_
,
err
:=
runWithArgs
(
cliArgs
)
require
.
ErrorContains
(
t
,
err
,
messageContains
)
require
.
ErrorContains
(
t
,
err
,
messageContains
)
...
@@ -103,7 +123,7 @@ func configForArgs(t *testing.T, cliArgs []string) config.Config {
...
@@ -103,7 +123,7 @@ func configForArgs(t *testing.T, cliArgs []string) config.Config {
func
runWithArgs
(
cliArgs
[]
string
)
(
log
.
Logger
,
config
.
Config
,
error
)
{
func
runWithArgs
(
cliArgs
[]
string
)
(
log
.
Logger
,
config
.
Config
,
error
)
{
cfg
:=
new
(
config
.
Config
)
cfg
:=
new
(
config
.
Config
)
var
logger
log
.
Logger
var
logger
log
.
Logger
fullArgs
:=
append
([]
string
{
"op-
program
"
},
cliArgs
...
)
fullArgs
:=
append
([]
string
{
"op-
challenger
"
},
cliArgs
...
)
err
:=
run
(
fullArgs
,
func
(
log
log
.
Logger
,
config
*
config
.
Config
)
error
{
err
:=
run
(
fullArgs
,
func
(
log
log
.
Logger
,
config
*
config
.
Config
)
error
{
logger
=
log
logger
=
log
cfg
=
config
cfg
=
config
...
@@ -126,17 +146,17 @@ func addRequiredArgsExcept(name string, optionalArgs ...string) []string {
...
@@ -126,17 +146,17 @@ func addRequiredArgsExcept(name string, optionalArgs ...string) []string {
func
requiredArgs
()
map
[
string
]
string
{
func
requiredArgs
()
map
[
string
]
string
{
return
map
[
string
]
string
{
return
map
[
string
]
string
{
"--l1-eth-rpc"
:
l1EthRpc
,
"--agree-with-proposed-output"
:
agreeWithProposedOutput
,
"--game-address"
:
gameAddressValue
,
"--l1-eth-rpc"
:
l1EthRpc
,
"--alphabet"
:
alphabetTrace
,
"--game-address"
:
gameAddressValue
,
"--alphabet"
:
alphabetTrace
,
}
}
}
}
func
toArgList
(
req
map
[
string
]
string
)
[]
string
{
func
toArgList
(
req
map
[
string
]
string
)
[]
string
{
var
combined
[]
string
var
combined
[]
string
for
name
,
value
:=
range
req
{
for
name
,
value
:=
range
req
{
combined
=
append
(
combined
,
name
)
combined
=
append
(
combined
,
fmt
.
Sprintf
(
"%s=%s"
,
name
,
value
))
combined
=
append
(
combined
,
value
)
}
}
return
combined
return
combined
}
}
op-challenger/config/config.go
View file @
051aa24d
...
@@ -21,22 +21,26 @@ var (
...
@@ -21,22 +21,26 @@ var (
// This also contains config options for auxiliary services.
// This also contains config options for auxiliary services.
// It is used to initialize the challenger.
// It is used to initialize the challenger.
type
Config
struct
{
type
Config
struct
{
L1EthRpc
string
// L1 RPC Url
L1EthRpc
string
// L1 RPC Url
GameAddress
common
.
Address
// Address of the fault game
GameAddress
common
.
Address
// Address of the fault game
AlphabetTrace
string
// String for the AlphabetTraceProvider
AlphabetTrace
string
// String for the AlphabetTraceProvider
AgreeWithProposedOutput
bool
// Temporary config if we agree or disagree with the posted output
TxMgrConfig
txmgr
.
CLIConfig
TxMgrConfig
txmgr
.
CLIConfig
}
}
func
NewConfig
(
l1EthRpc
string
,
func
NewConfig
(
l1EthRpc
string
,
GameAddress
common
.
Address
,
GameAddress
common
.
Address
,
AlphabetTrace
string
,
AlphabetTrace
string
,
AgreeWithProposedOutput
bool
,
)
Config
{
)
Config
{
return
Config
{
return
Config
{
L1EthRpc
:
l1EthRpc
,
L1EthRpc
:
l1EthRpc
,
GameAddress
:
GameAddress
,
GameAddress
:
GameAddress
,
AlphabetTrace
:
AlphabetTrace
,
AlphabetTrace
:
AlphabetTrace
,
TxMgrConfig
:
txmgr
.
NewCLIConfig
(
l1EthRpc
),
TxMgrConfig
:
txmgr
.
NewCLIConfig
(
l1EthRpc
),
AgreeWithProposedOutput
:
AgreeWithProposedOutput
,
}
}
}
}
...
@@ -70,9 +74,10 @@ func NewConfigFromCLI(ctx *cli.Context) (*Config, error) {
...
@@ -70,9 +74,10 @@ func NewConfigFromCLI(ctx *cli.Context) (*Config, error) {
return
&
Config
{
return
&
Config
{
// Required Flags
// Required Flags
L1EthRpc
:
ctx
.
String
(
flags
.
L1EthRpcFlag
.
Name
),
L1EthRpc
:
ctx
.
String
(
flags
.
L1EthRpcFlag
.
Name
),
GameAddress
:
dgfAddress
,
GameAddress
:
dgfAddress
,
AlphabetTrace
:
ctx
.
String
(
flags
.
AlphabetFlag
.
Name
),
AlphabetTrace
:
ctx
.
String
(
flags
.
AlphabetFlag
.
Name
),
TxMgrConfig
:
txMgrConfig
,
AgreeWithProposedOutput
:
ctx
.
Bool
(
flags
.
AgreeWithProposedOutputFlag
.
Name
),
TxMgrConfig
:
txMgrConfig
,
},
nil
},
nil
}
}
op-challenger/config/config_test.go
View file @
051aa24d
...
@@ -9,13 +9,14 @@ import (
...
@@ -9,13 +9,14 @@ import (
)
)
var
(
var
(
validL1EthRpc
=
"http://localhost:8545"
validL1EthRpc
=
"http://localhost:8545"
validGameAddress
=
common
.
HexToAddress
(
"0x7bdd3b028C4796eF0EAf07d11394d0d9d8c24139"
)
validGameAddress
=
common
.
HexToAddress
(
"0x7bdd3b028C4796eF0EAf07d11394d0d9d8c24139"
)
validAlphabetTrace
=
"abcdefgh"
validAlphabetTrace
=
"abcdefgh"
agreeWithProposedOutput
=
true
)
)
func
validConfig
()
Config
{
func
validConfig
()
Config
{
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
validAlphabetTrace
)
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
validAlphabetTrace
,
agreeWithProposedOutput
)
return
cfg
return
cfg
}
}
...
...
op-challenger/fault/agent.go
View file @
051aa24d
...
@@ -9,22 +9,24 @@ import (
...
@@ -9,22 +9,24 @@ import (
)
)
type
Agent
struct
{
type
Agent
struct
{
solver
*
Solver
solver
*
Solver
trace
TraceProvider
trace
TraceProvider
loader
Loader
loader
Loader
responder
Responder
responder
Responder
maxDepth
int
maxDepth
int
log
log
.
Logger
agreeWithProposedOutput
bool
log
log
.
Logger
}
}
func
NewAgent
(
loader
Loader
,
maxDepth
int
,
trace
TraceProvider
,
responder
Responder
,
log
log
.
Logger
)
Agent
{
func
NewAgent
(
loader
Loader
,
maxDepth
int
,
trace
TraceProvider
,
responder
Responder
,
agreeWithProposedOutput
bool
,
log
log
.
Logger
)
Agent
{
return
Agent
{
return
Agent
{
solver
:
NewSolver
(
maxDepth
,
trace
),
solver
:
NewSolver
(
maxDepth
,
trace
),
trace
:
trace
,
trace
:
trace
,
loader
:
loader
,
loader
:
loader
,
responder
:
responder
,
responder
:
responder
,
maxDepth
:
maxDepth
,
maxDepth
:
maxDepth
,
log
:
log
,
agreeWithProposedOutput
:
agreeWithProposedOutput
,
log
:
log
,
}
}
}
}
...
@@ -59,7 +61,7 @@ func (a *Agent) newGameFromContracts(ctx context.Context) (Game, error) {
...
@@ -59,7 +61,7 @@ func (a *Agent) newGameFromContracts(ctx context.Context) (Game, error) {
if
len
(
claims
)
==
0
{
if
len
(
claims
)
==
0
{
return
nil
,
errors
.
New
(
"no claims"
)
return
nil
,
errors
.
New
(
"no claims"
)
}
}
game
:=
NewGameState
(
claims
[
0
],
uint64
(
a
.
maxDepth
))
game
:=
NewGameState
(
a
.
agreeWithProposedOutput
,
claims
[
0
],
uint64
(
a
.
maxDepth
))
if
err
:=
game
.
PutAll
(
claims
[
1
:
]);
err
!=
nil
{
if
err
:=
game
.
PutAll
(
claims
[
1
:
]);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to load claims into the local state: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to load claims into the local state: %w"
,
err
)
}
}
...
...
op-challenger/fault/cmd/examples/full.go
View file @
051aa24d
...
@@ -26,6 +26,6 @@ func FullGame() {
...
@@ -26,6 +26,6 @@ func FullGame() {
},
},
}
}
o
:=
fault
.
NewOrchestrator
(
maxDepth
,
[]
fault
.
TraceProvider
{
canonicalProvider
,
disputedProvider
},
[]
string
{
"charlie"
,
"mallory"
},
root
)
o
:=
fault
.
NewOrchestrator
(
maxDepth
,
[]
fault
.
TraceProvider
{
canonicalProvider
,
disputedProvider
},
[]
string
{
"charlie"
,
"mallory"
},
[]
bool
{
false
,
true
},
root
)
o
.
Start
()
o
.
Start
()
}
}
op-challenger/fault/game.go
View file @
051aa24d
...
@@ -43,23 +43,37 @@ type extendedClaim struct {
...
@@ -43,23 +43,37 @@ type extendedClaim struct {
// gameState is a struct that represents the state of a dispute game.
// gameState is a struct that represents the state of a dispute game.
// The game state implements the [Game] interface.
// The game state implements the [Game] interface.
type
gameState
struct
{
type
gameState
struct
{
root
ClaimData
agreeWithProposedOutput
bool
claims
map
[
ClaimData
]
*
extendedClaim
root
ClaimData
depth
uint64
claims
map
[
ClaimData
]
*
extendedClaim
depth
uint64
}
}
// NewGameState returns a new game state.
// NewGameState returns a new game state.
// The provided [Claim] is used as the root node.
// The provided [Claim] is used as the root node.
func
NewGameState
(
root
Claim
,
depth
uint64
)
*
gameState
{
func
NewGameState
(
agreeWithProposedOutput
bool
,
root
Claim
,
depth
uint64
)
*
gameState
{
claims
:=
make
(
map
[
ClaimData
]
*
extendedClaim
)
claims
:=
make
(
map
[
ClaimData
]
*
extendedClaim
)
claims
[
root
.
ClaimData
]
=
&
extendedClaim
{
claims
[
root
.
ClaimData
]
=
&
extendedClaim
{
self
:
root
,
self
:
root
,
children
:
make
([]
ClaimData
,
0
),
children
:
make
([]
ClaimData
,
0
),
}
}
return
&
gameState
{
return
&
gameState
{
root
:
root
.
ClaimData
,
agreeWithProposedOutput
:
agreeWithProposedOutput
,
claims
:
claims
,
root
:
root
.
ClaimData
,
depth
:
depth
,
claims
:
claims
,
depth
:
depth
,
}
}
// AgreeWithLevel returns if the game state agrees with the provided claim level.
func
(
g
*
gameState
)
AgreeWithClaimLevel
(
claim
Claim
)
bool
{
isOddLevel
:=
claim
.
Depth
()
%
2
==
1
// If we agree with the proposed output, we agree with odd levels
// If we disagree with the proposed output, we agree with the root claim level & even levels
if
g
.
agreeWithProposedOutput
{
return
isOddLevel
}
else
{
return
!
isOddLevel
}
}
}
}
...
@@ -79,7 +93,8 @@ func (g *gameState) Put(claim Claim) error {
...
@@ -79,7 +93,8 @@ func (g *gameState) Put(claim Claim) error {
if
claim
.
IsRoot
()
||
g
.
IsDuplicate
(
claim
)
{
if
claim
.
IsRoot
()
||
g
.
IsDuplicate
(
claim
)
{
return
ErrClaimExists
return
ErrClaimExists
}
}
if
parent
,
ok
:=
g
.
claims
[
claim
.
Parent
];
!
ok
{
parent
,
ok
:=
g
.
claims
[
claim
.
Parent
]
if
!
ok
{
return
errors
.
New
(
"no parent claim"
)
return
errors
.
New
(
"no parent claim"
)
}
else
{
}
else
{
parent
.
children
=
append
(
parent
.
children
,
claim
.
ClaimData
)
parent
.
children
=
append
(
parent
.
children
,
claim
.
ClaimData
)
...
...
op-challenger/fault/game_test.go
View file @
051aa24d
...
@@ -48,7 +48,7 @@ func createTestClaims() (Claim, Claim, Claim, Claim) {
...
@@ -48,7 +48,7 @@ func createTestClaims() (Claim, Claim, Claim, Claim) {
func
TestIsDuplicate
(
t
*
testing
.
T
)
{
func
TestIsDuplicate
(
t
*
testing
.
T
)
{
// Setup the game state.
// Setup the game state.
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
top
))
// Root + Top should be duplicates
// Root + Top should be duplicates
...
@@ -65,7 +65,7 @@ func TestIsDuplicate(t *testing.T) {
...
@@ -65,7 +65,7 @@ func TestIsDuplicate(t *testing.T) {
func
TestGame_Put_RootAlreadyExists
(
t
*
testing
.
T
)
{
func
TestGame_Put_RootAlreadyExists
(
t
*
testing
.
T
)
{
// Setup the game state.
// Setup the game state.
top
,
_
,
_
,
_
:=
createTestClaims
()
top
,
_
,
_
,
_
:=
createTestClaims
()
g
:=
NewGameState
(
top
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
top
,
testMaxDepth
)
// Try to put the root claim into the game state again.
// Try to put the root claim into the game state again.
err
:=
g
.
Put
(
top
)
err
:=
g
.
Put
(
top
)
...
@@ -77,7 +77,7 @@ func TestGame_Put_RootAlreadyExists(t *testing.T) {
...
@@ -77,7 +77,7 @@ func TestGame_Put_RootAlreadyExists(t *testing.T) {
func
TestGame_PutAll_RootAlreadyExists
(
t
*
testing
.
T
)
{
func
TestGame_PutAll_RootAlreadyExists
(
t
*
testing
.
T
)
{
// Setup the game state.
// Setup the game state.
root
,
_
,
_
,
_
:=
createTestClaims
()
root
,
_
,
_
,
_
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
// Try to put the root claim into the game state again.
// Try to put the root claim into the game state again.
err
:=
g
.
PutAll
([]
Claim
{
root
})
err
:=
g
.
PutAll
([]
Claim
{
root
})
...
@@ -88,7 +88,7 @@ func TestGame_PutAll_RootAlreadyExists(t *testing.T) {
...
@@ -88,7 +88,7 @@ func TestGame_PutAll_RootAlreadyExists(t *testing.T) {
// instance errors when the given claim already exists in state.
// instance errors when the given claim already exists in state.
func
TestGame_PutAll_AlreadyExists
(
t
*
testing
.
T
)
{
func
TestGame_PutAll_AlreadyExists
(
t
*
testing
.
T
)
{
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
err
:=
g
.
PutAll
([]
Claim
{
top
,
middle
})
err
:=
g
.
PutAll
([]
Claim
{
top
,
middle
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -101,7 +101,7 @@ func TestGame_PutAll_AlreadyExists(t *testing.T) {
...
@@ -101,7 +101,7 @@ func TestGame_PutAll_AlreadyExists(t *testing.T) {
func
TestGame_PutAll_ParentsAndChildren
(
t
*
testing
.
T
)
{
func
TestGame_PutAll_ParentsAndChildren
(
t
*
testing
.
T
)
{
// Setup the game state.
// Setup the game state.
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
// We should not be able to get the parent of the root claim.
// We should not be able to get the parent of the root claim.
parent
,
err
:=
g
.
getParent
(
root
)
parent
,
err
:=
g
.
getParent
(
root
)
...
@@ -127,7 +127,7 @@ func TestGame_PutAll_ParentsAndChildren(t *testing.T) {
...
@@ -127,7 +127,7 @@ func TestGame_PutAll_ParentsAndChildren(t *testing.T) {
func
TestGame_Put_AlreadyExists
(
t
*
testing
.
T
)
{
func
TestGame_Put_AlreadyExists
(
t
*
testing
.
T
)
{
// Setup the game state.
// Setup the game state.
top
,
middle
,
_
,
_
:=
createTestClaims
()
top
,
middle
,
_
,
_
:=
createTestClaims
()
g
:=
NewGameState
(
top
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
top
,
testMaxDepth
)
// Put the next claim into state.
// Put the next claim into state.
err
:=
g
.
Put
(
middle
)
err
:=
g
.
Put
(
middle
)
...
@@ -142,7 +142,7 @@ func TestGame_Put_AlreadyExists(t *testing.T) {
...
@@ -142,7 +142,7 @@ func TestGame_Put_AlreadyExists(t *testing.T) {
func
TestGame_Put_ParentsAndChildren
(
t
*
testing
.
T
)
{
func
TestGame_Put_ParentsAndChildren
(
t
*
testing
.
T
)
{
// Setup the game state.
// Setup the game state.
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
// We should not be able to get the parent of the root claim.
// We should not be able to get the parent of the root claim.
parent
,
err
:=
g
.
getParent
(
root
)
parent
,
err
:=
g
.
getParent
(
root
)
...
@@ -175,7 +175,7 @@ func TestGame_Put_ParentsAndChildren(t *testing.T) {
...
@@ -175,7 +175,7 @@ func TestGame_Put_ParentsAndChildren(t *testing.T) {
func
TestGame_ClaimPairs
(
t
*
testing
.
T
)
{
func
TestGame_ClaimPairs
(
t
*
testing
.
T
)
{
// Setup the game state.
// Setup the game state.
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
// Add top claim to the game state.
// Add top claim to the game state.
err
:=
g
.
Put
(
top
)
err
:=
g
.
Put
(
top
)
...
@@ -199,7 +199,7 @@ func TestGame_ClaimPairs(t *testing.T) {
...
@@ -199,7 +199,7 @@ func TestGame_ClaimPairs(t *testing.T) {
// those functions return an error.
// those functions return an error.
func
TestPrePostStateOnlyOnLeafClaim
(
t
*
testing
.
T
)
{
func
TestPrePostStateOnlyOnLeafClaim
(
t
*
testing
.
T
)
{
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
PutAll
([]
Claim
{
top
,
middle
,
bottom
}))
require
.
NoError
(
t
,
g
.
PutAll
([]
Claim
{
top
,
middle
,
bottom
}))
_
,
err
:=
g
.
PreStateClaim
(
middle
)
_
,
err
:=
g
.
PreStateClaim
(
middle
)
...
@@ -210,7 +210,7 @@ func TestPrePostStateOnlyOnLeafClaim(t *testing.T) {
...
@@ -210,7 +210,7 @@ func TestPrePostStateOnlyOnLeafClaim(t *testing.T) {
func
TestPreStateClaim
(
t
*
testing
.
T
)
{
func
TestPreStateClaim
(
t
*
testing
.
T
)
{
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
...
@@ -224,7 +224,7 @@ func TestPreStateClaim(t *testing.T) {
...
@@ -224,7 +224,7 @@ func TestPreStateClaim(t *testing.T) {
func
TestPostStateClaim
(
t
*
testing
.
T
)
{
func
TestPostStateClaim
(
t
*
testing
.
T
)
{
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
...
@@ -234,3 +234,27 @@ func TestPostStateClaim(t *testing.T) {
...
@@ -234,3 +234,27 @@ func TestPostStateClaim(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
middle
,
post
)
require
.
Equal
(
t
,
middle
,
post
)
}
}
func
TestAgreeWithClaimLevelDisagreeWithOutput
(
t
*
testing
.
T
)
{
// Setup the game state.
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
PutAll
([]
Claim
{
top
,
middle
,
bottom
}))
require
.
True
(
t
,
g
.
AgreeWithClaimLevel
(
root
))
require
.
False
(
t
,
g
.
AgreeWithClaimLevel
(
top
))
require
.
True
(
t
,
g
.
AgreeWithClaimLevel
(
middle
))
require
.
False
(
t
,
g
.
AgreeWithClaimLevel
(
bottom
))
}
func
TestAgreeWithClaimLevelAgreeWithOutput
(
t
*
testing
.
T
)
{
// Setup the game state.
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
true
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
PutAll
([]
Claim
{
top
,
middle
,
bottom
}))
require
.
False
(
t
,
g
.
AgreeWithClaimLevel
(
root
))
require
.
True
(
t
,
g
.
AgreeWithClaimLevel
(
top
))
require
.
False
(
t
,
g
.
AgreeWithClaimLevel
(
middle
))
require
.
True
(
t
,
g
.
AgreeWithClaimLevel
(
bottom
))
}
op-challenger/fault/orchestrator.go
View file @
051aa24d
...
@@ -15,7 +15,7 @@ type Orchestrator struct {
...
@@ -15,7 +15,7 @@ type Orchestrator struct {
claimLen
,
stepLen
,
step
int
claimLen
,
stepLen
,
step
int
}
}
func
NewOrchestrator
(
maxDepth
uint64
,
traces
[]
TraceProvider
,
names
[]
string
,
root
Claim
)
Orchestrator
{
func
NewOrchestrator
(
maxDepth
uint64
,
traces
[]
TraceProvider
,
names
[]
string
,
agreeWithProposedOutput
[]
bool
,
root
Claim
)
Orchestrator
{
o
:=
Orchestrator
{
o
:=
Orchestrator
{
agents
:
make
([]
Agent
,
len
(
traces
)),
agents
:
make
([]
Agent
,
len
(
traces
)),
claims
:
[]
Claim
{
root
},
claims
:
[]
Claim
{
root
},
...
@@ -23,7 +23,7 @@ func NewOrchestrator(maxDepth uint64, traces []TraceProvider, names []string, ro
...
@@ -23,7 +23,7 @@ func NewOrchestrator(maxDepth uint64, traces []TraceProvider, names []string, ro
}
}
log
.
Info
(
"Starting game"
,
"root_letter"
,
string
(
root
.
Value
[
31
:
]))
log
.
Info
(
"Starting game"
,
"root_letter"
,
string
(
root
.
Value
[
31
:
]))
for
i
,
trace
:=
range
traces
{
for
i
,
trace
:=
range
traces
{
o
.
agents
[
i
]
=
NewAgent
(
&
o
,
int
(
maxDepth
),
trace
,
&
o
,
log
.
New
(
"role"
,
names
[
i
]))
o
.
agents
[
i
]
=
NewAgent
(
&
o
,
int
(
maxDepth
),
trace
,
&
o
,
agreeWithProposedOutput
[
i
],
log
.
New
(
"role"
,
names
[
i
]))
}
}
return
o
return
o
}
}
...
...
op-challenger/fault/solver_test.go
View file @
051aa24d
...
@@ -85,7 +85,7 @@ func TestAttemptStep(t *testing.T) {
...
@@ -85,7 +85,7 @@ func TestAttemptStep(t *testing.T) {
canonicalProvider
:=
NewAlphabetProvider
(
"abcdefgh"
,
uint64
(
maxDepth
))
canonicalProvider
:=
NewAlphabetProvider
(
"abcdefgh"
,
uint64
(
maxDepth
))
solver
:=
NewSolver
(
maxDepth
,
canonicalProvider
)
solver
:=
NewSolver
(
maxDepth
,
canonicalProvider
)
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
root
,
testMaxDepth
)
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
...
...
op-challenger/flags/flags.go
View file @
051aa24d
...
@@ -33,6 +33,11 @@ var (
...
@@ -33,6 +33,11 @@ var (
Usage
:
"Alphabet Trace (temporary)"
,
Usage
:
"Alphabet Trace (temporary)"
,
EnvVars
:
prefixEnvVars
(
"ALPHABET"
),
EnvVars
:
prefixEnvVars
(
"ALPHABET"
),
}
}
AgreeWithProposedOutputFlag
=
&
cli
.
BoolFlag
{
Name
:
"agree-with-proposed-output"
,
Usage
:
"Temporary hardcoded flag if we agree or disagree with the proposed output."
,
EnvVars
:
prefixEnvVars
(
"AGREE_WITH_PROPOSED_OUTPUT"
),
}
// Optional Flags
// Optional Flags
)
)
...
@@ -41,6 +46,7 @@ var requiredFlags = []cli.Flag{
...
@@ -41,6 +46,7 @@ var requiredFlags = []cli.Flag{
L1EthRpcFlag
,
L1EthRpcFlag
,
DGFAddressFlag
,
DGFAddressFlag
,
AlphabetFlag
,
AlphabetFlag
,
AgreeWithProposedOutputFlag
,
}
}
// optionalFlags is a list of unchecked cli flags
// optionalFlags is a list of unchecked cli flags
...
...
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