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
57a89fbb
Unverified
Commit
57a89fbb
authored
Jan 17, 2023
by
Michael de Hoog
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Receive latest block hash from admin_stopSequencer
Pass block hash to admin_startSequencer
parent
f4b6928d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
39 deletions
+66
-39
l2_verifier.go
op-e2e/actions/l2_verifier.go
+3
-3
system_test.go
op-e2e/system_test.go
+3
-2
api.go
op-node/node/api.go
+5
-5
server_test.go
op-node/node/server_test.go
+3
-3
driver.go
op-node/rollup/driver/driver.go
+2
-2
state.go
op-node/rollup/driver/state.go
+50
-24
No files found.
op-e2e/actions/l2_verifier.go
View file @
57a89fbb
...
...
@@ -113,12 +113,12 @@ func (s *l2VerifierBackend) ResetDerivationPipeline(ctx context.Context) error {
return
nil
}
func
(
s
*
l2VerifierBackend
)
StartSequencer
(
ctx
context
.
Context
)
error
{
func
(
s
*
l2VerifierBackend
)
StartSequencer
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
error
{
return
nil
}
func
(
s
*
l2VerifierBackend
)
StopSequencer
(
ctx
context
.
Context
)
error
{
return
errors
.
New
(
"stopping the L2Verifier sequencer is not supported"
)
func
(
s
*
l2VerifierBackend
)
StopSequencer
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
return
common
.
Hash
{},
errors
.
New
(
"stopping the L2Verifier sequencer is not supported"
)
}
func
(
s
*
L2Verifier
)
L2Finalized
()
eth
.
L2BlockRef
{
...
...
op-e2e/system_test.go
View file @
57a89fbb
...
...
@@ -1153,7 +1153,8 @@ func TestStopStartSequencer(t *testing.T) {
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
err
=
nodeRPC
.
CallContext
(
ctx
,
nil
,
"admin_stopSequencer"
)
blockHash
:=
common
.
Hash
{}
err
=
nodeRPC
.
CallContext
(
ctx
,
&
blockHash
,
"admin_stopSequencer"
)
require
.
Nil
(
t
,
err
,
"Error stopping sequencer"
)
blockBefore
=
latestBlock
(
t
,
l2Seq
)
...
...
@@ -1163,7 +1164,7 @@ func TestStopStartSequencer(t *testing.T) {
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
err
=
nodeRPC
.
CallContext
(
ctx
,
nil
,
"admin_startSequencer"
)
err
=
nodeRPC
.
CallContext
(
ctx
,
nil
,
"admin_startSequencer"
,
blockHash
)
require
.
Nil
(
t
,
err
,
"Error starting sequencer"
)
blockBefore
=
latestBlock
(
t
,
l2Seq
)
...
...
op-node/node/api.go
View file @
57a89fbb
...
...
@@ -26,8 +26,8 @@ type driverClient interface {
SyncStatus
(
ctx
context
.
Context
)
(
*
eth
.
SyncStatus
,
error
)
BlockRefWithStatus
(
ctx
context
.
Context
,
num
uint64
)
(
eth
.
L2BlockRef
,
*
eth
.
SyncStatus
,
error
)
ResetDerivationPipeline
(
context
.
Context
)
error
StartSequencer
(
c
ontext
.
Context
)
error
StopSequencer
(
context
.
Context
)
error
StartSequencer
(
c
tx
context
.
Context
,
blockHash
common
.
Hash
)
error
StopSequencer
(
context
.
Context
)
(
common
.
Hash
,
error
)
}
type
rpcMetrics
interface
{
...
...
@@ -53,13 +53,13 @@ func (n *adminAPI) ResetDerivationPipeline(ctx context.Context) error {
return
n
.
dr
.
ResetDerivationPipeline
(
ctx
)
}
func
(
n
*
adminAPI
)
StartSequencer
(
ctx
context
.
Context
)
error
{
func
(
n
*
adminAPI
)
StartSequencer
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
error
{
recordDur
:=
n
.
m
.
RecordRPCServerRequest
(
"admin_startSequencer"
)
defer
recordDur
()
return
n
.
dr
.
StartSequencer
(
ctx
)
return
n
.
dr
.
StartSequencer
(
ctx
,
blockHash
)
}
func
(
n
*
adminAPI
)
StopSequencer
(
ctx
context
.
Context
)
error
{
func
(
n
*
adminAPI
)
StopSequencer
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
recordDur
:=
n
.
m
.
RecordRPCServerRequest
(
"admin_stopSequencer"
)
defer
recordDur
()
return
n
.
dr
.
StopSequencer
(
ctx
)
...
...
op-node/node/server_test.go
View file @
57a89fbb
...
...
@@ -219,10 +219,10 @@ func (c *mockDriverClient) ResetDerivationPipeline(ctx context.Context) error {
return
c
.
Mock
.
MethodCalled
(
"ResetDerivationPipeline"
)
.
Get
(
0
)
.
(
error
)
}
func
(
c
*
mockDriverClient
)
StartSequencer
(
ctx
context
.
Context
)
error
{
func
(
c
*
mockDriverClient
)
StartSequencer
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
error
{
return
c
.
Mock
.
MethodCalled
(
"StartSequencer"
)
.
Get
(
0
)
.
(
error
)
}
func
(
c
*
mockDriverClient
)
StopSequencer
(
ctx
context
.
Context
)
error
{
return
c
.
Mock
.
MethodCalled
(
"StopSequencer"
)
.
Get
(
0
)
.
(
error
)
func
(
c
*
mockDriverClient
)
StopSequencer
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
return
c
.
Mock
.
MethodCalled
(
"StopSequencer"
)
.
Get
(
0
)
.
(
common
.
Hash
),
nil
}
op-node/rollup/driver/driver.go
View file @
57a89fbb
...
...
@@ -97,8 +97,8 @@ func NewDriver(driverCfg *Config, cfg *rollup.Config, l2 L2Chain, l1 L1Chain, ne
idleDerivation
:
false
,
stateReq
:
make
(
chan
chan
struct
{}),
forceReset
:
make
(
chan
chan
struct
{},
10
),
startSequencer
:
make
(
chan
chan
struct
{}
,
10
),
stopSequencer
:
make
(
chan
chan
struct
{}
,
10
),
startSequencer
:
make
(
chan
hashAndErrorChannel
,
10
),
stopSequencer
:
make
(
chan
chan
hashAndError
,
10
),
config
:
cfg
,
driverConfig
:
driverCfg
,
done
:
make
(
chan
struct
{}),
...
...
op-node/rollup/driver/state.go
View file @
57a89fbb
package
driver
import
(
"bytes"
"context"
"encoding/json"
"errors"
...
...
@@ -9,6 +10,7 @@ import (
gosync
"sync"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-node/eth"
...
...
@@ -42,13 +44,13 @@ type Driver struct {
// It tells the caller that the reset occurred by closing the passed in channel.
forceReset
chan
chan
struct
{}
// Upon receiving a
channel in this channel, the sequencer is started
.
// It tells the caller that the sequencer started by closing the passed in channel.
startSequencer
chan
chan
struct
{}
// Upon receiving a
hash in this channel, the sequencer is started at the given hash
.
// It tells the caller that the sequencer started by closing the passed in channel
(or returning an error)
.
startSequencer
chan
hashAndErrorChannel
// Upon receiving a channel in this channel, the sequencer is stopped.
// It tells the caller that the sequencer stopped by
closing the passed in channel
.
stopSequencer
chan
chan
struct
{}
// It tells the caller that the sequencer stopped by
returning the latest sequenced L2 block hash
.
stopSequencer
chan
chan
hashAndError
// Rollup config: rollup chain configuration
config
*
rollup
.
Config
...
...
@@ -375,15 +377,26 @@ func (s *Driver) eventLoop() {
s
.
derivation
.
Reset
()
s
.
metrics
.
RecordPipelineReset
()
close
(
respCh
)
case
respCh
:=
<-
s
.
startSequencer
:
case
resp
:=
<-
s
.
startSequencer
:
unsafeHead
:=
s
.
derivation
.
UnsafeL2Head
()
.
Hash
if
s
.
driverConfig
.
SequencerEnabled
{
resp
.
err
<-
errors
.
New
(
"sequencer already running"
)
}
else
if
!
bytes
.
Equal
(
unsafeHead
[
:
],
resp
.
hash
[
:
])
{
resp
.
err
<-
fmt
.
Errorf
(
"block hash does not match: head %s, received %s"
,
unsafeHead
.
String
(),
resp
.
hash
.
String
())
}
else
{
s
.
log
.
Info
(
"Sequencer has been started"
)
s
.
driverConfig
.
SequencerEnabled
=
true
sequencingPlannedOnto
=
eth
.
BlockID
{}
close
(
respCh
)
close
(
resp
.
err
)
}
case
respCh
:=
<-
s
.
stopSequencer
:
if
!
s
.
driverConfig
.
SequencerEnabled
{
respCh
<-
hashAndError
{
err
:
errors
.
New
(
"sequencer not running"
)}
}
else
{
s
.
log
.
Warn
(
"Sequencer has been stopped"
)
s
.
driverConfig
.
SequencerEnabled
=
false
close
(
respCh
)
respCh
<-
hashAndError
{
hash
:
s
.
derivation
.
UnsafeL2Head
()
.
Hash
}
}
case
<-
s
.
done
:
return
}
...
...
@@ -408,32 +421,35 @@ func (s *Driver) ResetDerivationPipeline(ctx context.Context) error {
}
}
func
(
s
*
Driver
)
StartSequencer
(
ctx
context
.
Context
)
error
{
respCh
:=
make
(
chan
struct
{},
1
)
func
(
s
*
Driver
)
StartSequencer
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
error
{
h
:=
hashAndErrorChannel
{
hash
:
blockHash
,
err
:
make
(
chan
error
,
1
),
}
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
case
s
.
startSequencer
<-
respC
h
:
case
s
.
startSequencer
<-
h
:
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
case
<-
respCh
:
return
nil
case
e
:=
<-
h
.
err
:
return
e
}
}
}
func
(
s
*
Driver
)
StopSequencer
(
ctx
context
.
Context
)
error
{
respCh
:=
make
(
chan
struct
{}
,
1
)
func
(
s
*
Driver
)
StopSequencer
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
respCh
:=
make
(
chan
hashAndError
,
1
)
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
return
c
ommon
.
Hash
{},
c
tx
.
Err
()
case
s
.
stopSequencer
<-
respCh
:
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
case
<-
respCh
:
return
nil
return
c
ommon
.
Hash
{},
c
tx
.
Err
()
case
he
:=
<-
respCh
:
return
he
.
hash
,
he
.
err
}
}
}
...
...
@@ -502,3 +518,13 @@ func (s *Driver) snapshot(event string) {
"l2Safe"
,
deferJSONString
{
s
.
derivation
.
SafeL2Head
()},
"l2FinalizedHead"
,
deferJSONString
{
s
.
derivation
.
Finalized
()})
}
type
hashAndError
struct
{
hash
common
.
Hash
err
error
}
type
hashAndErrorChannel
struct
{
hash
common
.
Hash
err
chan
error
}
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