Skip to content

Commit 79155fe

Browse files
vm: eip6110 update deposits layout verifier
1 parent 7e23f5e commit 79155fe

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

packages/vm/src/requests.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
bigIntToBytes,
88
bytesToBigInt,
99
bytesToHex,
10-
bytesToInt,
1110
concatBytes,
1211
createAddressFromString,
1312
setLengthLeft,
@@ -22,11 +21,11 @@ const WITHDRAWAL_CREDENTIALS_OFFSET = BigInt(256)
2221
const AMOUNT_OFFSET = BigInt(320)
2322
const SIGNATURE_OFFSET = BigInt(384)
2423
const INDEX_OFFSET = BigInt(512)
25-
const PUBKEY_SIZE = 48
26-
const WITHDRAWAL_CREDENTIALS_SIZE = 32
27-
const AMOUNT_SIZE = 8
28-
const SIGNATURE_SIZE = 96
29-
const INDEX_SIZE = 8
24+
const PUBKEY_SIZE = BigInt(48)
25+
const WITHDRAWAL_CREDENTIALS_SIZE = BigInt(32)
26+
const AMOUNT_SIZE = BigInt(8)
27+
const SIGNATURE_SIZE = BigInt(96)
28+
const INDEX_SIZE = BigInt(8)
3029
const LOG_SIZE = 576
3130
const LOG_LAYOUT_MISMATCH = 'invalid deposit log: unsupported data layout'
3231

@@ -204,24 +203,30 @@ function parseDepositLog(requestData: Uint8Array) {
204203
const sigIdx = Number(sigIdxBigInt)
205204
const indexIdx = Number(indexIdxBigInt)
206205

207-
const pubKeySize = bytesToInt(requestData.slice(pubKeyIdx, pubKeyIdx + 32))
208-
const withdrawalCreditsSize = bytesToInt(
206+
const pubKeySizeBigInt = bytesToBigInt(requestData.slice(pubKeyIdx, pubKeyIdx + 32))
207+
const withdrawalCreditsSizeBigInt = bytesToBigInt(
209208
requestData.slice(withdrawalCreditsIdx, withdrawalCreditsIdx + 32),
210209
)
211-
const amountSize = bytesToInt(requestData.slice(amountIdx, amountIdx + 32))
212-
const sigSize = bytesToInt(requestData.slice(sigIdx, sigIdx + 32))
213-
const indexSize = bytesToInt(requestData.slice(indexIdx, indexIdx + 32))
210+
const amountSizeBigInt = bytesToBigInt(requestData.slice(amountIdx, amountIdx + 32))
211+
const sigSizeBigInt = bytesToBigInt(requestData.slice(sigIdx, sigIdx + 32))
212+
const indexSizeBigInt = bytesToBigInt(requestData.slice(indexIdx, indexIdx + 32))
214213

215214
if (
216-
pubKeySize !== PUBKEY_SIZE ||
217-
withdrawalCreditsSize !== WITHDRAWAL_CREDENTIALS_SIZE ||
218-
amountSize !== AMOUNT_SIZE ||
219-
sigSize !== SIGNATURE_SIZE ||
220-
indexSize !== INDEX_SIZE
215+
pubKeySizeBigInt !== PUBKEY_SIZE ||
216+
withdrawalCreditsSizeBigInt !== WITHDRAWAL_CREDENTIALS_SIZE ||
217+
amountSizeBigInt !== AMOUNT_SIZE ||
218+
sigSizeBigInt !== SIGNATURE_SIZE ||
219+
indexSizeBigInt !== INDEX_SIZE
221220
) {
222221
throw EthereumJSErrorWithoutCode(LOG_LAYOUT_MISMATCH)
223222
}
224223

224+
const pubKeySize = Number(pubKeySizeBigInt)
225+
const withdrawalCreditsSize = Number(withdrawalCreditsSizeBigInt)
226+
const amountSize = Number(amountSizeBigInt)
227+
const sigSize = Number(sigSizeBigInt)
228+
const indexSize = Number(indexSizeBigInt)
229+
225230
const pubkey = requestData.slice(pubKeyIdx + 32, pubKeyIdx + 32 + pubKeySize)
226231
const withdrawalCredentials = requestData.slice(
227232
withdrawalCreditsIdx + 32,

0 commit comments

Comments
 (0)