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
868e8aa2
Unverified
Commit
868e8aa2
authored
Sep 01, 2023
by
mergify[bot]
Committed by
GitHub
Sep 01, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into aj/no-move-on-lost-games
parents
de34fa50
7303bef5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
0 deletions
+103
-0
README.md
op-challenger/README.md
+43
-0
list_games.sh
op-challenger/scripts/list_games.sh
+37
-0
resolve.sh
op-challenger/scripts/resolve.sh
+23
-0
No files found.
op-challenger/README.md
View file @
868e8aa2
...
...
@@ -28,6 +28,23 @@ This are not intended to be used in production, only to support manual testing a
dispute games work. They also serve as examples of how to use
`cast`
to manually interact with the dispute game
contracts.
### Understanding Revert Reasons
When actions performed by these scripts fails, they typically print a message that includes the
abi encoded revert reason provided by the contract. e.g.
```
Error:
(code: 3, message: execution reverted, data: Some(String("0x67fe1950")))
```
The
`cast 4byte`
command can be used to decode these revert reasons. e.g.
```
shell
$
cast 4byte 0x67fe1950
GameNotInProgress
()
```
### Dependencies
These scripts assume that the following tools are installed and available on the current
`PATH`
:
...
...
@@ -78,6 +95,32 @@ Performs a move to either attack or defend the latest claim in the specified gam
These arguments must specify a way for
`cast`
to sign the transactions.
See
`cast send --help`
for supported options.
### [resolve.sh](scripts/resolve.sh)
```
shell
./scripts/resolve.sh <RPC_URL> <GAME_ADDRESS> <SIGNER_ARGS>...
```
Resolves a dispute game. Note that this will fail if the dispute game has already been resolved
or if the clocks have not yet expired and further moves are possible.
If the game is resolved successfully, the result is printed.
*
`RPC_URL`
- the RPC endpoint of the L1 endpoint to use (e.g.
`http://localhost:8545`
).
*
`GAME_ADDRESS`
- the address of the dispute game to resolve.
*
`SIGNER_ARGS`
the remaining args are past as arguments to
`cast`
when sending transactions.
These arguments must specify a way for
`cast`
to sign the transactions.
See
`cast send --help`
for supported options.
### [list_games.sh](scripts/list_games.sh)
```
shell
./scripts/list_games.sh <RPC> <GAME_FACTORY_ADDRESS>
```
Prints the games created by the game factory along with their current status.
*
`RPC_URL`
- the RPC endpoint of the L1 endpoint to use (e.g.
`http://localhost:8545`
).
*
`GAME_FACTORY_ADDRESS`
- the address of the dispute game factory contract on L1.
### [list_claims.sh](scripts/list_claims.sh)
...
...
op-challenger/scripts/list_games.sh
0 → 100755
View file @
868e8aa2
#!/usr/bin/env bash
set
-euo
pipefail
RPC
=
${
1
:?Must
specify RPC address
}
FACTORY_ADDR
=
${
2
:?Must
specify dispute game factory address
}
COUNT
=
$(
cast call
--rpc-url
"
${
RPC
}
"
"
${
FACTORY_ADDR
}
"
'gameCount() returns(uint256)'
)
echo
"Game count:
${
COUNT
}
"
if
[[
"
${
COUNT
}
"
==
"0"
]]
then
exit
fi
((
COUNT
=
COUNT-1
))
for
i
in
$(
seq
0
"
${
COUNT
}
"
)
do
GAME
=
$(
cast call
--rpc-url
"
${
RPC
}
"
"
${
FACTORY_ADDR
}
"
'gameAtIndex(uint256) returns(uint8, uint64, address)'
"
${
i
}
"
)
SAVEIFS
=
$IFS
# Save current IFS (Internal Field Separator)
IFS
=
$'
\n
'
# Change IFS to newline char
GAME
=(
$GAME
)
# split the string into an array by the same name
IFS
=
$SAVEIFS
# Restore original IFS
GAME_ADDR
=
"
${
GAME
[2]
}
"
STATUS
=
$(
cast call
--rpc-url
"
${
RPC
}
"
"
${
GAME_ADDR
}
"
"status() return(uint8)"
| cast to-dec
)
if
[[
"
${
STATUS
}
"
==
"0"
]]
then
STATUS
=
"In Progress"
elif
[[
"
${
STATUS
}
"
==
"1"
]]
then
STATUS
=
"Challenger Wins"
elif
[[
"
${
STATUS
}
"
==
"2"
]]
then
STATUS
=
"Defender Wins"
fi
echo
"
${
i
}
Game:
${
GAME_ADDR
}
Type:
${
GAME
[0]
}
Created:
${
GAME
[1]
}
Status:
${
STATUS
}
"
done
op-challenger/scripts/resolve.sh
0 → 100755
View file @
868e8aa2
#!/bin/bash
set
-euo
pipefail
RPC
=
${
1
:?Must
specify RPC URL
}
GAME_ADDR
=
${
2
:?Must
specify game address
}
SIGNER_ARGS
=
"
${
@
:3
}
"
# Perform the move.
RESULT_DATA
=
$(
cast send
--rpc-url
"
${
RPC
}
"
${
SIGNER_ARGS
}
"
${
GAME_ADDR
}
"
"resolve()"
--json
)
RESULT
=
$(
echo
"
${
RESULT_DATA
}
"
| jq
-r
'.logs[0].topics[1]'
| cast to-dec
)
if
[[
"
${
RESULT
}
"
==
"0"
]]
then
RESULT
=
"In Progress"
elif
[[
"
${
RESULT
}
"
==
"1"
]]
then
RESULT
=
"Challenger Wins"
elif
[[
"
${
RESULT
}
"
==
"2"
]]
then
RESULT
=
"Defender Wins"
fi
echo
"Result:
$RESULT
"
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