From b49ff15281350494a1a66587e71e34f02eeca9ba Mon Sep 17 00:00:00 2001 From: g11tech Date: Thu, 27 Jun 2024 17:53:25 +0530 Subject: [PATCH] util: rename withdrawal request's validatorPublicKey to validatorPubkey (#3474) --- packages/block/src/from-beacon-payload.ts | 4 ++-- packages/block/test/eip7685block.spec.ts | 2 +- packages/client/src/rpc/validation.ts | 6 +++--- packages/util/src/requests.ts | 22 +++++++++++----------- packages/util/test/requests.spec.ts | 2 +- packages/vm/src/requests.ts | 6 ++---- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/packages/block/src/from-beacon-payload.ts b/packages/block/src/from-beacon-payload.ts index 263272cbc5..3ad5257a44 100644 --- a/packages/block/src/from-beacon-payload.ts +++ b/packages/block/src/from-beacon-payload.ts @@ -20,7 +20,7 @@ type BeaconDepositRequest = { type BeaconWithdrawalRequest = { source_address: PrefixedHexString - validator_public_key: PrefixedHexString + validator_pub_key: PrefixedHexString amount: PrefixedHexString } @@ -160,7 +160,7 @@ export function executionPayloadFromBeaconPayload(payload: BeaconPayloadJson): E if (payload.withdrawal_requests !== undefined && payload.withdrawal_requests !== null) { executionPayload.withdrawalRequests = payload.withdrawal_requests.map((breq) => ({ sourceAddress: breq.source_address, - validatorPublicKey: breq.validator_public_key, + validatorPubkey: breq.validator_pub_key, amount: breq.amount, })) } diff --git a/packages/block/test/eip7685block.spec.ts b/packages/block/test/eip7685block.spec.ts index 1d1962aacb..7c1c2f293a 100644 --- a/packages/block/test/eip7685block.spec.ts +++ b/packages/block/test/eip7685block.spec.ts @@ -26,7 +26,7 @@ function getRandomDepositRequest(): CLRequest { function getRandomWithdrawalRequest(): CLRequest { const withdrawalRequestData = { sourceAddress: randomBytes(20), - validatorPublicKey: randomBytes(48), + validatorPubkey: randomBytes(48), amount: bytesToBigInt(randomBytes(8)), } return WithdrawalRequest.fromRequestData(withdrawalRequestData) as CLRequest diff --git a/packages/client/src/rpc/validation.ts b/packages/client/src/rpc/validation.ts index d6207289fd..84afefdb48 100644 --- a/packages/client/src/rpc/validation.ts +++ b/packages/client/src/rpc/validation.ts @@ -485,7 +485,7 @@ export const validators = { }, get withdrawalRequest() { - return (requiredFields: string[] = ['sourceAddress', 'validatorPublicKey', 'amount']) => { + return (requiredFields: string[] = ['sourceAddress', 'validatorPubkey', 'amount']) => { return (params: any[], index: number) => { if (typeof params[index] !== 'object') { return { @@ -517,8 +517,8 @@ export const validators = { if (v !== undefined) return v } - // validate validatorPublicKey - for (const field of [wt.validatorPublicKey]) { + // validate validatorPubkey + for (const field of [wt.validatorPubkey]) { const v = validate(field, this.bytes48) if (v !== undefined) return v } diff --git a/packages/util/src/requests.ts b/packages/util/src/requests.ts index cc651113bd..9df5121b66 100644 --- a/packages/util/src/requests.ts +++ b/packages/util/src/requests.ts @@ -30,7 +30,7 @@ export type DepositRequestV1 = { export type WithdrawalRequestV1 = { sourceAddress: PrefixedHexString // DATA 20 bytes - validatorPublicKey: PrefixedHexString // DATA 48 bytes + validatorPubkey: PrefixedHexString // DATA 48 bytes amount: PrefixedHexString // QUANTITY 8 bytes in gwei } @@ -49,7 +49,7 @@ export type DepositRequestData = { export type WithdrawalRequestData = { sourceAddress: Uint8Array - validatorPublicKey: Uint8Array + validatorPubkey: Uint8Array amount: bigint } @@ -140,22 +140,22 @@ export class DepositRequest extends CLRequest { export class WithdrawalRequest extends CLRequest { constructor( public readonly sourceAddress: Uint8Array, - public readonly validatorPublicKey: Uint8Array, + public readonly validatorPubkey: Uint8Array, public readonly amount: bigint ) { super(CLRequestType.Withdrawal) } public static fromRequestData(withdrawalData: WithdrawalRequestData): WithdrawalRequest { - const { sourceAddress, validatorPublicKey, amount } = withdrawalData - return new WithdrawalRequest(sourceAddress, validatorPublicKey, amount) + const { sourceAddress, validatorPubkey, amount } = withdrawalData + return new WithdrawalRequest(sourceAddress, validatorPubkey, amount) } public static fromJSON(jsonData: WithdrawalRequestV1): WithdrawalRequest { - const { sourceAddress, validatorPublicKey, amount } = jsonData + const { sourceAddress, validatorPubkey, amount } = jsonData return this.fromRequestData({ sourceAddress: hexToBytes(sourceAddress), - validatorPublicKey: hexToBytes(validatorPublicKey), + validatorPubkey: hexToBytes(validatorPubkey), amount: hexToBigInt(amount), }) } @@ -165,27 +165,27 @@ export class WithdrawalRequest extends CLRequest { return concatBytes( Uint8Array.from([this.type]), - RLP.encode([this.sourceAddress, this.validatorPublicKey, amountBytes]) + RLP.encode([this.sourceAddress, this.validatorPubkey, amountBytes]) ) } toJSON(): WithdrawalRequestV1 { return { sourceAddress: bytesToHex(this.sourceAddress), - validatorPublicKey: bytesToHex(this.validatorPublicKey), + validatorPubkey: bytesToHex(this.validatorPubkey), amount: bigIntToHex(this.amount), } } public static deserialize(bytes: Uint8Array): WithdrawalRequest { - const [sourceAddress, validatorPublicKey, amount] = RLP.decode(bytes.slice(1)) as [ + const [sourceAddress, validatorPubkey, amount] = RLP.decode(bytes.slice(1)) as [ Uint8Array, Uint8Array, Uint8Array ] return this.fromRequestData({ sourceAddress, - validatorPublicKey, + validatorPubkey, amount: bytesToBigInt(amount), }) } diff --git a/packages/util/test/requests.spec.ts b/packages/util/test/requests.spec.ts index 297fb30f41..5e798f98e4 100644 --- a/packages/util/test/requests.spec.ts +++ b/packages/util/test/requests.spec.ts @@ -38,7 +38,7 @@ describe('Requests', () => { it('withdrawal request', () => { const withdrawalRequestData = { sourceAddress: randomBytes(20), - validatorPublicKey: randomBytes(48), + validatorPubkey: randomBytes(48), amount: bytesToBigInt(randomBytes(8)), } diff --git a/packages/vm/src/requests.ts b/packages/vm/src/requests.ts index 3e727cdbfd..6d8d2f4f48 100644 --- a/packages/vm/src/requests.ts +++ b/packages/vm/src/requests.ts @@ -89,11 +89,9 @@ const accumulateEIP7002Requests = async ( for (let startByte = 0; startByte < resultsBytes.length; startByte += 76) { const slicedBytes = resultsBytes.slice(startByte, startByte + 76) const sourceAddress = slicedBytes.slice(0, 20) // 20 Bytes - const validatorPublicKey = slicedBytes.slice(20, 68) // 48 Bytes + const validatorPubkey = slicedBytes.slice(20, 68) // 48 Bytes const amount = bytesToBigInt(unpadBytes(slicedBytes.slice(68, 76))) // 8 Bytes / Uint64 - requests.push( - WithdrawalRequest.fromRequestData({ sourceAddress, validatorPublicKey, amount }) - ) + requests.push(WithdrawalRequest.fromRequestData({ sourceAddress, validatorPubkey, amount })) } }