-
Notifications
You must be signed in to change notification settings - Fork 75
ETCM-365: Version info in Hello.clientId #794
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 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8c9b57d
ETCM-365: Add BuildInfo sbt plugin.
aakoshh 9684d23
ETCM-365: Put the version info into the client ID. Allow override fro…
aakoshh 5c50868
ETCM-365: Fix nix repo for new sbt plugins.
aakoshh 8ae086f
ETCM-365: Generate protobuf file into a sub-directory.
aakoshh e1ac90e
ETCM-365: Instead of override, use -Dmantis.client-id as an agumented…
aakoshh 1ad426a
ETCM-365: Public method return value.
aakoshh 892df1b
Merge remote-tracking branch 'origin/develop' into ETCM-365-hello-cli…
aakoshh 9782cde
ETCM-365: Update client identity key name and format.
aakoshh b55adbd
ETCM-365: Remove leftover comment.
aakoshh 8eff047
ETCM-365: More precise regex in test.
aakoshh 9818b0b
ETCM-365: Allow underscore in Java version.
aakoshh 96fb1c7
Merge remote-tracking branch 'origin/develop' into ETCM-365-hello-cli…
aakoshh 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
Large diffs are not rendered by default.
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
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,44 @@ | ||
package io.iohk.ethereum.utils | ||
|
||
object VersionInfo { | ||
|
||
/** Produce a node name that get sent in `WireProtocol.Hello.clientId` according to Ethereum conventions. | ||
* | ||
* Check out examples on https://etcnodes.org | ||
* | ||
* e.g. | ||
* - mantis/v3.0-cd5ae33/linux-amd64/ubuntu-openjdk64bitservervm-java-11.0.9 | ||
* - besu/v20.10.0/linux-x86_64/oracle_openjdk-java-11 | ||
* - coregeth/v1.11.8-stable-305b5089/linux-amd64/go1.14.4 | ||
*/ | ||
def nodeName(maybeClientId: Option[String] = None): String = { | ||
val app = { | ||
val name = BuildInfo.name | ||
val id = maybeClientId.map("-" + _).getOrElse("") | ||
s"$name$id" | ||
} | ||
val version = { | ||
val version = BuildInfo.version | ||
val commit = BuildInfo.gitHeadCommit.map("-" + _.take(7)).getOrElse("") | ||
ntallar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
s"v$version$commit" | ||
} | ||
val os = { | ||
val name = norm(prop("os.name")) | ||
val arch = norm(prop("os.arch")) | ||
s"$name-$arch" | ||
} | ||
val vm = { | ||
val vendor = norm(prop("java.vendor")) | ||
val vmName = norm(prop("java.vm.name")) | ||
val version = prop("java.version") | ||
s"$vendor-$vmName-java-$version" | ||
} | ||
s"$app/$version/$os/$vm" | ||
} | ||
|
||
private def prop(name: String) = | ||
System.getProperty(name) | ||
|
||
private def norm(value: String) = | ||
value.toLowerCase.replaceAll("[^a-z0-9]+", "") | ||
} |
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
mantis { | ||
|
||
client-id = "mantis" | ||
|
||
datadir = "/tmp/mantis-test/" | ||
|
||
secure-random-algo = "NativePRNGNonBlocking" | ||
|
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,10 @@ | ||
package io.iohk.ethereum.utils | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class ConfigSpec extends AnyFlatSpec with Matchers { | ||
"clientId" should "by default come from VersionInfo" in { | ||
Config.clientId shouldBe VersionInfo.nodeName() | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/scala/io/iohk/ethereum/utils/VersionInfoSpec.scala
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,16 @@ | ||
package io.iohk.ethereum.utils | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class VersionInfoSpec extends AnyFlatSpec with Matchers { | ||
behavior of "nodeName" | ||
|
||
it should "preserve major and minor Java version" in { | ||
VersionInfo.nodeName() should fullyMatch regex """mantis/v\d.*-[a-z0-9]{7}/.+-.+/.+-.+-java-\d+\.\d+.*""" | ||
} | ||
|
||
it should "augment the name with an identity" in { | ||
VersionInfo.nodeName(Some("etc")) should startWith("mantis-etc/") | ||
} | ||
} |
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.