Skip to content
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

feat: add block time metric #707

Merged
merged 3 commits into from
Apr 18, 2024
Merged

feat: add block time metric #707

merged 3 commits into from
Apr 18, 2024

Conversation

Thegaram
Copy link

1. Purpose or design rationale of this PR

Track block time, defined as the gap between the timestamps of two consecutive blocks.

Note: This is not exactly the same as the time it takes to produce a block but it's correlated. The relevant code is here:

header.Time = parent.Time + c.config.Period
if header.Time < uint64(time.Now().Unix()) {
header.Time = uint64(time.Now().Unix())
}

E.g. if block #100 is at 100s, then we set block #101's timestamp as 103s, but in reality we seal and broadcast this block at 106s. Then, block #102's timestamp will be set as 106 or higher. So this metric will capture the delay.

I decided to track this metric in writeBlockWithState because this way it's tracked both in signer nodes (from WriteBlockWithState, called by worker) and follower nodes (from InsertChain).

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • feat: A new feature

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

@Thegaram Thegaram merged commit 0252f85 into develop Apr 18, 2024
7 checks passed
@Thegaram Thegaram deleted the feat-block-time-metric branch April 18, 2024 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants