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
778a047a
Unverified
Commit
778a047a
authored
Jul 31, 2023
by
OptimismBot
Committed by
GitHub
Jul 31, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6427 from ethereum-optimism/jm/startblock
feat(chain-mon): Default wd-mon scan from start of FPW
parents
5cac5c42
75749414
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
4 deletions
+56
-4
helpers.ts
packages/chain-mon/src/wd-mon/helpers.ts
+41
-0
service.ts
packages/chain-mon/src/wd-mon/service.ts
+15
-4
No files found.
packages/chain-mon/src/wd-mon/helpers.ts
0 → 100644
View file @
778a047a
import
{
Provider
}
from
'
@ethersproject/abstract-provider
'
import
{
Logger
}
from
'
@eth-optimism/common-ts
'
/**
* Finds
*
* @param
* @param
* @param
* @returns
*/
export
const
getLastFinalizedBlock
=
async
(
l1RpcProvider
:
Provider
,
faultProofWindow
:
number
,
logger
:
Logger
):
Promise
<
number
>
=>
{
let
guessWindowStartBlock
try
{
const
l1Block
=
await
l1RpcProvider
.
getBlock
(
'
latest
'
)
// The time corresponding to the start of the FPW, based on the current block.
const
windowStartTime
=
l1Block
.
timestamp
-
faultProofWindow
// Use the FPW to find the block number that is the start of the FPW.
guessWindowStartBlock
=
l1Block
.
number
-
faultProofWindow
/
12
let
block
=
await
l1RpcProvider
.
getBlock
(
guessWindowStartBlock
)
while
(
block
.
timestamp
>
windowStartTime
)
{
guessWindowStartBlock
--
block
=
await
l1RpcProvider
.
getBlock
(
guessWindowStartBlock
)
}
return
block
.
number
}
catch
(
err
)
{
logger
.
fatal
(
'
error when calling querying for block
'
,
{
errors
:
err
,
})
throw
new
Error
(
`unable to find block number
${
guessWindowStartBlock
||
'
latest
'
}
`
)
}
}
packages/chain-mon/src/wd-mon/service.ts
View file @
778a047a
...
@@ -13,6 +13,7 @@ import { Event } from 'ethers'
...
@@ -13,6 +13,7 @@ import { Event } from 'ethers'
import
dateformat
from
'
dateformat
'
import
dateformat
from
'
dateformat
'
import
{
version
}
from
'
../../package.json
'
import
{
version
}
from
'
../../package.json
'
import
{
getLastFinalizedBlock
as
getLastFinalizedBlock
}
from
'
./helpers
'
type
Options
=
{
type
Options
=
{
l1RpcProvider
:
Provider
l1RpcProvider
:
Provider
...
@@ -30,7 +31,7 @@ type Metrics = {
...
@@ -30,7 +31,7 @@ type Metrics = {
type
State
=
{
type
State
=
{
messenger
:
CrossChainMessenger
messenger
:
CrossChainMessenger
highestUncheckedBlockNumber
:
number
highestUncheckedBlockNumber
:
number
f
inalization
Window
:
number
f
aultProof
Window
:
number
forgeryDetected
:
boolean
forgeryDetected
:
boolean
}
}
...
@@ -109,10 +110,20 @@ export class WithdrawalMonitor extends BaseServiceV2<Options, Metrics, State> {
...
@@ -109,10 +110,20 @@ export class WithdrawalMonitor extends BaseServiceV2<Options, Metrics, State> {
// Not detected by default.
// Not detected by default.
this
.
state
.
forgeryDetected
=
false
this
.
state
.
forgeryDetected
=
false
// For now we'll just start take it from the env or the tip of the chain
this
.
state
.
faultProofWindow
=
await
this
.
state
.
messenger
.
getChallengePeriodSeconds
()
this
.
logger
.
info
(
`fault proof window is
${
this
.
state
.
faultProofWindow
}
seconds`
)
// Set the start block number.
if
(
this
.
options
.
startBlockNumber
===
-
1
)
{
if
(
this
.
options
.
startBlockNumber
===
-
1
)
{
this
.
state
.
highestUncheckedBlockNumber
=
// We default to starting from the last finalized block.
await
this
.
options
.
l1RpcProvider
.
getBlockNumber
()
this
.
state
.
highestUncheckedBlockNumber
=
await
getLastFinalizedBlock
(
this
.
options
.
l1RpcProvider
,
this
.
state
.
faultProofWindow
,
this
.
logger
)
}
else
{
}
else
{
this
.
state
.
highestUncheckedBlockNumber
=
this
.
options
.
startBlockNumber
this
.
state
.
highestUncheckedBlockNumber
=
this
.
options
.
startBlockNumber
}
}
...
...
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