Skip to content

Commit

Permalink
Handle unknown metrics in gossipsub onScrapeMetrics (#3889)
Browse files Browse the repository at this point in the history
* Handle unknown metrics in gossipsub onScrapeMetrics

* Change version to 0.34.4

Co-authored-by: Lion - dapplion <[email protected]>
  • Loading branch information
twoeths and dapplion authored Apr 6, 2022
1 parent e15c549 commit 4d766d1
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 71 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.34.2",
"version": "0.34.4",
"stream": "true",
"command": {
"version": {
Expand Down
10 changes: 5 additions & 5 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "0.34.2",
"version": "0.34.4",
"main": "lib/index.js",
"files": [
"lib/**/*.d.ts",
Expand All @@ -36,10 +36,10 @@
},
"dependencies": {
"@chainsafe/abort-controller": "^3.0.1",
"@chainsafe/lodestar-config": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-types": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-config": "^0.34.4",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/lodestar-types": "^0.34.4",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/persistent-merkle-tree": "^0.3.7",
"@chainsafe/ssz": "^0.8.20",
"cross-fetch": "^3.1.4",
Expand Down
10 changes: 5 additions & 5 deletions packages/beacon-state-transition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "0.34.2",
"version": "0.34.4",
"main": "lib/index.js",
"files": [
"lib/**/*.d.ts",
Expand All @@ -36,10 +36,10 @@
"types": "lib/index.d.ts",
"dependencies": {
"@chainsafe/bls": "6.0.3",
"@chainsafe/lodestar-config": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-types": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-config": "^0.34.4",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/lodestar-types": "^0.34.4",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/persistent-merkle-tree": "^0.3.7",
"@chainsafe/persistent-ts": "^0.19.1",
"@chainsafe/ssz": "^0.8.20",
Expand Down
20 changes: 10 additions & 10 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainsafe/lodestar-cli",
"version": "0.34.2",
"version": "0.34.4",
"description": "Command line interface for other packages",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
Expand Down Expand Up @@ -54,15 +54,15 @@
"@chainsafe/bls-keystore": "2.0.0",
"@chainsafe/blst": "^0.2.2",
"@chainsafe/discv5": "^0.6.7",
"@chainsafe/lodestar": "^0.34.2",
"@chainsafe/lodestar-api": "^0.34.2",
"@chainsafe/lodestar-beacon-state-transition": "^0.34.2",
"@chainsafe/lodestar-config": "^0.34.2",
"@chainsafe/lodestar-db": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-types": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-validator": "^0.34.2",
"@chainsafe/lodestar": "^0.34.4",
"@chainsafe/lodestar-api": "^0.34.4",
"@chainsafe/lodestar-beacon-state-transition": "^0.34.4",
"@chainsafe/lodestar-config": "^0.34.4",
"@chainsafe/lodestar-db": "^0.34.4",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/lodestar-types": "^0.34.4",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/lodestar-validator": "^0.34.4",
"@chainsafe/ssz": "^0.8.20",
"@types/lockfile": "^1.0.1",
"bip39": "^3.0.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainsafe/lodestar-config",
"version": "0.34.2",
"version": "0.34.4",
"description": "Chain configuration required for lodestar",
"author": "ChainSafe Systems",
"license": "Apache-2.0",
Expand Down Expand Up @@ -42,8 +42,8 @@
"blockchain"
],
"dependencies": {
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-types": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/lodestar-types": "^0.34.4",
"@chainsafe/ssz": "^0.8.20"
}
}
6 changes: 3 additions & 3 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainsafe/lodestar-db",
"version": "0.34.2",
"version": "0.34.4",
"description": "DB modules of Lodestar",
"author": "ChainSafe Systems",
"homepage": "https://github.com/ChainSafe/lodestar#readme",
Expand Down Expand Up @@ -36,8 +36,8 @@
"check-readme": "typescript-docs-verifier"
},
"dependencies": {
"@chainsafe/lodestar-config": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-config": "^0.34.4",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/ssz": "^0.8.20",
"@types/levelup": "^4.3.3",
"it-all": "^1.0.2",
Expand Down
12 changes: 6 additions & 6 deletions packages/fork-choice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "0.34.2",
"version": "0.34.4",
"main": "lib/index.js",
"files": [
"lib/**/*.d.ts",
Expand All @@ -37,11 +37,11 @@
"check-readme": "typescript-docs-verifier"
},
"dependencies": {
"@chainsafe/lodestar-beacon-state-transition": "^0.34.2",
"@chainsafe/lodestar-config": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-types": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-beacon-state-transition": "^0.34.4",
"@chainsafe/lodestar-config": "^0.34.4",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/lodestar-types": "^0.34.4",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/ssz": "^0.8.20"
},
"keywords": [
Expand Down
12 changes: 6 additions & 6 deletions packages/light-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "0.34.2",
"version": "0.34.4",
"main": "lib/index.js",
"files": [
"lib/**/*.d.ts",
Expand All @@ -37,11 +37,11 @@
"dependencies": {
"@chainsafe/abort-controller": "^3.0.1",
"@chainsafe/bls": "6.0.3",
"@chainsafe/lodestar-api": "^0.34.2",
"@chainsafe/lodestar-config": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-types": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-api": "^0.34.4",
"@chainsafe/lodestar-config": "^0.34.4",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/lodestar-types": "^0.34.4",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/persistent-merkle-tree": "^0.3.7",
"@chainsafe/ssz": "^0.8.20",
"cross-fetch": "^3.1.4",
Expand Down
22 changes: 11 additions & 11 deletions packages/lodestar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "0.34.2",
"version": "0.34.4",
"main": "lib/index.js",
"files": [
"lib/**/*.d.ts",
Expand Down Expand Up @@ -64,16 +64,16 @@
"@chainsafe/bls": "6.0.3",
"@chainsafe/discv5": "^0.6.7",
"@chainsafe/libp2p-noise": "5.0.3",
"@chainsafe/lodestar-api": "^0.34.2",
"@chainsafe/lodestar-beacon-state-transition": "^0.34.2",
"@chainsafe/lodestar-config": "^0.34.2",
"@chainsafe/lodestar-db": "^0.34.2",
"@chainsafe/lodestar-fork-choice": "^0.34.2",
"@chainsafe/lodestar-light-client": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-types": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-validator": "^0.34.2",
"@chainsafe/lodestar-api": "^0.34.4",
"@chainsafe/lodestar-beacon-state-transition": "^0.34.4",
"@chainsafe/lodestar-config": "^0.34.4",
"@chainsafe/lodestar-db": "^0.34.4",
"@chainsafe/lodestar-fork-choice": "^0.34.4",
"@chainsafe/lodestar-light-client": "^0.34.4",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/lodestar-types": "^0.34.4",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/lodestar-validator": "^0.34.4",
"@chainsafe/persistent-merkle-tree": "^0.3.7",
"@chainsafe/snappy-stream": "5.0.0",
"@chainsafe/ssz": "^0.8.20",
Expand Down
18 changes: 11 additions & 7 deletions packages/lodestar/src/network/gossip/gossipsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,17 @@ export class Eth2Gossipsub extends Gossipsub {
// Ignore topics with 0 peers. May prevent overriding after a fork
if (peers.size === 0) continue;

const topic = this.gossipTopicCache.getTopic(topicString);
if (topic.type === GossipType.beacon_attestation) {
peersByBeaconAttSubnetByFork.set(topic.fork, topic.subnet, peers.size);
} else if (topic.type === GossipType.sync_committee) {
peersByBeaconSyncSubnetByFork.set(topic.fork, topic.subnet, peers.size);
} else {
peersByTypeByFork.set(topic.fork, topic.type, peers.size);
// there are some new topics in the network so `getKnownTopic()` returns undefined
// for example in prater: /eth2/82f4a72b/optimistic_light_client_update_v0/ssz_snappy
const topic = this.gossipTopicCache.getKnownTopic(topicString);
if (topic !== undefined) {
if (topic.type === GossipType.beacon_attestation) {
peersByBeaconAttSubnetByFork.set(topic.fork, topic.subnet, peers.size);
} else if (topic.type === GossipType.sync_committee) {
peersByBeaconSyncSubnetByFork.set(topic.fork, topic.subnet, peers.size);
} else {
peersByTypeByFork.set(topic.fork, topic.type, peers.size);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions packages/lodestar/src/network/gossip/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class GossipTopicCache implements IGossipTopicCache {

constructor(private readonly forkDigestContext: IForkDigestContext) {}

/** Returns cached GossipTopic, otherwise attempts to parse it from the str */
getTopic(topicStr: string): GossipTopic {
let topic = this.topicsByTopicStr.get(topicStr);
if (topic === undefined) {
Expand All @@ -26,6 +27,11 @@ export class GossipTopicCache implements IGossipTopicCache {
return topic;
}

/** Returns cached GossipTopic, otherwise returns undefined */
getKnownTopic(topicStr: string): GossipTopic | undefined {
return this.topicsByTopicStr.get(topicStr);
}

setTopic(topicStr: string, topic: GossipTopic): void {
if (!this.topicsByTopicStr.has(topicStr)) {
this.topicsByTopicStr.set(topicStr, {encoding: DEFAULT_ENCODING, ...topic});
Expand Down
2 changes: 1 addition & 1 deletion packages/params/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainsafe/lodestar-params",
"version": "0.34.2",
"version": "0.34.4",
"description": "Chain parameters required for lodestar",
"author": "ChainSafe Systems",
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/spec-test-util/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainsafe/lodestar-spec-test-util",
"version": "0.34.2",
"version": "0.34.4",
"description": "Spec test suite generator from yaml test files",
"author": "ChainSafe Systems",
"license": "Apache-2.0",
Expand Down Expand Up @@ -45,7 +45,7 @@
"blockchain"
],
"dependencies": {
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/ssz": "^0.8.20",
"async-retry": "^1.3.3",
"axios": "^0.21.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "0.34.2",
"version": "0.34.4",
"main": "lib/index.js",
"files": [
"lib/**/*.d.ts",
Expand All @@ -35,7 +35,7 @@
},
"types": "lib/index.d.ts",
"dependencies": {
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/ssz": "^0.8.20"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/ChainSafe/lodestar/issues"
},
"version": "0.34.2",
"version": "0.34.4",
"main": "lib/index.js",
"files": [
"lib/**/*.d.ts",
Expand Down
16 changes: 8 additions & 8 deletions packages/validator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainsafe/lodestar-validator",
"version": "0.34.2",
"version": "0.34.4",
"description": "A Typescript implementation of the validator client",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
Expand Down Expand Up @@ -47,13 +47,13 @@
"dependencies": {
"@chainsafe/abort-controller": "^3.0.1",
"@chainsafe/bls": "6.0.3",
"@chainsafe/lodestar-api": "^0.34.2",
"@chainsafe/lodestar-beacon-state-transition": "^0.34.2",
"@chainsafe/lodestar-config": "^0.34.2",
"@chainsafe/lodestar-db": "^0.34.2",
"@chainsafe/lodestar-params": "^0.34.2",
"@chainsafe/lodestar-types": "^0.34.2",
"@chainsafe/lodestar-utils": "^0.34.2",
"@chainsafe/lodestar-api": "^0.34.4",
"@chainsafe/lodestar-beacon-state-transition": "^0.34.4",
"@chainsafe/lodestar-config": "^0.34.4",
"@chainsafe/lodestar-db": "^0.34.4",
"@chainsafe/lodestar-params": "^0.34.4",
"@chainsafe/lodestar-types": "^0.34.4",
"@chainsafe/lodestar-utils": "^0.34.4",
"@chainsafe/ssz": "^0.8.20",
"bigint-buffer": "^1.1.5",
"cross-fetch": "^3.1.4",
Expand Down

0 comments on commit 4d766d1

Please sign in to comment.