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
157e89a2
Unverified
Commit
157e89a2
authored
2 years ago
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: action test derivation with flaky l1 rpc
parent
8fed3675
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
7 deletions
+68
-7
l1_replica.go
op-e2e/actions/l1_replica.go
+17
-7
sync_test.go
op-e2e/actions/sync_test.go
+51
-0
No files found.
op-e2e/actions/l1_replica.go
View file @
157e89a2
...
...
@@ -42,7 +42,7 @@ type L1Replica struct {
l1Cfg
*
core
.
Genesis
l1Signer
types
.
Signer
failL1RPC
error
// mock error
failL1RPC
func
()
error
// mock error
}
// NewL1Replica constructs a L1Replica starting at the given genesis.
...
...
@@ -145,10 +145,18 @@ func (s *L1Replica) CanonL1Chain() func(num uint64) *types.Block {
// ActL1RPCFail makes the next L1 RPC request to this node fail
func
(
s
*
L1Replica
)
ActL1RPCFail
(
t
Testing
)
{
if
s
.
failL1RPC
!=
nil
{
// already set to fail?
t
.
InvalidAction
(
"already have a mock l1 rpc fail set"
)
failed
:=
false
s
.
failL1RPC
=
func
()
error
{
if
failed
{
return
nil
}
failed
=
true
return
errors
.
New
(
"mock L1 RPC error"
)
}
s
.
failL1RPC
=
errors
.
New
(
"mock L1 RPC error"
)
}
func
(
s
*
L1Replica
)
MockL1RPCErrors
(
fn
func
()
error
)
{
s
.
failL1RPC
=
fn
}
func
(
s
*
L1Replica
)
EthClient
()
*
ethclient
.
Client
{
...
...
@@ -161,9 +169,11 @@ func (s *L1Replica) RPCClient() client.RPC {
return
testutils
.
RPCErrFaker
{
RPC
:
client
.
NewBaseRPCClient
(
cl
),
ErrFn
:
func
()
error
{
err
:=
s
.
failL1RPC
s
.
failL1RPC
=
nil
// reset back, only error once.
return
err
if
s
.
failL1RPC
!=
nil
{
return
s
.
failL1RPC
()
}
else
{
return
nil
}
},
}
}
...
...
This diff is collapsed.
Click to expand it.
op-e2e/actions/sync_test.go
0 → 100644
View file @
157e89a2
package
actions
import
(
"errors"
"math/rand"
"testing"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)
func
TestDerivationWithFlakyL1RPC
(
gt
*
testing
.
T
)
{
t
:=
NewDefaultTesting
(
gt
)
dp
:=
e2eutils
.
MakeDeployParams
(
t
,
defaultRollupTestParams
)
sd
:=
e2eutils
.
Setup
(
t
,
dp
,
defaultAlloc
)
log
:=
testlog
.
Logger
(
t
,
log
.
LvlError
)
// mute all the temporary derivation errors that we forcefully create
_
,
miner
,
sequencer
,
_
,
verifier
,
_
,
batcher
:=
setupReorgTestActors
(
t
,
dp
,
sd
,
log
)
rng
:=
rand
.
New
(
rand
.
NewSource
(
1234
))
sequencer
.
ActL2PipelineFull
(
t
)
verifier
.
ActL2PipelineFull
(
t
)
// build a L1 chain with 20 blocks and matching L2 chain and batches to test some derivation work
miner
.
ActEmptyBlock
(
t
)
for
i
:=
0
;
i
<
20
;
i
++
{
sequencer
.
ActL1HeadSignal
(
t
)
sequencer
.
ActL2PipelineFull
(
t
)
sequencer
.
ActBuildToL1Head
(
t
)
batcher
.
ActSubmitAll
(
t
)
miner
.
ActL1StartBlock
(
12
)(
t
)
miner
.
ActL1IncludeTx
(
batcher
.
batcherAddr
)(
t
)
miner
.
ActL1EndBlock
(
t
)
}
// Make verifier aware of head
verifier
.
ActL1HeadSignal
(
t
)
// Now make the L1 RPC very flaky: requests will randomly fail with 50% chance
miner
.
MockL1RPCErrors
(
func
()
error
{
if
rng
.
Intn
(
2
)
==
0
{
return
errors
.
New
(
"mock rpc error"
)
}
return
nil
})
// And sync the verifier
verifier
.
ActL2PipelineFull
(
t
)
// Verifier should be synced, even though it hit lots of temporary L1 RPC errors
require
.
Equal
(
t
,
sequencer
.
L2Unsafe
(),
verifier
.
L2Safe
(),
"verifier is synced"
)
}
This diff is collapsed.
Click to expand it.
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