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
66af289c
Commit
66af289c
authored
May 17, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only mark a batch as checked at the end of the main loop
parent
4611198b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
22 deletions
+15
-22
service.ts
packages/fault-detector/src/service.ts
+15
-22
No files found.
packages/fault-detector/src/service.ts
View file @
66af289c
...
...
@@ -46,7 +46,7 @@ type State = {
fpw
:
number
oo
:
OutputOracle
<
any
>
messenger
:
CrossChainMessenger
highestChecked
BatchIndex
:
number
current
BatchIndex
:
number
diverged
:
boolean
}
...
...
@@ -254,27 +254,19 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
// but it happens often on testnets because the FPW is very short.
if
(
firstUnfinalized
===
undefined
)
{
this
.
logger
.
info
(
`no unfinalized batches found, starting from latest`
)
this
.
state
.
highestChecked
BatchIndex
=
(
this
.
state
.
current
BatchIndex
=
(
await
this
.
state
.
oo
.
getTotalElements
()
).
toNumber
()
}
else
{
this
.
state
.
highestChecked
BatchIndex
=
firstUnfinalized
this
.
state
.
current
BatchIndex
=
firstUnfinalized
}
}
else
{
this
.
state
.
highestChecked
BatchIndex
=
this
.
options
.
startBatchIndex
this
.
state
.
current
BatchIndex
=
this
.
options
.
startBatchIndex
}
this
.
logger
.
info
(
`starting height`
,
{
startBatchIndex
:
this
.
state
.
highestChecked
BatchIndex
,
this
.
logger
.
info
(
'
starting height
'
,
{
startBatchIndex
:
this
.
state
.
current
BatchIndex
,
})
// Set the initial metrics.
this
.
metrics
.
highestBatchIndex
.
set
(
{
type
:
'
checked
'
,
},
this
.
state
.
highestCheckedBatchIndex
)
}
async
routes
(
router
:
ExpressRouter
):
Promise
<
void
>
{
...
...
@@ -303,7 +295,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
return
}
if
(
this
.
state
.
highestChecked
BatchIndex
>=
latestBatchIndex
)
{
if
(
this
.
state
.
current
BatchIndex
>=
latestBatchIndex
)
{
await
sleep
(
15000
)
return
}
else
{
...
...
@@ -316,7 +308,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
}
this
.
logger
.
info
(
`checking batch`
,
{
batchIndex
:
this
.
state
.
highestChecked
BatchIndex
,
batchIndex
:
this
.
state
.
current
BatchIndex
,
latestIndex
:
latestBatchIndex
,
})
...
...
@@ -324,7 +316,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
try
{
event
=
await
findEventForStateBatch
(
this
.
state
.
oo
,
this
.
state
.
highestChecked
BatchIndex
this
.
state
.
current
BatchIndex
)
}
catch
(
err
)
{
this
.
logger
.
error
(
`got error when connecting to node`
,
{
...
...
@@ -528,20 +520,21 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
}
}
// Mark the current batch index as checked
this
.
logger
.
info
(
`checked batch ok`
,
{
batchIndex
:
this
.
state
.
highestChecked
BatchIndex
,
batchIndex
:
this
.
state
.
current
BatchIndex
,
})
this
.
state
.
highestCheckedBatchIndex
++
this
.
metrics
.
highestBatchIndex
.
set
(
{
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
.
currentBatchIndex
++
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