Skip to content

Commit

Permalink
relocate utils
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Dec 23, 2023
1 parent 6db180a commit 1d0e4a7
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 16 deletions.
3 changes: 2 additions & 1 deletion packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {fromHexString, toHexString} from "@chainsafe/ssz";
import {routes, ServerApi, ResponseFormat} from "@lodestar/api";
import {computeTimeAtSlot, reconstructFullBlockOrContents, computeBlobSidecars} from "@lodestar/state-transition";
import {computeTimeAtSlot, reconstructFullBlockOrContents} from "@lodestar/state-transition";
import {SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
import {sleep, toHex} from "@lodestar/utils";
import {allForks, deneb, isSignedBlockContents, ProducedBlockSource} from "@lodestar/types";
import {BlockSource, getBlockInput, ImportBlockOpts, BlockInput} from "../../../../chain/blocks/types.js";
import {promiseAllMaybeAsync} from "../../../../util/promises.js";
import {isOptimisticBlock} from "../../../../util/forkChoice.js";
import {computeBlobSidecars} from "../../../../util/blobs.js";
import {BlockError, BlockErrorCode} from "../../../../chain/errors/index.js";
import {OpSource} from "../../../../metrics/validatorMonitor.js";
import {NetworkEvent} from "../../../../network/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/blocks/importBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
computeStartSlotAtEpoch,
isStateValidatorsNodesPopulated,
RootCache,
kzgCommitmentToVersionedHash,
} from "@lodestar/state-transition";
import {routes} from "@lodestar/api";
import {ForkChoiceError, ForkChoiceErrorCode, EpochDifference, AncestorStatus} from "@lodestar/fork-choice";
Expand All @@ -16,6 +15,7 @@ import {ZERO_HASH_HEX} from "../../constants/index.js";
import {toCheckpointHex} from "../stateCache/index.js";
import {isOptimisticBlock} from "../../util/forkChoice.js";
import {isQueueErrorAborted} from "../../util/queue/index.js";
import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
import {ChainEvent, ReorgEventData} from "../emitter.js";
import {REPROCESS_MIN_TIME_TO_NEXT_SLOT_SEC} from "../reprocess.js";
import type {BeaconChain} from "../chain.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
isExecutionBlockBodyType,
isMergeTransitionBlock as isMergeTransitionBlockFn,
isExecutionEnabled,
kzgCommitmentToVersionedHash,
} from "@lodestar/state-transition";
import {bellatrix, allForks, Slot, deneb} from "@lodestar/types";
import {
Expand All @@ -24,6 +23,7 @@ import {ForkSeq, SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY} from "@lodestar/params";
import {IExecutionEngine} from "../../execution/engine/interface.js";
import {BlockError, BlockErrorCode} from "../errors/index.js";
import {IClock} from "../../util/clock.js";
import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
import {BlockProcessOpts} from "../options.js";
import {ExecutionPayloadStatus} from "../../execution/engine/interface.js";
import {IEth1ForBlockProduction} from "../../eth1/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/execution/engine/mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import crypto from "node:crypto";
import {kzgCommitmentToVersionedHash} from "@lodestar/state-transition";
import {bellatrix, deneb, RootHex, ssz} from "@lodestar/types";
import {fromHex, toHex} from "@lodestar/utils";
import {
Expand All @@ -12,6 +11,7 @@ import {
} from "@lodestar/params";
import {ZERO_HASH_HEX} from "../../constants/index.js";
import {ckzg} from "../../util/kzg.js";
import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
import {quantityToNum} from "../../eth1/provider/utils.js";
import {
EngineApiRpcParamTypes,
Expand Down
6 changes: 5 additions & 1 deletion packages/beacon-node/src/network/processor/gossipHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler
}

if (e.action === GossipAction.REJECT) {
chain.persistInvalidSszValue(ssz.deneb.BlobSidecar, blobSidecar, `gossip_reject_slot_${slot}_index_${blobSidecar.index}`);
chain.persistInvalidSszValue(
ssz.deneb.BlobSidecar,
blobSidecar,
`gossip_reject_slot_${slot}_index_${blobSidecar.index}`
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {Tree} from "@chainsafe/persistent-merkle-tree";
import {VERSIONED_HASH_VERSION_KZG, KZG_COMMITMENT_GINDEX0, ForkName} from "@lodestar/params";
import {deneb, ssz, allForks} from "@lodestar/types";
import {ChainForkConfig} from "@lodestar/config";

import {signedBlockToSignedHeader} from "./blockRoot.js";
import {signedBlockToSignedHeader} from "@lodestar/state-transition";

type VersionHash = Uint8Array;

Expand Down
8 changes: 2 additions & 6 deletions packages/beacon-node/test/spec/presets/fork_choice.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import path from "node:path";
import {expect} from "chai";
import {toHexString} from "@chainsafe/ssz";
import {
BeaconStateAllForks,
isExecutionStateType,
signedBlockToSignedHeader,
computeInclusionProof,
} from "@lodestar/state-transition";
import {BeaconStateAllForks, isExecutionStateType, signedBlockToSignedHeader} from "@lodestar/state-transition";
import {InputType} from "@lodestar/spec-test-util";
import {CheckpointWithHex, ForkChoice} from "@lodestar/fork-choice";
import {phase0, allForks, bellatrix, ssz, RootHex, deneb} from "@lodestar/types";
Expand All @@ -15,6 +10,7 @@ import {createBeaconConfig} from "@lodestar/config";
import {ACTIVE_PRESET, ForkSeq, isForkBlobs} from "@lodestar/params";
import {BeaconChain} from "../../../src/chain/index.js";
import {ClockEvent} from "../../../src/util/clock.js";
import {computeInclusionProof} from "../../../src/util/blobs.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {testLogger} from "../../utils/logger.js";
import {getConfig} from "../../utils/config.js";
Expand Down
3 changes: 1 addition & 2 deletions packages/beacon-node/test/unit/util/kzg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import {describe, it, expect, afterEach, beforeAll} from "vitest";
import {bellatrix, deneb, ssz} from "@lodestar/types";
import {BYTES_PER_FIELD_ELEMENT, BLOB_TX_TYPE} from "@lodestar/params";
import {createBeaconConfig, createChainForkConfig, defaultChainConfig} from "@lodestar/config";
import {kzgCommitmentToVersionedHash} from "@lodestar/state-transition";
import {computeBlobSidecars} from "@lodestar/state-transition";
import {computeBlobSidecars, kzgCommitmentToVersionedHash} from "../../../src/util/blobs.js";
import {loadEthereumTrustedSetup, initCKZG, ckzg, FIELD_ELEMENTS_PER_BLOB_MAINNET} from "../../../src/util/kzg.js";
import {validateBlobSidecars, validateGossipBlobSidecar} from "../../../src/chain/validation/blobSidecar.js";
import {getMockedBeaconChain} from "../../__mocks__/mockedBeaconChain.js";
Expand Down
1 change: 0 additions & 1 deletion packages/state-transition/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from "./attestation.js";
export * from "./attesterStatus.js";
export * from "./balance.js";
export * from "./blindedBlock.js";
export * from "./blobs.js";
export * from "./capella.js";
export * from "./execution.js";
export * from "./blockRoot.js";
Expand Down

0 comments on commit 1d0e4a7

Please sign in to comment.