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
47854533
Unverified
Commit
47854533
authored
May 17, 2023
by
OptimismBot
Committed by
GitHub
May 17, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5729 from ethereum-optimism/hamdi/fd.checked.batch.index
[fault-detector] current batch index
parents
df65becb
78db51b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
21 deletions
+22
-21
service.ts
packages/fault-detector/src/service.ts
+22
-21
No files found.
packages/fault-detector/src/service.ts
View file @
47854533
...
@@ -46,7 +46,7 @@ type State = {
...
@@ -46,7 +46,7 @@ type State = {
fpw
:
number
fpw
:
number
oo
:
OutputOracle
<
any
>
oo
:
OutputOracle
<
any
>
messenger
:
CrossChainMessenger
messenger
:
CrossChainMessenger
highestChecked
BatchIndex
:
number
current
BatchIndex
:
number
diverged
:
boolean
diverged
:
boolean
}
}
...
@@ -254,27 +254,22 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -254,27 +254,22 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
// but it happens often on testnets because the FPW is very short.
// but it happens often on testnets because the FPW is very short.
if
(
firstUnfinalized
===
undefined
)
{
if
(
firstUnfinalized
===
undefined
)
{
this
.
logger
.
info
(
`no unfinalized batches found, starting from latest`
)
this
.
logger
.
info
(
`no unfinalized batches found, starting from latest`
)
this
.
state
.
highestChecked
BatchIndex
=
(
this
.
state
.
current
BatchIndex
=
(
await
this
.
state
.
oo
.
getTotalElements
()
await
this
.
state
.
oo
.
getTotalElements
()
).
toNumber
()
).
toNumber
()
}
else
{
}
else
{
this
.
state
.
highestChecked
BatchIndex
=
firstUnfinalized
this
.
state
.
current
BatchIndex
=
firstUnfinalized
}
}
}
else
{
}
else
{
this
.
state
.
highestChecked
BatchIndex
=
this
.
options
.
startBatchIndex
this
.
state
.
current
BatchIndex
=
this
.
options
.
startBatchIndex
}
}
this
.
logger
.
info
(
`starting height`
,
{
this
.
logger
.
info
(
'
starting height
'
,
{
startBatchIndex
:
this
.
state
.
highestChecked
BatchIndex
,
startBatchIndex
:
this
.
state
.
current
BatchIndex
,
})
})
// Set the initial metrics.
// Set the initial metrics.
this
.
metrics
.
highestBatchIndex
.
set
(
this
.
metrics
.
isCurrentlyMismatched
.
set
(
0
)
{
type
:
'
checked
'
,
},
this
.
state
.
highestCheckedBatchIndex
)
}
}
async
routes
(
router
:
ExpressRouter
):
Promise
<
void
>
{
async
routes
(
router
:
ExpressRouter
):
Promise
<
void
>
{
...
@@ -286,6 +281,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -286,6 +281,8 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
}
}
async
main
():
Promise
<
void
>
{
async
main
():
Promise
<
void
>
{
const
startMs
=
Date
.
now
()
let
latestBatchIndex
:
number
let
latestBatchIndex
:
number
try
{
try
{
latestBatchIndex
=
(
await
this
.
state
.
oo
.
getTotalElements
()).
toNumber
()
latestBatchIndex
=
(
await
this
.
state
.
oo
.
getTotalElements
()).
toNumber
()
...
@@ -303,7 +300,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -303,7 +300,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
return
return
}
}
if
(
this
.
state
.
highestChecked
BatchIndex
>=
latestBatchIndex
)
{
if
(
this
.
state
.
current
BatchIndex
>=
latestBatchIndex
)
{
await
sleep
(
15000
)
await
sleep
(
15000
)
return
return
}
else
{
}
else
{
...
@@ -316,7 +313,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -316,7 +313,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
}
}
this
.
logger
.
info
(
`checking batch`
,
{
this
.
logger
.
info
(
`checking batch`
,
{
batchIndex
:
this
.
state
.
highestChecked
BatchIndex
,
batchIndex
:
this
.
state
.
current
BatchIndex
,
latestIndex
:
latestBatchIndex
,
latestIndex
:
latestBatchIndex
,
})
})
...
@@ -324,7 +321,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -324,7 +321,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
try
{
try
{
event
=
await
findEventForStateBatch
(
event
=
await
findEventForStateBatch
(
this
.
state
.
oo
,
this
.
state
.
oo
,
this
.
state
.
highestChecked
BatchIndex
this
.
state
.
current
BatchIndex
)
)
}
catch
(
err
)
{
}
catch
(
err
)
{
this
.
logger
.
error
(
`got error when connecting to node`
,
{
this
.
logger
.
error
(
`got error when connecting to node`
,
{
...
@@ -528,20 +525,24 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -528,20 +525,24 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
}
}
}
}
this
.
logger
.
info
(
`checked batch ok`
,
{
const
elapsedMs
=
Date
.
now
()
-
startMs
batchIndex
:
this
.
state
.
highestCheckedBatchIndex
,
})
this
.
state
.
highestCheckedBatchIndex
++
// Mark the current batch index as checked
this
.
logger
.
info
(
'
checked batch ok
'
,
{
batchIndex
:
this
.
state
.
currentBatchIndex
,
timeMs
:
elapsedMs
,
})
this
.
metrics
.
highestBatchIndex
.
set
(
this
.
metrics
.
highestBatchIndex
.
set
(
{
{
type
:
'
checked
'
,
type
:
'
checked
'
,
},
},
this
.
state
.
highestChecked
BatchIndex
this
.
state
.
current
BatchIndex
)
)
// If we got through the above without throwing an error, we should be fine to reset.
// If we got through the above without throwing an error, we should be
// fine to reset and move onto the next batch
this
.
state
.
diverged
=
false
this
.
state
.
diverged
=
false
this
.
state
.
currentBatchIndex
++
this
.
metrics
.
isCurrentlyMismatched
.
set
(
0
)
this
.
metrics
.
isCurrentlyMismatched
.
set
(
0
)
}
}
}
}
...
...
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