-
Notifications
You must be signed in to change notification settings - Fork 136
app/*: report EL version metric #4434
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1e6ee5c
Report EL version metric
KaloyanTanev 9e72cbc
Update app/monitoringapi.go
KaloyanTanev 7fa6398
Fix breaking change from Copilot review...
KaloyanTanev 38deee0
Silently skip on missing EL
KaloyanTanev 3340cdc
Add tests
KaloyanTanev d9e3a68
Fix metrics doc
KaloyanTanev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| // Copyright © 2022-2026 Obol Labs Inc. Licensed under the terms of a Business Source License 1.1 | ||
|
|
||
| package eth1wrap | ||
|
|
||
| import ( | ||
| "context" | ||
| "regexp" | ||
|
|
||
| "github.com/obolnetwork/charon/app/log" | ||
| "github.com/obolnetwork/charon/app/version" | ||
| "github.com/obolnetwork/charon/app/z" | ||
| ) | ||
|
|
||
| var ( | ||
| minGethVersion = mustParse("v1.16.7") | ||
| minNethermindVersion = mustParse("v1.35.0") | ||
| minBesuVersion = mustParse("v25.11.0") | ||
| minErigonVersion = mustParse("v3.2.2") | ||
| minRethVersion = mustParse("v1.9.1") | ||
|
|
||
| minimumExecutionEngineVersion = map[string]version.SemVer{ | ||
| "Geth": minGethVersion, | ||
| "Nethermind": minNethermindVersion, | ||
| "besu": minBesuVersion, | ||
| "erigon": minErigonVersion, | ||
| "reth": minRethVersion, | ||
| } | ||
|
|
||
| incompatibleExecutionEngineVersion = map[string][]version.SemVer{} | ||
| ) | ||
|
|
||
| func mustParse(v string) version.SemVer { | ||
| sv, err := version.Parse(v) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| return sv | ||
| } | ||
|
|
||
| type ExecutionEngineVersionStatus int | ||
|
|
||
| const ( | ||
| ELVersionOK ExecutionEngineVersionStatus = iota | ||
| ELVersionFormatError | ||
| ELVersionUnknownClient | ||
| ELVersionTooOld | ||
| ELVersionIncompatible | ||
| ) | ||
|
|
||
| var elVersionExtractRegex = regexp.MustCompile(`^([^/]+)/v?([0-9]+\.[0-9]+\.[0-9]+)`) | ||
|
|
||
| // checkExecutionEngineVersionStatus checks the version of the execution engine client against the minimum required version. | ||
| func checkExecutionEngineVersionStatus(elVersion string) (status ExecutionEngineVersionStatus, clVer string, minVer string) { | ||
| matches := elVersionExtractRegex.FindStringSubmatch(elVersion) | ||
| if len(matches) != 3 { | ||
| return ELVersionFormatError, "", "" | ||
| } | ||
|
|
||
| client := matches[1] | ||
|
|
||
| clientVersion, err := version.Parse("v" + matches[2]) | ||
| if err != nil { | ||
| return ELVersionFormatError, "", "" | ||
| } | ||
|
|
||
| minVersion, ok := minimumExecutionEngineVersion[client] | ||
| if !ok { | ||
| return ELVersionUnknownClient, "", "" | ||
| } | ||
|
|
||
| if version.Compare(clientVersion, minVersion) == -1 { | ||
| return ELVersionTooOld, clientVersion.String(), minVersion.String() | ||
| } | ||
|
|
||
| for _, badVer := range incompatibleExecutionEngineVersion[client] { | ||
| if version.Compare(clientVersion, badVer) == 0 { | ||
| return ELVersionIncompatible, clientVersion.String(), "" | ||
| } | ||
| } | ||
|
|
||
| return ELVersionOK, clientVersion.String(), minVersion.String() | ||
| } | ||
|
KaloyanTanev marked this conversation as resolved.
|
||
|
|
||
| // CheckExecutionEngineVersion checks the version of the execution engine client and logs a warning | ||
| // if the version is below the minimum, incompatible, or the client is not recognized. | ||
| func CheckExecutionEngineVersion(ctx context.Context, elVersion string) { | ||
| status, currentVersion, minVersion := checkExecutionEngineVersionStatus(elVersion) | ||
|
|
||
| //nolint:revive // enforce-switch-style: the list is exhaustive and there is no need for default | ||
| switch status { | ||
| case ELVersionFormatError: | ||
| log.Warn(ctx, "Failed to parse execution engine version string due to unexpected format. This may indicate an unsupported or custom execution engine build", | ||
| nil, z.Str("input", elVersion)) | ||
| case ELVersionUnknownClient: | ||
| log.Warn(ctx, "Unknown execution engine client detected. The client is not in the supported client list and may cause compatibility issues", | ||
| nil, z.Str("client", elVersion)) | ||
| case ELVersionTooOld: | ||
| log.Warn(ctx, "Execution engine client version is below the minimum supported version. Please upgrade your execution engine to ensure compatibility and security", | ||
| nil, z.Str("client_version", currentVersion), z.Str("minimum_required", minVersion)) | ||
| case ELVersionIncompatible: | ||
| log.Warn(ctx, "Execution engine client version is known to be incompatible with Charon. Please upgrade or downgrade your execution engine to a compatible version", | ||
| nil, z.Str("client_version", currentVersion)) | ||
| case ELVersionOK: | ||
| // Do nothing | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.