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
bf04d9e4
Unverified
Commit
bf04d9e4
authored
Jun 30, 2023
by
OptimismBot
Committed by
GitHub
Jun 30, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6221 from ethereum-optimism/refcell/step-func
feat(op-challenger): Responder Step Function
parents
6036c08e
87617a72
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
6 deletions
+42
-6
orchestrator.go
op-challenger/fault/orchestrator.go
+4
-0
responder.go
op-challenger/fault/responder.go
+28
-6
types.go
op-challenger/fault/types.go
+10
-0
No files found.
op-challenger/fault/orchestrator.go
View file @
bf04d9e4
...
...
@@ -34,6 +34,10 @@ func (o *Orchestrator) Respond(_ context.Context, response Claim) error {
return
nil
}
func
(
o
*
Orchestrator
)
Step
(
ctx
context
.
Context
,
stepData
StepCallData
)
error
{
return
nil
}
func
(
o
*
Orchestrator
)
Start
()
{
for
i
:=
0
;
i
<
len
(
o
.
agents
);
i
++
{
go
runAgent
(
&
o
.
agents
[
i
],
o
.
outputChs
[
i
])
...
...
op-challenger/fault/responder.go
View file @
bf04d9e4
...
...
@@ -74,17 +74,19 @@ func (r *faultResponder) BuildTx(ctx context.Context, response Claim) ([]byte, e
// Respond takes a [Claim] and executes the response action.
func
(
r
*
faultResponder
)
Respond
(
ctx
context
.
Context
,
response
Claim
)
error
{
// Build the transaction data.
txData
,
err
:=
r
.
BuildTx
(
ctx
,
response
)
if
err
!=
nil
{
return
err
}
return
r
.
sendTxAndWait
(
ctx
,
txData
)
}
// Send the transaction through the [txmgr].
// sendTxAndWait sends a transaction through the [txmgr] and waits for a receipt.
// This sets the tx GasLimit to 0, performing gas estimation online through the [txmgr].
func
(
r
*
faultResponder
)
sendTxAndWait
(
ctx
context
.
Context
,
txData
[]
byte
)
error
{
receipt
,
err
:=
r
.
txMgr
.
Send
(
ctx
,
txmgr
.
TxCandidate
{
To
:
&
r
.
fdgAddr
,
TxData
:
txData
,
// Setting GasLimit to 0 performs gas estimation online through the [txmgr].
To
:
&
r
.
fdgAddr
,
TxData
:
txData
,
GasLimit
:
0
,
})
if
err
!=
nil
{
...
...
@@ -95,6 +97,26 @@ func (r *faultResponder) Respond(ctx context.Context, response Claim) error {
}
else
{
r
.
log
.
Info
(
"responder tx successfully published"
,
"tx_hash"
,
receipt
.
TxHash
)
}
return
nil
}
// buildStepTxData creates the transaction data for the step function.
func
(
r
*
faultResponder
)
buildStepTxData
(
stepData
StepCallData
)
([]
byte
,
error
)
{
return
r
.
fdgAbi
.
Pack
(
"step"
,
big
.
NewInt
(
int64
(
stepData
.
StateIndex
)),
big
.
NewInt
(
int64
(
stepData
.
ClaimIndex
)),
stepData
.
IsAttack
,
stepData
.
StateData
,
stepData
.
Proof
,
)
}
// Step accepts step data and executes the step on the fault dispute game contract.
func
(
r
*
faultResponder
)
Step
(
ctx
context
.
Context
,
stepData
StepCallData
)
error
{
txData
,
err
:=
r
.
buildStepTxData
(
stepData
)
if
err
!=
nil
{
return
err
}
return
r
.
sendTxAndWait
(
ctx
,
txData
)
}
op-challenger/fault/types.go
View file @
bf04d9e4
...
...
@@ -12,6 +12,15 @@ var (
ErrIndexTooLarge
=
errors
.
New
(
"index is larger than the maximum index"
)
)
// StepCallData encapsulates the data needed to perform a step.
type
StepCallData
struct
{
StateIndex
uint64
ClaimIndex
uint64
IsAttack
bool
StateData
[]
byte
Proof
[]
byte
}
// TraceProvider is a generic way to get a claim value at a specific
// step in the trace.
// The [AlphabetProvider] is a minimal implementation of this interface.
...
...
@@ -60,4 +69,5 @@ func (c *Claim) DefendsParent() bool {
// For full op-challenger this means executing the transaction on chain.
type
Responder
interface
{
Respond
(
ctx
context
.
Context
,
response
Claim
)
error
Step
(
ctx
context
.
Context
,
stepData
StepCallData
)
error
}
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