Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
1cede34
Updates to allow test:spec-min|main work, some edits to contributing …
dgcoffman Oct 17, 2022
6ba5243
Sketch out EIP-4844 types
dgcoffman Oct 19, 2022
1ca3287
Spec-matching configs and presets
dgcoffman Oct 19, 2022
78d7190
Beacon chain types complete
dgcoffman Oct 19, 2022
5852287
Add DOMAIN_BLOBS_SIDECAR
dgcoffman Oct 19, 2022
03649bb
Capella and 4844 state upgrades
dgcoffman Oct 19, 2022
ca28429
Add engine_getBlobsBundleV1 Engine API call
dgcoffman Oct 19, 2022
018f80b
When producing a block to propose, assign blobKzgCommitments from Eng…
dgcoffman Oct 20, 2022
ee4ab00
Fix state upgrade and patch blocks with missing fields when necessary
dgcoffman Oct 20, 2022
3b37059
Fix: Accidentally removed assigning execution payload to block
dgcoffman Oct 21, 2022
84c8671
Add beacon_block_and_blobs_sidecar gossip type
dgcoffman Oct 28, 2022
c066fae
Fix allForks SSZ types
dgcoffman Oct 28, 2022
a7c698b
Revert upgradeStateToCapella
dgcoffman Oct 28, 2022
6841f3d
Revert Capella ssz type change
dgcoffman Oct 28, 2022
558ef96
Fix assigning excessDataGas to ExecutionPayload
dgcoffman Oct 28, 2022
66cbf3a
Add chain config constants and validator types
dgcoffman Oct 28, 2022
10e5585
Add a couple more of the polynomial commitment types
dgcoffman Oct 29, 2022
01f49d9
Scaffold block proposing w/ KZG commitments
dgcoffman Oct 29, 2022
2926f11
publishBlockWithBlobs implementation. A lot more moon math scaffoldin…
dgcoffman Oct 31, 2022
85e51a3
Use SSZ object correctly
dgcoffman Oct 31, 2022
594e07f
Drill blobs all the way through
dgcoffman Nov 1, 2022
5e69a50
Use computeAggregateKzgProof from the c-kzg package and delete all th…
dgcoffman Nov 5, 2022
7610968
Bump @types/node
dgcoffman Nov 7, 2022
40e2283
Bump c-kzg to the version that compiles on Linux
dgcoffman Nov 7, 2022
8230d13
Load KZG setup
dgcoffman Nov 7, 2022
20db61b
Fix trusted_setup file path
dgcoffman Nov 7, 2022
0c0546f
Add unit test just to verify the c-kzg library works
dgcoffman Nov 8, 2022
208e062
Bump c-kzg again
dgcoffman Nov 8, 2022
4c27da3
processBlocks for 4844 blocks. Do not compute aggregate proof for emp…
dgcoffman Nov 8, 2022
bc88957
Delete unused polynomialCommitments file
dgcoffman Nov 8, 2022
96e6fb6
Update version of c-kzg to one which does not crash for blobs arrays …
dgcoffman Nov 8, 2022
7851d78
Bump c-kzg to version that handles empty array of blobs -- remove app…
dgcoffman Nov 9, 2022
f856410
Blind code processBlobKzgCommitments
dgcoffman Nov 15, 2022
d73e4a3
Set excessDataGas in latestExecutionPayloadHeader
dgcoffman Nov 15, 2022
91d163f
Block processing state transition
dgcoffman Nov 16, 2022
a31b7c8
Add blob repository
dgcoffman Nov 16, 2022
25194ff
stateTransition now needs to do a db read...
dgcoffman Nov 16, 2022
155d601
Awkwardly drill through db.blob.get every that does a state transition
dgcoffman Nov 16, 2022
c5509fa
Move some code into util/blobs/
dgcoffman Nov 16, 2022
9e0f3a8
Remove hardcoding that was dealing with EL not having Capella. Add va…
dgcoffman Nov 16, 2022
9a4d3c2
Add blobs_sidecars_by_range ReqResp method
dgcoffman Nov 16, 2022
0378d8f
Start implementing blobsSidecarsByRange
dgcoffman Nov 16, 2022
27674aa
Remove hardcoded withdrawalsRoot assignment
dgcoffman Nov 16, 2022
5e5067c
Maybe this onBlobsSidecarsByRange impl works
dgcoffman Nov 16, 2022
4456b82
Rename BlobRepository -> BlobsSidecarRepository
dgcoffman Nov 16, 2022
17a93e8
stateTransition must be sync. Move processBlobKzgCommitments into a p…
dgcoffman Nov 16, 2022
337164e
Fix blobsBundle parsing. Upgrade c-kzg to a version which does not cr…
dgcoffman Nov 17, 2022
1bd9bb8
Better error message
dgcoffman Nov 17, 2022
2942065
Transform JSON trusted setup
dgcoffman Nov 17, 2022
013d173
stateTransition is not async
dgcoffman Nov 17, 2022
c7a6f01
Various fixes to state-transition block processing
dgcoffman Nov 17, 2022
828454d
Temporarily allow verifyAggregateKzgProof to fail during isDataAvailable
dgcoffman Nov 17, 2022
2a3a9a0
Fix versioned hash comparison
dgcoffman Nov 17, 2022
2b59a3c
Blobs bundle does not have aggregated_proof
dgcoffman Nov 17, 2022
dec9841
Remove the tolerance for KZG failing
dgcoffman Nov 18, 2022
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
5 changes: 0 additions & 5 deletions packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,8 @@ export function getBeaconBlockApi({

metrics?.registerBeaconBlock(OpSource.api, seenTimestampSec, message);

console.log("BLOB SAVING 1. publishBlockWithBlobs is calling chain.processBlock");

// TODO EIP-4844 is it appropriate to do this here?
await db.blobsSidecar.add(blobsSidecar);

console.log("Persisted blobsSidecar to the database", blobsSidecar.beaconBlockRoot);

await Promise.all([
network.gossip.publishSignedBeaconBlockAndBlobsSidecar(signedBeaconBlockAndBlobsSidecar),
// TODO EIP-4844 processBlock for signedBeaconBlockAndBlobsSidecar
Expand Down
2 changes: 0 additions & 2 deletions packages/beacon-node/src/chain/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export async function processBlocks(
blocks: allForks.SignedBeaconBlock[],
opts: BlockProcessOpts & ImportBlockOpts
): Promise<void> {
console.log("BLOB SAVING 3. the processBlocks job is running");

if (blocks.length === 0) {
return; // TODO: or throw?
} else if (blocks.length > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@ export async function verifyBlocksStateTransitionOnly(

let blobsSidecar: BlobsSidecar | undefined;
if (verifyBlobs) {
console.log("verifyBlocksStateTransitionOnly is requiring blob verification");

const id = blindedOrFullBlockHashTreeRoot(config, block.message);
console.log("Attempting to retrieve blob with id: ", id);
// We fetch the blobsSidecar from the DB here,
// instead of inside stateTransition as the consensus-spec indicates.
blobsSidecar = (await db.blobsSidecar.get(id)) ?? undefined;
console.log("Retreived blobs sidecar from db!", blobsSidecar);
}

// STFN - per_slot_processing() + per_block_processing()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export async function produceBlockBody<T extends BlockType>(

// Capella and later forks have blsToExecutionChanges on BeaconBlockBody
if (forkSeq >= ForkSeq.capella) {
console.log("Building a block body for Capella or later -- assigning blsToExecutionChanges");
// TODO EIP-4844 How should this actually be set? Capella
(blockBody as capella.BeaconBlockBody).blsToExecutionChanges = [];
}
Expand Down Expand Up @@ -210,12 +209,8 @@ export async function produceBlockBody<T extends BlockType>(
if (forkSeq >= ForkSeq.eip4844) {
const blobsBundle = await this.executionEngine.getBlobsBundle(payloadId);

try {
// These checks are described by the spec as optional
validateBlobsAndKzgCommitments(payload as eip4844.ExecutionPayload, blobsBundle.blobs, blobsBundle.kzgs);
} catch (e) {
console.log("validateBlobsAndKzgCommitments FAILED but we're ignoring that for now!", e);
}
// These checks are described by the spec as optional
validateBlobsAndKzgCommitments(payload as eip4844.ExecutionPayload, blobsBundle.blobs, blobsBundle.kzgs);

(blockBody as eip4844.BeaconBlockBody).blobKzgCommitments = blobsBundle.kzgs;
blobs = blobsBundle.blobs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {eip4844} from "@lodestar/types";

import {Blob, KZGCommitment} from "@lodestar/types/eip4844";
import {verifyKzgCommitmentsAgainstTransactions} from "@lodestar/state-transition/block";
import {typedArraysAreEqual} from "@lodestar/state-transition";

/**
* https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/validator.md#blob-kzg-commitments
Expand All @@ -27,7 +28,7 @@ export function validateBlobsAndKzgCommitments(
// assert [blob_to_kzg_commitment(blob) == commitment for blob, commitment in zip(blobs, blob_kzg_commitments)]
blobs.forEach((blob, index) => {
const computedCommitment = blobToKzgCommitment(blob);
if (computedCommitment !== blobKzgCommitments[index]) {
if (!typedArraysAreEqual(computedCommitment, blobKzgCommitments[index])) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed the equality check

throw new Error(
`Error validating execution payload during block construction: KZG commitment supplied by execution client does not match that computed by Lodestar. At index ${index}. Computed: ${computedCommitment} but blobs bundle contained ${blobKzgCommitments[index]}`
);
Expand Down
1 change: 0 additions & 1 deletion packages/beacon-node/src/execution/engine/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ export class ExecutionEngineMock implements IExecutionEngine {
blockHash: new Uint8Array(),
kzgs: [],
blobs: [],
aggregatedProof: new Uint8Array(),
};
}

Expand Down
1 change: 0 additions & 1 deletion packages/state-transition/src/block/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export function processBlock(
// https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/beacon-chain.md#block-processing
if (fork >= ForkSeq.eip4844 && verifyBlobs) {
const body = block.body as eip4844.BeaconBlockBody;
console.log("Running state transition processBlock for block #", body.executionPayload.blockNumber);
processBlobKzgCommitments(body);

// New in EIP-4844, note: Can sync optimistically without this condition, see note on `is_data_available`
Expand Down
21 changes: 5 additions & 16 deletions packages/state-transition/src/util/blobs/isDataAvailable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function isDataAvailable(
beaconBlockRoot: Root,
blobKzgCommitments: KZGCommitment[]
): boolean {
console.log("Running isDataAvailable");
if (!sidecar) {
return false;
}
Expand Down Expand Up @@ -73,20 +72,10 @@ function validateBlobsSidecar(
);
}

// assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof)
let isProofValid = false;
try {
isProofValid = verifyAggregateKzgProof(blobs, expectedKzgCommitments, kzgAggregatedProof);
} catch (e) {
// Temporary -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here
console.log("An exception was throw during verifyAggregateKzgProof. code 1 = bad arguments", e);
// throw e;
return;
}

// Temporary -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here
if (!isProofValid) {
console.log("aggregate KZG proof was not valid", kzgAggregatedProof);
// throw new BlobsSidecarValidationError(`aggregate KZG proof was not valid ${kzgAggregatedProof}`);
// No need to verify the aggregate proof of zero blobs. Also c-kzg throws.
// https://github.com/dankrad/c-kzg/pull/12/files#r1025851956
if (blobs.length) {
// assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof)
verifyAggregateKzgProof(blobs, expectedKzgCommitments, kzgAggregatedProof);
}
}