Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util,block: rename deposit receipt to deposit request #3408

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/block/src/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export class Block {
transactions,
withdrawals: withdrawalsData,
requestsRoot,
depositReceipts,
depositRequests,
withdrawalRequests,
executionWitness,
} = payload
Expand Down Expand Up @@ -464,13 +464,13 @@ export class Block {
requestsRoot: reqRoot,
}

const hasDepositRequests = depositReceipts !== undefined && depositReceipts !== null
const hasDepositRequests = depositRequests !== undefined && depositRequests !== null
const hasWithdrawalRequests = withdrawalRequests !== undefined && withdrawalRequests !== null
const requests =
hasDepositRequests || hasWithdrawalRequests ? ([] as CLRequest<CLRequestType>[]) : undefined

if (depositReceipts !== undefined && depositReceipts !== null) {
for (const dJson of depositReceipts) {
if (depositRequests !== undefined && depositRequests !== null) {
for (const dJson of depositRequests) {
requests!.push(DepositRequest.fromJSON(dJson))
}
}
Expand Down Expand Up @@ -1001,15 +1001,15 @@ export class Block {
executionWitness: this.executionWitness,

// lets add the request fields first and then iterate over requests to fill them up
depositReceipts: this.common.isActivatedEIP(6110) ? [] : undefined,
depositRequests: this.common.isActivatedEIP(6110) ? [] : undefined,
withdrawalRequests: this.common.isActivatedEIP(7002) ? [] : undefined,
}

if (this.requests !== undefined) {
for (const request of this.requests) {
switch (request.type) {
case CLRequestType.Deposit:
executionPayload.depositReceipts!.push((request as DepositRequest).toJSON())
executionPayload.depositRequests!.push((request as DepositRequest).toJSON())
continue

case CLRequestType.Withdrawal:
Expand All @@ -1018,7 +1018,7 @@ export class Block {
}
}
} else if (
executionPayload.depositReceipts !== undefined ||
executionPayload.depositRequests !== undefined ||
executionPayload.withdrawalRequests !== undefined
) {
throw Error(`Undefined requests for activated deposit or withdrawal requests`)
Expand Down
2 changes: 1 addition & 1 deletion packages/block/src/from-beacon-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function executionPayloadFromBeaconPayload(payload: BeaconPayloadJson): E

// requests
if (payload.deposit_receipts !== undefined && payload.deposit_receipts !== null) {
executionPayload.depositReceipts = payload.deposit_receipts.map((breq) => ({
executionPayload.depositRequests = payload.deposit_receipts.map((breq) => ({
pubkey: breq.pubkey,
withdrawalCredentials: breq.withdrawal_credentials,
amount: breq.amount,
Expand Down
4 changes: 2 additions & 2 deletions packages/block/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
BytesLike,
CLRequest,
CLRequestType,
DepositReceiptV1,
DepositRequestV1,
JsonRpcWithdrawal,
PrefixedHexString,
RequestBytes,
Expand Down Expand Up @@ -306,6 +306,6 @@ export type ExecutionPayload = {
// VerkleExecutionWitness is already a hex serialized object
executionWitness?: VerkleExecutionWitness | null // QUANTITY, 64 Bits, null implies not available
requestsRoot?: PrefixedHexString | string | null // DATA, 32 bytes, null implies EIP 7685 not active yet
depositReceipts?: DepositReceiptV1[] // Array of 6110 deposit requests
depositRequests?: DepositRequestV1[] // Array of 6110 deposit requests
withdrawalRequests?: WithdrawalRequestV1[] // Array of 7002 withdrawal requests
}
4 changes: 2 additions & 2 deletions packages/client/src/rpc/modules/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UNKNOWN_PAYLOAD } from '../../error-code.js'

import type { Skeleton } from '../../../service/index.js'
import type { Block, ExecutionPayload } from '@ethereumjs/block'
import type { DepositReceiptV1, PrefixedHexString, WithdrawalRequestV1 } from '@ethereumjs/util'
import type { DepositRequestV1, PrefixedHexString, WithdrawalRequestV1 } from '@ethereumjs/util'

export enum Status {
ACCEPTED = 'ACCEPTED',
Expand All @@ -29,7 +29,7 @@ export type ExecutionPayloadV2 = ExecutionPayloadV1 & { withdrawals: WithdrawalV
// parentBeaconBlockRoot comes separate in new payloads and needs to be added to payload data
export type ExecutionPayloadV3 = ExecutionPayloadV2 & { excessBlobGas: Uint64; blobGasUsed: Uint64 }
export type ExecutionPayloadV4 = ExecutionPayloadV3 & {
depositReceipts: DepositReceiptV1[]
depositRequests: DepositRequestV1[]
withdrawalRequests: WithdrawalRequestV1[]
}

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/rpc/modules/engine/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const executionPayloadV3FieldValidators = {

export const executionPayloadV4FieldValidators = {
...executionPayloadV3FieldValidators,
depositReceipts: validators.array(validators.depositReceipt()),
depositRequests: validators.array(validators.depositRequest()),
withdrawalRequests: validators.array(validators.withdrawalRequest()),
}

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/rpc/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ export const validators = {
}
},

get depositReceipt() {
get depositRequest() {
return (
requiredFields: string[] = ['pubkey', 'withdrawalCredentials', 'amount', 'signature', 'index']
) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/rpc/engine/newPayloadV4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe(`${method}: call with executionPayloadV4`, () => {
withdrawals: [],
blobGasUsed: '0x0',
excessBlobGas: '0x0',
depositReceipts: [],
depositRequests: [],
withdrawalRequests: [],
blockHash: '0x87994ea69d14924d908ed979bf2aadd91f0954f95792c3fcf442d2513af957c4',
stateRoot: '0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45',
Expand Down
8 changes: 4 additions & 4 deletions packages/util/src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum CLRequestType {
Withdrawal = 0x01,
}

export type DepositReceiptV1 = {
export type DepositRequestV1 = {
pubkey: PrefixedHexString // DATA 48 bytes
withdrawalCredentials: PrefixedHexString // DATA 32 bytes
amount: PrefixedHexString // QUANTITY 8 bytes in gwei
Expand All @@ -35,7 +35,7 @@ export type WithdrawalRequestV1 = {
}

export interface RequestJSON {
[CLRequestType.Deposit]: DepositReceiptV1
[CLRequestType.Deposit]: DepositRequestV1
[CLRequestType.Withdrawal]: WithdrawalRequestV1
}

Expand Down Expand Up @@ -91,7 +91,7 @@ export class DepositRequest extends CLRequest<CLRequestType.Deposit> {
return new DepositRequest(pubkey, withdrawalCredentials, amount, signature, index)
}

public static fromJSON(jsonData: DepositReceiptV1): DepositRequest {
public static fromJSON(jsonData: DepositRequestV1): DepositRequest {
const { pubkey, withdrawalCredentials, amount, signature, index } = jsonData
return this.fromRequestData({
pubkey: hexToBytes(pubkey),
Expand All @@ -113,7 +113,7 @@ export class DepositRequest extends CLRequest<CLRequestType.Deposit> {
)
}

toJSON(): DepositReceiptV1 {
toJSON(): DepositRequestV1 {
return {
pubkey: bytesToHex(this.pubkey),
withdrawalCredentials: bytesToHex(this.withdrawalCredentials),
Expand Down
Loading