@lodestar/state-transition 1.29.0-dev.d203cc3a06 → 1.29.0-dev.ea21eb2404
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.
|
@@ -17,25 +17,33 @@ export function processPendingConsolidations(state, cache) {
|
|
|
17
17
|
let nextPendingConsolidation = 0;
|
|
18
18
|
const validators = state.validators;
|
|
19
19
|
const cachedBalances = cache.balances;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
let chunkStartIndex = 0;
|
|
21
|
+
const chunkSize = 100;
|
|
22
|
+
const pendingConsolidationsLength = state.pendingConsolidations.length;
|
|
23
|
+
outer: while (chunkStartIndex < pendingConsolidationsLength) {
|
|
24
|
+
const consolidationChunk = state.pendingConsolidations.getReadonlyByRange(chunkStartIndex, chunkSize);
|
|
25
|
+
for (const pendingConsolidation of consolidationChunk) {
|
|
26
|
+
const { sourceIndex, targetIndex } = pendingConsolidation;
|
|
27
|
+
const sourceValidator = validators.getReadonly(sourceIndex);
|
|
28
|
+
if (sourceValidator.slashed) {
|
|
29
|
+
nextPendingConsolidation++;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (sourceValidator.withdrawableEpoch > nextEpoch) {
|
|
33
|
+
break outer;
|
|
34
|
+
}
|
|
35
|
+
// Calculate the consolidated balance
|
|
36
|
+
const sourceEffectiveBalance = Math.min(state.balances.get(sourceIndex), sourceValidator.effectiveBalance);
|
|
37
|
+
// Move active balance to target. Excess balance is withdrawable.
|
|
38
|
+
decreaseBalance(state, sourceIndex, sourceEffectiveBalance);
|
|
39
|
+
increaseBalance(state, targetIndex, sourceEffectiveBalance);
|
|
40
|
+
if (cachedBalances) {
|
|
41
|
+
cachedBalances[sourceIndex] -= sourceEffectiveBalance;
|
|
42
|
+
cachedBalances[targetIndex] += sourceEffectiveBalance;
|
|
43
|
+
}
|
|
24
44
|
nextPendingConsolidation++;
|
|
25
|
-
continue;
|
|
26
45
|
}
|
|
27
|
-
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
// Move active balance to target. Excess balance is withdrawable.
|
|
31
|
-
const sourceEffectiveBalance = Math.min(state.balances.get(sourceIndex), state.validators.getReadonly(sourceIndex).effectiveBalance);
|
|
32
|
-
decreaseBalance(state, sourceIndex, sourceEffectiveBalance);
|
|
33
|
-
increaseBalance(state, targetIndex, sourceEffectiveBalance);
|
|
34
|
-
if (cachedBalances) {
|
|
35
|
-
cachedBalances[sourceIndex] -= sourceEffectiveBalance;
|
|
36
|
-
cachedBalances[targetIndex] += sourceEffectiveBalance;
|
|
37
|
-
}
|
|
38
|
-
nextPendingConsolidation++;
|
|
46
|
+
chunkStartIndex += chunkSize;
|
|
39
47
|
}
|
|
40
48
|
state.pendingConsolidations = state.pendingConsolidations.sliceFrom(nextPendingConsolidation);
|
|
41
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPendingConsolidations.js","sourceRoot":"","sources":["../../src/epoch/processPendingConsolidations.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAE,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAGpE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAA+B,EAAE,KAA2B;IACvG,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IAC3C,IAAI,wBAAwB,GAAG,CAAC,CAAC;IACjC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IACpC,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC;IAEtC,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"processPendingConsolidations.js","sourceRoot":"","sources":["../../src/epoch/processPendingConsolidations.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAE,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAGpE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU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AAC;gBACnB,cAAc,CAAC,WAAW,CAAC,IAAI,sBAAsB,CAAC;gBACtD,cAAc,CAAC,WAAW,CAAC,IAAI,sBAAsB,CAAC;YACxD,CAAC;YAED,wBAAwB,EAAE,CAAC;QAC7B,CAAC;QACD,eAAe,IAAI,SAAS,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,qBAAqB,GAAG,KAAK,CAAC,qBAAqB,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;AAChG,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.29.0-dev.
|
|
14
|
+
"version": "1.29.0-dev.ea21eb2404",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@chainsafe/pubkey-index-map": "2.0.0",
|
|
66
66
|
"@chainsafe/ssz": "^1.2.0",
|
|
67
67
|
"@chainsafe/swap-or-not-shuffle": "^1.2.1",
|
|
68
|
-
"@lodestar/config": "1.29.0-dev.
|
|
69
|
-
"@lodestar/params": "1.29.0-dev.
|
|
70
|
-
"@lodestar/types": "1.29.0-dev.
|
|
71
|
-
"@lodestar/utils": "1.29.0-dev.
|
|
68
|
+
"@lodestar/config": "1.29.0-dev.ea21eb2404",
|
|
69
|
+
"@lodestar/params": "1.29.0-dev.ea21eb2404",
|
|
70
|
+
"@lodestar/types": "1.29.0-dev.ea21eb2404",
|
|
71
|
+
"@lodestar/utils": "1.29.0-dev.ea21eb2404",
|
|
72
72
|
"bigint-buffer": "^1.1.5"
|
|
73
73
|
},
|
|
74
74
|
"keywords": [
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"beacon",
|
|
78
78
|
"blockchain"
|
|
79
79
|
],
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "0670f559f0d9ae2ce130d39041a7acafa135e4ab"
|
|
81
81
|
}
|