Skip to content

add engine_getClientVersionV1#7512

Merged
pinges merged 14 commits intobesu-eth:mainfrom
Matilda-Clerke:6471-add-engine-getClientVersionV1
Aug 27, 2024
Merged

add engine_getClientVersionV1#7512
pinges merged 14 commits intobesu-eth:mainfrom
Matilda-Clerke:6471-add-engine-getClientVersionV1

Conversation

@Matilda-Clerke
Copy link
Copy Markdown
Contributor

PR description

Add the engine_getClientVersionV1 to the engine RPC API

Fixed Issue(s)

#6471

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
public class JsonRpcTestMethodsFactory {

private static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming this to better match its source in BesuInfo

…gain

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

static {
if (VERSION == null) {
COMMIT = null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of NULL, would it be better to return empty String ""?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is there a test that covers NULL commit? How would it be reported?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it's difficult to test the value of COMMIT because BesuInfo pulls data from the class' package which isn't typically set outside of a proper build.

As for null vs empty String, philosophically I'd rather it be null. The api doesn't really specify what should be supplied if a value isn't available.

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
COMMIT = null;
} else {
Pattern pattern = Pattern.compile("v?\\d*\\.\\d*\\.\\d*-\\w+-(?<commit>[0-9a-fA-F]{8})");
Matcher matcher = pattern.matcher(VERSION);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the develop builds include the commit hash in the version at the moment, so this won't work for github release versions.

I tested locally using ./gradlew -Prelease.releaseVersion=99.9.0 -Pversion=99.9.0 assemble installDist and the commit field in the response was null.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sure how else to get the commit hash. The purpose of the field is to give a specific commit at which the application was run, and for github releases there seems to be an accompanying tag, so the version itself can be used to find the exact commit if desired.

Do you think it would be worthwhile finding some other way to get the commit field populated?

Copy link
Copy Markdown
Contributor

@pinges pinges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pinges pinges enabled auto-merge (squash) August 27, 2024 04:30
@pinges pinges merged commit e0aa4f6 into besu-eth:main Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants