@lodestar/state-transition 1.23.0-dev.d69d809e7a → 1.23.0-dev.e6c1c5b3e3

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.
Files changed (103) hide show
  1. package/lib/block/isValidIndexedAttestation.js +2 -6
  2. package/lib/block/isValidIndexedAttestation.js.map +1 -1
  3. package/lib/block/processAttestationPhase0.js +4 -8
  4. package/lib/block/processAttestationPhase0.js.map +1 -1
  5. package/lib/block/processConsolidationRequest.js +54 -8
  6. package/lib/block/processConsolidationRequest.js.map +1 -1
  7. package/lib/block/processDeposit.d.ts +4 -1
  8. package/lib/block/processDeposit.js +33 -37
  9. package/lib/block/processDeposit.js.map +1 -1
  10. package/lib/block/processDepositRequest.d.ts +1 -2
  11. package/lib/block/processDepositRequest.js +11 -3
  12. package/lib/block/processDepositRequest.js.map +1 -1
  13. package/lib/block/processEth1Data.js +1 -3
  14. package/lib/block/processEth1Data.js.map +1 -1
  15. package/lib/block/processOperations.js +1 -1
  16. package/lib/block/processOperations.js.map +1 -1
  17. package/lib/block/processSyncCommittee.js +1 -3
  18. package/lib/block/processSyncCommittee.js.map +1 -1
  19. package/lib/block/processWithdrawalRequest.js +1 -1
  20. package/lib/block/processWithdrawalRequest.js.map +1 -1
  21. package/lib/block/processWithdrawals.js +3 -2
  22. package/lib/block/processWithdrawals.js.map +1 -1
  23. package/lib/cache/epochCache.d.ts +5 -3
  24. package/lib/cache/epochCache.js +22 -23
  25. package/lib/cache/epochCache.js.map +1 -1
  26. package/lib/cache/epochTransitionCache.d.ts +0 -5
  27. package/lib/cache/epochTransitionCache.js +0 -2
  28. package/lib/cache/epochTransitionCache.js.map +1 -1
  29. package/lib/cache/pubkeyCache.d.ts +1 -9
  30. package/lib/cache/pubkeyCache.js +0 -18
  31. package/lib/cache/pubkeyCache.js.map +1 -1
  32. package/lib/cache/stateCache.js +2 -0
  33. package/lib/cache/stateCache.js.map +1 -1
  34. package/lib/cache/syncCommitteeCache.d.ts +1 -1
  35. package/lib/cache/syncCommitteeCache.js +1 -1
  36. package/lib/cache/syncCommitteeCache.js.map +1 -1
  37. package/lib/constants/constants.d.ts +3 -4
  38. package/lib/constants/constants.js +4 -4
  39. package/lib/constants/constants.js.map +1 -1
  40. package/lib/epoch/index.d.ts +3 -3
  41. package/lib/epoch/index.js +5 -5
  42. package/lib/epoch/index.js.map +1 -1
  43. package/lib/epoch/processEffectiveBalanceUpdates.js +4 -7
  44. package/lib/epoch/processEffectiveBalanceUpdates.js.map +1 -1
  45. package/lib/epoch/processPendingConsolidations.js +7 -12
  46. package/lib/epoch/processPendingConsolidations.js.map +1 -1
  47. package/lib/epoch/{processPendingBalanceDeposits.d.ts → processPendingDeposits.d.ts} +4 -4
  48. package/lib/epoch/processPendingDeposits.js +102 -0
  49. package/lib/epoch/processPendingDeposits.js.map +1 -0
  50. package/lib/index.d.ts +2 -1
  51. package/lib/index.js +2 -1
  52. package/lib/index.js.map +1 -1
  53. package/lib/metrics.js +2 -0
  54. package/lib/metrics.js.map +1 -1
  55. package/lib/signatureSets/attesterSlashings.js +1 -3
  56. package/lib/signatureSets/attesterSlashings.js.map +1 -1
  57. package/lib/signatureSets/proposerSlashings.js +1 -3
  58. package/lib/signatureSets/proposerSlashings.js.map +1 -1
  59. package/lib/slot/upgradeStateToAltair.js +1 -0
  60. package/lib/slot/upgradeStateToAltair.js.map +1 -1
  61. package/lib/slot/upgradeStateToCapella.js +1 -0
  62. package/lib/slot/upgradeStateToCapella.js.map +1 -1
  63. package/lib/slot/upgradeStateToDeneb.js +1 -0
  64. package/lib/slot/upgradeStateToDeneb.js.map +1 -1
  65. package/lib/slot/upgradeStateToElectra.d.ts +0 -1
  66. package/lib/slot/upgradeStateToElectra.js +19 -36
  67. package/lib/slot/upgradeStateToElectra.js.map +1 -1
  68. package/lib/util/balance.d.ts +1 -1
  69. package/lib/util/blindedBlock.js +17 -13
  70. package/lib/util/blindedBlock.js.map +1 -1
  71. package/lib/util/computeAnchorCheckpoint.js.map +1 -1
  72. package/lib/util/deposit.js +2 -6
  73. package/lib/util/deposit.js.map +1 -1
  74. package/lib/util/electra.d.ts +0 -1
  75. package/lib/util/electra.js +19 -27
  76. package/lib/util/electra.js.map +1 -1
  77. package/lib/util/epochShuffling.d.ts +1 -0
  78. package/lib/util/epochShuffling.js +31 -12
  79. package/lib/util/epochShuffling.js.map +1 -1
  80. package/lib/util/execution.js +5 -9
  81. package/lib/util/execution.js.map +1 -1
  82. package/lib/util/genesis.js +8 -3
  83. package/lib/util/genesis.js.map +1 -1
  84. package/lib/util/index.d.ts +0 -1
  85. package/lib/util/index.js +0 -1
  86. package/lib/util/index.js.map +1 -1
  87. package/lib/util/loadState/loadValidator.js +1 -3
  88. package/lib/util/loadState/loadValidator.js.map +1 -1
  89. package/lib/util/seed.js +1 -1
  90. package/lib/util/seed.js.map +1 -1
  91. package/lib/util/shufflingDecisionRoot.js +5 -11
  92. package/lib/util/shufflingDecisionRoot.js.map +1 -1
  93. package/lib/util/validator.d.ts +0 -1
  94. package/lib/util/validator.js +2 -10
  95. package/lib/util/validator.js.map +1 -1
  96. package/lib/util/weakSubjectivity.js +0 -1
  97. package/lib/util/weakSubjectivity.js.map +1 -1
  98. package/package.json +10 -8
  99. package/lib/epoch/processPendingBalanceDeposits.js +0 -68
  100. package/lib/epoch/processPendingBalanceDeposits.js.map +0 -1
  101. package/lib/util/shuffle.d.ts +0 -9
  102. package/lib/util/shuffle.js +0 -197
  103. package/lib/util/shuffle.js.map +0 -1
