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
90449eb7
Unverified
Commit
90449eb7
authored
Aug 15, 2023
by
mergify[bot]
Committed by
GitHub
Aug 15, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into jg/txmgr_harden
parents
0e52218c
c501244f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
27 deletions
+72
-27
helper.go
op-e2e/e2eutils/disputegame/helper.go
+21
-1
faultproof_test.go
op-e2e/faultproof_test.go
+31
-0
operation.go
op-service/backoff/operation.go
+20
-26
No files found.
op-e2e/e2eutils/disputegame/helper.go
View file @
90449eb7
...
@@ -11,7 +11,9 @@ import (
...
@@ -11,7 +11,9 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/fault/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/fault/alphabet"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
...
@@ -52,6 +54,7 @@ type FactoryHelper struct {
...
@@ -52,6 +54,7 @@ type FactoryHelper struct {
require
*
require
.
Assertions
require
*
require
.
Assertions
client
*
ethclient
.
Client
client
*
ethclient
.
Client
opts
*
bind
.
TransactOpts
opts
*
bind
.
TransactOpts
factoryAddr
common
.
Address
factory
*
bindings
.
DisputeGameFactory
factory
*
bindings
.
DisputeGameFactory
blockOracle
*
bindings
.
BlockOracle
blockOracle
*
bindings
.
BlockOracle
l2oo
*
bindings
.
L2OutputOracleCaller
l2oo
*
bindings
.
L2OutputOracleCaller
...
@@ -65,7 +68,8 @@ func NewFactoryHelper(t *testing.T, ctx context.Context, deployments *genesis.L1
...
@@ -65,7 +68,8 @@ func NewFactoryHelper(t *testing.T, ctx context.Context, deployments *genesis.L1
require
.
NoError
(
err
)
require
.
NoError
(
err
)
require
.
NotNil
(
deployments
,
"No deployments"
)
require
.
NotNil
(
deployments
,
"No deployments"
)
factory
,
err
:=
bindings
.
NewDisputeGameFactory
(
deployments
.
DisputeGameFactoryProxy
,
client
)
factoryAddr
:=
deployments
.
DisputeGameFactoryProxy
factory
,
err
:=
bindings
.
NewDisputeGameFactory
(
factoryAddr
,
client
)
require
.
NoError
(
err
)
require
.
NoError
(
err
)
blockOracle
,
err
:=
bindings
.
NewBlockOracle
(
deployments
.
BlockOracle
,
client
)
blockOracle
,
err
:=
bindings
.
NewBlockOracle
(
deployments
.
BlockOracle
,
client
)
require
.
NoError
(
err
)
require
.
NoError
(
err
)
...
@@ -78,6 +82,7 @@ func NewFactoryHelper(t *testing.T, ctx context.Context, deployments *genesis.L1
...
@@ -78,6 +82,7 @@ func NewFactoryHelper(t *testing.T, ctx context.Context, deployments *genesis.L1
client
:
client
,
client
:
client
,
opts
:
opts
,
opts
:
opts
,
factory
:
factory
,
factory
:
factory
,
factoryAddr
:
factoryAddr
,
blockOracle
:
blockOracle
,
blockOracle
:
blockOracle
,
l2oo
:
l2oo
,
l2oo
:
l2oo
,
}
}
...
@@ -150,6 +155,21 @@ func (h *FactoryHelper) StartCannonGame(ctx context.Context, rootClaim common.Ha
...
@@ -150,6 +155,21 @@ func (h *FactoryHelper) StartCannonGame(ctx context.Context, rootClaim common.Ha
},
},
}
}
}
}
func
(
h
*
FactoryHelper
)
StartChallenger
(
ctx
context
.
Context
,
l1Endpoint
string
,
name
string
,
options
...
challenger
.
Option
)
*
challenger
.
Helper
{
opts
:=
[]
challenger
.
Option
{
func
(
c
*
config
.
Config
)
{
// Uncomment when challenger actually supports setting the game factory address
//c.FactoryAddress = h.factoryAddr
c
.
TraceType
=
config
.
TraceTypeAlphabet
},
}
opts
=
append
(
opts
,
options
...
)
c
:=
challenger
.
NewChallenger
(
h
.
t
,
ctx
,
l1Endpoint
,
name
,
opts
...
)
h
.
t
.
Cleanup
(
func
()
{
_
=
c
.
Close
()
})
return
c
}
// waitForProposals waits until there are at least two proposals in the output oracle
// waitForProposals waits until there are at least two proposals in the output oracle
// This is the minimum required for creating a game.
// This is the minimum required for creating a game.
...
...
op-e2e/faultproof_test.go
View file @
90449eb7
...
@@ -13,6 +13,37 @@ import (
...
@@ -13,6 +13,37 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
func
TestCannonMultipleGames
(
t
*
testing
.
T
)
{
t
.
Skip
(
"Challenger doesn't yet support multiple games"
)
InitParallel
(
t
)
ctx
:=
context
.
Background
()
sys
,
l1Client
:=
startFaultDisputeSystem
(
t
)
t
.
Cleanup
(
sys
.
Close
)
gameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
.
cfg
.
L1Deployments
,
l1Client
)
// Start a challenger with the correct alphabet trace
gameFactory
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"TowerDefense"
,
func
(
c
*
config
.
Config
)
{
c
.
AgreeWithProposedOutput
=
true
c
.
AlphabetTrace
=
"abcdefg"
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Alice
)
})
game1
:=
gameFactory
.
StartAlphabetGame
(
ctx
,
"abcxyz"
)
// Wait for the challenger to respond to the first game
game1
.
WaitForClaimCount
(
ctx
,
2
)
game2
:=
gameFactory
.
StartAlphabetGame
(
ctx
,
"zyxabc"
)
// Wait for the challenger to respond to the second game
game2
.
WaitForClaimCount
(
ctx
,
2
)
// Challenger should respond to new claims
game2
.
Attack
(
ctx
,
1
,
common
.
Hash
{
0xaa
})
game2
.
WaitForClaimCount
(
ctx
,
4
)
game1
.
Defend
(
ctx
,
1
,
common
.
Hash
{
0xaa
})
game1
.
WaitForClaimCount
(
ctx
,
4
)
}
func
TestResolveDisputeGame
(
t
*
testing
.
T
)
{
func
TestResolveDisputeGame
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
InitParallel
(
t
)
...
...
op-service/backoff/operation.go
View file @
90449eb7
...
@@ -17,6 +17,10 @@ func (e *ErrFailedPermanently) Error() string {
...
@@ -17,6 +17,10 @@ func (e *ErrFailedPermanently) Error() string {
return
fmt
.
Sprintf
(
"operation failed permanently after %d attempts: %v"
,
e
.
attempts
,
e
.
LastErr
)
return
fmt
.
Sprintf
(
"operation failed permanently after %d attempts: %v"
,
e
.
attempts
,
e
.
LastErr
)
}
}
func
(
e
*
ErrFailedPermanently
)
Unwrap
()
error
{
return
e
.
LastErr
}
type
pair
[
T
,
U
any
]
struct
{
type
pair
[
T
,
U
any
]
struct
{
a
T
a
T
b
U
b
U
...
@@ -35,37 +39,27 @@ func Do2[T, U any](ctx context.Context, maxAttempts int, strategy Strategy, op f
...
@@ -35,37 +39,27 @@ func Do2[T, U any](ctx context.Context, maxAttempts int, strategy Strategy, op f
// with delays in between each retry according to the provided
// with delays in between each retry according to the provided
// Strategy.
// Strategy.
func
Do
[
T
any
](
ctx
context
.
Context
,
maxAttempts
int
,
strategy
Strategy
,
op
func
()
(
T
,
error
))
(
T
,
error
)
{
func
Do
[
T
any
](
ctx
context
.
Context
,
maxAttempts
int
,
strategy
Strategy
,
op
func
()
(
T
,
error
))
(
T
,
error
)
{
var
empty
T
var
empty
,
ret
T
var
err
error
if
maxAttempts
<
1
{
if
maxAttempts
<
1
{
return
empty
,
fmt
.
Errorf
(
"need at least 1 attempt to run op, but have %d max attempts"
,
maxAttempts
)
return
empty
,
fmt
.
Errorf
(
"need at least 1 attempt to run op, but have %d max attempts"
,
maxAttempts
)
}
}
var
attempt
int
reattemptCh
:=
make
(
chan
struct
{},
1
)
for
i
:=
0
;
i
<
maxAttempts
;
i
++
{
doReattempt
:=
func
()
{
if
ctx
.
Err
()
!=
nil
{
reattemptCh
<-
struct
{}{}
}
doReattempt
()
for
{
select
{
case
<-
ctx
.
Done
()
:
return
empty
,
ctx
.
Err
()
return
empty
,
ctx
.
Err
()
case
<-
reattemptCh
:
attempt
++
ret
,
err
:=
op
()
if
err
==
nil
{
return
ret
,
nil
}
if
attempt
==
maxAttempts
{
return
empty
,
&
ErrFailedPermanently
{
attempts
:
maxAttempts
,
LastErr
:
err
,
}
}
time
.
AfterFunc
(
strategy
.
Duration
(
attempt
-
1
),
doReattempt
)
}
}
ret
,
err
=
op
()
if
err
==
nil
{
return
ret
,
nil
}
// Don't sleep when we are about to exit the loop & return ErrFailedPermanently
if
i
!=
maxAttempts
-
1
{
time
.
Sleep
(
strategy
.
Duration
(
i
))
}
}
return
empty
,
&
ErrFailedPermanently
{
attempts
:
maxAttempts
,
LastErr
:
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