Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move WithBytes to types package #7201

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/beacon-node/src/network/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
deneb,
phase0,
SignedAggregateAndProof,
WithBytes,
} from "@lodestar/types";
import {PeerIdStr} from "../util/peerId.js";
import {INetworkEventBus} from "./events.js";
Expand All @@ -36,8 +37,6 @@ import {GossipType} from "./gossip/interface.js";
import {PendingGossipsubMessage} from "./processor/types.js";
import {PeerAction} from "./peers/index.js";

export type WithBytes<T> = {data: T; bytes: Uint8Array};

/**
* The architecture of the network looks like so:
* - core:
Expand Down
3 changes: 2 additions & 1 deletion packages/beacon-node/src/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
LightClientOptimisticUpdate,
LightClientUpdate,
SignedAggregateAndProof,
WithBytes,
} from "@lodestar/types";
import {routes} from "@lodestar/api";
import {ResponseIncoming} from "@lodestar/reqresp";
Expand All @@ -29,7 +30,7 @@ import {IBeaconDb} from "../db/interface.js";
import {PeerIdStr, peerIdToString} from "../util/peerId.js";
import {IClock} from "../util/clock.js";
import {NetworkOptions} from "./options.js";
import {WithBytes, INetwork} from "./interface.js";
import {INetwork} from "./interface.js";
import {ReqRespMethod} from "./reqresp/index.js";
import {GossipHandlers, GossipTopicMap, GossipType, GossipTypeMap} from "./gossip/index.js";
import {PeerAction, PeerScoreStats} from "./peers/index.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {ChainForkConfig} from "@lodestar/config";
import {deneb, Epoch, phase0, SignedBeaconBlock, Slot} from "@lodestar/types";
import {deneb, Epoch, phase0, SignedBeaconBlock, Slot, WithBytes} from "@lodestar/types";
import {ForkSeq} from "@lodestar/params";
import {computeEpochAtSlot} from "@lodestar/state-transition";

import {BlobsSource, BlockInput, BlockSource, getBlockInput, BlockInputDataBlobs} from "../../chain/blocks/types.js";
import {PeerIdStr} from "../../util/peerId.js";
import {INetwork, WithBytes} from "../interface.js";
import {INetwork} from "../interface.js";

export async function beaconBlocksMaybeBlobsByRange(
config: ChainForkConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Type} from "@chainsafe/ssz";
import {ResponseIncoming, RequestErrorCode, RequestError} from "@lodestar/reqresp";
import {WithBytes} from "@lodestar/types";
import {ResponseTypeGetter} from "../types.js";
import {WithBytes} from "../../interface.js";

/**
* Sink for `<response_chunk>*`, from
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {ResponseIncoming} from "@lodestar/reqresp";
import {LodestarError} from "@lodestar/utils";
import {phase0, SignedBeaconBlock} from "@lodestar/types";
import {WithBytes} from "../../interface.js";
import {phase0, SignedBeaconBlock, WithBytes} from "@lodestar/types";
import {ReqRespMethod, responseSszTypeByMethod} from "../types.js";
import {sszDeserializeResponse} from "./collect.js";

Expand Down
3 changes: 1 addition & 2 deletions packages/beacon-node/src/sync/backfill/verify.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {CachedBeaconStateAllForks, ISignatureSet, getBlockProposerSignatureSet} from "@lodestar/state-transition";
import {BeaconConfig} from "@lodestar/config";
import {Root, ssz, Slot, SignedBeaconBlock} from "@lodestar/types";
import {Root, ssz, Slot, SignedBeaconBlock, WithBytes} from "@lodestar/types";
import {GENESIS_SLOT} from "@lodestar/params";
import {IBlsVerifier} from "../../chain/bls/index.js";
import {WithBytes} from "../../network/interface.js";
import {BackfillSyncError, BackfillSyncErrorCode} from "./errors.js";

export type BackfillBlockHeader = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import {fileURLToPath} from "node:url";
import {describe, it, expect} from "vitest";
import {createBeaconConfig} from "@lodestar/config";
import {config} from "@lodestar/config/default";
import {phase0, ssz} from "@lodestar/types";
import {phase0, ssz, WithBytes} from "@lodestar/types";
import {verifyBlockSequence} from "../../../../src/sync/backfill/verify.js";
import {WithBytes} from "../../../../src/network/interface.js";
import {ZERO_HASH} from "../../../../src/constants/constants.js";
import {BackfillSyncErrorCode, BackfillSyncError} from "./../../../../src/sync/backfill/errors.js";

Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export enum ProducedBlockSource {
engine = "engine",
}

export type WithBytes<T> = {
data: T;
/** SSZ serialized `data` bytes */
bytes: Uint8Array;
};

export type WithOptionalBytes<T> = {
data: T;
/** SSZ serialized `data` bytes */
Expand Down
Loading