@@ -1,68 +0,0 @@
1
- import { FAR_FUTURE_EPOCH } from "@lodestar/params";
2
- import { increaseBalance } from "../util/balance.js";
3
- import { getActivationExitChurnLimit } from "../util/validator.js";
4
- /**
5
- * Starting from Electra:
6
- * Process pending balance deposits from state subject to churn limit and depsoitBalanceToConsume.
7
- * For each eligible `deposit`, call `increaseBalance()`.
8
- * Remove the processed deposits from `state.pendingBalanceDeposits`.
9
- * Update `state.depositBalanceToConsume` for the next epoch
10
- *
11
- * TODO Electra: Update ssz library to support batch push to `pendingBalanceDeposits`
12
- */
13
- export function processPendingBalanceDeposits(state, cache) {
14
- const nextEpoch = state.epochCtx.epoch + 1;
15
- const availableForProcessing = state.depositBalanceToConsume + BigInt(getActivationExitChurnLimit(state.epochCtx));
16
- let processedAmount = 0n;
17
- let nextDepositIndex = 0;
18
- const depositsToPostpone = [];
19
- const validators = state.validators;
20
- const cachedBalances = cache.balances;
21
- for (const deposit of state.pendingBalanceDeposits.getAllReadonly()) {
22
- const { amount, index: depositIndex } = deposit;
23
- const validator = validators.getReadonly(depositIndex);
24
- // Validator is exiting, postpone the deposit until after withdrawable epoch
25
- if (validator.exitEpoch < FAR_FUTURE_EPOCH) {
26
- if (nextEpoch <= validator.withdrawableEpoch) {
27
- depositsToPostpone.push(deposit);
28
- }
29
- else {
30
- // Deposited balance will never become active. Increase balance but do not consume churn
31
- increaseBalance(state, depositIndex, Number(amount));
32
- if (cachedBalances) {
33
- cachedBalances[depositIndex] += Number(amount);
34
- }
35
- }
36
- }
37
- else {
38
- // Validator is not exiting, attempt to process deposit
39
- if (processedAmount + amount > availableForProcessing) {
40
- // Deposit does not fit in the churn, no more deposit processing in this epoch.
41
- break;
42
- }
43
- else {
44
- // Deposit fits in the churn, process it. Increase balance and consume churn.
45
- increaseBalance(state, depositIndex, Number(amount));
46
- if (cachedBalances) {
47
- cachedBalances[depositIndex] += Number(amount);
48
- }
49
- processedAmount = processedAmount + amount;
50
- }
51
- }
52
- // Regardless of how the deposit was handled, we move on in the queue.
53
- nextDepositIndex++;
54
- }
55
- const remainingPendingBalanceDeposits = state.pendingBalanceDeposits.sliceFrom(nextDepositIndex);
56
- state.pendingBalanceDeposits = remainingPendingBalanceDeposits;
57
- if (remainingPendingBalanceDeposits.length === 0) {
58
- state.depositBalanceToConsume = 0n;
59
- }
60
- else {
61
- state.depositBalanceToConsume = availableForProcessing - processedAmount;
62
- }
63
- // TODO Electra: add a function in ListCompositeTreeView to support batch push operation
64
- for (const deposit of depositsToPostpone) {
65
- state.pendingBalanceDeposits.push(deposit);
66
- }
67
- }
68
- //# sourceMappingURL=processPendingBalanceDeposits.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processPendingBalanceDeposits.js","sourceRoot":"","sources":["../../src/epoch/processPendingBalanceDeposits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,2BAA2B,EAAC,MAAM,sBAAsB,CAAC;AAEjE;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAAC,KAA+B,EAAE,KAA2B;IACxG,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IAC3C,MAAM,sBAAsB,GAAG,KAAK,CAAC,uBAAuB,GAAG,MAAM,CAAC,2BAA2B,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnH,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,IAAI,gBAAgB,GAAG,CAAC,CAAC;IACzB,MAAM,kBAAkB,GAAG,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IACpC,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC;IAEtC,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,sBAAsB,CAAC,cAAc,EAAE,EAAE,CAAC;QACpE,MAAM,EAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAC,GAAG,OAAO,CAAC;QAC9C,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAEvD,4EAA4E;QAC5E,IAAI,SAAS,CAAC,SAAS,GAAG,gBAAgB,EAAE,CAAC;YAC3C,IAAI,SAAS,IAAI,SAAS,CAAC,iBAAiB,EAAE,CAAC;gBAC7C,kBAAkB,CAAC,IAAI,CAAC,OAAO,C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bytes32 } from "@lodestar/types";
2
- type Shuffleable = {
3
- readonly length: number;
4
- [index: number]: number;
5
- };
6
- export declare function shuffleList(input: Shuffleable, seed: Bytes32): void;
7
- export declare function unshuffleList(input: Shuffleable, seed: Bytes32): void;
8
- export {};
9
- //# sourceMappingURL=shuffle.d.ts.map
@@ -1,197 +0,0 @@
1
- import { digest } from "@chainsafe/as-sha256";
2
- import { SHUFFLE_ROUND_COUNT } from "@lodestar/params";
3
- import { assert, bytesToBigInt } from "@lodestar/utils";
4
- // ShuffleList shuffles a list, using the given seed for randomness. Mutates the input list.
5
- export function shuffleList(input, seed) {
6
- innerShuffleList(input, seed, true);
7
- }
8
- // UnshuffleList undoes a list shuffling using the seed of the shuffling. Mutates the input list.
9
- export function unshuffleList(input, seed) {
10
- innerShuffleList(input, seed, false);
11
- }
12
- const _SHUFFLE_H_SEED_SIZE = 32;
13
- const _SHUFFLE_H_ROUND_SIZE = 1;
14
- const _SHUFFLE_H_POSITION_WINDOW_SIZE = 4;
15
- const _SHUFFLE_H_PIVOT_VIEW_SIZE = _SHUFFLE_H_SEED_SIZE + _SHUFFLE_H_ROUND_SIZE;
16
- const _SHUFFLE_H_TOTAL_SIZE = _SHUFFLE_H_SEED_SIZE + _SHUFFLE_H_ROUND_SIZE + _SHUFFLE_H_POSITION_WINDOW_SIZE;
17
- /*
18
-
19
- def shuffle(list_size, seed):
20
- indices = list(range(list_size))
21
- for round in range(90):
22
- hash_bytes = b''.join([
23
- hash(seed + round.to_bytes(1, 'little') + (i).to_bytes(4, 'little'))
24
- for i in range((list_size + 255) // 256)
25
- ])
26
- pivot = int.from_bytes(hash(seed + round.to_bytes(1, 'little')), 'little') % list_size
27
-
28
- powers_of_two = [1, 2, 4, 8, 16, 32, 64, 128]
29
-
30
- for i, index in enumerate(indices):
31
- flip = (pivot - index) % list_size
32
- hash_pos = index if index > flip else flip
33
- byte = hash_bytes[hash_pos // 8]
34
- if byte & powers_of_two[hash_pos % 8]:
35
- indices[i] = flip
36
- return indices
37
-
38
- Heavily-optimized version of the set-shuffling algorithm proposed by Vitalik to shuffle all items in a list together.
39
-
40
- Original here:
41
- https://github.com/ethereum/consensus-specs/pull/576
42
-
43
- Main differences, implemented by @protolambda:
44
- - User can supply input slice to shuffle, simple provide [0,1,2,3,4, ...] to get a list of cleanly shuffled indices.
45
- - Input slice is shuffled (hence no return value), no new array is allocated
46
- - Allocations as minimal as possible: only a very minimal buffer for hashing
47
- (this should be allocated on the stack, compiler will find it with escape analysis).
48
- This is not bigger than what's used for shuffling a single index!
49
- As opposed to larger allocations (size O(n) instead of O(1)) made in the original.
50
- - Replaced pseudocode/python workarounds with bit-logic.
51
- - User can provide their own hash-function (as long as it outputs a 32 len byte slice)
52
-
53
- This Typescript version is an adaption of the Python version, in turn an adaption of the original Go version.
54
- Python: https://github.com/protolambda/eth2fastspec/blob/14e04e9db77ef7c8b7788ffdaa7e142d7318dd7e/eth2fastspec.py#L63
55
- Go: https://github.com/protolambda/eth2-shuffle
56
- All three implemented by @protolambda, but meant for public use, like the original spec version.
57
- */
58
- function setPositionUint32(value, buf) {
59
- // Little endian, optimized version
60
- buf[_SHUFFLE_H_PIVOT_VIEW_SIZE] = (value >> 0) & 0xff;
61
- buf[_SHUFFLE_H_PIVOT_VIEW_SIZE + 1] = (value >> 8) & 0xff;
62
- buf[_SHUFFLE_H_PIVOT_VIEW_SIZE + 2] = (value >> 16) & 0xff;
63
- buf[_SHUFFLE_H_PIVOT_VIEW_SIZE + 3] = (value >> 24) & 0xff;
64
- }
65
- // Shuffles or unshuffles, depending on the `dir` (true for shuffling, false for unshuffling
66
- function innerShuffleList(input, seed, dir) {
67
- if (input.length <= 1) {
68
- // nothing to (un)shuffle
69
- return;
70
- }
71
- if (SHUFFLE_ROUND_COUNT == 0) {
72
- // no shuffling
73
- return;
74
- }
75
- // uint32 is sufficient, and necessary in JS,
76
- // as we do a lot of bit math on it, which cannot be done as fast on more bits.
77
- const listSize = input.length >>> 0;
78
- // check if list size fits in uint32
79
- assert.equal(listSize, input.length, "input length does not fit uint32");
80
- // check that the seed is 32 bytes
81
- assert.lte(seed.length, _SHUFFLE_H_SEED_SIZE, `seed length is not lte ${_SHUFFLE_H_SEED_SIZE} bytes`);
82
- const buf = Buffer.alloc(_SHUFFLE_H_TOTAL_SIZE);
83
- let r = 0;
84
- if (!dir) {
85
- // Start at last round.
86
- // Iterating through the rounds in reverse, un-swaps everything, effectively un-shuffling the list.
87
- r = SHUFFLE_ROUND_COUNT - 1;
88
- }
89
- // Seed is always the first 32 bytes of the hash input, we never have to change this part of the buffer.
90
- buf.set(seed, 0);
91
- // initial values here are not used: overwritten first within the inner for loop.
92
- let source = seed; // just setting it to a Bytes32
93
- let byteV = 0;
94
- // eslint-disable-next-line no-constant-condition
95
- while (true) {
96
- // spec: pivot = bytes_to_int(hash(seed + int_to_bytes1(round))[0:8]) % list_size
97
- // This is the "int_to_bytes1(round)", appended to the seed.
98
- buf[_SHUFFLE_H_SEED_SIZE] = r;
99
- // Seed is already in place, now just hash the correct part of the buffer, and take a uint64 from it,
100
- // and modulo it to get a pivot within range.
101
- const h = digest(buf.subarray(0, _SHUFFLE_H_PIVOT_VIEW_SIZE));
102
- const pivot = Number(bytesToBigInt(h.subarray(0, 8)) % BigInt(listSize)) >>> 0;
103
- // Split up the for-loop in two:
104
- // 1. Handle the part from 0 (incl) to pivot (incl). This is mirrored around (pivot / 2)
105
- // 2. Handle the part from pivot (excl) to N (excl). This is mirrored around ((pivot / 2) + (size/2))
106
- // The pivot defines a split in the array, with each of the splits mirroring their data within the split.
107
- // Print out some example even/odd sized index lists, with some even/odd pivots,
108
- // and you can deduce how the mirroring works exactly.
109
- // Note that the mirror is strict enough to not consider swapping the index @mirror with itself.
110
- let mirror = (pivot + 1) >> 1;
111
- // Since we are iterating through the "positions" in order, we can just repeat the hash every 256th position.
112
- // No need to pre-compute every possible hash for efficiency like in the example code.
113
- // We only need it consecutively (we are going through each in reverse order however, but same thing)
114
- //
115
- // spec: source = hash(seed + int_to_bytes1(round) + int_to_bytes4(position // 256))
116
- // - seed is still in 0:32 (excl., 32 bytes)
117
- // - round number is still in 32
118
- // - mix in the position for randomness, except the last byte of it,
119
- // which will be used later to select a bit from the resulting hash.
120
- // We start from the pivot position, and work back to the mirror position (of the part left to the pivot).
121
- // This makes us process each pear exactly once (instead of unnecessarily twice, like in the spec)
122
- setPositionUint32(pivot >> 8, buf); // already using first pivot byte below.
123
- source = digest(buf);
124
- byteV = source[(pivot & 0xff) >> 3];
125
- for (let i = 0, j; i < mirror; i++) {
126
- j = pivot - i;
127
- // -- step() fn start
128
- // The pair is i,j. With j being the bigger of the two, hence the "position" identifier of the pair.
129
- // Every 256th bit (aligned to j).
130
- if ((j & 0xff) == 0xff) {
131
- // just overwrite the last part of the buffer, reuse the start (seed, round)
132
- setPositionUint32(j >> 8, buf);
133
- source = digest(buf);
134
- }
135
- // Same trick with byte retrieval. Only every 8th.
136
- if ((j & 0x7) == 0x7) {
137
- byteV = source[(j & 0xff) >> 3];
138
- }
139
- const bitV = (byteV >> (j & 0x7)) & 0x1;
140
- if (bitV == 1) {
141
- // swap the pair items
142
- const tmp = input[j];
143
- input[j] = input[i];
144
- input[i] = tmp;
145
- }
146
- // -- step() fn end
147
- }
148
- // Now repeat, but for the part after the pivot.
149
- mirror = (pivot + listSize + 1) >> 1;
150
- const end = listSize - 1;
151
- // Again, seed and round input is in place, just update the position.
152
- // We start at the end, and work back to the mirror point.
153
- // This makes us process each pear exactly once (instead of unnecessarily twice, like in the spec)
154
- setPositionUint32(end >> 8, buf);
155
- source = digest(buf);
156
- byteV = source[(end & 0xff) >> 3];
157
- for (let i = pivot + 1, j; i < mirror; i++) {
158
- j = end - i + pivot + 1;
159
- // -- step() fn start
160
- // The pair is i,j. With j being the bigger of the two, hence the "position" identifier of the pair.
161
- // Every 256th bit (aligned to j).
162
- if ((j & 0xff) == 0xff) {
163
- // just overwrite the last part of the buffer, reuse the start (seed, round)
164
- setPositionUint32(j >> 8, buf);
165
- source = digest(buf);
166
- }
167
- // Same trick with byte retrieval. Only every 8th.
168
- if ((j & 0x7) == 0x7) {
169
- byteV = source[(j & 0xff) >> 3];
170
- }
171
- const bitV = (byteV >> (j & 0x7)) & 0x1;
172
- if (bitV == 1) {
173
- // swap the pair items
174
- const tmp = input[j];
175
- input[j] = input[i];
176
- input[i] = tmp;
177
- }
178
- // -- step() fn end
179
- }
180
- // go forwards?
181
- if (dir) {
182
- // -> shuffle
183
- r += 1;
184
- if (r == SHUFFLE_ROUND_COUNT) {
185
- break;
186
- }
187
- }
188
- else {
189
- if (r == 0) {
190
- break;
191
- }
192
- // -> un-shuffle
193
- r -= 1;
194
- }
195
- }
196
- }
197
- //# sourceMappingURL=shuffle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shuffle.js","sourceRoot":"","sources":["../../src/util/shuffle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAC,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAQtD,4FAA4F;AAC5F,MAAM,UAAU,WAAW,CAAC,KAAkB,EAAE,IAAa;IAC3D,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,aAAa,CAAC,KAAkB,EAAE,IAAa;IAC7D,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAC1C,MAAM,0BAA0B,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAChF,MAAM,qBAAqB,GAAG,oBAAoB,GAAG,qBAAqB,GAAG,+BAA+B,CAAC;AAE7G;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