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
f56bc8cd
Unverified
Commit
f56bc8cd
authored
Nov 30, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
challenger: Don't export the base dispute game contract.
parent
4c16e214
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
38 deletions
+38
-38
disputegame.go
op-challenger/game/fault/contracts/disputegame.go
+20
-20
disputegame_test.go
op-challenger/game/fault/contracts/disputegame_test.go
+9
-9
faultdisputegame.go
op-challenger/game/fault/contracts/faultdisputegame.go
+2
-2
faultdisputegame_test.go
op-challenger/game/fault/contracts/faultdisputegame_test.go
+2
-2
outputbisectiongame.go
op-challenger/game/fault/contracts/outputbisectiongame.go
+3
-3
outputbisectiongame_test.go
...allenger/game/fault/contracts/outputbisectiongame_test.go
+2
-2
No files found.
op-challenger/game/fault/contracts/disputegame.go
View file @
f56bc8cd
...
...
@@ -29,7 +29,7 @@ const (
methodVM
=
"VM"
)
type
D
isputeGameContract
struct
{
type
d
isputeGameContract
struct
{
multiCaller
*
batching
.
MultiCaller
contract
*
batching
.
BoundContract
}
...
...
@@ -55,7 +55,7 @@ func asProposal(p contractProposal) Proposal {
}
}
func
(
f
*
D
isputeGameContract
)
GetGameDuration
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
func
(
f
*
d
isputeGameContract
)
GetGameDuration
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodGameDuration
))
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"failed to fetch game duration: %w"
,
err
)
...
...
@@ -63,7 +63,7 @@ func (f *DisputeGameContract) GetGameDuration(ctx context.Context) (uint64, erro
return
result
.
GetUint64
(
0
),
nil
}
func
(
f
*
D
isputeGameContract
)
GetMaxGameDepth
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
func
(
f
*
d
isputeGameContract
)
GetMaxGameDepth
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodMaxGameDepth
))
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"failed to fetch max game depth: %w"
,
err
)
...
...
@@ -71,7 +71,7 @@ func (f *DisputeGameContract) GetMaxGameDepth(ctx context.Context) (uint64, erro
return
result
.
GetBigInt
(
0
)
.
Uint64
(),
nil
}
func
(
f
*
D
isputeGameContract
)
GetAbsolutePrestateHash
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
func
(
f
*
d
isputeGameContract
)
GetAbsolutePrestateHash
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodAbsolutePrestate
))
if
err
!=
nil
{
return
common
.
Hash
{},
fmt
.
Errorf
(
"failed to fetch absolute prestate hash: %w"
,
err
)
...
...
@@ -79,7 +79,7 @@ func (f *DisputeGameContract) GetAbsolutePrestateHash(ctx context.Context) (comm
return
result
.
GetHash
(
0
),
nil
}
func
(
f
*
D
isputeGameContract
)
GetL1Head
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
func
(
f
*
d
isputeGameContract
)
GetL1Head
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodL1Head
))
if
err
!=
nil
{
return
common
.
Hash
{},
fmt
.
Errorf
(
"failed to fetch L1 head: %w"
,
err
)
...
...
@@ -87,7 +87,7 @@ func (f *DisputeGameContract) GetL1Head(ctx context.Context) (common.Hash, error
return
result
.
GetHash
(
0
),
nil
}
func
(
f
*
D
isputeGameContract
)
GetStatus
(
ctx
context
.
Context
)
(
gameTypes
.
GameStatus
,
error
)
{
func
(
f
*
d
isputeGameContract
)
GetStatus
(
ctx
context
.
Context
)
(
gameTypes
.
GameStatus
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodStatus
))
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"failed to fetch status: %w"
,
err
)
...
...
@@ -95,7 +95,7 @@ func (f *DisputeGameContract) GetStatus(ctx context.Context) (gameTypes.GameStat
return
gameTypes
.
GameStatusFromUint8
(
result
.
GetUint8
(
0
))
}
func
(
f
*
D
isputeGameContract
)
GetClaimCount
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
func
(
f
*
d
isputeGameContract
)
GetClaimCount
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodClaimCount
))
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"failed to fetch claim count: %w"
,
err
)
...
...
@@ -103,7 +103,7 @@ func (f *DisputeGameContract) GetClaimCount(ctx context.Context) (uint64, error)
return
result
.
GetBigInt
(
0
)
.
Uint64
(),
nil
}
func
(
f
*
D
isputeGameContract
)
GetClaim
(
ctx
context
.
Context
,
idx
uint64
)
(
types
.
Claim
,
error
)
{
func
(
f
*
d
isputeGameContract
)
GetClaim
(
ctx
context
.
Context
,
idx
uint64
)
(
types
.
Claim
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodClaim
,
new
(
big
.
Int
)
.
SetUint64
(
idx
)))
if
err
!=
nil
{
return
types
.
Claim
{},
fmt
.
Errorf
(
"failed to fetch claim %v: %w"
,
idx
,
err
)
...
...
@@ -111,7 +111,7 @@ func (f *DisputeGameContract) GetClaim(ctx context.Context, idx uint64) (types.C
return
f
.
decodeClaim
(
result
,
int
(
idx
)),
nil
}
func
(
f
*
D
isputeGameContract
)
GetAllClaims
(
ctx
context
.
Context
)
([]
types
.
Claim
,
error
)
{
func
(
f
*
d
isputeGameContract
)
GetAllClaims
(
ctx
context
.
Context
)
([]
types
.
Claim
,
error
)
{
count
,
err
:=
f
.
GetClaimCount
(
ctx
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to load claim count: %w"
,
err
)
...
...
@@ -134,7 +134,7 @@ func (f *DisputeGameContract) GetAllClaims(ctx context.Context) ([]types.Claim,
return
claims
,
nil
}
func
(
f
*
D
isputeGameContract
)
vm
(
ctx
context
.
Context
)
(
*
VMContract
,
error
)
{
func
(
f
*
d
isputeGameContract
)
vm
(
ctx
context
.
Context
)
(
*
VMContract
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodVM
))
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to fetch VM addr: %w"
,
err
)
...
...
@@ -143,22 +143,22 @@ func (f *DisputeGameContract) vm(ctx context.Context) (*VMContract, error) {
return
NewVMContract
(
vmAddr
,
f
.
multiCaller
)
}
func
(
f
*
D
isputeGameContract
)
AttackTx
(
parentContractIndex
uint64
,
pivot
common
.
Hash
)
(
txmgr
.
TxCandidate
,
error
)
{
func
(
f
*
d
isputeGameContract
)
AttackTx
(
parentContractIndex
uint64
,
pivot
common
.
Hash
)
(
txmgr
.
TxCandidate
,
error
)
{
call
:=
f
.
contract
.
Call
(
methodAttack
,
new
(
big
.
Int
)
.
SetUint64
(
parentContractIndex
),
pivot
)
return
call
.
ToTxCandidate
()
}
func
(
f
*
D
isputeGameContract
)
DefendTx
(
parentContractIndex
uint64
,
pivot
common
.
Hash
)
(
txmgr
.
TxCandidate
,
error
)
{
func
(
f
*
d
isputeGameContract
)
DefendTx
(
parentContractIndex
uint64
,
pivot
common
.
Hash
)
(
txmgr
.
TxCandidate
,
error
)
{
call
:=
f
.
contract
.
Call
(
methodDefend
,
new
(
big
.
Int
)
.
SetUint64
(
parentContractIndex
),
pivot
)
return
call
.
ToTxCandidate
()
}
func
(
f
*
D
isputeGameContract
)
StepTx
(
claimIdx
uint64
,
isAttack
bool
,
stateData
[]
byte
,
proof
[]
byte
)
(
txmgr
.
TxCandidate
,
error
)
{
func
(
f
*
d
isputeGameContract
)
StepTx
(
claimIdx
uint64
,
isAttack
bool
,
stateData
[]
byte
,
proof
[]
byte
)
(
txmgr
.
TxCandidate
,
error
)
{
call
:=
f
.
contract
.
Call
(
methodStep
,
new
(
big
.
Int
)
.
SetUint64
(
claimIdx
),
isAttack
,
stateData
,
proof
)
return
call
.
ToTxCandidate
()
}
func
(
f
*
D
isputeGameContract
)
CallResolveClaim
(
ctx
context
.
Context
,
claimIdx
uint64
)
error
{
func
(
f
*
d
isputeGameContract
)
CallResolveClaim
(
ctx
context
.
Context
,
claimIdx
uint64
)
error
{
call
:=
f
.
resolveClaimCall
(
claimIdx
)
_
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
call
)
if
err
!=
nil
{
...
...
@@ -167,16 +167,16 @@ func (f *DisputeGameContract) CallResolveClaim(ctx context.Context, claimIdx uin
return
nil
}
func
(
f
*
D
isputeGameContract
)
ResolveClaimTx
(
claimIdx
uint64
)
(
txmgr
.
TxCandidate
,
error
)
{
func
(
f
*
d
isputeGameContract
)
ResolveClaimTx
(
claimIdx
uint64
)
(
txmgr
.
TxCandidate
,
error
)
{
call
:=
f
.
resolveClaimCall
(
claimIdx
)
return
call
.
ToTxCandidate
()
}
func
(
f
*
D
isputeGameContract
)
resolveClaimCall
(
claimIdx
uint64
)
*
batching
.
ContractCall
{
func
(
f
*
d
isputeGameContract
)
resolveClaimCall
(
claimIdx
uint64
)
*
batching
.
ContractCall
{
return
f
.
contract
.
Call
(
methodResolveClaim
,
new
(
big
.
Int
)
.
SetUint64
(
claimIdx
))
}
func
(
f
*
D
isputeGameContract
)
CallResolve
(
ctx
context
.
Context
)
(
gameTypes
.
GameStatus
,
error
)
{
func
(
f
*
d
isputeGameContract
)
CallResolve
(
ctx
context
.
Context
)
(
gameTypes
.
GameStatus
,
error
)
{
call
:=
f
.
resolveCall
()
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
call
)
if
err
!=
nil
{
...
...
@@ -185,16 +185,16 @@ func (f *DisputeGameContract) CallResolve(ctx context.Context) (gameTypes.GameSt
return
gameTypes
.
GameStatusFromUint8
(
result
.
GetUint8
(
0
))
}
func
(
f
*
D
isputeGameContract
)
ResolveTx
()
(
txmgr
.
TxCandidate
,
error
)
{
func
(
f
*
d
isputeGameContract
)
ResolveTx
()
(
txmgr
.
TxCandidate
,
error
)
{
call
:=
f
.
resolveCall
()
return
call
.
ToTxCandidate
()
}
func
(
f
*
D
isputeGameContract
)
resolveCall
()
*
batching
.
ContractCall
{
func
(
f
*
d
isputeGameContract
)
resolveCall
()
*
batching
.
ContractCall
{
return
f
.
contract
.
Call
(
methodResolve
)
}
func
(
f
*
D
isputeGameContract
)
decodeClaim
(
result
*
batching
.
CallResult
,
contractIndex
int
)
types
.
Claim
{
func
(
f
*
d
isputeGameContract
)
decodeClaim
(
result
*
batching
.
CallResult
,
contractIndex
int
)
types
.
Claim
{
parentIndex
:=
result
.
GetUint32
(
0
)
countered
:=
result
.
GetBool
(
1
)
claim
:=
result
.
GetHash
(
2
)
...
...
op-challenger/game/fault/contracts/disputegame_test.go
View file @
f56bc8cd
...
...
@@ -20,7 +20,7 @@ var (
oracleAddr
=
common
.
HexToAddress
(
"0x44442842371dFC380576ebb09Ae16Cb6B6ca4444"
)
)
type
disputeGameSetupFunc
func
(
t
*
testing
.
T
)
(
*
batchingTest
.
AbiBasedRpc
,
*
D
isputeGameContract
)
type
disputeGameSetupFunc
func
(
t
*
testing
.
T
)
(
*
batchingTest
.
AbiBasedRpc
,
*
d
isputeGameContract
)
func
runCommonDisputeGameTests
(
t
*
testing
.
T
,
setup
disputeGameSetupFunc
)
{
tests
:=
[]
struct
{
...
...
@@ -52,19 +52,19 @@ func runSimpleGettersTest(t *testing.T, setup disputeGameSetupFunc) {
args
[]
interface
{}
result
interface
{}
expected
interface
{}
// Defaults to expecting the same as result
call
func
(
game
*
D
isputeGameContract
)
(
any
,
error
)
call
func
(
game
*
d
isputeGameContract
)
(
any
,
error
)
}{
{
method
:
methodStatus
,
result
:
types
.
GameStatusChallengerWon
,
call
:
func
(
game
*
D
isputeGameContract
)
(
any
,
error
)
{
call
:
func
(
game
*
d
isputeGameContract
)
(
any
,
error
)
{
return
game
.
GetStatus
(
context
.
Background
())
},
},
{
method
:
methodGameDuration
,
result
:
uint64
(
5566
),
call
:
func
(
game
*
D
isputeGameContract
)
(
any
,
error
)
{
call
:
func
(
game
*
d
isputeGameContract
)
(
any
,
error
)
{
return
game
.
GetGameDuration
(
context
.
Background
())
},
},
...
...
@@ -72,14 +72,14 @@ func runSimpleGettersTest(t *testing.T, setup disputeGameSetupFunc) {
method
:
methodMaxGameDepth
,
result
:
big
.
NewInt
(
128
),
expected
:
uint64
(
128
),
call
:
func
(
game
*
D
isputeGameContract
)
(
any
,
error
)
{
call
:
func
(
game
*
d
isputeGameContract
)
(
any
,
error
)
{
return
game
.
GetMaxGameDepth
(
context
.
Background
())
},
},
{
method
:
methodAbsolutePrestate
,
result
:
common
.
Hash
{
0xab
},
call
:
func
(
game
*
D
isputeGameContract
)
(
any
,
error
)
{
call
:
func
(
game
*
d
isputeGameContract
)
(
any
,
error
)
{
return
game
.
GetAbsolutePrestateHash
(
context
.
Background
())
},
},
...
...
@@ -87,21 +87,21 @@ func runSimpleGettersTest(t *testing.T, setup disputeGameSetupFunc) {
method
:
methodClaimCount
,
result
:
big
.
NewInt
(
9876
),
expected
:
uint64
(
9876
),
call
:
func
(
game
*
D
isputeGameContract
)
(
any
,
error
)
{
call
:
func
(
game
*
d
isputeGameContract
)
(
any
,
error
)
{
return
game
.
GetClaimCount
(
context
.
Background
())
},
},
{
method
:
methodL1Head
,
result
:
common
.
Hash
{
0xdd
,
0xbb
},
call
:
func
(
game
*
D
isputeGameContract
)
(
any
,
error
)
{
call
:
func
(
game
*
d
isputeGameContract
)
(
any
,
error
)
{
return
game
.
GetL1Head
(
context
.
Background
())
},
},
{
method
:
methodResolve
,
result
:
types
.
GameStatusInProgress
,
call
:
func
(
game
*
D
isputeGameContract
)
(
any
,
error
)
{
call
:
func
(
game
*
d
isputeGameContract
)
(
any
,
error
)
{
return
game
.
CallResolve
(
context
.
Background
())
},
},
...
...
op-challenger/game/fault/contracts/faultdisputegame.go
View file @
f56bc8cd
...
...
@@ -17,7 +17,7 @@ const (
)
type
FaultDisputeGameContract
struct
{
D
isputeGameContract
d
isputeGameContract
}
func
NewFaultDisputeGameContract
(
addr
common
.
Address
,
caller
*
batching
.
MultiCaller
)
(
*
FaultDisputeGameContract
,
error
)
{
...
...
@@ -27,7 +27,7 @@ func NewFaultDisputeGameContract(addr common.Address, caller *batching.MultiCall
}
return
&
FaultDisputeGameContract
{
DisputeGameContract
:
D
isputeGameContract
{
disputeGameContract
:
d
isputeGameContract
{
multiCaller
:
caller
,
contract
:
batching
.
NewBoundContract
(
fdgAbi
,
addr
),
},
...
...
op-challenger/game/fault/contracts/faultdisputegame_test.go
View file @
f56bc8cd
...
...
@@ -14,9 +14,9 @@ import (
)
func
TestFaultDisputeGameContract_CommonTests
(
t
*
testing
.
T
)
{
runCommonDisputeGameTests
(
t
,
func
(
t
*
testing
.
T
)
(
*
batchingTest
.
AbiBasedRpc
,
*
D
isputeGameContract
)
{
runCommonDisputeGameTests
(
t
,
func
(
t
*
testing
.
T
)
(
*
batchingTest
.
AbiBasedRpc
,
*
d
isputeGameContract
)
{
stubRpc
,
contract
:=
setupFaultDisputeGameTest
(
t
)
return
stubRpc
,
&
contract
.
D
isputeGameContract
return
stubRpc
,
&
contract
.
d
isputeGameContract
})
}
...
...
op-challenger/game/fault/contracts/outputbisectiongame.go
View file @
f56bc8cd
...
...
@@ -19,7 +19,7 @@ var (
)
type
OutputBisectionGameContract
struct
{
D
isputeGameContract
d
isputeGameContract
}
func
NewOutputBisectionGameContract
(
addr
common
.
Address
,
caller
*
batching
.
MultiCaller
)
(
*
OutputBisectionGameContract
,
error
)
{
...
...
@@ -29,7 +29,7 @@ func NewOutputBisectionGameContract(addr common.Address, caller *batching.MultiC
}
return
&
OutputBisectionGameContract
{
DisputeGameContract
:
D
isputeGameContract
{
disputeGameContract
:
d
isputeGameContract
{
multiCaller
:
caller
,
contract
:
batching
.
NewBoundContract
(
contractAbi
,
addr
),
},
...
...
@@ -78,7 +78,7 @@ func (f *OutputBisectionGameContract) addLocalDataTx(claimIdx uint64, data *type
return
call
.
ToTxCandidate
()
}
func
(
f
*
D
isputeGameContract
)
addGlobalDataTx
(
ctx
context
.
Context
,
data
*
types
.
PreimageOracleData
)
(
txmgr
.
TxCandidate
,
error
)
{
func
(
f
*
d
isputeGameContract
)
addGlobalDataTx
(
ctx
context
.
Context
,
data
*
types
.
PreimageOracleData
)
(
txmgr
.
TxCandidate
,
error
)
{
vm
,
err
:=
f
.
vm
(
ctx
)
if
err
!=
nil
{
return
txmgr
.
TxCandidate
{},
err
...
...
op-challenger/game/fault/contracts/outputbisectiongame_test.go
View file @
f56bc8cd
...
...
@@ -14,9 +14,9 @@ import (
)
func
TestOutputBisectionGameContract_CommonTests
(
t
*
testing
.
T
)
{
runCommonDisputeGameTests
(
t
,
func
(
t
*
testing
.
T
)
(
*
batchingTest
.
AbiBasedRpc
,
*
D
isputeGameContract
)
{
runCommonDisputeGameTests
(
t
,
func
(
t
*
testing
.
T
)
(
*
batchingTest
.
AbiBasedRpc
,
*
d
isputeGameContract
)
{
stubRpc
,
contract
:=
setupOutputBisectionGameTest
(
t
)
return
stubRpc
,
&
contract
.
D
isputeGameContract
return
stubRpc
,
&
contract
.
d
isputeGameContract
})
}
...
...
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