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
18c4160a
Unverified
Commit
18c4160a
authored
Jul 24, 2023
by
mergify[bot]
Committed by
GitHub
Jul 24, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into refcell/solver-module
parents
16a623d5
94ab1561
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 @
18c4160a
...
@@ -29,6 +29,7 @@ func (t TraceType) String() string {
...
@@ -29,6 +29,7 @@ func (t TraceType) String() string {
return
string
(
t
)
return
string
(
t
)
}
}
// Set implements the Set method required by the [cli.Generic] interface.
func
(
t
*
TraceType
)
Set
(
value
string
)
error
{
func
(
t
*
TraceType
)
Set
(
value
string
)
error
{
if
!
ValidTraceType
(
TraceType
(
value
))
{
if
!
ValidTraceType
(
TraceType
(
value
))
{
return
fmt
.
Errorf
(
"unknown trace type: %q"
,
value
)
return
fmt
.
Errorf
(
"unknown trace type: %q"
,
value
)
...
...
op-challenger/fault/responder.go
View file @
18c4160a
...
@@ -5,13 +5,13 @@ import (
...
@@ -5,13 +5,13 @@ import (
"math/big"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"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-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"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/ethereum/go-ethereum/log"
)
)
...
@@ -63,7 +63,7 @@ func (r *faultResponder) buildResolveData() ([]byte, error) {
...
@@ -63,7 +63,7 @@ func (r *faultResponder) buildResolveData() ([]byte, error) {
}
}
// BuildTx builds the transaction for the [faultResponder].
// 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
()
{
if
response
.
DefendsParent
()
{
txData
,
err
:=
r
.
buildFaultDefendData
(
response
.
ParentContractIndex
,
response
.
ValueBytes
())
txData
,
err
:=
r
.
buildFaultDefendData
(
response
.
ParentContractIndex
,
response
.
ValueBytes
())
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -104,7 +104,7 @@ func (r *faultResponder) Resolve(ctx context.Context) error {
...
@@ -104,7 +104,7 @@ func (r *faultResponder) Resolve(ctx context.Context) error {
}
}
// Respond takes a [Claim] and executes the response action.
// 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
)
txData
,
err
:=
r
.
BuildTx
(
ctx
,
response
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -123,7 +123,7 @@ func (r *faultResponder) sendTxAndWait(ctx context.Context, txData []byte) error
...
@@ -123,7 +123,7 @@ func (r *faultResponder) sendTxAndWait(ctx context.Context, txData []byte) error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
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
)
r
.
log
.
Error
(
"Responder tx successfully published but reverted"
,
"tx_hash"
,
receipt
.
TxHash
)
}
else
{
}
else
{
r
.
log
.
Debug
(
"Responder tx successfully published"
,
"tx_hash"
,
receipt
.
TxHash
)
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
...
@@ -132,7 +132,7 @@ func (r *faultResponder) sendTxAndWait(ctx context.Context, txData []byte) error
}
}
// buildStepTxData creates the transaction data for the step function.
// 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
(
return
r
.
fdgAbi
.
Pack
(
"step"
,
"step"
,
big
.
NewInt
(
int64
(
stepData
.
ClaimIndex
)),
big
.
NewInt
(
int64
(
stepData
.
ClaimIndex
)),
...
@@ -143,7 +143,7 @@ func (r *faultResponder) buildStepTxData(stepData types2.StepCallData) ([]byte,
...
@@ -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.
// 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
)
txData
,
err
:=
r
.
buildStepTxData
(
stepData
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
op-challenger/fault/responder_test.go
View file @
18c4160a
...
@@ -7,13 +7,13 @@ import (
...
@@ -7,13 +7,13 @@ import (
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"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-node/testlog"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"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/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -31,12 +31,12 @@ type mockTxManager struct {
...
@@ -31,12 +31,12 @@ type mockTxManager struct {
sendFails
bool
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
{
if
m
.
sendFails
{
return
nil
,
mockSendError
return
nil
,
mockSendError
}
}
m
.
sends
++
m
.
sends
++
return
types
.
NewReceipt
(
return
eth
types
.
NewReceipt
(
[]
byte
{},
[]
byte
{},
false
,
false
,
0
,
0
,
...
@@ -108,14 +108,14 @@ func TestResponder_Resolve_Success(t *testing.T) {
...
@@ -108,14 +108,14 @@ func TestResponder_Resolve_Success(t *testing.T) {
// bubbles up the error returned by the [txmgr.Send] method.
// bubbles up the error returned by the [txmgr.Send] method.
func
TestResponder_Respond_SendFails
(
t
*
testing
.
T
)
{
func
TestResponder_Respond_SendFails
(
t
*
testing
.
T
)
{
responder
,
mockTxMgr
:=
newTestFaultResponder
(
t
,
true
)
responder
,
mockTxMgr
:=
newTestFaultResponder
(
t
,
true
)
err
:=
responder
.
Respond
(
context
.
Background
(),
types
2
.
Claim
{
err
:=
responder
.
Respond
(
context
.
Background
(),
types
.
Claim
{
ClaimData
:
types
2
.
ClaimData
{
ClaimData
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x01
},
Value
:
common
.
Hash
{
0x01
},
Position
:
types
2
.
NewPositionFromGIndex
(
2
),
Position
:
types
.
NewPositionFromGIndex
(
2
),
},
},
Parent
:
types
2
.
ClaimData
{
Parent
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x02
},
Value
:
common
.
Hash
{
0x02
},
Position
:
types
2
.
NewPositionFromGIndex
(
1
),
Position
:
types
.
NewPositionFromGIndex
(
1
),
},
},
ContractIndex
:
0
,
ContractIndex
:
0
,
ParentContractIndex
:
0
,
ParentContractIndex
:
0
,
...
@@ -128,14 +128,14 @@ func TestResponder_Respond_SendFails(t *testing.T) {
...
@@ -128,14 +128,14 @@ func TestResponder_Respond_SendFails(t *testing.T) {
// succeeds when the tx candidate is successfully sent through the txmgr.
// succeeds when the tx candidate is successfully sent through the txmgr.
func
TestResponder_Respond_Success
(
t
*
testing
.
T
)
{
func
TestResponder_Respond_Success
(
t
*
testing
.
T
)
{
responder
,
mockTxMgr
:=
newTestFaultResponder
(
t
,
false
)
responder
,
mockTxMgr
:=
newTestFaultResponder
(
t
,
false
)
err
:=
responder
.
Respond
(
context
.
Background
(),
types
2
.
Claim
{
err
:=
responder
.
Respond
(
context
.
Background
(),
types
.
Claim
{
ClaimData
:
types
2
.
ClaimData
{
ClaimData
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x01
},
Value
:
common
.
Hash
{
0x01
},
Position
:
types
2
.
NewPositionFromGIndex
(
2
),
Position
:
types
.
NewPositionFromGIndex
(
2
),
},
},
Parent
:
types
2
.
ClaimData
{
Parent
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x02
},
Value
:
common
.
Hash
{
0x02
},
Position
:
types
2
.
NewPositionFromGIndex
(
1
),
Position
:
types
.
NewPositionFromGIndex
(
1
),
},
},
ContractIndex
:
0
,
ContractIndex
:
0
,
ParentContractIndex
:
0
,
ParentContractIndex
:
0
,
...
@@ -148,14 +148,14 @@ func TestResponder_Respond_Success(t *testing.T) {
...
@@ -148,14 +148,14 @@ func TestResponder_Respond_Success(t *testing.T) {
// returns a tx candidate with the correct data for an attack tx.
// returns a tx candidate with the correct data for an attack tx.
func
TestResponder_BuildTx_Attack
(
t
*
testing
.
T
)
{
func
TestResponder_BuildTx_Attack
(
t
*
testing
.
T
)
{
responder
,
_
:=
newTestFaultResponder
(
t
,
false
)
responder
,
_
:=
newTestFaultResponder
(
t
,
false
)
responseClaim
:=
types
2
.
Claim
{
responseClaim
:=
types
.
Claim
{
ClaimData
:
types
2
.
ClaimData
{
ClaimData
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x01
},
Value
:
common
.
Hash
{
0x01
},
Position
:
types
2
.
NewPositionFromGIndex
(
2
),
Position
:
types
.
NewPositionFromGIndex
(
2
),
},
},
Parent
:
types
2
.
ClaimData
{
Parent
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x02
},
Value
:
common
.
Hash
{
0x02
},
Position
:
types
2
.
NewPositionFromGIndex
(
1
),
Position
:
types
.
NewPositionFromGIndex
(
1
),
},
},
ContractIndex
:
0
,
ContractIndex
:
0
,
ParentContractIndex
:
7
,
ParentContractIndex
:
7
,
...
@@ -179,14 +179,14 @@ func TestResponder_BuildTx_Attack(t *testing.T) {
...
@@ -179,14 +179,14 @@ func TestResponder_BuildTx_Attack(t *testing.T) {
// returns a tx candidate with the correct data for a defend tx.
// returns a tx candidate with the correct data for a defend tx.
func
TestResponder_BuildTx_Defend
(
t
*
testing
.
T
)
{
func
TestResponder_BuildTx_Defend
(
t
*
testing
.
T
)
{
responder
,
_
:=
newTestFaultResponder
(
t
,
false
)
responder
,
_
:=
newTestFaultResponder
(
t
,
false
)
responseClaim
:=
types
2
.
Claim
{
responseClaim
:=
types
.
Claim
{
ClaimData
:
types
2
.
ClaimData
{
ClaimData
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x01
},
Value
:
common
.
Hash
{
0x01
},
Position
:
types
2
.
NewPositionFromGIndex
(
3
),
Position
:
types
.
NewPositionFromGIndex
(
3
),
},
},
Parent
:
types
2
.
ClaimData
{
Parent
:
types
.
ClaimData
{
Value
:
common
.
Hash
{
0x02
},
Value
:
common
.
Hash
{
0x02
},
Position
:
types
2
.
NewPositionFromGIndex
(
6
),
Position
:
types
.
NewPositionFromGIndex
(
6
),
},
},
ContractIndex
:
0
,
ContractIndex
:
0
,
ParentContractIndex
:
7
,
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