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
0c769680
Commit
0c769680
authored
Jul 26, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(c-mon): rename state batch to output
parent
a6ed3392
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
53 deletions
+57
-53
short-days-help.md
.changeset/short-days-help.md
+5
-0
helpers.ts
packages/chain-mon/src/fault-mon/helpers.ts
+6
-6
service.ts
packages/chain-mon/src/fault-mon/service.ts
+42
-43
helpers.spec.ts
packages/chain-mon/test/fault-mon/helpers.spec.ts
+4
-4
No files found.
.changeset/short-days-help.md
0 → 100644
View file @
0c769680
---
'
@eth-optimism/chain-mon'
:
patch
---
Update language in fault-mon from batches to outputs
packages/chain-mon/src/fault-mon/helpers.ts
View file @
0c769680
...
@@ -31,22 +31,22 @@ export const findOutputForIndex = async (
...
@@ -31,22 +31,22 @@ export const findOutputForIndex = async (
}
}
/**
/**
* Finds the first
state batch
index that has not yet passed the fault proof window.
* Finds the first
L2 output
index that has not yet passed the fault proof window.
*
*
* @param oracle Output oracle contract.
* @param oracle Output oracle contract.
* @returns Starting
state root batch
index.
* @returns Starting
L2 output
index.
*/
*/
export
const
findFirstUnfinalized
StateBatch
Index
=
async
(
export
const
findFirstUnfinalized
Output
Index
=
async
(
oracle
:
Contract
,
oracle
:
Contract
,
fpw
:
number
,
fpw
:
number
,
logger
?:
Logger
logger
?:
Logger
):
Promise
<
number
>
=>
{
):
Promise
<
number
>
=>
{
const
latestBlock
=
await
oracle
.
provider
.
getBlock
(
'
latest
'
)
const
latestBlock
=
await
oracle
.
provider
.
getBlock
(
'
latest
'
)
const
total
Batche
s
=
(
await
oracle
.
nextOutputIndex
()).
toNumber
()
const
total
Output
s
=
(
await
oracle
.
nextOutputIndex
()).
toNumber
()
// Perform a binary search to find the next batch that will pass the challenge period.
// Perform a binary search to find the next batch that will pass the challenge period.
let
lo
=
0
let
lo
=
0
let
hi
=
total
Batche
s
let
hi
=
total
Output
s
while
(
lo
!==
hi
)
{
while
(
lo
!==
hi
)
{
const
mid
=
Math
.
floor
((
lo
+
hi
)
/
2
)
const
mid
=
Math
.
floor
((
lo
+
hi
)
/
2
)
const
outputData
=
await
findOutputForIndex
(
oracle
,
mid
,
logger
)
const
outputData
=
await
findOutputForIndex
(
oracle
,
mid
,
logger
)
...
@@ -60,7 +60,7 @@ export const findFirstUnfinalizedStateBatchIndex = async (
...
@@ -60,7 +60,7 @@ export const findFirstUnfinalizedStateBatchIndex = async (
// Result will be zero if the chain is less than FPW seconds old. Only returns undefined in the
// Result will be zero if the chain is less than FPW seconds old. Only returns undefined in the
// case that no batches have been submitted for an entire challenge period.
// case that no batches have been submitted for an entire challenge period.
if
(
lo
===
total
Batche
s
)
{
if
(
lo
===
total
Output
s
)
{
return
undefined
return
undefined
}
else
{
}
else
{
return
lo
return
lo
...
...
packages/chain-mon/src/fault-mon/service.ts
View file @
0c769680
...
@@ -25,20 +25,17 @@ import { Contract, ethers } from 'ethers'
...
@@ -25,20 +25,17 @@ import { Contract, ethers } from 'ethers'
import
dateformat
from
'
dateformat
'
import
dateformat
from
'
dateformat
'
import
{
version
}
from
'
../../package.json
'
import
{
version
}
from
'
../../package.json
'
import
{
import
{
findFirstUnfinalizedOutputIndex
,
findOutputForIndex
}
from
'
./helpers
'
findFirstUnfinalizedStateBatchIndex
,
findOutputForIndex
,
}
from
'
./helpers
'
type
Options
=
{
type
Options
=
{
l1RpcProvider
:
Provider
l1RpcProvider
:
Provider
l2RpcProvider
:
Provider
l2RpcProvider
:
Provider
start
Batch
Index
:
number
start
Output
Index
:
number
optimismPortalAddress
?:
string
optimismPortalAddress
?:
string
}
}
type
Metrics
=
{
type
Metrics
=
{
highest
Batch
Index
:
Gauge
highest
Output
Index
:
Gauge
isCurrentlyMismatched
:
Gauge
isCurrentlyMismatched
:
Gauge
nodeConnectionFailures
:
Gauge
nodeConnectionFailures
:
Gauge
}
}
...
@@ -47,7 +44,7 @@ type State = {
...
@@ -47,7 +44,7 @@ type State = {
faultProofWindow
:
number
faultProofWindow
:
number
outputOracle
:
Contract
outputOracle
:
Contract
messenger
:
CrossChainMessenger
messenger
:
CrossChainMessenger
current
Batch
Index
:
number
current
Output
Index
:
number
diverged
:
boolean
diverged
:
boolean
}
}
...
@@ -70,7 +67,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -70,7 +67,7 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
validator
:
validators
.
provider
,
validator
:
validators
.
provider
,
desc
:
'
Provider for interacting with L2
'
,
desc
:
'
Provider for interacting with L2
'
,
},
},
start
Batch
Index
:
{
start
Output
Index
:
{
validator
:
validators
.
num
,
validator
:
validators
.
num
,
default
:
-
1
,
default
:
-
1
,
desc
:
'
The L2 height to start from
'
,
desc
:
'
The L2 height to start from
'
,
...
@@ -84,9 +81,9 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -84,9 +81,9 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
},
},
},
},
metricsSpec
:
{
metricsSpec
:
{
highest
Batch
Index
:
{
highest
Output
Index
:
{
type
:
Gauge
,
type
:
Gauge
,
desc
:
'
Highest
batch
indices (checked and known)
'
,
desc
:
'
Highest
output
indices (checked and known)
'
,
labels
:
[
'
type
'
],
labels
:
[
'
type
'
],
},
},
isCurrentlyMismatched
:
{
isCurrentlyMismatched
:
{
...
@@ -200,30 +197,32 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -200,30 +197,32 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
this
.
state
.
outputOracle
=
this
.
state
.
messenger
.
contracts
.
l1
.
L2OutputOracle
this
.
state
.
outputOracle
=
this
.
state
.
messenger
.
contracts
.
l1
.
L2OutputOracle
// Figure out where to start syncing from.
// Figure out where to start syncing from.
if
(
this
.
options
.
start
Batch
Index
===
-
1
)
{
if
(
this
.
options
.
start
Output
Index
===
-
1
)
{
this
.
logger
.
info
(
'
finding appropriate starting unfinalized
batch
'
)
this
.
logger
.
info
(
'
finding appropriate starting unfinalized
output
'
)
const
firstUnfinalized
=
await
findFirstUnfinalized
StateBatch
Index
(
const
firstUnfinalized
=
await
findFirstUnfinalized
Output
Index
(
this
.
state
.
outputOracle
,
this
.
state
.
outputOracle
,
this
.
state
.
faultProofWindow
,
this
.
state
.
faultProofWindow
,
this
.
logger
this
.
logger
)
)
// We may not have an unfinalized
batches in the case where no batche
s have been submitted
// We may not have an unfinalized
outputs in the case where no output
s have been submitted
// for the entire duration of the FAULTPROOFWINDOW. We generally do not expect this to happen on mainnet,
// for the entire duration of the FAULTPROOFWINDOW. We generally do not expect this to happen on mainnet,
// but it happens often on testnets because the FAULTPROOFWINDOW is very short.
// but it happens often on testnets because the FAULTPROOFWINDOW is very short.
if
(
firstUnfinalized
===
undefined
)
{
if
(
firstUnfinalized
===
undefined
)
{
this
.
logger
.
info
(
'
no unfinalized batches found. skipping all batches.
'
)
this
.
logger
.
info
(
const
totalBatches
=
await
this
.
state
.
outputOracle
.
nextOutputIndex
()
'
no unfinalized outputes found. skipping all outputes.
'
this
.
state
.
currentBatchIndex
=
totalBatches
.
toNumber
()
-
1
)
const
totalOutputes
=
await
this
.
state
.
outputOracle
.
nextOutputIndex
()
this
.
state
.
currentOutputIndex
=
totalOutputes
.
toNumber
()
-
1
}
else
{
}
else
{
this
.
state
.
current
Batch
Index
=
firstUnfinalized
this
.
state
.
current
Output
Index
=
firstUnfinalized
}
}
}
else
{
}
else
{
this
.
state
.
current
BatchIndex
=
this
.
options
.
startBatch
Index
this
.
state
.
current
OutputIndex
=
this
.
options
.
startOutput
Index
}
}
this
.
logger
.
info
(
'
starting
batch
'
,
{
this
.
logger
.
info
(
'
starting
output
'
,
{
batchIndex
:
this
.
state
.
currentBatch
Index
,
outputIndex
:
this
.
state
.
currentOutput
Index
,
})
})
// Set the initial metrics.
// Set the initial metrics.
...
@@ -241,12 +240,12 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -241,12 +240,12 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
async
main
():
Promise
<
void
>
{
async
main
():
Promise
<
void
>
{
const
startMs
=
Date
.
now
()
const
startMs
=
Date
.
now
()
let
latest
Batch
Index
:
number
let
latest
Output
Index
:
number
try
{
try
{
const
total
Batch
es
=
await
this
.
state
.
outputOracle
.
nextOutputIndex
()
const
total
Output
es
=
await
this
.
state
.
outputOracle
.
nextOutputIndex
()
latest
BatchIndex
=
totalBatch
es
.
toNumber
()
-
1
latest
OutputIndex
=
totalOutput
es
.
toNumber
()
-
1
}
catch
(
err
)
{
}
catch
(
err
)
{
this
.
logger
.
error
(
'
failed to query total # of
batch
es
'
,
{
this
.
logger
.
error
(
'
failed to query total # of
output
es
'
,
{
error
:
err
,
error
:
err
,
node
:
'
l1
'
,
node
:
'
l1
'
,
section
:
'
nextOutputIndex
'
,
section
:
'
nextOutputIndex
'
,
...
@@ -259,34 +258,34 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -259,34 +258,34 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
return
return
}
}
if
(
this
.
state
.
current
BatchIndex
>
latestBatch
Index
)
{
if
(
this
.
state
.
current
OutputIndex
>
latestOutput
Index
)
{
this
.
logger
.
info
(
'
batch
index is ahead of the oracle. waiting...
'
,
{
this
.
logger
.
info
(
'
output
index is ahead of the oracle. waiting...
'
,
{
batchIndex
:
this
.
state
.
currentBatch
Index
,
outputIndex
:
this
.
state
.
currentOutput
Index
,
latest
Batch
Index
,
latest
Output
Index
,
})
})
await
sleep
(
15000
)
await
sleep
(
15000
)
return
return
}
}
this
.
metrics
.
highest
BatchIndex
.
set
({
type
:
'
known
'
},
latestBatch
Index
)
this
.
metrics
.
highest
OutputIndex
.
set
({
type
:
'
known
'
},
latestOutput
Index
)
this
.
logger
.
info
(
'
checking
batch
'
,
{
this
.
logger
.
info
(
'
checking
output
'
,
{
batchIndex
:
this
.
state
.
currentBatch
Index
,
outputIndex
:
this
.
state
.
currentOutput
Index
,
latest
Batch
Index
,
latest
Output
Index
,
})
})
let
outputData
:
BedrockOutputData
let
outputData
:
BedrockOutputData
try
{
try
{
outputData
=
await
findOutputForIndex
(
outputData
=
await
findOutputForIndex
(
this
.
state
.
outputOracle
,
this
.
state
.
outputOracle
,
this
.
state
.
current
Batch
Index
,
this
.
state
.
current
Output
Index
,
this
.
logger
this
.
logger
)
)
}
catch
(
err
)
{
}
catch
(
err
)
{
this
.
logger
.
error
(
'
failed to fetch output associated with
batch
'
,
{
this
.
logger
.
error
(
'
failed to fetch output associated with
output
'
,
{
error
:
err
,
error
:
err
,
node
:
'
l1
'
,
node
:
'
l1
'
,
section
:
'
findOutputForIndex
'
,
section
:
'
findOutputForIndex
'
,
batchIndex
:
this
.
state
.
currentBatch
Index
,
outputIndex
:
this
.
state
.
currentOutput
Index
,
})
})
this
.
metrics
.
nodeConnectionFailures
.
inc
({
this
.
metrics
.
nodeConnectionFailures
.
inc
({
layer
:
'
l1
'
,
layer
:
'
l1
'
,
...
@@ -397,20 +396,20 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
...
@@ -397,20 +396,20 @@ export class FaultDetector extends BaseServiceV2<Options, Metrics, State> {
const
elapsedMs
=
Date
.
now
()
-
startMs
const
elapsedMs
=
Date
.
now
()
-
startMs
// Mark the current
batch
index as checked
// Mark the current
output
index as checked
this
.
logger
.
info
(
'
checked
batch
ok
'
,
{
this
.
logger
.
info
(
'
checked
output
ok
'
,
{
batchIndex
:
this
.
state
.
currentBatch
Index
,
outputIndex
:
this
.
state
.
currentOutput
Index
,
timeMs
:
elapsedMs
,
timeMs
:
elapsedMs
,
})
})
this
.
metrics
.
highest
Batch
Index
.
set
(
this
.
metrics
.
highest
Output
Index
.
set
(
{
type
:
'
checked
'
},
{
type
:
'
checked
'
},
this
.
state
.
current
Batch
Index
this
.
state
.
current
Output
Index
)
)
// If we got through the above without throwing an error, we should be
// If we got through the above without throwing an error, we should be
// fine to reset and move onto the next
batch
// fine to reset and move onto the next
output
this
.
state
.
diverged
=
false
this
.
state
.
diverged
=
false
this
.
state
.
current
Batch
Index
++
this
.
state
.
current
Output
Index
++
this
.
metrics
.
isCurrentlyMismatched
.
set
(
0
)
this
.
metrics
.
isCurrentlyMismatched
.
set
(
0
)
}
}
}
}
...
...
packages/chain-mon/test/fault-mon/helpers.spec.ts
View file @
0c769680
...
@@ -8,7 +8,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
...
@@ -8,7 +8,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import
{
expect
}
from
'
./setup
'
import
{
expect
}
from
'
./setup
'
import
{
import
{
findOutputForIndex
,
findOutputForIndex
,
findFirstUnfinalized
StateBatch
Index
,
findFirstUnfinalized
Output
Index
,
}
from
'
../../src/fault-mon
'
}
from
'
../../src/fault-mon
'
describe
(
'
helpers
'
,
()
=>
{
describe
(
'
helpers
'
,
()
=>
{
...
@@ -122,7 +122,7 @@ describe('helpers', () => {
...
@@ -122,7 +122,7 @@ describe('helpers', () => {
})
})
it
(
'
should find the first batch older than the FPW
'
,
async
()
=>
{
it
(
'
should find the first batch older than the FPW
'
,
async
()
=>
{
const
first
=
await
findFirstUnfinalized
StateBatch
Index
(
const
first
=
await
findFirstUnfinalized
Output
Index
(
L2OutputOracle
,
L2OutputOracle
,
deployConfig
.
finalizationPeriodSeconds
deployConfig
.
finalizationPeriodSeconds
)
)
...
@@ -164,7 +164,7 @@ describe('helpers', () => {
...
@@ -164,7 +164,7 @@ describe('helpers', () => {
})
})
it
(
'
should return zero
'
,
async
()
=>
{
it
(
'
should return zero
'
,
async
()
=>
{
const
first
=
await
findFirstUnfinalized
StateBatch
Index
(
const
first
=
await
findFirstUnfinalized
Output
Index
(
L2OutputOracle
,
L2OutputOracle
,
deployConfig
.
finalizationPeriodSeconds
deployConfig
.
finalizationPeriodSeconds
)
)
...
@@ -214,7 +214,7 @@ describe('helpers', () => {
...
@@ -214,7 +214,7 @@ describe('helpers', () => {
})
})
it
(
'
should return undefined
'
,
async
()
=>
{
it
(
'
should return undefined
'
,
async
()
=>
{
const
first
=
await
findFirstUnfinalized
StateBatch
Index
(
const
first
=
await
findFirstUnfinalized
Output
Index
(
L2OutputOracle
,
L2OutputOracle
,
deployConfig
.
finalizationPeriodSeconds
deployConfig
.
finalizationPeriodSeconds
)
)
...
...
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