@lodestar/fork-choice 1.36.0-dev.793f92c091 → 1.36.0-dev.b739d2d697
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeDeltas.d.ts","sourceRoot":"","sources":["../../src/protoArray/computeDeltas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAK3C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,WAAW,EAAE,EACpB,WAAW,EAAE,0BAA0B,EACvC,WAAW,EAAE,0BAA0B,EACvC,mBAAmB,EAAE,GAAG,CAAC,cAAc,CAAC,GACvC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"computeDeltas.d.ts","sourceRoot":"","sources":["../../src/protoArray/computeDeltas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAK3C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,WAAW,EAAE,EACpB,WAAW,EAAE,0BAA0B,EACvC,WAAW,EAAE,0BAA0B,EACvC,mBAAmB,EAAE,GAAG,CAAC,cAAc,CAAC,GACvC,MAAM,EAAE,CA+EV"}
|
|
@@ -16,6 +16,10 @@ export function computeDeltas(numProtoNodes, votes, oldBalances, newBalances, eq
|
|
|
16
16
|
// avoid creating new variables in the loop to potentially reduce GC pressure
|
|
17
17
|
let oldBalance, newBalance;
|
|
18
18
|
let currentIndex, nextIndex;
|
|
19
|
+
// sort equivocating indices to avoid Set.has() in the loop
|
|
20
|
+
const equivocatingArray = Array.from(equivocatingIndices).sort((a, b) => a - b);
|
|
21
|
+
let equivocatingIndex = 0;
|
|
22
|
+
let equivocatingValidatorIndex = equivocatingArray[equivocatingIndex];
|
|
19
23
|
for (let vIndex = 0; vIndex < votes.length; vIndex++) {
|
|
20
24
|
const vote = votes[vIndex];
|
|
21
25
|
// There is no need to create a score change if the validator has never voted or both of their
|
|
@@ -34,7 +38,7 @@ export function computeDeltas(numProtoNodes, votes, oldBalances, newBalances, eq
|
|
|
34
38
|
// state to a new state with a higher epoch that is on a different fork because that fork may have
|
|
35
39
|
// on-boarded fewer validators than the prior fork.
|
|
36
40
|
newBalance = newBalances === oldBalances ? oldBalance : (newBalances[vIndex] ?? 0);
|
|
37
|
-
if (
|
|
41
|
+
if (vIndex === equivocatingValidatorIndex) {
|
|
38
42
|
// this function could be called multiple times but we only want to process slashing validator for 1 time
|
|
39
43
|
if (currentIndex !== null) {
|
|
40
44
|
if (currentIndex >= numProtoNodes) {
|
|
@@ -46,6 +50,8 @@ export function computeDeltas(numProtoNodes, votes, oldBalances, newBalances, eq
|
|
|
46
50
|
deltas[currentIndex] -= oldBalance;
|
|
47
51
|
}
|
|
48
52
|
vote.currentIndex = null;
|
|
53
|
+
equivocatingIndex++;
|
|
54
|
+
equivocatingValidatorIndex = equivocatingArray[equivocatingIndex];
|
|
49
55
|
continue;
|
|
50
56
|
}
|
|
51
57
|
if (currentIndex !== nextIndex || oldBalance !== newBalance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeDeltas.js","sourceRoot":"","sources":["../../src/protoArray/computeDeltas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAE,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAGjE,mDAAmD;AACnD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAU,CAAC;AAEnC;;;;;;;;GAQG;A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BACpB,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC;YACrC,CAAC;YAED,sDAAsD;YACtD,gGAAgG;YAChG,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,SAAS,IAAI,aAAa,EAAE,CAAC;oBAC/B,MAAM,IAAI,eAAe,CAAC;wBACxB,IAAI,EAAE,mBAAmB,CAAC,kBAAkB;wBAC5C,KAAK,EAAE,SAAS;qBACjB,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC;YAClC,CAAC;QACH,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAChC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.36.0-dev.
|
|
14
|
+
"version": "1.36.0-dev.b739d2d697",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@chainsafe/ssz": "^1.2.2",
|
|
43
|
-
"@lodestar/config": "1.36.0-dev.
|
|
44
|
-
"@lodestar/params": "1.36.0-dev.
|
|
45
|
-
"@lodestar/state-transition": "1.36.0-dev.
|
|
46
|
-
"@lodestar/types": "1.36.0-dev.
|
|
47
|
-
"@lodestar/utils": "1.36.0-dev.
|
|
43
|
+
"@lodestar/config": "1.36.0-dev.b739d2d697",
|
|
44
|
+
"@lodestar/params": "1.36.0-dev.b739d2d697",
|
|
45
|
+
"@lodestar/state-transition": "1.36.0-dev.b739d2d697",
|
|
46
|
+
"@lodestar/types": "1.36.0-dev.b739d2d697",
|
|
47
|
+
"@lodestar/utils": "1.36.0-dev.b739d2d697"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"ethereum",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"beacon",
|
|
53
53
|
"blockchain"
|
|
54
54
|
],
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "079ab121db316f98d8527f64f26d5301be27066c"
|
|
56
56
|
}
|
|
@@ -28,6 +28,10 @@ export function computeDeltas(
|
|
|
28
28
|
// avoid creating new variables in the loop to potentially reduce GC pressure
|
|
29
29
|
let oldBalance: number, newBalance: number;
|
|
30
30
|
let currentIndex: number | null, nextIndex: number | null;
|
|
31
|
+
// sort equivocating indices to avoid Set.has() in the loop
|
|
32
|
+
const equivocatingArray = Array.from(equivocatingIndices).sort((a, b) => a - b);
|
|
33
|
+
let equivocatingIndex = 0;
|
|
34
|
+
let equivocatingValidatorIndex = equivocatingArray[equivocatingIndex];
|
|
31
35
|
|
|
32
36
|
for (let vIndex = 0; vIndex < votes.length; vIndex++) {
|
|
33
37
|
const vote = votes[vIndex];
|
|
@@ -50,7 +54,7 @@ export function computeDeltas(
|
|
|
50
54
|
// on-boarded fewer validators than the prior fork.
|
|
51
55
|
newBalance = newBalances === oldBalances ? oldBalance : (newBalances[vIndex] ?? 0);
|
|
52
56
|
|
|
53
|
-
if (
|
|
57
|
+
if (vIndex === equivocatingValidatorIndex) {
|
|
54
58
|
// this function could be called multiple times but we only want to process slashing validator for 1 time
|
|
55
59
|
if (currentIndex !== null) {
|
|
56
60
|
if (currentIndex >= numProtoNodes) {
|
|
@@ -62,6 +66,8 @@ export function computeDeltas(
|
|
|
62
66
|
deltas[currentIndex] -= oldBalance;
|
|
63
67
|
}
|
|
64
68
|
vote.currentIndex = null;
|
|
69
|
+
equivocatingIndex++;
|
|
70
|
+
equivocatingValidatorIndex = equivocatingArray[equivocatingIndex];
|
|
65
71
|
continue;
|
|
66
72
|
}
|
|
67
73
|
|