Skip to content

Commit

Permalink
Release v1.4.2 (#5105)
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain authored Feb 7, 2023
2 parents cbb7619 + 68c82ba commit 440c59f
Show file tree
Hide file tree
Showing 22 changed files with 153 additions and 102 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": "1.4.1",
"version": "1.4.2",
"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": "1.4.1",
"version": "1.4.2",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -70,10 +70,10 @@
"dependencies": {
"@chainsafe/persistent-merkle-tree": "^0.4.2",
"@chainsafe/ssz": "^0.9.2",
"@lodestar/config": "^1.4.1",
"@lodestar/params": "^1.4.1",
"@lodestar/types": "^1.4.1",
"@lodestar/utils": "^1.4.1",
"@lodestar/config": "^1.4.2",
"@lodestar/params": "^1.4.2",
"@lodestar/types": "^1.4.2",
"@lodestar/utils": "^1.4.2",
"cross-fetch": "^3.1.4",
"eventsource": "^2.0.2",
"qs": "^6.10.1"
Expand Down
24 changes: 12 additions & 12 deletions packages/beacon-node/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": "1.4.1",
"version": "1.4.2",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -114,17 +114,17 @@
"@libp2p/peer-id-factory": "^2.0.1",
"@libp2p/prometheus-metrics": "^1.1.2",
"@libp2p/tcp": "^6.1.0",
"@lodestar/api": "^1.4.1",
"@lodestar/config": "^1.4.1",
"@lodestar/db": "^1.4.1",
"@lodestar/fork-choice": "^1.4.1",
"@lodestar/light-client": "^1.4.1",
"@lodestar/params": "^1.4.1",
"@lodestar/reqresp": "^1.4.1",
"@lodestar/state-transition": "^1.4.1",
"@lodestar/types": "^1.4.1",
"@lodestar/utils": "^1.4.1",
"@lodestar/validator": "^1.4.1",
"@lodestar/api": "^1.4.2",
"@lodestar/config": "^1.4.2",
"@lodestar/db": "^1.4.2",
"@lodestar/fork-choice": "^1.4.2",
"@lodestar/light-client": "^1.4.2",
"@lodestar/params": "^1.4.2",
"@lodestar/reqresp": "^1.4.2",
"@lodestar/state-transition": "^1.4.2",
"@lodestar/types": "^1.4.2",
"@lodestar/utils": "^1.4.2",
"@lodestar/validator": "^1.4.2",
"@multiformats/multiaddr": "^11.0.0",
"@types/datastore-level": "^3.0.0",
"buffer-xor": "^2.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/lightClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ export class LightClientServer {
isFinalityUpdate: attestedData.isFinalized,
};

if (!isBetterUpdate(prevBestUpdateSummary, nextBestUpdate)) {
if (!isBetterUpdate(nextBestUpdate, prevBestUpdateSummary)) {
this.metrics?.lightclientServer.updateNotBetter.inc();
return;
}
Expand Down
10 changes: 9 additions & 1 deletion packages/beacon-node/src/metrics/metrics/lodestar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ export function createLodestarMetrics(
help: "Histogram of current count of long lived attnets of connected peers",
buckets: [0, 4, 16, 32, 64],
}),
peerScore: register.histogram({
peerScoreByClient: register.histogram<"client">({
name: "lodestar_app_peer_score",
help: "Current peer score at lodestar app side",
// Min score = -100, max score = 100, disconnect = -20, ban = -50
buckets: [-100, -50, -20, 0, 25],
labelNames: ["client"],
}),
peerConnectionLength: register.histogram({
name: "lodestar_peer_connection_seconds",
Expand Down Expand Up @@ -174,6 +175,13 @@ export function createLodestarMetrics(
help: "number of mesh peers, labeled by client",
labelNames: ["client"],
}),
scoreByClient: register.histogram<"client">({
name: "lodestar_gossip_score_by_client",
help: "Gossip peer score by client",
labelNames: ["client"],
// based on gossipScoreThresholds and negativeGossipScoreIgnoreThreshold
buckets: [-16000, -8000, -4000, -1000, 0, 5, 100],
}),
score: register.avgMinMax({
name: "lodestar_gossip_score_avg_min_max",
help: "Avg min max of all gossip peer scores",
Expand Down
6 changes: 6 additions & 0 deletions packages/beacon-node/src/network/gossip/scoringParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export const gossipScoreThresholds: PeerScoreThresholds = {
opportunisticGraftThreshold: 5,
};

/**
* Peer may sometimes has negative gossipsub score and we give it time to recover, however gossipsub score comes below this we need to take into account.
* Given gossipsubThresold = -4000, it's comfortable to only ignore negative score gossip peer score > -1000
*/
export const negativeGossipScoreIgnoreThreshold = -1000;

type MeshMessageInfo = {
decaySlots: number;
capFactor: number;
Expand Down
5 changes: 4 additions & 1 deletion packages/beacon-node/src/network/peers/peerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,9 @@ export class PeerManager {

// peerLongLivedAttnets metric is a count
metrics.peerLongLivedAttnets.reset();
metrics.peerScoreByClient.reset();
metrics.peerConnectionLength.reset();
metrics.gossipPeer.scoreByClient.reset();

// reset client counts _for each client_ to 0
for (const client of Object.values(ClientKind)) {
Expand All @@ -659,7 +661,8 @@ export class PeerManager {

// TODO: Consider optimizing by doing observe in batch
metrics.peerLongLivedAttnets.observe(attnets ? attnets.getTrueBitIndexes().length : 0);
metrics.peerScore.observe(this.peerRpcScores.getScore(peerId));
metrics.peerScoreByClient.observe({client}, this.peerRpcScores.getScore(peerId));
metrics.gossipPeer.scoreByClient.observe({client}, this.peerRpcScores.getGossipScore(peerId));
metrics.peerConnectionLength.observe((now - openCnx.stat.timeline.open) / 1000);
total++;
}
Expand Down
16 changes: 12 additions & 4 deletions packages/beacon-node/src/network/peers/score.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {PeerId} from "@libp2p/interface-peer-id";
import {MapDef, pruneSetToMax} from "@lodestar/utils";
import {gossipScoreThresholds} from "../gossip/scoringParameters.js";
import {gossipScoreThresholds, negativeGossipScoreIgnoreThreshold} from "../gossip/scoringParameters.js";
import {IMetrics} from "../../metrics/index.js";

/** The default score for new peers */
Expand Down Expand Up @@ -78,6 +78,7 @@ type PeerIdStr = string;

export interface IPeerRpcScoreStore {
getScore(peer: PeerId): number;
getGossipScore(peer: PeerId): number;
getScoreState(peer: PeerId): ScoreState;
dumpPeerScoreStats(): PeerScoreStats;
applyAction(peer: PeerId, action: PeerAction, actionName: string): void;
Expand Down Expand Up @@ -107,7 +108,6 @@ export type PeerScoreStat = {
export class PeerRpcScoreStore implements IPeerRpcScoreStore {
private readonly scores = new MapDef<PeerIdStr, PeerScore>(() => new PeerScore());
private readonly metrics: IMetrics | null;
private readonly lastUpdate = new Map<string, number>();

// TODO: Persist scores, at least BANNED status to disk

Expand All @@ -119,6 +119,10 @@ export class PeerRpcScoreStore implements IPeerRpcScoreStore {
return this.scores.get(peer.toString())?.getScore() ?? DEFAULT_SCORE;
}

getGossipScore(peer: PeerId): number {
return this.scores.get(peer.toString())?.getGossipScore() ?? DEFAULT_SCORE;
}

getScoreState(peer: PeerId): ScoreState {
return scoreToState(this.getScore(peer));
}
Expand Down Expand Up @@ -177,6 +181,10 @@ export class PeerScore {
return this.score;
}

getGossipScore(): number {
return this.gossipScore;
}

add(scoreDelta: number): void {
let newScore = this.lodestarScore + scoreDelta;
if (newScore > MAX_SCORE) newScore = MAX_SCORE;
Expand All @@ -198,7 +206,7 @@ export class PeerScore {
// Using exponential decay based on a constant half life.
const sinceLastUpdateMs = nowMs - this.lastUpdate;
// If peer was banned, lastUpdate will be in the future
if (sinceLastUpdateMs > 0 && this.lodestarScore !== 0) {
if (sinceLastUpdateMs > 0) {
this.lastUpdate = nowMs;
// e^(-ln(2)/HL*t)
const decayFactor = Math.exp(HALFLIFE_DECAY_MS * sinceLastUpdateMs);
Expand Down Expand Up @@ -284,7 +292,7 @@ export function updateGossipsubScores(
const gossipsubScore = gossipsubScores.get(peerId);
if (gossipsubScore !== undefined) {
let ignore = false;
if (gossipsubScore < 0 && toIgnoreNegativePeers > 0) {
if (gossipsubScore < 0 && gossipsubScore > negativeGossipScoreIgnoreThreshold && toIgnoreNegativePeers > 0) {
// We ignore the negative score for the best negative peers so that their
// gossipsub score can recover without getting disconnected.
ignore = true;
Expand Down
64 changes: 45 additions & 19 deletions packages/beacon-node/test/unit/network/peers/score.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,54 @@ describe("simple block provider score tracking", function () {

describe("updateGossipsubScores", function () {
const sandbox = sinon.createSandbox();
const peerRpcScoresStub = sandbox.createStubInstance(PeerRpcScoreStore);
let peerRpcScoresStub: PeerRpcScoreStore;
beforeEach(() => {
peerRpcScoresStub = sandbox.createStubInstance(PeerRpcScoreStore);
});

this.afterEach(() => {
sandbox.restore();
});

it("should update gossipsub peer scores", () => {
updateGossipsubScores(
peerRpcScoresStub,
new Map([
["a", 10],
["b", -10],
["c", -20],
["d", -5],
]),
2
);
expect(peerRpcScoresStub.updateGossipsubScore).to.be.calledWith("a", 10, false);
// should ignore b d since they are 2 biggest negative scores
expect(peerRpcScoresStub.updateGossipsubScore).to.be.calledWith("b", -10, true);
expect(peerRpcScoresStub.updateGossipsubScore).to.be.calledWith("d", -5, true);
// should not ignore c as it's lowest negative scores
expect(peerRpcScoresStub.updateGossipsubScore).to.be.calledWith("c", -20, false);
});
const testCases: {name: string; peerScores: [string, number, boolean][]; maxIgnore: number}[] = [
{
name: "Should NOT ignore negative score of <= -1000",
peerScores: [
["a", 10, false],
// ignore the next 3 because maxIgnore is 5
["b", -10, true],
["c", -20, true],
["d", -5, true],
// not ignore because score is low
["e", -1000, false],
],
maxIgnore: 5,
},
{
name: "Should NOT ignore last negative score",
peerScores: [
["a", 10, false],
// ignore the next 3 because maxIgnore is 5
["b", -10, true],
["c", -20, true],
["d", -5, true],
// not ignore because maxIgnore is 3
["e", -30, false],
],
maxIgnore: 3,
},
];

for (const {name, peerScores, maxIgnore} of testCases) {
it(name, () => {
const peerScoreMap = new Map<string, number>();
for (const [key, value] of peerScores) {
peerScoreMap.set(key, value);
}
updateGossipsubScores(peerRpcScoresStub, peerScoreMap, maxIgnore);
for (const [key, value, ignore] of peerScores) {
expect(peerRpcScoresStub.updateGossipsubScore).to.be.calledWith(key, value, ignore);
}
});
}
});
22 changes: 11 additions & 11 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainsafe/lodestar",
"version": "1.4.1",
"version": "1.4.2",
"description": "Command line interface for lodestar",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
Expand Down Expand Up @@ -61,16 +61,16 @@
"@chainsafe/discv5": "^3.0.0",
"@chainsafe/ssz": "^0.9.2",
"@libp2p/peer-id-factory": "^2.0.1",
"@lodestar/api": "^1.4.1",
"@lodestar/beacon-node": "^1.4.1",
"@lodestar/config": "^1.4.1",
"@lodestar/db": "^1.4.1",
"@lodestar/light-client": "^1.4.1",
"@lodestar/params": "^1.4.1",
"@lodestar/state-transition": "^1.4.1",
"@lodestar/types": "^1.4.1",
"@lodestar/utils": "^1.4.1",
"@lodestar/validator": "^1.4.1",
"@lodestar/api": "^1.4.2",
"@lodestar/beacon-node": "^1.4.2",
"@lodestar/config": "^1.4.2",
"@lodestar/db": "^1.4.2",
"@lodestar/light-client": "^1.4.2",
"@lodestar/params": "^1.4.2",
"@lodestar/state-transition": "^1.4.2",
"@lodestar/types": "^1.4.2",
"@lodestar/utils": "^1.4.2",
"@lodestar/validator": "^1.4.2",
"@multiformats/multiaddr": "^11.0.0",
"@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": "@lodestar/config",
"version": "1.4.1",
"version": "1.4.2",
"description": "Chain configuration required for lodestar",
"author": "ChainSafe Systems",
"license": "Apache-2.0",
Expand Down Expand Up @@ -66,7 +66,7 @@
],
"dependencies": {
"@chainsafe/ssz": "^0.9.2",
"@lodestar/params": "^1.4.1",
"@lodestar/types": "^1.4.1"
"@lodestar/params": "^1.4.2",
"@lodestar/types": "^1.4.2"
}
}
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": "@lodestar/db",
"version": "1.4.1",
"version": "1.4.2",
"description": "DB modules of Lodestar",
"author": "ChainSafe Systems",
"homepage": "https://github.com/ChainSafe/lodestar#readme",
Expand Down Expand Up @@ -39,8 +39,8 @@
},
"dependencies": {
"@chainsafe/ssz": "^0.9.2",
"@lodestar/config": "^1.4.1",
"@lodestar/utils": "^1.4.1",
"@lodestar/config": "^1.4.2",
"@lodestar/utils": "^1.4.2",
"@types/levelup": "^4.3.3",
"it-all": "^2.0.0",
"level": "^8.0.0"
Expand Down
10 changes: 5 additions & 5 deletions packages/flare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lodestar/flare",
"version": "1.4.1",
"version": "1.4.2",
"description": "Beacon chain debugging tool",
"author": "ChainSafe Systems",
"license": "Apache-2.0",
Expand Down Expand Up @@ -59,10 +59,10 @@
"blockchain"
],
"dependencies": {
"@lodestar/api": "^1.4.1",
"@lodestar/config": "^1.4.1",
"@lodestar/state-transition": "^1.4.1",
"@lodestar/types": "^1.4.1",
"@lodestar/api": "^1.4.2",
"@lodestar/config": "^1.4.2",
"@lodestar/state-transition": "^1.4.2",
"@lodestar/types": "^1.4.2",
"source-map-support": "^0.5.19",
"yargs": "^16.1.0"
},
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": "1.4.1",
"version": "1.4.2",
"type": "module",
"exports": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down Expand Up @@ -40,11 +40,11 @@
},
"dependencies": {
"@chainsafe/ssz": "^0.9.2",
"@lodestar/config": "^1.4.1",
"@lodestar/params": "^1.4.1",
"@lodestar/state-transition": "^1.4.1",
"@lodestar/types": "^1.4.1",
"@lodestar/utils": "^1.4.1"
"@lodestar/config": "^1.4.2",
"@lodestar/params": "^1.4.2",
"@lodestar/state-transition": "^1.4.2",
"@lodestar/types": "^1.4.2",
"@lodestar/utils": "^1.4.2"
},
"keywords": [
"ethereum",
Expand Down
Loading

0 comments on commit 440c59f

Please sign in to comment.