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
346d2d3e
Commit
346d2d3e
authored
Jul 24, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small touchups following #6413
parent
6c5085a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
31 deletions
+32
-31
config.go
op-challenger/config/config.go
+1
-0
responder.go
op-challenger/fault/responder.go
+7
-7
responder_test.go
op-challenger/fault/responder_test.go
+24
-24
No files found.
op-challenger/config/config.go
View file @
346d2d3e
...
...
@@ -29,6 +29,7 @@ func (t TraceType) String() string {
return
string
(
t
)
}
// Set implements the Set method required by the [cli.Generic] interface.
func
(
t
*
TraceType
)
Set
(
value
string
)
error
{
if
!
ValidTraceType
(
TraceType
(
value
))
{
return
fmt
.
Errorf
(
"unknown trace type: %q"
,
value
)
...
...
op-challenger/fault/responder.go
View file @
346d2d3e
...
...
@@ -5,13 +5,13 @@ import (
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
types2
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
ethtypes
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
)
...
...
@@ -63,7 +63,7 @@ func (r *faultResponder) buildResolveData() ([]byte, error) {
}
// BuildTx builds the transaction for the [faultResponder].
func
(
r
*
faultResponder
)
BuildTx
(
ctx
context
.
Context
,
response
types
2
.
Claim
)
([]
byte
,
error
)
{
func
(
r
*
faultResponder
)
BuildTx
(
ctx
context
.
Context
,
response
types
.
Claim
)
([]
byte
,
error
)
{
if
response
.
DefendsParent
()
{
txData
,
err
:=
r
.
buildFaultDefendData
(
response
.
ParentContractIndex
,
response
.
ValueBytes
())
if
err
!=
nil
{
...
...
@@ -104,7 +104,7 @@ func (r *faultResponder) Resolve(ctx context.Context) error {
}
// Respond takes a [Claim] and executes the response action.
func
(
r
*
faultResponder
)
Respond
(
ctx
context
.
Context
,
response
types
2
.
Claim
)
error
{
func
(
r
*
faultResponder
)
Respond
(
ctx
context
.
Context
,
response
types
.
Claim
)
error
{
txData
,
err
:=
r
.
BuildTx
(
ctx
,
response
)
if
err
!=
nil
{
return
err
...
...
@@ -123,7 +123,7 @@ func (r *faultResponder) sendTxAndWait(ctx context.Context, txData []byte) error
if
err
!=
nil
{
return
err
}
if
receipt
.
Status
==
types
.
ReceiptStatusFailed
{
if
receipt
.
Status
==
eth
types
.
ReceiptStatusFailed
{
r
.
log
.
Error
(
"Responder tx successfully published but reverted"
,
"tx_hash"
,
receipt
.
TxHash
)
}
else
{
r
.
log
.
Debug
(
"Responder tx successfully published"
,
"tx_hash"
,
receipt
.
TxHash
)
...
...
@@ -132,7 +132,7 @@ func (r *faultResponder) sendTxAndWait(ctx context.Context, txData []byte) error
}
// buildStepTxData creates the transaction data for the step function.
func
(
r
*
faultResponder
)
buildStepTxData
(
stepData
types
2
.
StepCallData
)
([]
byte
,
error
)
{
func
(
r
*
faultResponder
)
buildStepTxData
(
stepData
types
.
StepCallData
)
([]
byte
,
error
)
{
return
r
.
fdgAbi
.
Pack
(
"step"
,
big
.
NewInt
(
int64
(
stepData
.
ClaimIndex
)),
...
...
@@ -143,7 +143,7 @@ func (r *faultResponder) buildStepTxData(stepData types2.StepCallData) ([]byte,
}
// Step accepts step data and executes the step on the fault dispute game contract.
func
(
r
*
faultResponder
)
Step
(
ctx
context
.
Context
,
stepData
types
2
.
StepCallData
)
error
{
func
(
r
*
faultResponder
)
Step
(
ctx
context
.
Context
,
stepData
types
.
StepCallData
)
error
{
txData
,
err
:=
r
.
buildStepTxData
(
stepData
)
if
err
!=
nil
{
return
err
...
...
op-challenger/fault/responder_test.go
View file @
346d2d3e
...
...
@@ -7,13 +7,13 @@ import (
"testing"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
types2
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
ethtypes
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
...
...
@@ -31,12 +31,12 @@ type mockTxManager struct {
sendFails
bool
}
func
(
m
*
mockTxManager
)
Send
(
ctx
context
.
Context
,
candidate
txmgr
.
TxCandidate
)
(
*
types
.
Receipt
,
error
)
{
func
(
m
*
mockTxManager
)
Send
(
ctx
context
.
Context
,
candidate
txmgr
.
TxCandidate
)
(
*
eth
types
.
Receipt
,
error
)
{
if
m
.
sendFails
{
return
nil
,
mockSendError
}
m
.
sends
++
return
types
.
NewReceipt
(
return
eth
types
.
NewReceipt
(
[]
byte
{},
false
,
0
,
...
...
@@ -108,14 +108,14 @@ func TestResponder_Resolve_Success(t *testing.T) {
// bubbles up the error returned by the [txmgr.Send] method.
func
TestResponder_Respond_SendFails
(
t
*
testing
.
T
)
{
responder
,
mockTxMgr
:=
newTestFaultResponder
(
t
,
true
)
err
:=
responder
.
Respond
(
context
.
Background
(),
types
2
.
Claim
{
ClaimData
:
types
2
.
ClaimData
{
err
:=
responder
.
Respond
(
context
.
Background
(),
types
.
Claim
{
ClaimData
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x01
},
Position
:
types
2
.
NewPositionFromGIndex
(
2
),
Position
:
types
.
NewPositionFromGIndex
(
2
),
},
Parent
:
types
2
.
ClaimData
{
Parent
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x02
},
Position
:
types
2
.
NewPositionFromGIndex
(
1
),
Position
:
types
.
NewPositionFromGIndex
(
1
),
},
ContractIndex
:
0
,
ParentContractIndex
:
0
,
...
...
@@ -128,14 +128,14 @@ func TestResponder_Respond_SendFails(t *testing.T) {
// succeeds when the tx candidate is successfully sent through the txmgr.
func
TestResponder_Respond_Success
(
t
*
testing
.
T
)
{
responder
,
mockTxMgr
:=
newTestFaultResponder
(
t
,
false
)
err
:=
responder
.
Respond
(
context
.
Background
(),
types
2
.
Claim
{
ClaimData
:
types
2
.
ClaimData
{
err
:=
responder
.
Respond
(
context
.
Background
(),
types
.
Claim
{
ClaimData
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x01
},
Position
:
types
2
.
NewPositionFromGIndex
(
2
),
Position
:
types
.
NewPositionFromGIndex
(
2
),
},
Parent
:
types
2
.
ClaimData
{
Parent
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x02
},
Position
:
types
2
.
NewPositionFromGIndex
(
1
),
Position
:
types
.
NewPositionFromGIndex
(
1
),
},
ContractIndex
:
0
,
ParentContractIndex
:
0
,
...
...
@@ -148,14 +148,14 @@ func TestResponder_Respond_Success(t *testing.T) {
// returns a tx candidate with the correct data for an attack tx.
func
TestResponder_BuildTx_Attack
(
t
*
testing
.
T
)
{
responder
,
_
:=
newTestFaultResponder
(
t
,
false
)
responseClaim
:=
types
2
.
Claim
{
ClaimData
:
types
2
.
ClaimData
{
responseClaim
:=
types
.
Claim
{
ClaimData
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x01
},
Position
:
types
2
.
NewPositionFromGIndex
(
2
),
Position
:
types
.
NewPositionFromGIndex
(
2
),
},
Parent
:
types
2
.
ClaimData
{
Parent
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x02
},
Position
:
types
2
.
NewPositionFromGIndex
(
1
),
Position
:
types
.
NewPositionFromGIndex
(
1
),
},
ContractIndex
:
0
,
ParentContractIndex
:
7
,
...
...
@@ -179,14 +179,14 @@ func TestResponder_BuildTx_Attack(t *testing.T) {
// returns a tx candidate with the correct data for a defend tx.
func
TestResponder_BuildTx_Defend
(
t
*
testing
.
T
)
{
responder
,
_
:=
newTestFaultResponder
(
t
,
false
)
responseClaim
:=
types
2
.
Claim
{
ClaimData
:
types
2
.
ClaimData
{
responseClaim
:=
types
.
Claim
{
ClaimData
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x01
},
Position
:
types
2
.
NewPositionFromGIndex
(
3
),
Position
:
types
.
NewPositionFromGIndex
(
3
),
},
Parent
:
types
2
.
ClaimData
{
Parent
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x02
},
Position
:
types
2
.
NewPositionFromGIndex
(
6
),
Position
:
types
.
NewPositionFromGIndex
(
6
),
},
ContractIndex
:
0
,
ParentContractIndex
:
7
,
...
...
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