Skip to content

Commit

Permalink
chore: blob inclusion proof PR cleanup (#6239)
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech authored Dec 27, 2023
1 parent 9c4641a commit bd83b09
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/errors/blobSidecarError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type BlobSidecarErrorType =
| {code: BlobSidecarErrorCode.PARENT_UNKNOWN; parentRoot: RootHex}
| {code: BlobSidecarErrorCode.NOT_LATER_THAN_PARENT; parentSlot: Slot; slot: Slot}
| {code: BlobSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID}
| {code: BlobSidecarErrorCode.INCLUSION_PROOF_INVALID}
| {code: BlobSidecarErrorCode.INCLUSION_PROOF_INVALID; slot: Slot; blobIdx: number}
| {code: BlobSidecarErrorCode.INCORRECT_PROPOSER; proposerIndex: ValidatorIndex};

export class BlobSidecarGossipError extends GossipActionError<BlobSidecarErrorType> {}
8 changes: 4 additions & 4 deletions packages/beacon-node/src/chain/validation/blobSidecar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {ChainForkConfig} from "@lodestar/config";
import {deneb, Root, Slot, ssz} from "@lodestar/types";
import {toHex, verifyMerkleBranch} from "@lodestar/utils";
import {computeStartSlotAtEpoch, getBlockHeaderProposerSignatureSet} from "@lodestar/state-transition";
Expand All @@ -12,7 +11,6 @@ import {IBeaconChain} from "../interface.js";
import {RegenCaller} from "../regen/index.js";

export async function validateGossipBlobSidecar(
config: ChainForkConfig,
chain: IBeaconChain,
blobSidecar: deneb.BlobSidecar,
gossipIndex: number
Expand Down Expand Up @@ -116,9 +114,11 @@ export async function validateGossipBlobSidecar(
}

// verify if the blob inclusion proof is correct
if (!validateInclusionProof(config, blobSidecar)) {
if (!validateInclusionProof(blobSidecar)) {
throw new BlobSidecarGossipError(GossipAction.REJECT, {
code: BlobSidecarErrorCode.INCLUSION_PROOF_INVALID,
slot: blobSidecar.signedBlockHeader.message.slot,
blobIdx: blobSidecar.index,
});
}

Expand Down Expand Up @@ -216,7 +216,7 @@ function validateBlobsAndProofs(
}
}

function validateInclusionProof(config: ChainForkConfig, blobSidecar: deneb.BlobSidecar): boolean {
function validateInclusionProof(blobSidecar: deneb.BlobSidecar): boolean {
return verifyMerkleBranch(
ssz.deneb.KZGCommitment.hashTreeRoot(blobSidecar.kzgCommitment),
blobSidecar.kzgCommitmentInclusionProof,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler
});

try {
await validateGossipBlobSidecar(config, chain, blobSidecar, gossipIndex);
await validateGossipBlobSidecar(chain, blobSidecar, gossipIndex);
return blockInput;
} catch (e) {
if (e instanceof BlobSidecarGossipError) {
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/test/unit/util/kzg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("C-KZG", async () => {

blobSidecars.forEach(async (blobSidecar) => {
try {
await validateGossipBlobSidecar(chain.config, chain, blobSidecar, blobSidecar.index);
await validateGossipBlobSidecar(chain, blobSidecar, blobSidecar.index);
} catch (error) {
// We expect some error from here
// console.log(error);
Expand Down

0 comments on commit bd83b09

Please sign in to comment.