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

chore: blob inclusion proof PR cleanup #6239

Merged
merged 1 commit into from
Dec 27, 2023
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
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
Loading