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
03994850
Unverified
Commit
03994850
authored
Jun 28, 2023
by
OptimismBot
Committed by
GitHub
Jun 28, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6190 from ethereum-optimism/aj/get-synch-status
op-node: Add `admin_sequencerActive` RPC method
parents
ff6d2983
bff6bab5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
4 deletions
+69
-4
l2_verifier.go
op-e2e/actions/l2_verifier.go
+4
-0
system_adminrpc_test.go
op-e2e/system_adminrpc_test.go
+22
-4
api.go
op-node/node/api.go
+7
-0
server_test.go
op-node/node/server_test.go
+4
-0
driver.go
op-node/rollup/driver/driver.go
+1
-0
state.go
op-node/rollup/driver/state.go
+25
-0
rollupclient.go
op-node/sources/rollupclient.go
+6
-0
No files found.
op-e2e/actions/l2_verifier.go
View file @
03994850
...
...
@@ -121,6 +121,10 @@ func (s *l2VerifierBackend) StopSequencer(ctx context.Context) (common.Hash, err
return
common
.
Hash
{},
errors
.
New
(
"stopping the L2Verifier sequencer is not supported"
)
}
func
(
s
*
l2VerifierBackend
)
SequencerActive
(
ctx
context
.
Context
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
s
*
L2Verifier
)
L2Finalized
()
eth
.
L2BlockRef
{
return
s
.
derivation
.
Finalized
()
}
...
...
op-e2e/system_adminrpc_test.go
View file @
03994850
...
...
@@ -26,18 +26,30 @@ func TestStopStartSequencer(t *testing.T) {
nodeRPC
,
err
:=
rpc
.
DialContext
(
context
.
Background
(),
rollupNode
.
HTTPEndpoint
())
require
.
Nil
(
t
,
err
,
"Error dialing node"
)
rollupClient
:=
sources
.
NewRollupClient
(
client
.
NewBaseRPCClient
(
nodeRPC
))
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
active
,
err
:=
rollupClient
.
SequencerActive
(
ctx
)
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
active
,
"sequencer should be active"
)
blockBefore
:=
latestBlock
(
t
,
l2Seq
)
time
.
Sleep
(
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
+
1
)
*
time
.
Second
)
blockAfter
:=
latestBlock
(
t
,
l2Seq
)
require
.
Greaterf
(
t
,
blockAfter
,
blockBefore
,
"Chain did not advance"
)
ctx
,
cancel
:
=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
blockHash
:=
common
.
Hash
{}
err
=
nodeRPC
.
CallContext
(
ctx
,
&
blockHash
,
"admin_stopSequencer"
)
blockHash
,
err
:=
rollupClient
.
StopSequencer
(
ctx
)
require
.
Nil
(
t
,
err
,
"Error stopping sequencer"
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
active
,
err
=
rollupClient
.
SequencerActive
(
ctx
)
require
.
NoError
(
t
,
err
)
require
.
False
(
t
,
active
,
"sequencer should be inactive"
)
blockBefore
=
latestBlock
(
t
,
l2Seq
)
time
.
Sleep
(
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
+
1
)
*
time
.
Second
)
blockAfter
=
latestBlock
(
t
,
l2Seq
)
...
...
@@ -45,9 +57,15 @@ func TestStopStartSequencer(t *testing.T) {
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
err
=
nodeRPC
.
CallContext
(
ctx
,
nil
,
"admin_startSequencer"
,
blockHash
)
err
=
rollupClient
.
StartSequencer
(
ctx
,
blockHash
)
require
.
Nil
(
t
,
err
,
"Error starting sequencer"
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
active
,
err
=
rollupClient
.
SequencerActive
(
ctx
)
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
active
,
"sequencer should be active again"
)
blockBefore
=
latestBlock
(
t
,
l2Seq
)
time
.
Sleep
(
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
+
1
)
*
time
.
Second
)
blockAfter
=
latestBlock
(
t
,
l2Seq
)
...
...
op-node/node/api.go
View file @
03994850
...
...
@@ -28,6 +28,7 @@ type driverClient interface {
ResetDerivationPipeline
(
context
.
Context
)
error
StartSequencer
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
error
StopSequencer
(
context
.
Context
)
(
common
.
Hash
,
error
)
SequencerActive
(
context
.
Context
)
(
bool
,
error
)
}
type
rpcMetrics
interface
{
...
...
@@ -65,6 +66,12 @@ func (n *adminAPI) StopSequencer(ctx context.Context) (common.Hash, error) {
return
n
.
dr
.
StopSequencer
(
ctx
)
}
func
(
n
*
adminAPI
)
SequencerActive
(
ctx
context
.
Context
)
(
bool
,
error
)
{
recordDur
:=
n
.
m
.
RecordRPCServerRequest
(
"admin_sequencerActive"
)
defer
recordDur
()
return
n
.
dr
.
SequencerActive
(
ctx
)
}
type
nodeAPI
struct
{
config
*
rollup
.
Config
client
l2EthClient
...
...
op-node/node/server_test.go
View file @
03994850
...
...
@@ -227,3 +227,7 @@ func (c *mockDriverClient) StartSequencer(ctx context.Context, blockHash common.
func
(
c
*
mockDriverClient
)
StopSequencer
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
{
return
c
.
Mock
.
MethodCalled
(
"StopSequencer"
)
.
Get
(
0
)
.
(
common
.
Hash
),
nil
}
func
(
c
*
mockDriverClient
)
SequencerActive
(
ctx
context
.
Context
)
(
bool
,
error
)
{
return
c
.
Mock
.
MethodCalled
(
"SequencerActive"
)
.
Get
(
0
)
.
(
bool
),
nil
}
op-node/rollup/driver/driver.go
View file @
03994850
...
...
@@ -127,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
),
sequencerActive
:
make
(
chan
chan
bool
,
10
),
sequencerNotifs
:
sequencerStateListener
,
config
:
cfg
,
driverConfig
:
driverCfg
,
...
...
op-node/rollup/driver/state.go
View file @
03994850
...
...
@@ -47,6 +47,11 @@ type Driver struct {
// It tells the caller that the sequencer stopped by returning the latest sequenced L2 block hash.
stopSequencer
chan
chan
hashAndError
// Upon receiving a channel in this channel, the current sequencer status is queried.
// It tells the caller the status by outputting a boolean to the provided channel:
// true when the sequencer is active, false when it is not.
sequencerActive
chan
chan
bool
// sequencerNotifs is notified when the sequencer is started or stopped
sequencerNotifs
SequencerStateListener
...
...
@@ -373,6 +378,8 @@ func (s *Driver) eventLoop() {
s
.
driverConfig
.
SequencerStopped
=
true
respCh
<-
hashAndError
{
hash
:
s
.
derivation
.
UnsafeL2Head
()
.
Hash
}
}
case
respCh
:=
<-
s
.
sequencerActive
:
respCh
<-
!
s
.
driverConfig
.
SequencerStopped
case
<-
s
.
done
:
return
}
...
...
@@ -436,6 +443,24 @@ func (s *Driver) StopSequencer(ctx context.Context) (common.Hash, error) {
}
}
func
(
s
*
Driver
)
SequencerActive
(
ctx
context
.
Context
)
(
bool
,
error
)
{
if
!
s
.
driverConfig
.
SequencerEnabled
{
return
false
,
nil
}
respCh
:=
make
(
chan
bool
,
1
)
select
{
case
<-
ctx
.
Done
()
:
return
false
,
ctx
.
Err
()
case
s
.
sequencerActive
<-
respCh
:
select
{
case
<-
ctx
.
Done
()
:
return
false
,
ctx
.
Err
()
case
active
:=
<-
respCh
:
return
active
,
nil
}
}
}
// syncStatus returns the current sync status, and should only be called synchronously with
// the driver event loop to avoid retrieval of an inconsistent status.
func
(
s
*
Driver
)
syncStatus
()
*
eth
.
SyncStatus
{
...
...
op-node/sources/rollupclient.go
View file @
03994850
...
...
@@ -52,3 +52,9 @@ func (r *RollupClient) StopSequencer(ctx context.Context) (common.Hash, error) {
err
:=
r
.
rpc
.
CallContext
(
ctx
,
&
result
,
"admin_stopSequencer"
)
return
result
,
err
}
func
(
r
*
RollupClient
)
SequencerActive
(
ctx
context
.
Context
)
(
bool
,
error
)
{
var
result
bool
err
:=
r
.
rpc
.
CallContext
(
ctx
,
&
result
,
"admin_sequencerActive"
)
return
result
,
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