diff --git a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts index d4aa2337fe3f..79e258960b2c 100644 --- a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts @@ -8,7 +8,7 @@ import {BlockSource, getBlockInput, ImportBlockOpts, BlockInput} from "../../../ 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 {BlockError, BlockErrorCode, BlockGossipError} from "../../../../chain/errors/index.js"; import {OpSource} from "../../../../metrics/validatorMonitor.js"; import {NetworkEvent} from "../../../../network/index.js"; import {ApiModules} from "../../types.js"; @@ -83,6 +83,13 @@ export function getBeaconBlockApi({ try { await validateGossipBlock(config, chain, signedBlock, fork); } catch (error) { + if (error instanceof BlockGossipError && error.type.code === BlockErrorCode.ALREADY_KNOWN) { + chain.logger.debug("Ignoring known block during publishing", valLogMeta); + // Blocks might already be published by another node as part of a fallback setup or DVT cluster + // and can reach our node by gossip before the api. The error can be ignored and should not result in a 500 response. + return; + } + chain.logger.error("Gossip validations failed while publishing the block", valLogMeta, error as Error); chain.persistInvalidSszValue( chain.config.getForkTypes(slot).SignedBeaconBlock,