Skip to content

Commit

Permalink
Merge branch 'devnet-5' into eip-7623
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Dec 19, 2024
2 parents 8dcb666 + fc3c150 commit 6b61450
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 26 deletions.
13 changes: 12 additions & 1 deletion packages/client/src/rpc/modules/engine/util/getPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
49 changes: 27 additions & 22 deletions packages/client/src/rpc/modules/engine/util/newPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,35 @@ export const validateAndGen7685RequestsHash = (
common: Common,
executionRequests: PrefixedHexString[],
): PrefixedHexString => {
let validationError: string | null = null

const requests: CLRequest<CLRequestType>[] = []
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
Expand Down
17 changes: 14 additions & 3 deletions packages/client/test/rpc/engine/newPayloadV4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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, [
Expand Down

0 comments on commit 6b61450

Please sign in to comment.