-
-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize merge tracker and add merge metrics #4350
Changes from 1 commit
a383d7c
b92f6f9
9b5e0e7
51a74fc
37f82e5
3277894
239f22d
7e84d92
2f8204a
59a4e21
a153c63
97bc0a1
57a8fbf
fbcf640
c5ea976
e0c642e
6c5cd12
ba902cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ export class Eth1MergeBlockTracker { | |
// Set latestBlock stats | ||
metrics.eth1.eth1LatestBlockNumber.set(this.latestEth1Block.number); | ||
metrics.eth1.eth1LatestBlockTD.set(Number(this.latestEth1Block.totalDifficulty / this.safeTDFactor)); | ||
metrics.eth1.eth1LatestBlockTimestamp.set(this.latestEth1Block.timestamp); | ||
metrics.eth1.eth1LatestBlockTimestamp.set(this.latestEth1Block.timestamp * 1000); | ||
} | ||
}); | ||
} | ||
|
@@ -135,7 +135,7 @@ export class Eth1MergeBlockTracker { | |
return { | ||
ttdHit: false, | ||
tdFactor: this.safeTDFactor, | ||
tdDiffScaled: Number((this.latestEth1Block.totalDifficulty / this.safeTDFactor) as bigint), | ||
tdDiffScaled: Number((tdDiff / this.safeTDFactor) as bigint), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! 🙏 |
||
ttd: this.config.TERMINAL_TOTAL_DIFFICULTY, | ||
td: this.latestEth1Block.totalDifficulty, | ||
timestamp: this.latestEth1Block.timestamp, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,10 +71,12 @@ export async function runNodeNotifier(modules: NodeNotifierModules): Promise<voi | |
// Notifier log lines must be kept at a reasonable max width otherwise it's very hard to read | ||
const tdProgress = chain.eth1.getTDProgress(); | ||
if (tdProgress !== null && !tdProgress.ttdHit) { | ||
tdTimeSeries.addPoint(tdProgress.tdDiffScaled, tdProgress.timestamp); | ||
// TimeSeries accept time in Ms while timestamp is in Sec | ||
tdTimeSeries.addPoint(tdProgress.tdDiffScaled, tdProgress.timestamp * 1000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or TimeSeries.addPoint can take seconds instead and simplify the consumers since all want sec right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right! we can shift to seconds |
||
|
||
const timestampTDD = tdTimeSeries.computeY0Point(); | ||
const secToTTD = Math.floor(Date.now() / 1000) - timestampTDD; | ||
// It is possible to get ttd estimate with an error at imminent merge | ||
const secToTTD = Math.max(Math.floor(timestampTDD - Date.now() / 1000), 0); | ||
const timeLeft = isFinite(secToTTD) ? prettyTimeDiffSec(secToTTD) : "?"; | ||
|
||
logger.info(`TTD in ${timeLeft} current TD ${tdProgress.td} / ${tdProgress.ttd}`); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prometheus metrics always deal with IS units, so in case of time it must be seconds. See https://prometheus.io/docs/practices/naming/#metric-names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved collection in seconds, and update the dashboard expression (*1000) which displays with unit "From now" which seems to be using ms.