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

DO NOT MERGE, only for rebase testing #14391

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3555a65
Add in column sidecars protos (#13862)
nalepae Jul 17, 2024
bb76ce2
add it (#13865)
nisdas Apr 11, 2024
6e42f3d
add in networking params (#13866)
nisdas Apr 11, 2024
f6ae4ce
Add Support For Discovery Of Column Subnets (#13883)
nisdas Apr 17, 2024
e208e83
Add Data Column Gossip Handlers (#13894)
nisdas Apr 22, 2024
fdecb12
Add Request And Response RPC Methods For Data Columns (#13909)
nisdas Apr 24, 2024
e8c1a7e
Peer das core (#13877)
nalepae Apr 24, 2024
2693723
Implement `custody_subnet_count` ENR field. (#13915)
nalepae Apr 24, 2024
90cf1ea
Update .bazelrc (#13931)
nisdas Apr 29, 2024
572ceb2
Implement peer DAS proposer RPC (#13922)
nalepae Apr 30, 2024
3ea4c4e
Add DA Check For Data Columns (#13938)
nisdas May 2, 2024
47ef948
Spectests (#13940)
nalepae May 2, 2024
89df093
`SendDataColumnSidecarByRoot`: Return `RODataColumn` instead of `ROBl…
nalepae May 7, 2024
a65f64b
[PeerDAS] Upgrade c-kzg-4844 package (#13967)
jtraglia May 9, 2024
09e5b5f
Enable E2E For PeerDAS (#13945)
nisdas May 13, 2024
064da69
Implement Data Columns By Range Request And Response Methods (#13972)
nisdas May 14, 2024
573d7ec
Sample from peers some data columns. (#13980)
nalepae May 15, 2024
1411f89
Set Custody Count Correctly (#14004)
nisdas May 16, 2024
171e768
Fix beacon chain config. (#14017)
nalepae May 17, 2024
552629d
Fix `CustodyColumns` to comply with alpha-2 spectests. (#14008)
nalepae May 17, 2024
e4ec873
Request Data Columns When Fetching Pending Blocks (#14007)
nisdas May 17, 2024
a4fa492
Disable Evaluators For E2E (#14019)
nisdas May 17, 2024
2c7f3bd
Fix Custody Columns (#14021)
nisdas May 17, 2024
276684b
PeerDAS: Implement reconstruction. (#14036)
nalepae May 29, 2024
98bfe2b
PeerDAS: Implement / use data column feed from database. (#14062)
nalepae Jun 4, 2024
e221320
PeerDAS: Withhold data on purpose. (#14076)
nalepae Jun 4, 2024
2457327
`recoverBlobs`: Cover the `0 < blobsCount < fieldparams.MaxBlobsPerBl…
nalepae Jun 4, 2024
496352d
PeerDAS: Only saved custodied columns even after reconstruction. (#14…
nalepae Jun 6, 2024
90331a9
PeerDAS: Gossip the reconstructed columns (#14079)
nalepae Jun 6, 2024
d01c448
PeerDAS: Stop generating new P2P private key at start. (#14099)
nalepae Jun 12, 2024
e625374
[PeerDAS] rework ENR custody_subnet_count and add tests (#14077)
0x00101010 Jun 12, 2024
90badee
[PeerDAS] fixes and tests for gossiping out data columns (#14102)
0x00101010 Jun 13, 2024
0fb3c1a
[PeerDAS] implement DataColumnSidecarsByRootReq and fix related bugs …
0x00101010 Jun 14, 2024
e0c39fa
Fix columns sampling (#14118)
nalepae Jun 18, 2024
6eb56a9
PeerDAS: move custody subnet count into helper function (#14117)
0x00101010 Jun 20, 2024
5cf08b4
PeerDAS: add data column batch config (#14122)
0x00101010 Jun 21, 2024
3f6a28f
PeerDAS: Implement IncrementalDAS (#14109)
nalepae Jun 21, 2024
f7a9d60
chore: Encapsulate all kzg functionality for PeerDAS into the kzg pac…
kevaundray Jul 3, 2024
1121c48
chore!: Refactor `RecoverBlob` to `RecoverCellsAndProofs` (#14160)
kevaundray Jul 3, 2024
dd2f522
Activate PeerDAS with the EIP7594 Fork Epoch (#14184)
nisdas Jul 8, 2024
afde039
Move log from error to debug. (#14194)
nalepae Jul 8, 2024
5722193
chore!: Make Cell be a flat sequence of bytes (#14159)
kevaundray Jul 9, 2024
0724db0
PeerDAS: Add KZG verification when sampling (#14187)
nalepae Jul 9, 2024
5b3e252
Trigger PeerDAS At Deneb For E2E (#14193)
nisdas Jul 9, 2024
d699427
chore!: Use `RecoverCellsAndKZGProofs` instead of `RecoverAllCells ` …
kevaundray Jul 9, 2024
91a6f27
[PeerDAS] Parallelize data column sampling (#14105)
0x00101010 Jul 16, 2024
7dd280d
Implement and use `filterPeerForDataColumnsSubnet`. (#14230)
nalepae Jul 17, 2024
71bd64a
Add Current Changes (#14231)
nisdas Jul 17, 2024
91239ca
Update ckzg4844 to latest version of das branch (#14223)
jtraglia Jul 17, 2024
5c4e378
PeerDAS: Run reconstruction in parallel. (#14236)
nalepae Jul 18, 2024
5e7dc86
Make deepsource happy (#14237)
nalepae Jul 19, 2024
1e75690
PeerDAS: Fix initial sync (#14208)
nalepae Jul 25, 2024
ca7f3df
Fix data columns sampling (#14263)
nalepae Jul 29, 2024
8557218
PeerDAS: Add `MetadataV3` with `custody_subnet_count` (#14274)
nalepae Aug 5, 2024
5b87e54
Add Data Column Verification (#14287)
nisdas Aug 12, 2024
e74d7b6
Implement `/eth/v1/beacon/blob_sidecars/{block_id}` for peerDAS. (#14…
nalepae Aug 14, 2024
9612e3a
Fix CI in PeerDAS (#14347)
nisdas Aug 15, 2024
1f5276a
Update Config To Latest Value (#14352)
nisdas Aug 22, 2024
ef86a0e
Use Data Column Validation Across Prysm (#14377)
nisdas Aug 26, 2024
bd7ec3f
Change Custody Count to Uint8 (#14386)
nisdas Aug 27, 2024
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
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ coverage --define=coverage_enabled=1
build --workspace_status_command=./hack/workspace_status.sh

build --define blst_disabled=false
build --compilation_mode=opt
run --define blst_disabled=false

build:blst_disabled --define blst_disabled=true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Golangci-lint
uses: golangci/golangci-lint-action@v5
with:
version: v1.55.2
version: v1.56.1
args: --config=.golangci.yml --out-${NO_FUTURE}format colored-line-number

build:
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ linters:
- promlinter
- protogetter
- revive
- spancheck
- staticcheck
- stylecheck
- tagalign
Expand Down
3 changes: 3 additions & 0 deletions beacon-chain/blockchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ go_library(
"receive_attestation.go",
"receive_blob.go",
"receive_block.go",
"receive_data_column.go",
"service.go",
"tracked_proposer.go",
"weak_subjectivity_checks.go",
Expand All @@ -48,6 +49,7 @@ go_library(
"//beacon-chain/core/feed/state:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/light-client:go_default_library",
"//beacon-chain/core/peerdas:go_default_library",
"//beacon-chain/core/signing:go_default_library",
"//beacon-chain/core/time:go_default_library",
"//beacon-chain/core/transition:go_default_library",
Expand Down Expand Up @@ -158,6 +160,7 @@ go_test(
"//beacon-chain/operations/slashings:go_default_library",
"//beacon-chain/operations/voluntaryexits:go_default_library",
"//beacon-chain/p2p:go_default_library",
"//beacon-chain/p2p/testing:go_default_library",
"//beacon-chain/startup:go_default_library",
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/state-native:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/blockchain/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
)

var errMaxBlobsExceeded = errors.New("Expected commitments in block exceeds MAX_BLOBS_PER_BLOCK")
var errMaxDataColumnsExceeded = errors.New("Expected data columns for node exceeds NUMBER_OF_COLUMNS")

// An invalid block is the block that fails state transition based on the core protocol rules.
// The beacon node shall not be accepting nor building blocks that branch off from an invalid block.
Expand Down
4 changes: 4 additions & 0 deletions beacon-chain/blockchain/kzg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"kzg.go",
"trusted_setup.go",
"validation.go",
],
Expand All @@ -12,6 +13,9 @@ go_library(
deps = [
"//consensus-types/blocks:go_default_library",
"@com_github_crate_crypto_go_kzg_4844//:go_default_library",
"@com_github_ethereum_c_kzg_4844//bindings/go:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_ethereum_go_ethereum//crypto/kzg4844:go_default_library",
"@com_github_pkg_errors//:go_default_library",
],
)
Expand Down
109 changes: 109 additions & 0 deletions beacon-chain/blockchain/kzg/kzg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package kzg

import (
"errors"

ckzg4844 "github.com/ethereum/c-kzg-4844/bindings/go"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
)

// BytesPerBlob is the number of bytes in a single blob.
const BytesPerBlob = ckzg4844.BytesPerBlob

// Blob represents a serialized chunk of data.
type Blob [BytesPerBlob]byte

// BytesPerCell is the number of bytes in a single cell.
const BytesPerCell = ckzg4844.BytesPerCell

// Cell represents a chunk of an encoded Blob.
type Cell [BytesPerCell]byte

// Commitment represent a KZG commitment to a Blob.
type Commitment [48]byte

// Proof represents a KZG proof that attests to the validity of a Blob or parts of it.
type Proof [48]byte

// Bytes48 is a 48-byte array.
type Bytes48 = ckzg4844.Bytes48

// Bytes32 is a 32-byte array.
type Bytes32 = ckzg4844.Bytes32

// CellsAndProofs represents the Cells and Proofs corresponding to
// a single blob.
type CellsAndProofs struct {
Cells []Cell
Proofs []Proof
}

func BlobToKZGCommitment(blob *Blob) (Commitment, error) {
comm, err := kzg4844.BlobToCommitment(kzg4844.Blob(*blob))
if err != nil {
return Commitment{}, err
}
return Commitment(comm), nil
}

func ComputeBlobKZGProof(blob *Blob, commitment Commitment) (Proof, error) {
proof, err := kzg4844.ComputeBlobProof(kzg4844.Blob(*blob), kzg4844.Commitment(commitment))
if err != nil {
return [48]byte{}, err
}
return Proof(proof), nil
}

func ComputeCellsAndKZGProofs(blob *Blob) (CellsAndProofs, error) {
ckzgBlob := (*ckzg4844.Blob)(blob)
ckzgCells, ckzgProofs, err := ckzg4844.ComputeCellsAndKZGProofs(ckzgBlob)
if err != nil {
return CellsAndProofs{}, err
}

return makeCellsAndProofs(ckzgCells[:], ckzgProofs[:])
}

func VerifyCellKZGProofBatch(commitmentsBytes []Bytes48, cellIndices []uint64, cells []Cell, proofsBytes []Bytes48) (bool, error) {
// Convert `Cell` type to `ckzg4844.Cell`
ckzgCells := make([]ckzg4844.Cell, len(cells))
for i := range cells {
ckzgCells[i] = ckzg4844.Cell(cells[i])
}

return ckzg4844.VerifyCellKZGProofBatch(commitmentsBytes, cellIndices, ckzgCells, proofsBytes)
}

func RecoverCellsAndKZGProofs(cellIndices []uint64, partialCells []Cell) (CellsAndProofs, error) {
// Convert `Cell` type to `ckzg4844.Cell`
ckzgPartialCells := make([]ckzg4844.Cell, len(partialCells))
for i := range partialCells {
ckzgPartialCells[i] = ckzg4844.Cell(partialCells[i])
}

ckzgCells, ckzgProofs, err := ckzg4844.RecoverCellsAndKZGProofs(cellIndices, ckzgPartialCells)
if err != nil {
return CellsAndProofs{}, err
}

return makeCellsAndProofs(ckzgCells[:], ckzgProofs[:])
}

// Convert cells/proofs to the CellsAndProofs type defined in this package.
func makeCellsAndProofs(ckzgCells []ckzg4844.Cell, ckzgProofs []ckzg4844.KZGProof) (CellsAndProofs, error) {
if len(ckzgCells) != len(ckzgProofs) {
return CellsAndProofs{}, errors.New("different number of cells/proofs")
}

var cells []Cell
var proofs []Proof
for i := range ckzgCells {
cells = append(cells, Cell(ckzgCells[i]))
proofs = append(proofs, Proof(ckzgProofs[i]))
}

return CellsAndProofs{
Cells: cells,
Proofs: proofs,
}, nil
}
44 changes: 41 additions & 3 deletions beacon-chain/blockchain/kzg/trusted_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,62 @@ import (
"encoding/json"

GoKZG "github.com/crate-crypto/go-kzg-4844"
CKZG "github.com/ethereum/c-kzg-4844/bindings/go"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
)

var (
//go:embed trusted_setup.json
embeddedTrustedSetup []byte // 1.2Mb
kzgContext *GoKZG.Context
kzgLoaded bool
)

type TrustedSetup struct {
G1Monomial [GoKZG.ScalarsPerBlob]GoKZG.G1CompressedHexStr `json:"g1_monomial"`
G1Lagrange [GoKZG.ScalarsPerBlob]GoKZG.G1CompressedHexStr `json:"g1_lagrange"`
G2Monomial [65]GoKZG.G2CompressedHexStr `json:"g2_monomial"`
}

func Start() error {
parsedSetup := GoKZG.JSONTrustedSetup{}
err := json.Unmarshal(embeddedTrustedSetup, &parsedSetup)
trustedSetup := &TrustedSetup{}
err := json.Unmarshal(embeddedTrustedSetup, trustedSetup)
if err != nil {
return errors.Wrap(err, "could not parse trusted setup JSON")
}
kzgContext, err = GoKZG.NewContext4096(&parsedSetup)
kzgContext, err = GoKZG.NewContext4096(&GoKZG.JSONTrustedSetup{
SetupG2: trustedSetup.G2Monomial[:],
SetupG1Lagrange: trustedSetup.G1Lagrange})
if err != nil {
return errors.Wrap(err, "could not initialize go-kzg context")
}

// Length of a G1 point, converted from hex to binary.
g1MonomialBytes := make([]byte, len(trustedSetup.G1Monomial)*(len(trustedSetup.G1Monomial[0])-2)/2)
for i, g1 := range &trustedSetup.G1Monomial {
copy(g1MonomialBytes[i*(len(g1)-2)/2:], hexutil.MustDecode(g1))
}
// Length of a G1 point, converted from hex to binary.
g1LagrangeBytes := make([]byte, len(trustedSetup.G1Lagrange)*(len(trustedSetup.G1Lagrange[0])-2)/2)
for i, g1 := range &trustedSetup.G1Lagrange {
copy(g1LagrangeBytes[i*(len(g1)-2)/2:], hexutil.MustDecode(g1))
}
// Length of a G2 point, converted from hex to binary.
g2MonomialBytes := make([]byte, len(trustedSetup.G2Monomial)*(len(trustedSetup.G2Monomial[0])-2)/2)
for i, g2 := range &trustedSetup.G2Monomial {
copy(g2MonomialBytes[i*(len(g2)-2)/2:], hexutil.MustDecode(g2))
}
if !kzgLoaded {
// TODO: Provide a configuration option for this.
var precompute uint = 0

// Free the current trusted setup before running this method. CKZG
// panics if the same setup is run multiple times.
if err = CKZG.LoadTrustedSetup(g1MonomialBytes, g1LagrangeBytes, g2MonomialBytes, precompute); err != nil {
panic(err)
}
}
kzgLoaded = true
return nil
}
Loading
Loading