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

[Peerdas DO NOT MERGE] CI Tests before rebase #14656

Draft
wants to merge 84 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
c688c84
Add in column sidecars protos (#13862)
nalepae Jul 17, 2024
3e23f6e
add it (#13865)
nisdas Apr 11, 2024
9ffc19d
Add Support For Discovery Of Column Subnets (#13883)
nisdas Apr 17, 2024
d844026
Add Data Column Gossip Handlers (#13894)
nisdas Apr 22, 2024
3e722ea
Add Request And Response RPC Methods For Data Columns (#13909)
nisdas Apr 24, 2024
1bfbd39
Peer das core (#13877)
nalepae Apr 24, 2024
f503efc
Implement `custody_subnet_count` ENR field. (#13915)
nalepae Apr 24, 2024
b78c348
Update .bazelrc (#13931)
nisdas Apr 29, 2024
1355178
Implement peer DAS proposer RPC (#13922)
nalepae Apr 30, 2024
be0580e
Add DA Check For Data Columns (#13938)
nisdas May 2, 2024
dcbb543
Spectests (#13940)
nalepae May 2, 2024
8bd10df
`SendDataColumnSidecarByRoot`: Return `RODataColumn` instead of `ROBl…
nalepae May 7, 2024
b0ea450
[PeerDAS] Upgrade c-kzg-4844 package (#13967)
jtraglia May 9, 2024
32ce642
Enable E2E For PeerDAS (#13945)
nisdas May 13, 2024
6daa91c
Implement Data Columns By Range Request And Response Methods (#13972)
nisdas May 14, 2024
5e4deff
Sample from peers some data columns. (#13980)
nalepae May 15, 2024
c032e78
Set Custody Count Correctly (#14004)
nisdas May 16, 2024
496914c
Fix `CustodyColumns` to comply with alpha-2 spectests. (#14008)
nalepae May 17, 2024
013cb28
Request Data Columns When Fetching Pending Blocks (#14007)
nisdas May 17, 2024
e206506
Disable Evaluators For E2E (#14019)
nisdas May 17, 2024
b0ba05b
Fix Custody Columns (#14021)
nisdas May 17, 2024
d3c12ab
PeerDAS: Implement reconstruction. (#14036)
nalepae May 29, 2024
42f4c0f
PeerDAS: Implement / use data column feed from database. (#14062)
nalepae Jun 4, 2024
1e335e2
PeerDAS: Withhold data on purpose. (#14076)
nalepae Jun 4, 2024
0a010b5
`recoverBlobs`: Cover the `0 < blobsCount < fieldparams.MaxBlobsPerBl…
nalepae Jun 4, 2024
a7dc2e6
PeerDAS: Only saved custodied columns even after reconstruction. (#14…
nalepae Jun 6, 2024
81f4db0
PeerDAS: Gossip the reconstructed columns (#14079)
nalepae Jun 6, 2024
7a84729
PeerDAS: Stop generating new P2P private key at start. (#14099)
nalepae Jun 12, 2024
6e21220
[PeerDAS] rework ENR custody_subnet_count and add tests (#14077)
0x00101010 Jun 12, 2024
b6bad93
[PeerDAS] fixes and tests for gossiping out data columns (#14102)
0x00101010 Jun 13, 2024
7dd2fd5
[PeerDAS] implement DataColumnSidecarsByRootReq and fix related bugs …
0x00101010 Jun 14, 2024
bfdb6da
Fix columns sampling (#14118)
nalepae Jun 18, 2024
d0a3b9b
[PeerDAS] rework ENR custody_subnet_count and add tests (#14077)
0x00101010 Jun 20, 2024
78f90db
PeerDAS: add data column batch config (#14122)
0x00101010 Jun 21, 2024
48cf24e
PeerDAS: Implement IncrementalDAS (#14109)
nalepae Jun 21, 2024
2697794
chore: Encapsulate all kzg functionality for PeerDAS into the kzg pac…
kevaundray Jul 3, 2024
b469157
chore!: Refactor `RecoverBlob` to `RecoverCellsAndProofs` (#14160)
kevaundray Jul 3, 2024
dc2c90b
Activate PeerDAS with the EIP7594 Fork Epoch (#14184)
nisdas Jul 8, 2024
2845d87
Move log from error to debug. (#14194)
nalepae Jul 8, 2024
ac4c5fa
chore!: Make Cell be a flat sequence of bytes (#14159)
kevaundray Jul 9, 2024
54affa8
PeerDAS: Add KZG verification when sampling (#14187)
nalepae Jul 9, 2024
07fe76c
Trigger PeerDAS At Deneb For E2E (#14193)
nisdas Jul 9, 2024
7a256e9
chore!: Use `RecoverCellsAndKZGProofs` instead of `RecoverAllCells ` …
kevaundray Jul 9, 2024
d21c2bd
[PeerDAS] Parallelize data column sampling (#14105)
0x00101010 Jul 16, 2024
b40a8ed
Implement and use `filterPeerForDataColumnsSubnet`. (#14230)
nalepae Jul 17, 2024
000d480
Add Current Changes (#14231)
nisdas Jul 17, 2024
0517d76
Update ckzg4844 to latest version of das branch (#14223)
jtraglia Jul 17, 2024
6403064
PeerDAS: Run reconstruction in parallel. (#14236)
nalepae Jul 18, 2024
345e6ed
Make deepsource happy (#14237)
nalepae Jul 19, 2024
ca63efa
PeerDAS: Fix initial sync (#14208)
nalepae Jul 25, 2024
1995431
Fix data columns sampling (#14263)
nalepae Jul 29, 2024
e788a46
PeerDAS: Add `MetadataV3` with `custody_subnet_count` (#14274)
nalepae Aug 5, 2024
d75a7aa
Add Data Column Verification (#14287)
nisdas Aug 12, 2024
a732fe7
Implement `/eth/v1/beacon/blob_sidecars/{block_id}` for peerDAS. (#14…
nalepae Aug 14, 2024
0c91707
Fix CI in PeerDAS (#14347)
nisdas Aug 15, 2024
81b7a17
Update Config To Latest Value (#14352)
nisdas Aug 22, 2024
3652bec
Use Data Column Validation Across Prysm (#14377)
nisdas Aug 26, 2024
d1e43a2
Change Custody Count to Uint8 (#14386)
nisdas Aug 27, 2024
68da7da
Fix Bugs in PeerDAS Testing (#14396)
nisdas Aug 29, 2024
f58cf7e
PeerDAS: Improve logging and reduce the number of needed goroutines f…
nalepae Aug 29, 2024
a26980b
Set Precompute at 8 (#14399)
nisdas Aug 30, 2024
f92eb44
Add Data Column Computation Metrics (#14400)
nisdas Aug 30, 2024
db44df3
Fix Initial Sync with 128 data columns subnets (#14403)
nalepae Sep 3, 2024
2de1e6f
Revert "Change Custody Count to Uint8 (#14386)" (#14415)
nisdas Sep 4, 2024
2191faa
Fix CPU usage in small devnets (#14446)
nalepae Sep 13, 2024
c20c09c
Peerdas: Full subnet sampling and `sendBatchRootRequest` fix. (#14452)
nalepae Sep 18, 2024
83df293
Peerdas: Several updates (#14459)
nalepae Sep 19, 2024
19221b7
Update c-kzg-4844 to v2.0.1 (#14421)
jtraglia Sep 20, 2024
31d16da
PeerDAS: Multiple improvements (#14467)
nalepae Sep 23, 2024
77a6d29
PeerDAS: Re-enable full node joining the main fork (#14475)
nalepae Sep 24, 2024
f2b61a3
PeerDAS: Misc improvements (#14482)
nalepae Sep 26, 2024
f65f12f
Stop disconnecting peers for bad response / excessive colocation. (#1…
nalepae Sep 26, 2024
92f9b55
Put Subscriber in Goroutine (#14486)
nisdas Sep 27, 2024
01dbc33
PeerDAS: Fix initial sync (#14494)
nalepae Oct 1, 2024
43761a8
PeerDAS: Fix initial sync with super nodes (#14495)
nalepae Oct 1, 2024
a14634e
PeerDAS: Improve initial sync logs (#14496)
nalepae Oct 2, 2024
da53a8f
Fix Commitments Check (#14493)
nisdas Oct 4, 2024
e21261e
Data columns initial sync: Rework. (#14522)
nalepae Oct 15, 2024
9be69fb
PeerDAS: Fix major bug in `dataColumnSidecarsByRangeRPCHandler` and a…
nalepae Oct 16, 2024
9dac676
`streamDataColumnBatch`: Sort columns by index. (#14542)
nalepae Oct 16, 2024
3432ffa
PeerDAS: Batch columns verifications (#14559)
nalepae Oct 23, 2024
5f17317
Revert "Add error count prom metric (#14670)"
nalepae Nov 28, 2024
6537f80
Merge branch 'peerDAS' into peerDAS-do-not-merge
nalepae Nov 28, 2024
453ea01
`disconnectFromPeer`: Remove unused function.
nalepae Nov 28, 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
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- PeerDAS: Added proto for `DataColumnIdentifier`, `DataColumnSidecar`, `DataColumnSidecarsByRangeRequest` and `MetadataV2`.
- Better attestation packing for Electra. [PR](https://github.com/prysmaticlabs/prysm/pull/14534)
- P2P: Add logs when a peer is (dis)connected. Add the reason of the disconnection when we initiate it.
- Added a Prometheus error counter metric for HTTP requests to track beacon node requests.

### Changed

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 @@ -157,6 +159,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/v2/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/v2/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 = 8

// 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