Skip to content

Commit

Permalink
fix: build error
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Aug 31, 2023
1 parent 4f58fc5 commit fbeb88a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 14 deletions.
6 changes: 4 additions & 2 deletions packages/beacon-node/test/sim/mergemock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {LogLevel, sleep} from "@lodestar/utils";
import {TimestampFormatCode} from "@lodestar/logger";
import {SLOTS_PER_EPOCH} from "@lodestar/params";
import {ChainConfig} from "@lodestar/config";
import {Epoch, bellatrix} from "@lodestar/types";
import {Epoch, allForks, bellatrix} from "@lodestar/types";
import {ValidatorProposerConfig, BuilderSelection} from "@lodestar/validator";
import {routes} from "@lodestar/api";

Expand Down Expand Up @@ -210,7 +210,9 @@ describe("executionEngine / ExecutionEngineHttp", function () {
let builderBlocks = 0;
await new Promise<void>((resolve, _reject) => {
bn.chain.emitter.on(routes.events.EventType.block, async (blockData) => {
const {data: fullOrBlindedBlock} = await bn.api.beacon.getBlockV2(blockData.block);
const {data: fullOrBlindedBlock} = (await bn.api.beacon.getBlockV2(blockData.block)) as {
data: allForks.SignedBeaconBlock;
};
if (fullOrBlindedBlock !== undefined) {
const blockFeeRecipient = toHexString(
(fullOrBlindedBlock as bellatrix.SignedBeaconBlock).message.body.executionPayload.feeRecipient
Expand Down
7 changes: 5 additions & 2 deletions packages/beacon-node/test/sim/withdrawal-interop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {TimestampFormatCode} from "@lodestar/logger";
import {SLOTS_PER_EPOCH, ForkName} from "@lodestar/params";
import {ChainConfig} from "@lodestar/config";
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
import {Epoch, capella, Slot} from "@lodestar/types";
import {Epoch, capella, Slot, allForks} from "@lodestar/types";
import {ValidatorProposerConfig} from "@lodestar/validator";

import {ExecutionPayloadStatus, PayloadAttributes} from "../../src/execution/engine/interface.js";
Expand Down Expand Up @@ -369,7 +369,10 @@ async function retrieveCanonicalWithdrawals(bn: BeaconNode, fromSlot: Slot, toSl
});

if (block) {
if ((block.data as capella.SignedBeaconBlock).message.body.executionPayload?.withdrawals.length > 0) {
if (
((block as {data: allForks.SignedBeaconBlock}).data as capella.SignedBeaconBlock).message.body.executionPayload
?.withdrawals.length > 0
) {
withdrawalsBlocks++;
}
}
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/test/sim/multi_fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import path from "node:path";
import {sleep, toHex, toHexString} from "@lodestar/utils";
import {ApiError} from "@lodestar/api";
import {allForks} from "@lodestar/types";
import {CLIQUE_SEALING_PERIOD, SIM_TESTS_SECONDS_PER_SLOT} from "../utils/simulation/constants.js";
import {AssertionMatch, BeaconClient, ExecutionClient} from "../utils/simulation/interfaces.js";
import {SimulationEnvironment} from "../utils/simulation/SimulationEnvironment.js";
Expand Down Expand Up @@ -161,13 +162,14 @@ await unknownBlockSync.execution.job.start();
await unknownBlockSync.beacon.job.start();
const headForUnknownBlockSync = await env.nodes[0].beacon.api.beacon.getBlockV2("head");
ApiError.assert(headForUnknownBlockSync);
const headResponse = headForUnknownBlockSync.response as {data: allForks.SignedBeaconBlock};
await connectNewNode(unknownBlockSync, env.nodes);

// Wait for EL node to start and sync
await sleep(5000);

try {
ApiError.assert(await unknownBlockSync.beacon.api.beacon.publishBlock(headForUnknownBlockSync.response.data));
ApiError.assert(await unknownBlockSync.beacon.api.beacon.publishBlock(headResponse.data));

env.tracker.record({
message: "Publishing unknown block should fail",
Expand All @@ -185,11 +187,9 @@ try {
}
await waitForHead(env, unknownBlockSync, {
head: toHexString(
env.forkConfig
.getForkTypes(headForUnknownBlockSync.response.data.message.slot)
.BeaconBlock.hashTreeRoot(headForUnknownBlockSync.response.data.message)
env.forkConfig.getForkTypes(headResponse.data.message.slot).BeaconBlock.hashTreeRoot(headResponse.data.message)
),
slot: headForUnknownBlockSync.response.data.message.slot,
slot: headResponse.data.message.slot,
});

await env.stop();
2 changes: 1 addition & 1 deletion packages/cli/test/utils/simulation/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export async function fetchBlock(
continue;
}

return res.response.data;
return (res.response as {data: allForks.SignedBeaconBlock}).data;
}

return;
Expand Down
2 changes: 1 addition & 1 deletion packages/light-client/src/transport/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class LightClientRestTransport extends (EventEmitter as {new (): RestEven
async fetchBlock(blockRootAsString: string): Promise<{version: ForkName; data: allForks.SignedBeaconBlock}> {
const res = await this.api.beacon.getBlockV2(blockRootAsString);
ApiError.assert(res);
return res.response;
return res.response as {version: ForkName; data: allForks.SignedBeaconBlock};
}

onOptimisticUpdate(handler: (optimisticUpdate: allForks.LightClientOptimisticUpdate) => void): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/prover/src/utils/consensus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function fetchNearestBlock(
): Promise<capella.SignedBeaconBlock> {
const res = await api.beacon.getBlockV2(slot);

if (res.ok) return res.response.data;
if (res.ok) return (res.response as {data: allForks.SignedBeaconBlock}).data;

if (!res.ok && res.error.code === 404) {
return fetchNearestBlock(api, direction === "down" ? slot - 1 : slot + 1);
Expand Down
3 changes: 2 additions & 1 deletion packages/state-transition/test/perf/analyzeBlocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {getClient, ApiError} from "@lodestar/api";
import {config} from "@lodestar/config/default";
import {allForks} from "@lodestar/types";
import {getInfuraBeaconUrl} from "../utils/infura.js";

// Analyze how Ethereum Consensus blocks are in a target network to prepare accurate performance states and blocks
Expand Down Expand Up @@ -52,7 +53,7 @@ async function run(): Promise<void> {
}
ApiError.assert(result.value);

const block = result.value.response.data;
const block = (result.value.response as {data: allForks.SignedBeaconBlock}).data;

blocks++;
attestations += block.message.body.attestations.length;
Expand Down
4 changes: 3 additions & 1 deletion packages/state-transition/test/utils/testFileCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export async function getNetworkCachedBlock(
? await client.beacon.getBlock(String(slot))
: await client.beacon.getBlockV2(String(slot));
ApiError.assert(res);
return config.getForkTypes(slot).SignedBeaconBlock.serialize(res.response.data);
return config
.getForkTypes(slot)
.SignedBeaconBlock.serialize((res.response as {data: allForks.SignedBeaconBlock}).data);
},
]);

Expand Down

0 comments on commit fbeb88a

Please sign in to comment.