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
cbf3628a
Unverified
Commit
cbf3628a
authored
Nov 20, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Simplify exposed API for dispute game proposals.
parent
b01ff541
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
9 deletions
+30
-9
faultdisputegame.go
op-challenger/game/fault/contracts/faultdisputegame.go
+18
-3
faultdisputegame_test.go
op-challenger/game/fault/contracts/faultdisputegame_test.go
+12
-4
local_test.go
op-challenger/game/fault/trace/cannon/local_test.go
+0
-2
No files found.
op-challenger/game/fault/contracts/faultdisputegame.go
View file @
cbf3628a
...
...
@@ -36,12 +36,27 @@ type FaultDisputeGameContract struct {
contract
*
batching
.
BoundContract
}
type
Proposal
struct
{
// contractProposal matches the structure for output root proposals used by the contracts.
// It must exactly match the contract structure. The exposed API uses Proposal to decouple the contract
// and challenger representations of the proposal data.
type
contractProposal
struct
{
Index
*
big
.
Int
L2BlockNumber
*
big
.
Int
OutputRoot
common
.
Hash
}
type
Proposal
struct
{
L2BlockNumber
*
big
.
Int
OutputRoot
common
.
Hash
}
func
asProposal
(
p
contractProposal
)
Proposal
{
return
Proposal
{
L2BlockNumber
:
p
.
L2BlockNumber
,
OutputRoot
:
p
.
OutputRoot
,
}
}
func
NewFaultDisputeGameContract
(
addr
common
.
Address
,
caller
*
batching
.
MultiCaller
)
(
*
FaultDisputeGameContract
,
error
)
{
fdgAbi
,
err
:=
bindings
.
FaultDisputeGameMetaData
.
GetAbi
()
if
err
!=
nil
{
...
...
@@ -93,10 +108,10 @@ func (f *FaultDisputeGameContract) GetProposals(ctx context.Context) (Proposal,
return
Proposal
{},
Proposal
{},
fmt
.
Errorf
(
"failed to fetch proposals: %w"
,
err
)
}
var
agreed
,
disputed
Proposal
var
agreed
,
disputed
contract
Proposal
result
.
GetStruct
(
0
,
&
agreed
)
result
.
GetStruct
(
1
,
&
disputed
)
return
a
greed
,
disputed
,
nil
return
a
sProposal
(
agreed
),
asProposal
(
disputed
)
,
nil
}
func
(
f
*
FaultDisputeGameContract
)
GetStatus
(
ctx
context
.
Context
)
(
gameTypes
.
GameStatus
,
error
)
{
...
...
op-challenger/game/fault/contracts/faultdisputegame_test.go
View file @
cbf3628a
...
...
@@ -105,23 +105,31 @@ func TestGetProposals(t *testing.T) {
disputedIndex
:=
big
.
NewInt
(
7
)
disputedBlockNum
:=
big
.
NewInt
(
8
)
disputedRoot
:=
common
.
Hash
{
0xdd
}
agreed
:=
Proposal
{
agreed
:=
contract
Proposal
{
Index
:
agreedIndex
,
L2BlockNumber
:
agreedBlockNum
,
OutputRoot
:
agreedRoot
,
}
disputed
:=
Proposal
{
disputed
:=
contract
Proposal
{
Index
:
disputedIndex
,
L2BlockNumber
:
disputedBlockNum
,
OutputRoot
:
disputedRoot
,
}
expectedAgreed
:=
Proposal
{
L2BlockNumber
:
agreed
.
L2BlockNumber
,
OutputRoot
:
agreed
.
OutputRoot
,
}
expectedDisputed
:=
Proposal
{
L2BlockNumber
:
disputed
.
L2BlockNumber
,
OutputRoot
:
disputed
.
OutputRoot
,
}
stubRpc
.
SetResponse
(
fdgAddr
,
methodProposals
,
batching
.
BlockLatest
,
[]
interface
{}{},
[]
interface
{}{
agreed
,
disputed
,
})
actualAgreed
,
actualDisputed
,
err
:=
game
.
GetProposals
(
context
.
Background
())
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
a
greed
,
actualAgreed
)
require
.
Equal
(
t
,
d
isputed
,
actualDisputed
)
require
.
Equal
(
t
,
expectedA
greed
,
actualAgreed
)
require
.
Equal
(
t
,
expectedD
isputed
,
actualDisputed
)
}
func
TestGetClaim
(
t
*
testing
.
T
)
{
...
...
op-challenger/game/fault/trace/cannon/local_test.go
View file @
cbf3628a
...
...
@@ -17,12 +17,10 @@ func TestFetchLocalInputs(t *testing.T) {
contract
:=
&
mockGameInputsSource
{
l1Head
:
common
.
Hash
{
0xcc
},
starting
:
contracts
.
Proposal
{
Index
:
big
.
NewInt
(
6
),
L2BlockNumber
:
big
.
NewInt
(
2222
),
OutputRoot
:
common
.
Hash
{
0xdd
},
},
disputed
:
contracts
.
Proposal
{
Index
:
big
.
NewInt
(
7
),
L2BlockNumber
:
big
.
NewInt
(
3333
),
OutputRoot
:
common
.
Hash
{
0xee
},
},
...
...
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