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
51eca4ff
Commit
51eca4ff
authored
Jul 20, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Challenger resolution
parent
5f3aed08
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
6 deletions
+31
-6
challenger.go
op-challenger/challenger.go
+9
-2
agent.go
op-challenger/fault/agent.go
+18
-2
types.go
op-challenger/fault/types.go
+2
-0
devnetL1.json
packages/contracts-bedrock/deploy-config/devnetL1.json
+2
-2
No files found.
op-challenger/challenger.go
View file @
51eca4ff
package
op_challenger
package
op_challenger
import
(
import
(
"context"
"fmt"
"fmt"
"time"
"time"
...
@@ -48,8 +49,14 @@ func Main(logger log.Logger, cfg *config.Config) error {
...
@@ -48,8 +49,14 @@ func Main(logger log.Logger, cfg *config.Config) error {
for
{
for
{
logger
.
Info
(
"Performing action"
)
logger
.
Info
(
"Performing action"
)
_
=
agent
.
Act
()
_
=
agent
.
Act
(
context
.
Background
())
caller
.
LogGameInfo
()
status
,
_
:=
caller
.
GetGameStatus
(
context
.
Background
())
if
status
!=
0
{
caller
.
LogGameStatus
()
return
nil
}
else
{
caller
.
LogGameInfo
()
}
time
.
Sleep
(
300
*
time
.
Millisecond
)
time
.
Sleep
(
300
*
time
.
Millisecond
)
}
}
}
}
op-challenger/fault/agent.go
View file @
51eca4ff
...
@@ -29,8 +29,11 @@ func NewAgent(loader Loader, maxDepth int, trace TraceProvider, responder Respon
...
@@ -29,8 +29,11 @@ func NewAgent(loader Loader, maxDepth int, trace TraceProvider, responder Respon
}
}
// Act iterates the game & performs all of the next actions.
// Act iterates the game & performs all of the next actions.
func
(
a
*
Agent
)
Act
()
error
{
func
(
a
*
Agent
)
Act
(
ctx
context
.
Context
)
error
{
game
,
err
:=
a
.
newGameFromContracts
(
context
.
Background
())
if
a
.
tryResolve
(
ctx
)
{
return
nil
}
game
,
err
:=
a
.
newGameFromContracts
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
a
.
log
.
Error
(
"Failed to create new game"
,
"err"
,
err
)
a
.
log
.
Error
(
"Failed to create new game"
,
"err"
,
err
)
return
err
return
err
...
@@ -50,6 +53,19 @@ func (a *Agent) Act() error {
...
@@ -50,6 +53,19 @@ func (a *Agent) Act() error {
return
nil
return
nil
}
}
// tryResolve resolves the game if it is in a terminal state
// and returns true if the game resolves successfully.
func
(
a
*
Agent
)
tryResolve
(
ctx
context
.
Context
)
bool
{
if
a
.
responder
.
CanResolve
(
ctx
)
{
err
:=
a
.
responder
.
Resolve
(
ctx
)
if
err
!=
nil
{
return
true
}
a
.
log
.
Error
(
"failed to resolve the game"
,
"err"
,
err
)
}
return
false
}
// newGameFromContracts initializes a new game state from the state in the contract
// newGameFromContracts initializes a new game state from the state in the contract
func
(
a
*
Agent
)
newGameFromContracts
(
ctx
context
.
Context
)
(
Game
,
error
)
{
func
(
a
*
Agent
)
newGameFromContracts
(
ctx
context
.
Context
)
(
Game
,
error
)
{
claims
,
err
:=
a
.
loader
.
FetchClaims
(
ctx
)
claims
,
err
:=
a
.
loader
.
FetchClaims
(
ctx
)
...
...
op-challenger/fault/types.go
View file @
51eca4ff
...
@@ -76,6 +76,8 @@ func (c *Claim) DefendsParent() bool {
...
@@ -76,6 +76,8 @@ func (c *Claim) DefendsParent() bool {
// Responder takes a response action & executes.
// Responder takes a response action & executes.
// For full op-challenger this means executing the transaction on chain.
// For full op-challenger this means executing the transaction on chain.
type
Responder
interface
{
type
Responder
interface
{
CanResolve
(
ctx
context
.
Context
)
bool
Resolve
(
ctx
context
.
Context
)
error
Respond
(
ctx
context
.
Context
,
response
Claim
)
error
Respond
(
ctx
context
.
Context
,
response
Claim
)
error
Step
(
ctx
context
.
Context
,
stepData
StepCallData
)
error
Step
(
ctx
context
.
Context
,
stepData
StepCallData
)
error
}
}
packages/contracts-bedrock/deploy-config/devnetL1.json
View file @
51eca4ff
...
@@ -46,5 +46,5 @@
...
@@ -46,5 +46,5 @@
"l2GenesisRegolithTimeOffset"
:
"0x0"
,
"l2GenesisRegolithTimeOffset"
:
"0x0"
,
"faultGameAbsolutePrestate"
:
96
,
"faultGameAbsolutePrestate"
:
96
,
"faultGameMaxDepth"
:
4
,
"faultGameMaxDepth"
:
4
,
"faultGameMaxDuration"
:
604800
"faultGameMaxDuration"
:
120
}
}
\ No newline at end of file
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