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
786cca3d
Unverified
Commit
786cca3d
authored
Mar 21, 2024
by
Adrian Sutton
Committed by
GitHub
Mar 20, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Include bond with create game transactions (#9922)
parent
6483bb21
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
create_game.go
op-challenger/cmd/create_game.go
+1
-1
gamefactory.go
op-challenger/game/fault/contracts/gamefactory.go
+13
-2
gamefactory_test.go
op-challenger/game/fault/contracts/gamefactory_test.go
+5
-1
No files found.
op-challenger/cmd/create_game.go
View file @
786cca3d
...
@@ -43,7 +43,7 @@ func CreateGame(ctx *cli.Context) error {
...
@@ -43,7 +43,7 @@ func CreateGame(ctx *cli.Context) error {
return
fmt
.
Errorf
(
"failed to create dispute game factory bindings: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to create dispute game factory bindings: %w"
,
err
)
}
}
txCandidate
,
err
:=
contract
.
CreateTx
(
uint32
(
traceType
),
outputRoot
,
l2BlockNum
)
txCandidate
,
err
:=
contract
.
CreateTx
(
ctx
.
Context
,
uint32
(
traceType
),
outputRoot
,
l2BlockNum
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to create tx: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to create tx: %w"
,
err
)
}
}
...
...
op-challenger/game/fault/contracts/gamefactory.go
View file @
786cca3d
...
@@ -17,6 +17,7 @@ const (
...
@@ -17,6 +17,7 @@ const (
methodGameCount
=
"gameCount"
methodGameCount
=
"gameCount"
methodGameAtIndex
=
"gameAtIndex"
methodGameAtIndex
=
"gameAtIndex"
methodGameImpls
=
"gameImpls"
methodGameImpls
=
"gameImpls"
methodInitBonds
=
"initBonds"
methodCreateGame
=
"create"
methodCreateGame
=
"create"
methodGames
=
"games"
methodGames
=
"games"
)
)
...
@@ -135,9 +136,19 @@ func (f *DisputeGameFactoryContract) GetAllGames(ctx context.Context, blockHash
...
@@ -135,9 +136,19 @@ func (f *DisputeGameFactoryContract) GetAllGames(ctx context.Context, blockHash
return
games
,
nil
return
games
,
nil
}
}
func
(
f
*
DisputeGameFactoryContract
)
CreateTx
(
traceType
uint32
,
outputRoot
common
.
Hash
,
l2BlockNum
uint64
)
(
txmgr
.
TxCandidate
,
error
)
{
func
(
f
*
DisputeGameFactoryContract
)
CreateTx
(
ctx
context
.
Context
,
traceType
uint32
,
outputRoot
common
.
Hash
,
l2BlockNum
uint64
)
(
txmgr
.
TxCandidate
,
error
)
{
result
,
err
:=
f
.
multiCaller
.
SingleCall
(
ctx
,
rpcblock
.
Latest
,
f
.
contract
.
Call
(
methodInitBonds
,
traceType
))
if
err
!=
nil
{
return
txmgr
.
TxCandidate
{},
fmt
.
Errorf
(
"failed to fetch init bond: %w"
,
err
)
}
initBond
:=
result
.
GetBigInt
(
0
)
call
:=
f
.
contract
.
Call
(
methodCreateGame
,
traceType
,
outputRoot
,
common
.
BigToHash
(
big
.
NewInt
(
int64
(
l2BlockNum
)))
.
Bytes
())
call
:=
f
.
contract
.
Call
(
methodCreateGame
,
traceType
,
outputRoot
,
common
.
BigToHash
(
big
.
NewInt
(
int64
(
l2BlockNum
)))
.
Bytes
())
return
call
.
ToTxCandidate
()
candidate
,
err
:=
call
.
ToTxCandidate
()
if
err
!=
nil
{
return
txmgr
.
TxCandidate
{},
err
}
candidate
.
Value
=
initBond
return
candidate
,
err
}
}
func
(
f
*
DisputeGameFactoryContract
)
decodeGame
(
result
*
batching
.
CallResult
)
types
.
GameMetadata
{
func
(
f
*
DisputeGameFactoryContract
)
decodeGame
(
result
*
batching
.
CallResult
)
types
.
GameMetadata
{
...
...
op-challenger/game/fault/contracts/gamefactory_test.go
View file @
786cca3d
...
@@ -212,10 +212,14 @@ func TestCreateTx(t *testing.T) {
...
@@ -212,10 +212,14 @@ func TestCreateTx(t *testing.T) {
traceType
:=
uint32
(
123
)
traceType
:=
uint32
(
123
)
outputRoot
:=
common
.
Hash
{
0x01
}
outputRoot
:=
common
.
Hash
{
0x01
}
l2BlockNum
:=
common
.
BigToHash
(
big
.
NewInt
(
456
))
.
Bytes
()
l2BlockNum
:=
common
.
BigToHash
(
big
.
NewInt
(
456
))
.
Bytes
()
bond
:=
big
.
NewInt
(
49284294829
)
stubRpc
.
SetResponse
(
factoryAddr
,
methodInitBonds
,
rpcblock
.
Latest
,
[]
interface
{}{
traceType
},
[]
interface
{}{
bond
})
stubRpc
.
SetResponse
(
factoryAddr
,
methodCreateGame
,
rpcblock
.
Latest
,
[]
interface
{}{
traceType
,
outputRoot
,
l2BlockNum
},
nil
)
stubRpc
.
SetResponse
(
factoryAddr
,
methodCreateGame
,
rpcblock
.
Latest
,
[]
interface
{}{
traceType
,
outputRoot
,
l2BlockNum
},
nil
)
tx
,
err
:=
factory
.
CreateTx
(
traceType
,
outputRoot
,
uint64
(
456
))
tx
,
err
:=
factory
.
CreateTx
(
context
.
Background
(),
traceType
,
outputRoot
,
uint64
(
456
))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
stubRpc
.
VerifyTxCandidate
(
tx
)
stubRpc
.
VerifyTxCandidate
(
tx
)
require
.
NotNil
(
t
,
tx
.
Value
)
require
.
Truef
(
t
,
bond
.
Cmp
(
tx
.
Value
)
==
0
,
"Expected bond %v but was %v"
,
bond
,
tx
.
Value
)
}
}
func
setupDisputeGameFactoryTest
(
t
*
testing
.
T
)
(
*
batchingTest
.
AbiBasedRpc
,
*
DisputeGameFactoryContract
)
{
func
setupDisputeGameFactoryTest
(
t
*
testing
.
T
)
(
*
batchingTest
.
AbiBasedRpc
,
*
DisputeGameFactoryContract
)
{
...
...
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