From 7f5c4c5f2772615c7970096f0f7a24177279692f Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Mon, 16 Dec 2024 23:56:40 +0100 Subject: [PATCH 1/3] fix t8ntool empty requests reporting --- packages/vm/test/t8n/t8ntool.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/vm/test/t8n/t8ntool.ts b/packages/vm/test/t8n/t8ntool.ts index 19605a8fe1..d57563513e 100644 --- a/packages/vm/test/t8n/t8ntool.ts +++ b/packages/vm/test/t8n/t8ntool.ts @@ -303,7 +303,12 @@ export class TransitionTool { if (requests !== undefined) { // NOTE: EEST currently wants the raw request bytes, **excluding** the type - output.requests = requests.map((request) => bytesToHex(request.bytes.slice(1))) + output.requests = [] + for (const request of requests) { + if (request.bytes.length > 1) { + output.requests.push(bytesToHex(request.bytes.slice(1))) + } + } } if (this.rejected.length > 0) { From 13aafd650dcfafd688436ce82ec44cc9c5f8215b Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Thu, 19 Dec 2024 02:41:49 +0100 Subject: [PATCH 2/3] client: fix engine reporting empty requests --- .../src/rpc/modules/engine/util/getPayload.ts | 13 ++++- .../src/rpc/modules/engine/util/newPayload.ts | 49 ++++++++++--------- .../test/rpc/engine/newPayloadV4.spec.ts | 17 +++++-- 3 files changed, 53 insertions(+), 26 deletions(-) diff --git a/packages/client/src/rpc/modules/engine/util/getPayload.ts b/packages/client/src/rpc/modules/engine/util/getPayload.ts index fec0814f2d..615fbe04f7 100644 --- a/packages/client/src/rpc/modules/engine/util/getPayload.ts +++ b/packages/client/src/rpc/modules/engine/util/getPayload.ts @@ -25,9 +25,20 @@ export const blockToExecutionPayload = ( // ethereumjs does not provide any transaction censoring detection (yet) to suggest // overriding builder/mev-boost blocks const shouldOverrideBuilder = false + + let executionRequests = undefined + if (requests !== undefined) { + executionRequests = [] + for (const request of requests) { + if (request.bytes.length > 1) { + executionRequests.push(bytesToHex(request.bytes)) + } + } + } + return { executionPayload, - executionRequests: requests?.map((req) => bytesToHex(req.data)), + executionRequests, blockValue: bigIntToHex(value), blobsBundle, shouldOverrideBuilder, diff --git a/packages/client/src/rpc/modules/engine/util/newPayload.ts b/packages/client/src/rpc/modules/engine/util/newPayload.ts index 5155ddfc5a..c2c42e6f7a 100644 --- a/packages/client/src/rpc/modules/engine/util/newPayload.ts +++ b/packages/client/src/rpc/modules/engine/util/newPayload.ts @@ -57,30 +57,35 @@ export const validateAndGen7685RequestsHash = ( common: Common, executionRequests: PrefixedHexString[], ): PrefixedHexString => { - let validationError: string | null = null - const requests: CLRequest[] = [] - let requestIndex = 0 - if (common.isActivatedEIP(6110)) { - requests.push(new CLRequest(CLRequestType.Deposit, hexToBytes(executionRequests[requestIndex]))) - requestIndex++ - } - if (common.isActivatedEIP(7002)) { - requests.push( - new CLRequest(CLRequestType.Withdrawal, hexToBytes(executionRequests[requestIndex])), - ) - requestIndex++ - } - if (common.isActivatedEIP(7251)) { - requests.push( - new CLRequest(CLRequestType.Consolidation, hexToBytes(executionRequests[requestIndex])), - ) - requestIndex++ - } - if (requestIndex !== executionRequests.length) { - validationError = `Invalid executionRequests=${executionRequests.length} expected=${requestIndex}` - throw validationError + for (const request of executionRequests) { + const bytes = hexToBytes(request) + if (bytes.length === 0) { + throw new Error('Got a request without a request-identifier') + } + switch (bytes[0]) { + case 0: + if (!common.isActivatedEIP(6110)) { + throw new Error(`Deposit requests are not active`) + } + requests.push(new CLRequest(CLRequestType.Deposit, bytes.slice(1))) + break + case 1: + if (!common.isActivatedEIP(7002)) { + throw new Error(`Withdrawal requests are not active`) + } + requests.push(new CLRequest(CLRequestType.Withdrawal, bytes.slice(1))) + break + case 2: + if (!common.isActivatedEIP(7251)) { + throw new Error(`Consolidation requests are not active`) + } + requests.push(new CLRequest(CLRequestType.Consolidation, bytes.slice(1))) + break + default: + throw new Error(`Unknown request identifier: got ${bytes[0]}`) + } } const sha256Function = common.customCrypto.sha256 ?? sha256 diff --git a/packages/client/test/rpc/engine/newPayloadV4.spec.ts b/packages/client/test/rpc/engine/newPayloadV4.spec.ts index 3fdda74f04..6b5634024b 100644 --- a/packages/client/test/rpc/engine/newPayloadV4.spec.ts +++ b/packages/client/test/rpc/engine/newPayloadV4.spec.ts @@ -180,7 +180,7 @@ describe(`${method}: call with executionPayloadV4`, () => { assert.ok(res.error.message.includes(expectedError)) } - res = await rpc.request(method, [validBlock, [], parentBeaconBlockRoot, ['0x', '0x', '0x']]) + res = await rpc.request(method, [validBlock, [], parentBeaconBlockRoot, []]) assert.equal(res.result.status, 'VALID') res = await rpc.request('engine_forkchoiceUpdatedV3', validPayload) @@ -201,9 +201,20 @@ describe(`${method}: call with executionPayloadV4`, () => { res = await rpc.request('engine_getPayloadV4', [payloadId]) const { executionPayload, executionRequests } = res.result + + assert.ok( + executionRequests?.length === 1, + 'executionRequests should have the deposit request, and should exclude the other requests (these are empty)', + ) + + const depositRequestBytes = hexToBytes(executionRequests[0]) + assert.ok( + depositRequestBytes[0] === 0x00, + 'deposit request byte 0 is the deposit request identifier byte (0x00)', + ) assert.ok( - executionRequests?.length === 3, - 'executionRequests should have 3 entries for each request type', + depositRequestBytes.length > 1, + 'deposit request includes data (and is thus not empty)', ) res = await rpc.request(method, [ From fc3c150fdd675bb05c078afbef9dadecffb4abf8 Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Thu, 19 Dec 2024 02:52:24 +0100 Subject: [PATCH 3/3] t8n: fix requests reporting --- packages/vm/test/t8n/t8ntool.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/test/t8n/t8ntool.ts b/packages/vm/test/t8n/t8ntool.ts index d57563513e..fe322ffac7 100644 --- a/packages/vm/test/t8n/t8ntool.ts +++ b/packages/vm/test/t8n/t8ntool.ts @@ -306,7 +306,7 @@ export class TransitionTool { output.requests = [] for (const request of requests) { if (request.bytes.length > 1) { - output.requests.push(bytesToHex(request.bytes.slice(1))) + output.requests.push(bytesToHex(request.bytes)) } } }