Skip to content

Commit

Permalink
fix: update withdrawal request container to match consensus spec
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed May 16, 2024
1 parent 68ded3d commit a7d26dc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions packages/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export function serializeExecutionLayerWithdrawalRequest(
): ExecutionLayerWithdrawalRequestRpc {
return {
sourceAddress: bytesToData(withdrawalRequest.sourceAddress),
validatorPublicKey: bytesToData(withdrawalRequest.validatorPublicKey),
validatorPublicKey: bytesToData(withdrawalRequest.validatorPubkey),
amount: numToQuantity(withdrawalRequest.amount),
};
}
Expand All @@ -429,7 +429,7 @@ export function deserializeExecutionLayerWithdrawalRequest(
): electra.ExecutionLayerWithdrawalRequest {
return {
sourceAddress: dataToBytes(withdrawalRequest.sourceAddress, 20),
validatorPublicKey: dataToBytes(withdrawalRequest.validatorPublicKey, 48),
validatorPubkey: dataToBytes(withdrawalRequest.validatorPublicKey, 48),
amount: quantityToNum(withdrawalRequest.amount),
};
}
Expand Down
32 changes: 15 additions & 17 deletions packages/beacon-node/test/spec/presets/ssz_static.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import {expect, it, vi} from "vitest";
import {it, vi} from "vitest";
import {Type} from "@chainsafe/ssz";
import {ssz} from "@lodestar/types";
import {ACTIVE_PRESET, ForkName, ForkLightClient, ForkExecution} from "@lodestar/params";
Expand Down Expand Up @@ -58,24 +58,22 @@ const sszStatic =
(ssz.phase0 as Types)[typeName];

if (!sszType) {
expect.fail(
`Missing SSZ type definition for ${typeName}; this will prevent associated ssz_static tests to be executed`
);
} else {
const sszTypeNoUint = replaceUintTypeWithUintBigintType(sszType);
throw Error(`Missing SSZ type ${typeName} for fork ${fork}`);
}

const sszTypeNoUint = replaceUintTypeWithUintBigintType(sszType);

for (const testCase of fs.readdirSync(testSuiteDirpath)) {
// Do not manually skip tests here, do it in packages/beacon-node/test/spec/presets/index.test.ts
it(testCase, function () {
// Mainnet must deal with big full states and hash each one multiple times
if (ACTIVE_PRESET === "mainnet") {
vi.setConfig({testTimeout: 30 * 1000});
}
for (const testCase of fs.readdirSync(testSuiteDirpath)) {
// Do not manually skip tests here, do it in packages/beacon-node/test/spec/presets/index.test.ts
it(testCase, function () {
// Mainnet must deal with big full states and hash each one multiple times
if (ACTIVE_PRESET === "mainnet") {
vi.setConfig({testTimeout: 30 * 1000});
}

const testData = parseSszStaticTestcase(path.join(testSuiteDirpath, testCase));
runValidSszTest(sszTypeNoUint, testData);
});
}
const testData = parseSszStaticTestcase(path.join(testSuiteDirpath, testCase));
runValidSszTest(sszTypeNoUint, testData);
});
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function processExecutionLayerWithdrawalRequest(

// bail out if validator is not in beacon state
// note that we don't need to check for 6110 unfinalized vals as they won't be eligible for withdraw/exit anyway
const validatorIndex = pubkey2index.get(executionLayerWithdrawalRequest.validatorPublicKey);
const validatorIndex = pubkey2index.get(executionLayerWithdrawalRequest.validatorPubkey);
if (validatorIndex === undefined) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/electra/sszTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const DepositReceipts = new ListCompositeType(DepositReceipt, MAX_DEPOSIT
export const ExecutionLayerWithdrawalRequest = new ContainerType(
{
sourceAddress: ExecutionAddress,
validatorPublicKey: BLSPubkey,
validatorPubkey: BLSPubkey,
amount: UintNum64,
},
{typeName: "ExecutionLayerWithdrawalRequest", jsonCase: "eth2"}
Expand Down

0 comments on commit a7d26dc

Please sign in to comment.