-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Categorize peer by agent version (#3472)
* Parse client from agent version * Only show client name in req/resp log * Only parse client kind
- Loading branch information
Showing
5 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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,27 @@ | ||
export enum ClientKind { | ||
Lighthouse = "Lighthouse", | ||
Nimbus = "Nimbus", | ||
Teku = "Teku", | ||
Prysm = "Prysm", | ||
Lodestar = "Lodestar", | ||
Unknown = "Unknown", | ||
} | ||
|
||
export function clientFromAgentVersion(agentVersion: string): ClientKind { | ||
const slashIndex = agentVersion.indexOf("/"); | ||
const agent = slashIndex >= 0 ? agentVersion.slice(0, slashIndex) : agentVersion; | ||
switch (agent.toLowerCase()) { | ||
case "lighthouse": | ||
return ClientKind.Lighthouse; | ||
case "teku": | ||
return ClientKind.Teku; | ||
case "prysm": | ||
return ClientKind.Prysm; | ||
case "nimbus": | ||
return ClientKind.Nimbus; | ||
case "js-libp2p": | ||
return ClientKind.Lodestar; | ||
default: | ||
return ClientKind.Unknown; | ||
} | ||
} |
This file contains 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 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 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 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,38 @@ | ||
import {expect} from "chai"; | ||
import {clientFromAgentVersion, ClientKind} from "../../../../src/network/peers/client"; | ||
|
||
describe("clientFromAgentVersion", () => { | ||
const testCases: {name: string; agentVersion: string; client: ClientKind}[] = [ | ||
{ | ||
name: "lighthouse", | ||
agentVersion: "Lighthouse/v2.0.1-fff01b2/x86_64-linux", | ||
client: ClientKind.Lighthouse, | ||
}, | ||
{ | ||
name: "teku", | ||
agentVersion: "teku/teku/v21.11.0+62-g501ffa7/linux-x86_64/corretto-java-17", | ||
client: ClientKind.Teku, | ||
}, | ||
{ | ||
name: "nimbus", | ||
agentVersion: "nimbus", | ||
client: ClientKind.Nimbus, | ||
}, | ||
{ | ||
name: "prysm", | ||
agentVersion: "Prysm/v2.0.2/a80b1c252a9b4773493b41999769bf3134ac373f", | ||
client: ClientKind.Prysm, | ||
}, | ||
{ | ||
name: "lodestar", | ||
agentVersion: "js-libp2p/0.32.4", | ||
client: ClientKind.Lodestar, | ||
}, | ||
]; | ||
|
||
for (const {name, agentVersion, client} of testCases) { | ||
it(name, () => { | ||
expect(clientFromAgentVersion(agentVersion)).to.be.equal(client, `cannot parse ${name} agent version`); | ||
}); | ||
} | ||
}); |