Skip to content

Commit 9b5caf2

Browse files
committed
modify code to correctly patch generated requests on getpayload/build/pending block
1 parent 613c900 commit 9b5caf2

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

packages/client/src/miner/miner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ export class Miner {
332332
}
333333
if (interrupt) return
334334
// Build block, sealing it
335-
const block = await blockBuilder.build(this.nextSolution)
335+
const { block } = await blockBuilder.build(this.nextSolution)
336336
if (this.config.saveReceipts) {
337337
await this.execution.receiptsManager?.saveReceipts(block, receipts)
338338
}

packages/client/src/miner/pendingBlock.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type { Config } from '../config.js'
1919
import type { TxPool } from '../service/txpool.js'
2020
import type { Block, HeaderData } from '@ethereumjs/block'
2121
import type { TypedTransaction } from '@ethereumjs/tx'
22-
import type { PrefixedHexString, WithdrawalData } from '@ethereumjs/util'
22+
import type { CLRequest, CLRequestType, PrefixedHexString, WithdrawalData } from '@ethereumjs/util'
2323
import type { BlockBuilder, TxReceipt, VM } from '@ethereumjs/vm'
2424

2525
interface PendingBlockOpts {
@@ -239,7 +239,16 @@ export class PendingBlock {
239239
*/
240240
async build(
241241
payloadIdBytes: Uint8Array | string,
242-
): Promise<void | [block: Block, receipts: TxReceipt[], value: bigint, blobs?: BlobsBundle]> {
242+
): Promise<
243+
| void
244+
| [
245+
block: Block,
246+
receipts: TxReceipt[],
247+
value: bigint,
248+
blobs?: BlobsBundle,
249+
requests?: CLRequest<CLRequestType>[],
250+
]
251+
> {
243252
const payloadId =
244253
typeof payloadIdBytes !== 'string' ? bytesToHex(payloadIdBytes) : payloadIdBytes
245254
const builder = this.pendingPayloads.get(payloadId)
@@ -283,7 +292,7 @@ export class PendingBlock {
283292

284293
const { skippedByAddErrors, blobTxs } = await this.addTransactions(builder, txs)
285294

286-
const block = await builder.build()
295+
const { block, requests } = await builder.build()
287296

288297
// Construct blobs bundle
289298
const blobs = block.common.isActivatedEIP(4844)
@@ -301,7 +310,7 @@ export class PendingBlock {
301310
)}`,
302311
)
303312

304-
return [block, builder.transactionReceipts, builder.minerValue, blobs]
313+
return [block, builder.transactionReceipts, builder.minerValue, blobs, requests]
305314
}
306315

307316
private async addTransactions(builder: BlockBuilder, txs: TypedTransaction[]) {

packages/client/src/rpc/modules/engine/util/getPayload.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import { bigIntToHex } from '@ethereumjs/util'
1+
import { bigIntToHex, bytesToHex } from '@ethereumjs/util'
22

33
import type { BlobsBundle } from '../../../../miner/index.js'
44
import type { BlobsBundleV1 } from '../types.js'
55
import type { Block, ExecutionPayload } from '@ethereumjs/block'
6+
import type { CLRequest, CLRequestType } from '@ethereumjs/util'
67

78
/**
89
* Formats a block to {@link ExecutionPayloadV1}.
910
*/
10-
export const blockToExecutionPayload = (block: Block, value: bigint, bundle?: BlobsBundle) => {
11+
export const blockToExecutionPayload = (
12+
block: Block,
13+
value: bigint,
14+
bundle?: BlobsBundle,
15+
requests?: CLRequest<CLRequestType>[],
16+
) => {
1117
const executionPayload: ExecutionPayload = block.toExecutionPayload()
1218
// parentBeaconBlockRoot is not part of the CL payload
1319
if (executionPayload.parentBeaconBlockRoot !== undefined) {
1420
delete executionPayload.parentBeaconBlockRoot
1521
}
16-
const { executionRequests } = executionPayload
17-
if (executionPayload.executionRequests !== undefined) {
18-
delete executionPayload.executionRequests
19-
}
2022

2123
const blobsBundle: BlobsBundleV1 | undefined = bundle ? bundle : undefined
2224

@@ -25,7 +27,7 @@ export const blockToExecutionPayload = (block: Block, value: bigint, bundle?: Bl
2527
const shouldOverrideBuilder = false
2628
return {
2729
executionPayload,
28-
executionRequests,
30+
executionRequests: requests?.map((req) => bytesToHex(req.bytes)),
2931
blockValue: bigIntToHex(value),
3032
blobsBundle,
3133
shouldOverrideBuilder,

packages/client/test/rpc/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export async function runBlockWithTxs(
308308
for (const tx of txs) {
309309
await blockBuilder.addTransaction(tx, { skipHardForkValidation: true })
310310
}
311-
const block = await blockBuilder.build()
311+
const { block } = await blockBuilder.build()
312312

313313
// put block into chain and run execution
314314
await chain.putBlocks([block], fromEngine)

0 commit comments

Comments
 (0)