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
449321bd
Unverified
Commit
449321bd
authored
Jun 22, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Notify sequencer state listener when starting and stopping sequencer
parent
d252ea2b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
node.go
op-node/node/node.go
+1
-1
driver.go
op-node/rollup/driver/driver.go
+7
-1
state.go
op-node/rollup/driver/state.go
+11
-0
No files found.
op-node/node/node.go
View file @
449321bd
...
...
@@ -199,7 +199,7 @@ func (n *OpNode) initL2(ctx context.Context, cfg *Config, snapshotLog log.Logger
return
err
}
n
.
l2Driver
=
driver
.
NewDriver
(
&
cfg
.
Driver
,
&
cfg
.
Rollup
,
n
.
l2Source
,
n
.
l1Source
,
n
,
n
,
n
.
log
,
snapshotLog
,
n
.
metrics
)
n
.
l2Driver
=
driver
.
NewDriver
(
&
cfg
.
Driver
,
&
cfg
.
Rollup
,
n
.
l2Source
,
n
.
l1Source
,
n
,
n
,
n
.
log
,
snapshotLog
,
n
.
metrics
,
DisabledConfigPersistence
{}
)
return
nil
}
...
...
op-node/rollup/driver/driver.go
View file @
449321bd
...
...
@@ -102,8 +102,13 @@ type AltSync interface {
RequestL2Range
(
ctx
context
.
Context
,
start
,
end
eth
.
L2BlockRef
)
error
}
type
SequencerStateListener
interface
{
SequencerStarted
()
error
SequencerStopped
()
error
}
// NewDriver composes an events handler that tracks L1 state, triggers L2 derivation, and optionally sequences new L2 blocks.
func
NewDriver
(
driverCfg
*
Config
,
cfg
*
rollup
.
Config
,
l2
L2Chain
,
l1
L1Chain
,
altSync
AltSync
,
network
Network
,
log
log
.
Logger
,
snapshotLog
log
.
Logger
,
metrics
Metrics
)
*
Driver
{
func
NewDriver
(
driverCfg
*
Config
,
cfg
*
rollup
.
Config
,
l2
L2Chain
,
l1
L1Chain
,
altSync
AltSync
,
network
Network
,
log
log
.
Logger
,
snapshotLog
log
.
Logger
,
metrics
Metrics
,
sequencerStateListener
SequencerStateListener
)
*
Driver
{
l1
=
NewMeteredL1Fetcher
(
l1
,
metrics
)
l1State
:=
NewL1State
(
log
,
metrics
)
sequencerConfDepth
:=
NewConfDepth
(
driverCfg
.
SequencerConfDepth
,
l1State
.
L1Head
,
l1
)
...
...
@@ -122,6 +127,7 @@ func NewDriver(driverCfg *Config, cfg *rollup.Config, l2 L2Chain, l1 L1Chain, al
forceReset
:
make
(
chan
chan
struct
{},
10
),
startSequencer
:
make
(
chan
hashAndErrorChannel
,
10
),
stopSequencer
:
make
(
chan
chan
hashAndError
,
10
),
sequencerNotifs
:
sequencerStateListener
,
config
:
cfg
,
driverConfig
:
driverCfg
,
done
:
make
(
chan
struct
{}),
...
...
op-node/rollup/driver/state.go
View file @
449321bd
...
...
@@ -47,6 +47,9 @@ type Driver struct {
// It tells the caller that the sequencer stopped by returning the latest sequenced L2 block hash.
stopSequencer
chan
chan
hashAndError
// sequencerNotifs is notified when the sequencer is started or stopped
sequencerNotifs
SequencerStateListener
// Rollup config: rollup chain configuration
config
*
rollup
.
Config
...
...
@@ -334,6 +337,10 @@ func (s *Driver) eventLoop() {
}
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
{
if
err
:=
s
.
sequencerNotifs
.
SequencerStarted
();
err
!=
nil
{
resp
.
err
<-
fmt
.
Errorf
(
"sequencer start notification: %w"
,
err
)
continue
}
s
.
log
.
Info
(
"Sequencer has been started"
)
s
.
driverConfig
.
SequencerStopped
=
false
close
(
resp
.
err
)
...
...
@@ -343,6 +350,10 @@ func (s *Driver) eventLoop() {
if
s
.
driverConfig
.
SequencerStopped
{
respCh
<-
hashAndError
{
err
:
errors
.
New
(
"sequencer not running"
)}
}
else
{
if
err
:=
s
.
sequencerNotifs
.
SequencerStopped
();
err
!=
nil
{
respCh
<-
hashAndError
{
err
:
fmt
.
Errorf
(
"sequencer start notification: %w"
,
err
)}
continue
}
s
.
log
.
Warn
(
"Sequencer has been stopped"
)
s
.
driverConfig
.
SequencerStopped
=
true
respCh
<-
hashAndError
{
hash
:
s
.
derivation
.
UnsafeL2Head
()
.
Hash
}
...
...
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