Skip to content

Commit 8713832

Browse files
committed
chore: zero upper 4 bytes in prealloc'd buffers
1 parent 6653985 commit 8713832

File tree

1 file changed

+2
-0
lines changed
  • packages/state-transition/src/util

1 file changed

+2
-0
lines changed

packages/state-transition/src/util/seed.ts

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export function computeProposerIndex(
122122
let i = 0;
123123
const cachedHashInput = Buffer.allocUnsafe(32 + 8);
124124
cachedHashInput.set(seed, 0);
125+
cachedHashInput.writeUint32LE(0, 32 + 4);
125126
let cachedHash: Uint8Array | null = null;
126127
while (true) {
127128
// an optimized version of the below naive code
@@ -275,6 +276,7 @@ export function getNextSyncCommitteeIndices(
275276
let cachedHash: Uint8Array | null = null;
276277
const cachedHashInput = Buffer.allocUnsafe(32 + 8);
277278
cachedHashInput.set(seed, 0);
279+
cachedHashInput.writeUInt32LE(0, 32 + 4);
278280
// this simple cache makes sure we don't have to recompute the shuffled index for the next round of activeValidatorCount
279281
const shuffledResult = new Map<number, number>();
280282
while (syncCommitteeIndices.length < SYNC_COMMITTEE_SIZE) {

0 commit comments

Comments
 (0)