-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(plugin-api): expose Besu node version and commit hash via BesuConfiguration #10227
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright contributors to Besu. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.hyperledger.besu.services; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class BesuConfigurationImplTest { | ||
|
|
||
| @Test | ||
| void getBesuVersion_returnsNonEmptyString() { | ||
| BesuConfigurationImpl config = new BesuConfigurationImpl(); | ||
| String version = config.getBesuVersion(); | ||
| assertThat(version).isNotNull(); | ||
| assertThat(version).isNotEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| void getBesuCommitHash_returnsNonEmptyString() { | ||
| BesuConfigurationImpl config = new BesuConfigurationImpl(); | ||
| String commit = config.getBesuCommitHash(); | ||
| assertThat(commit).isNotNull(); | ||
| assertThat(commit).isNotEmpty(); | ||
| } | ||
|
Comment on lines
+25
to
+35
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -100,4 +100,24 @@ public interface BesuConfiguration extends BesuService { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Unstable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DataStorageConfiguration getDataStorageConfiguration(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Returns the version of the running Besu node. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * <p>The format follows semantic versioning: {@code "MAJOR.MINOR.PATCH"} for release builds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * (e.g., {@code "25.3.0"}) or {@code "MAJOR.MINOR.PATCH-qualifier"} for development builds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * (e.g., {@code "25.3.1-dev-ac23d311"}). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * <p>The format follows semantic versioning: {@code "MAJOR.MINOR.PATCH"} for release builds | |
| * (e.g., {@code "25.3.0"}) or {@code "MAJOR.MINOR.PATCH-qualifier"} for development builds | |
| * (e.g., {@code "25.3.1-dev-ac23d311"}). | |
| * <p>This is a human-readable Besu version string. For release builds, it is typically a | |
| * semantic version such as {@code "25.3.0"}. |
Outdated
Copilot
AI
Apr 13, 2026
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.
The Javadoc promises semantic-version formatting and a non-null return, but it doesn’t document what happens when build metadata is unavailable (e.g., missing/stripped manifest properties). Please document the exact fallback value(s) (such as \"UNKNOWN\") and whether the value is guaranteed to match the documented SemVer patterns in all build variants.
| * <p>The format follows semantic versioning: {@code "MAJOR.MINOR.PATCH"} for release builds | |
| * (e.g., {@code "25.3.0"}) or {@code "MAJOR.MINOR.PATCH-qualifier"} for development builds | |
| * (e.g., {@code "25.3.1-dev-ac23d311"}). | |
| * | |
| * <p>Available during all plugin lifecycle phases ({@code register} through {@code stop}). | |
| * | |
| * @return the Besu node version string, never null | |
| * <p>When build metadata is available, the returned value follows semantic versioning: | |
| * {@code "MAJOR.MINOR.PATCH"} for release builds (e.g., {@code "25.3.0"}) or | |
| * {@code "MAJOR.MINOR.PATCH-qualifier"} for development builds (e.g., | |
| * {@code "25.3.1-dev-ac23d311"}). | |
| * | |
| * <p>If the version metadata is unavailable (for example, if manifest properties are missing | |
| * or stripped), this method returns the literal string {@code "UNKNOWN"}. That fallback value | |
| * is never null, but it is not guaranteed to match the semantic-version patterns described | |
| * above. | |
| * | |
| * <p>Available during all plugin lifecycle phases ({@code register} through {@code stop}). | |
| * | |
| * @return the Besu node version string; never null, and {@code "UNKNOWN"} if version metadata | |
| * is unavailable |
Outdated
Copilot
AI
Apr 13, 2026
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.
Adding abstract methods to a public plugin API interface is source-breaking for any downstream code that implements BesuConfiguration (common in plugin unit tests via fakes/stubs). To reduce upgrade friction, consider making these default methods (with a documented fallback like \"UNKNOWN\") or introducing a new extended interface (e.g., BesuConfigurationV2) / dedicated service for version info so older implementers aren’t forced to update immediately.
| * @return the Besu node version string, never null | |
| */ | |
| String getBesuVersion(); | |
| /** | |
| * Returns the git commit hash of the running Besu build. | |
| * | |
| * @return the short git commit hash, never null | |
| */ | |
| String getBesuCommitHash(); | |
| * <p>The default implementation returns {@code "UNKNOWN"} to preserve source compatibility | |
| * for existing downstream implementations of this public plugin API. | |
| * | |
| * @return the Besu node version string, never null | |
| */ | |
| default String getBesuVersion() { | |
| return "UNKNOWN"; | |
| } | |
| /** | |
| * Returns the git commit hash of the running Besu build. | |
| * | |
| * <p>The default implementation returns {@code "UNKNOWN"} to preserve source compatibility | |
| * for existing downstream implementations of this public plugin API. | |
| * | |
| * @return the short git commit hash, never null | |
| */ | |
| default String getBesuCommitHash() { | |
| return "UNKNOWN"; | |
| } |
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.
These tests only assert non-null/non-empty, so they won’t catch regressions where the methods stop delegating correctly (e.g., returning a constant placeholder) or violate the documented format. Consider asserting equality with
BesuVersionUtils.shortVersion()/BesuVersionUtils.commit()and (optionally) validating basic format expectations (e.g., SemVer-like version, hex-ish commit hash) to better pin down the intended contract.