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
c04fdd7a
Unverified
Commit
c04fdd7a
authored
Nov 13, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Load VM address via new style bindings.
parent
772dbf30
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
10 deletions
+28
-10
faultdisputegame.go
op-challenger/game/fault/contracts/faultdisputegame.go
+9
-0
faultdisputegame_test.go
op-challenger/game/fault/contracts/faultdisputegame_test.go
+7
-0
register.go
op-challenger/game/fault/register.go
+3
-1
updater.go
op-challenger/game/fault/trace/cannon/updater.go
+4
-8
updater_test.go
op-challenger/game/fault/trace/cannon/updater_test.go
+5
-1
No files found.
op-challenger/game/fault/contracts/faultdisputegame.go
View file @
c04fdd7a
...
@@ -28,6 +28,7 @@ const (
...
@@ -28,6 +28,7 @@ const (
methodDefend
=
"defend"
methodDefend
=
"defend"
methodStep
=
"step"
methodStep
=
"step"
methodAddLocalData
=
"addLocalData"
methodAddLocalData
=
"addLocalData"
methodVM
=
"VM"
)
)
type
FaultDisputeGameContract
struct
{
type
FaultDisputeGameContract
struct
{
...
@@ -145,6 +146,14 @@ func (f *FaultDisputeGameContract) GetAllClaims(ctx context.Context) ([]types.Cl
...
@@ -145,6 +146,14 @@ func (f *FaultDisputeGameContract) GetAllClaims(ctx context.Context) ([]types.Cl
return
claims
,
nil
return
claims
,
nil
}
}
func
(
f
*
FaultDisputeGameContract
)
VMAddr
(
ctx
context
.
Context
)
(
common
.
Address
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
batching
.
BlockLatest
,
f
.
contract
.
Call
(
methodVM
))
if
err
!=
nil
{
return
common
.
Address
{},
fmt
.
Errorf
(
"failed to fetch VM addr: %w"
,
err
)
}
return
result
.
GetAddress
(
0
),
nil
}
func
(
f
*
FaultDisputeGameContract
)
AttackTx
(
parentContractIndex
uint64
,
pivot
common
.
Hash
)
(
txmgr
.
TxCandidate
,
error
)
{
func
(
f
*
FaultDisputeGameContract
)
AttackTx
(
parentContractIndex
uint64
,
pivot
common
.
Hash
)
(
txmgr
.
TxCandidate
,
error
)
{
call
:=
f
.
contract
.
Call
(
methodAttack
,
new
(
big
.
Int
)
.
SetUint64
(
parentContractIndex
),
pivot
)
call
:=
f
.
contract
.
Call
(
methodAttack
,
new
(
big
.
Int
)
.
SetUint64
(
parentContractIndex
),
pivot
)
return
call
.
ToTxCandidate
()
return
call
.
ToTxCandidate
()
...
...
op-challenger/game/fault/contracts/faultdisputegame_test.go
View file @
c04fdd7a
...
@@ -74,6 +74,13 @@ func TestSimpleGetters(t *testing.T) {
...
@@ -74,6 +74,13 @@ func TestSimpleGetters(t *testing.T) {
return
game
.
CallResolve
(
context
.
Background
())
return
game
.
CallResolve
(
context
.
Background
())
},
},
},
},
{
method
:
methodVM
,
result
:
common
.
Address
{
0xab
,
0xbc
},
call
:
func
(
game
*
FaultDisputeGameContract
)
(
any
,
error
)
{
return
game
.
VMAddr
(
context
.
Background
())
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
test
:=
test
test
:=
test
...
...
op-challenger/game/fault/register.go
View file @
c04fdd7a
...
@@ -42,11 +42,12 @@ func RegisterGameTypes(
...
@@ -42,11 +42,12 @@ func RegisterGameTypes(
if
cfg
.
TraceTypeEnabled
(
config
.
TraceTypeCannon
)
{
if
cfg
.
TraceTypeEnabled
(
config
.
TraceTypeCannon
)
{
resourceCreator
:=
func
(
addr
common
.
Address
,
contract
*
contracts
.
FaultDisputeGameContract
,
gameDepth
uint64
,
dir
string
)
(
faultTypes
.
TraceAccessor
,
faultTypes
.
OracleUpdater
,
gameValidator
,
error
)
{
resourceCreator
:=
func
(
addr
common
.
Address
,
contract
*
contracts
.
FaultDisputeGameContract
,
gameDepth
uint64
,
dir
string
)
(
faultTypes
.
TraceAccessor
,
faultTypes
.
OracleUpdater
,
gameValidator
,
error
)
{
logger
:=
logger
.
New
(
"game"
,
addr
)
provider
,
err
:=
cannon
.
NewTraceProvider
(
ctx
,
logger
,
m
,
cfg
,
contract
,
dir
,
gameDepth
)
provider
,
err
:=
cannon
.
NewTraceProvider
(
ctx
,
logger
,
m
,
cfg
,
contract
,
dir
,
gameDepth
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
fmt
.
Errorf
(
"create cannon trace provider: %w"
,
err
)
return
nil
,
nil
,
nil
,
fmt
.
Errorf
(
"create cannon trace provider: %w"
,
err
)
}
}
updater
,
err
:=
cannon
.
NewOracleUpdater
(
ctx
,
logger
,
txMgr
,
addr
,
client
,
contract
)
updater
,
err
:=
cannon
.
NewOracleUpdater
(
ctx
,
logger
,
txMgr
,
client
,
contract
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
fmt
.
Errorf
(
"failed to create the cannon updater: %w"
,
err
)
return
nil
,
nil
,
nil
,
fmt
.
Errorf
(
"failed to create the cannon updater: %w"
,
err
)
}
}
...
@@ -66,6 +67,7 @@ func RegisterGameTypes(
...
@@ -66,6 +67,7 @@ func RegisterGameTypes(
}
}
if
cfg
.
TraceTypeEnabled
(
config
.
TraceTypeAlphabet
)
{
if
cfg
.
TraceTypeEnabled
(
config
.
TraceTypeAlphabet
)
{
resourceCreator
:=
func
(
addr
common
.
Address
,
contract
*
contracts
.
FaultDisputeGameContract
,
gameDepth
uint64
,
dir
string
)
(
faultTypes
.
TraceAccessor
,
faultTypes
.
OracleUpdater
,
gameValidator
,
error
)
{
resourceCreator
:=
func
(
addr
common
.
Address
,
contract
*
contracts
.
FaultDisputeGameContract
,
gameDepth
uint64
,
dir
string
)
(
faultTypes
.
TraceAccessor
,
faultTypes
.
OracleUpdater
,
gameValidator
,
error
)
{
logger
:=
logger
.
New
(
"game"
,
addr
)
provider
:=
alphabet
.
NewTraceProvider
(
cfg
.
AlphabetTrace
,
gameDepth
)
provider
:=
alphabet
.
NewTraceProvider
(
cfg
.
AlphabetTrace
,
gameDepth
)
updater
:=
alphabet
.
NewOracleUpdater
(
logger
)
updater
:=
alphabet
.
NewOracleUpdater
(
logger
)
validator
:=
func
(
ctx
context
.
Context
,
contract
*
contracts
.
FaultDisputeGameContract
)
error
{
validator
:=
func
(
ctx
context
.
Context
,
contract
*
contracts
.
FaultDisputeGameContract
)
error
{
...
...
op-challenger/game/fault/trace/cannon/updater.go
View file @
c04fdd7a
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
)
)
type
GameContract
interface
{
type
GameContract
interface
{
VMAddr
(
ctx
context
.
Context
)
(
common
.
Address
,
error
)
AddLocalDataTx
(
data
*
types
.
PreimageOracleData
)
(
txmgr
.
TxCandidate
,
error
)
AddLocalDataTx
(
data
*
types
.
PreimageOracleData
)
(
txmgr
.
TxCandidate
,
error
)
}
}
...
@@ -37,18 +38,13 @@ func NewOracleUpdater(
...
@@ -37,18 +38,13 @@ func NewOracleUpdater(
ctx
context
.
Context
,
ctx
context
.
Context
,
logger
log
.
Logger
,
logger
log
.
Logger
,
txMgr
txmgr
.
TxManager
,
txMgr
txmgr
.
TxManager
,
fdgAddr
common
.
Address
,
client
bind
.
ContractCaller
,
client
bind
.
ContractCaller
,
gameContract
GameContract
,
gameContract
GameContract
,
)
(
*
cannonUpdater
,
error
)
{
)
(
*
cannonUpdater
,
error
)
{
gameCaller
,
err
:=
bindings
.
NewFaultDisputeGameCaller
(
fdgAddr
,
client
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"create caller for game %v: %w"
,
fdgAddr
,
err
)
}
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
vm
,
err
:=
gameC
aller
.
VM
(
opts
)
vm
,
err
:=
gameC
ontract
.
VMAddr
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to load VM address
from game %v: %w"
,
fdgAddr
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to load VM address
: %w"
,
err
)
}
}
mipsCaller
,
err
:=
bindings
.
NewMIPSCaller
(
vm
,
client
)
mipsCaller
,
err
:=
bindings
.
NewMIPSCaller
(
vm
,
client
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -56,7 +52,7 @@ func NewOracleUpdater(
...
@@ -56,7 +52,7 @@ func NewOracleUpdater(
}
}
oracleAddr
,
err
:=
mipsCaller
.
Oracle
(
opts
)
oracleAddr
,
err
:=
mipsCaller
.
Oracle
(
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to load pre-image oracle address
from game %v: %w"
,
fdgAddr
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to load pre-image oracle address
: %w"
,
err
)
}
}
return
NewOracleUpdaterWithOracle
(
logger
,
txMgr
,
gameContract
,
oracleAddr
)
return
NewOracleUpdaterWithOracle
(
logger
,
txMgr
,
gameContract
,
oracleAddr
)
}
}
...
...
op-challenger/game/fault/trace/cannon/updater_test.go
View file @
c04fdd7a
...
@@ -153,6 +153,10 @@ type mockGameContract struct {
...
@@ -153,6 +153,10 @@ type mockGameContract struct {
err
error
err
error
}
}
func
(
m
*
mockGameContract
)
AddLocalDataTx
(
data
*
types
.
PreimageOracleData
)
(
txmgr
.
TxCandidate
,
error
)
{
func
(
m
*
mockGameContract
)
VMAddr
(
_
context
.
Context
)
(
common
.
Address
,
error
)
{
return
common
.
Address
{
0xcc
},
nil
}
func
(
m
*
mockGameContract
)
AddLocalDataTx
(
_
*
types
.
PreimageOracleData
)
(
txmgr
.
TxCandidate
,
error
)
{
return
m
.
tx
,
m
.
err
return
m
.
tx
,
m
.
err
}
}
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