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
5f3a2caa
Commit
5f3a2caa
authored
Jul 19, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the game depth configurable via a CLI flag.
parent
8d720b21
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
48 deletions
+46
-48
README.md
op-challenger/README.md
+0
-32
challenger.go
op-challenger/challenger.go
+2
-3
charlie.sh
op-challenger/charlie.sh
+8
-1
main_test.go
op-challenger/cmd/main_test.go
+16
-2
config.go
op-challenger/config/config.go
+4
-0
config_test.go
op-challenger/config/config_test.go
+2
-1
flags.go
op-challenger/flags/flags.go
+6
-0
init_game.sh
op-challenger/init_game.sh
+0
-7
mallory.sh
op-challenger/mallory.sh
+8
-2
No files found.
op-challenger/README.md
View file @
5f3a2caa
...
@@ -20,35 +20,3 @@ to see a list of available options.
...
@@ -20,35 +20,3 @@ to see a list of available options.
`op-challenger`
is configurable via command line flags and environment variables. The help menu
`op-challenger`
is configurable via command line flags and environment variables. The help menu
shows the available config options and can be accessed by running
`./op-challenger --help`
.
shows the available config options and can be accessed by running
`./op-challenger --help`
.
Note that there are many global options, but the most important ones are:
-
`OP_CHALLENGER_L1_ETH_RPC`
: An L1 Ethereum RPC URL
-
`OP_CHALLENGER_ROLLUP_RPC`
: A Rollup Node RPC URL
-
`OP_CHALLENGER_L2OO_ADDRESS`
: The L2OutputOracle Contract Address
-
`OP_CHALLENGER_DGF_ADDRESS`
: Dispute Game Factory Contract Address
Here is a reduced output from running
`./op-challenger --help`
:
```
bash
NAME:
op-challenger - Modular Challenger Agent
USAGE:
main
[
global options]
command
[
command
options]
[
arguments...]
VERSION:
1.0.0
DESCRIPTION:
A modular op-stack challenge agent
for
output dispute games written
in
golang.
COMMANDS:
help
, h Shows a list of commands or
help
for
one
command
GLOBAL OPTIONS:
--l1-eth-rpc
value HTTP provider URL
for
L1.
[
$OP_CHALLENGER_L1_ETH_RPC
]
--rollup-rpc
value HTTP provider URL
for
the rollup node.
[
$OP_CHALLENGER_ROLLUP_RPC
]
--l2oo-address
value Address of the L2OutputOracle contract.
[
$OP_CHALLENGER_L2OO_ADDRESS
]
--dgf-address
value Address of the DisputeGameFactory contract.
[
$OP_CHALLENGER_DGF_ADDRESS
]
...
--help
,
-h
show
help
--version
,
-v
print the version
```
op-challenger/challenger.go
View file @
5f3a2caa
...
@@ -35,10 +35,9 @@ func Main(logger log.Logger, cfg *config.Config) error {
...
@@ -35,10 +35,9 @@ func Main(logger log.Logger, cfg *config.Config) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to create the responder: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to create the responder: %w"
,
err
)
}
}
gameDepth
:=
4
trace
:=
fault
.
NewAlphabetProvider
(
cfg
.
AlphabetTrace
,
uint64
(
cfg
.
GameDepth
))
trace
:=
fault
.
NewAlphabetProvider
(
cfg
.
AlphabetTrace
,
uint64
(
gameDepth
))
agent
:=
fault
.
NewAgent
(
loader
,
g
ameDepth
,
trace
,
responder
,
cfg
.
AgreeWithProposedOutput
,
logger
)
agent
:=
fault
.
NewAgent
(
loader
,
cfg
.
G
ameDepth
,
trace
,
responder
,
cfg
.
AgreeWithProposedOutput
,
logger
)
caller
,
err
:=
fault
.
NewFaultCallerFromBindings
(
cfg
.
GameAddress
,
client
,
logger
)
caller
,
err
:=
fault
.
NewFaultCallerFromBindings
(
cfg
.
GameAddress
,
client
,
logger
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
op-challenger/charlie.sh
View file @
5f3a2caa
...
@@ -14,4 +14,11 @@ MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
...
@@ -14,4 +14,11 @@ MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
FAULT_GAME_ADDRESS
=
"0x8daf17a20c9dba35f005b6324f493785d239719d"
FAULT_GAME_ADDRESS
=
"0x8daf17a20c9dba35f005b6324f493785d239719d"
./bin/op-challenger
--l1-eth-rpc
http://localhost:8545
--alphabet
"abcdefgh"
--game-address
$FAULT_GAME_ADDRESS
--private-key
$CHARLIE_KEY
--num-confirmations
1
--agree-with-proposed-output
=
true
./bin/op-challenger
\
--l1-eth-rpc
http://localhost:8545
\
--alphabet
"abcdefgh"
\
--game-address
$FAULT_GAME_ADDRESS
\
--private-key
$CHARLIE_KEY
\
--num-confirmations
1
\
--game-depth
4
\
--agree-with-proposed-output
=
true
op-challenger/cmd/main_test.go
View file @
5f3a2caa
...
@@ -16,6 +16,7 @@ var (
...
@@ -16,6 +16,7 @@ var (
gameAddressValue
=
"0xaa00000000000000000000000000000000000000"
gameAddressValue
=
"0xaa00000000000000000000000000000000000000"
alphabetTrace
=
"abcdefghijz"
alphabetTrace
=
"abcdefghijz"
agreeWithProposedOutput
=
"true"
agreeWithProposedOutput
=
"true"
gameDepth
=
"4"
)
)
func
TestLogLevel
(
t
*
testing
.
T
)
{
func
TestLogLevel
(
t
*
testing
.
T
)
{
...
@@ -35,12 +36,12 @@ func TestLogLevel(t *testing.T) {
...
@@ -35,12 +36,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
,
true
)
defaultCfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
alphabetTrace
,
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
),
alphabetTrace
,
true
)
cfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
alphabetTrace
,
true
,
4
)
require
.
NoError
(
t
,
cfg
.
Check
())
require
.
NoError
(
t
,
cfg
.
Check
())
}
}
...
@@ -109,6 +110,18 @@ func TestAgreeWithProposedOutput(t *testing.T) {
...
@@ -109,6 +110,18 @@ func TestAgreeWithProposedOutput(t *testing.T) {
})
})
}
}
func
TestGameDepth
(
t
*
testing
.
T
)
{
t
.
Run
(
"Required"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag game-depth is required"
,
addRequiredArgsExcept
(
"--game-depth"
))
})
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
value
:=
"4"
cfg
:=
configForArgs
(
t
,
addRequiredArgsExcept
(
"--game-depth"
,
"--game-depth="
+
value
))
require
.
Equal
(
t
,
value
,
fmt
.
Sprint
(
cfg
.
GameDepth
))
})
}
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
)
...
@@ -146,6 +159,7 @@ func addRequiredArgsExcept(name string, optionalArgs ...string) []string {
...
@@ -146,6 +159,7 @@ 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
{
"--game-depth"
:
gameDepth
,
"--agree-with-proposed-output"
:
agreeWithProposedOutput
,
"--agree-with-proposed-output"
:
agreeWithProposedOutput
,
"--l1-eth-rpc"
:
l1EthRpc
,
"--l1-eth-rpc"
:
l1EthRpc
,
"--game-address"
:
gameAddressValue
,
"--game-address"
:
gameAddressValue
,
...
...
op-challenger/config/config.go
View file @
5f3a2caa
...
@@ -25,6 +25,7 @@ type Config struct {
...
@@ -25,6 +25,7 @@ type Config struct {
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
AgreeWithProposedOutput
bool
// Temporary config if we agree or disagree with the posted output
GameDepth
int
// Depth of the game tree
TxMgrConfig
txmgr
.
CLIConfig
TxMgrConfig
txmgr
.
CLIConfig
}
}
...
@@ -34,6 +35,7 @@ func NewConfig(
...
@@ -34,6 +35,7 @@ func NewConfig(
GameAddress
common
.
Address
,
GameAddress
common
.
Address
,
AlphabetTrace
string
,
AlphabetTrace
string
,
AgreeWithProposedOutput
bool
,
AgreeWithProposedOutput
bool
,
GameDepth
int
,
)
Config
{
)
Config
{
return
Config
{
return
Config
{
L1EthRpc
:
l1EthRpc
,
L1EthRpc
:
l1EthRpc
,
...
@@ -41,6 +43,7 @@ func NewConfig(
...
@@ -41,6 +43,7 @@ func NewConfig(
AlphabetTrace
:
AlphabetTrace
,
AlphabetTrace
:
AlphabetTrace
,
TxMgrConfig
:
txmgr
.
NewCLIConfig
(
l1EthRpc
),
TxMgrConfig
:
txmgr
.
NewCLIConfig
(
l1EthRpc
),
AgreeWithProposedOutput
:
AgreeWithProposedOutput
,
AgreeWithProposedOutput
:
AgreeWithProposedOutput
,
GameDepth
:
GameDepth
,
}
}
}
}
...
@@ -78,6 +81,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*Config, error) {
...
@@ -78,6 +81,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*Config, error) {
GameAddress
:
dgfAddress
,
GameAddress
:
dgfAddress
,
AlphabetTrace
:
ctx
.
String
(
flags
.
AlphabetFlag
.
Name
),
AlphabetTrace
:
ctx
.
String
(
flags
.
AlphabetFlag
.
Name
),
AgreeWithProposedOutput
:
ctx
.
Bool
(
flags
.
AgreeWithProposedOutputFlag
.
Name
),
AgreeWithProposedOutput
:
ctx
.
Bool
(
flags
.
AgreeWithProposedOutputFlag
.
Name
),
GameDepth
:
ctx
.
Int
(
flags
.
GameDepthFlag
.
Name
),
TxMgrConfig
:
txMgrConfig
,
TxMgrConfig
:
txMgrConfig
,
},
nil
},
nil
}
}
op-challenger/config/config_test.go
View file @
5f3a2caa
...
@@ -13,10 +13,11 @@ var (
...
@@ -13,10 +13,11 @@ var (
validGameAddress
=
common
.
HexToAddress
(
"0x7bdd3b028C4796eF0EAf07d11394d0d9d8c24139"
)
validGameAddress
=
common
.
HexToAddress
(
"0x7bdd3b028C4796eF0EAf07d11394d0d9d8c24139"
)
validAlphabetTrace
=
"abcdefgh"
validAlphabetTrace
=
"abcdefgh"
agreeWithProposedOutput
=
true
agreeWithProposedOutput
=
true
gameDepth
=
4
)
)
func
validConfig
()
Config
{
func
validConfig
()
Config
{
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
validAlphabetTrace
,
agreeWithProposedOutput
)
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
validAlphabetTrace
,
agreeWithProposedOutput
,
gameDepth
)
return
cfg
return
cfg
}
}
...
...
op-challenger/flags/flags.go
View file @
5f3a2caa
...
@@ -38,6 +38,11 @@ var (
...
@@ -38,6 +38,11 @@ var (
Usage
:
"Temporary hardcoded flag if we agree or disagree with the proposed output."
,
Usage
:
"Temporary hardcoded flag if we agree or disagree with the proposed output."
,
EnvVars
:
prefixEnvVars
(
"AGREE_WITH_PROPOSED_OUTPUT"
),
EnvVars
:
prefixEnvVars
(
"AGREE_WITH_PROPOSED_OUTPUT"
),
}
}
GameDepthFlag
=
&
cli
.
IntFlag
{
Name
:
"game-depth"
,
Usage
:
"Depth of the game tree."
,
EnvVars
:
prefixEnvVars
(
"GAME_DEPTH"
),
}
// Optional Flags
// Optional Flags
)
)
...
@@ -47,6 +52,7 @@ var requiredFlags = []cli.Flag{
...
@@ -47,6 +52,7 @@ var requiredFlags = []cli.Flag{
DGFAddressFlag
,
DGFAddressFlag
,
AlphabetFlag
,
AlphabetFlag
,
AgreeWithProposedOutputFlag
,
AgreeWithProposedOutputFlag
,
GameDepthFlag
,
}
}
// optionalFlags is a list of unchecked cli flags
// optionalFlags is a list of unchecked cli flags
...
...
op-challenger/init_game.sh
View file @
5f3a2caa
...
@@ -4,7 +4,6 @@ set -euo pipefail
...
@@ -4,7 +4,6 @@ set -euo pipefail
DIR
=
$(
cd
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
&&
pwd
)
DIR
=
$(
cd
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
&&
pwd
)
cd
"
$DIR
"
cd
"
$DIR
"
# build the challenger to keep it up to date
make
make
cd
..
cd
..
...
@@ -21,21 +20,17 @@ CHARLIE_KEY="74feb147d72bfae943e6b4e483410933d9e447d5dc47d52432dcc2c1454dabb7"
...
@@ -21,21 +20,17 @@ CHARLIE_KEY="74feb147d72bfae943e6b4e483410933d9e447d5dc47d52432dcc2c1454dabb7"
MALLORY_ADDRESS
=
"0x4641c704a6c743f73ee1f36C7568Fbf4b80681e4"
MALLORY_ADDRESS
=
"0x4641c704a6c743f73ee1f36C7568Fbf4b80681e4"
MALLORY_KEY
=
"28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
MALLORY_KEY
=
"28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
echo
"----------------------------------------------------------------"
echo
"----------------------------------------------------------------"
echo
" - Fetching balance of the sponsor"
echo
" - Fetching balance of the sponsor"
echo
" - Balance:
$(
cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
)
"
echo
" - Balance:
$(
cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
)
"
echo
"----------------------------------------------------------------"
echo
"----------------------------------------------------------------"
echo
"Funding Charlie"
echo
"Funding Charlie"
cast send
$CHARLIE_ADDRESS
--value
5ether
--private-key
$DEVNET_SPONSOR
cast send
$CHARLIE_ADDRESS
--value
5ether
--private-key
$DEVNET_SPONSOR
echo
"Funding Mallory"
echo
"Funding Mallory"
cast send
$MALLORY_ADDRESS
--value
5ether
--private-key
$DEVNET_SPONSOR
cast send
$MALLORY_ADDRESS
--value
5ether
--private-key
$DEVNET_SPONSOR
# Fault game type = 0
# Fault game type = 0
GAME_TYPE
=
0
GAME_TYPE
=
0
# Root claim commits to the entire trace.
# Root claim commits to the entire trace.
...
@@ -45,8 +40,6 @@ ROOT_CLAIM=$(cast keccak $(cast abi-encode "f(uint256,uint256)" 15 122))
...
@@ -45,8 +40,6 @@ ROOT_CLAIM=$(cast keccak $(cast abi-encode "f(uint256,uint256)" 15 122))
# Doesn't matter right now since we're not deleting outputs, so just set it to 1
# Doesn't matter right now since we're not deleting outputs, so just set it to 1
EXTRA_DATA
=
$(
cast to-bytes32 1
)
EXTRA_DATA
=
$(
cast to-bytes32 1
)
echo
"Initializing the game"
echo
"Initializing the game"
cast call
--private-key
$MALLORY_KEY
$DISPUTE_GAME_PROXY
"create(uint8,bytes32,bytes)"
$GAME_TYPE
$ROOT_CLAIM
$EXTRA_DATA
cast call
--private-key
$MALLORY_KEY
$DISPUTE_GAME_PROXY
"create(uint8,bytes32,bytes)"
$GAME_TYPE
$ROOT_CLAIM
$EXTRA_DATA
cast send
--private-key
$MALLORY_KEY
$DISPUTE_GAME_PROXY
"create(uint8,bytes32,bytes)"
$GAME_TYPE
$ROOT_CLAIM
$EXTRA_DATA
cast send
--private-key
$MALLORY_KEY
$DISPUTE_GAME_PROXY
"create(uint8,bytes32,bytes)"
$GAME_TYPE
$ROOT_CLAIM
$EXTRA_DATA
op-challenger/mallory.sh
View file @
5f3a2caa
#!/bin/bash
#!/bin/bash
set
-euo
pipefail
set
-euo
pipefail
DIR
=
$(
cd
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
&&
pwd
)
DIR
=
$(
cd
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
&&
pwd
)
cd
"
$DIR
"
cd
"
$DIR
"
...
@@ -15,4 +14,11 @@ MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
...
@@ -15,4 +14,11 @@ MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
FAULT_GAME_ADDRESS
=
"0x8daf17a20c9dba35f005b6324f493785d239719d"
FAULT_GAME_ADDRESS
=
"0x8daf17a20c9dba35f005b6324f493785d239719d"
./bin/op-challenger
--l1-eth-rpc
http://localhost:8545
--alphabet
"abcdexyz"
--game-address
$FAULT_GAME_ADDRESS
--private-key
$MALLORY_KEY
--num-confirmations
1
--agree-with-proposed-output
=
false
./bin/op-challenger
\
--l1-eth-rpc
http://localhost:8545
\
--alphabet
"abcdexyz"
\
--game-address
$FAULT_GAME_ADDRESS
\
--private-key
$MALLORY_KEY
\
--num-confirmations
1
\
--game-depth
4
\
--agree-with-proposed-output
=
false
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