mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 23:48:06 -05:00
* Fulu: Implement params. * KZG tests: Re-implement `getRandBlob` to avoid tests cyclical dependencies. Not ideal, but any better idea welcome. * Fulu testing util: Implement `GenerateCellsAndProofs`. * Create `RODataColumn`. * Implement `MerkleProofKZGCommitments`. * Export `leavesFromCommitments`. * Implement peerDAS core. * Add changelog. * Update beacon-chain/core/peerdas/das_core.go Co-authored-by: terence <terence@prysmaticlabs.com> * Fix Terence's comment: Use `IsNil`. * Fix Terence's comment: Avoid useless `filteredIndices`. * Fix Terence's comment: Simplify odd/even cases. * Fix Terence's comment: Use `IsNil`. * Spectests: Add Fulu networking * Fix Terence's comment: `CustodyGroups`: Stick to the spec by returning a (sorted) slice. * Fix Terence's comment: `CustodyGroups`: Handle correctly the `maxUint256` case. * Update beacon-chain/core/peerdas/das_core.go Co-authored-by: terence <terence@prysmaticlabs.com> * Fix Terence's comment: `ComputeColumnsForCustodyGroup`: Add test if `custodyGroup == numberOfCustodyGroup` * `CustodyGroups`: Test if `custodyGroupCount > numberOfCustodyGroup`. * `CustodyGroups`: Add a shortcut if all custody groups are needed. * `ComputeCystodyGroupForColumn`: Move from `p2p_interface.go` to `das_core.go`. * Fix Terence's comment: Fix `ComputeCustodyGroupForColumn`. * Fix Terence's comment: Remove `constructCellsAndProofs` function. * Fix Terence's comment: `ValidatorsCustodyRequirement`: Use effective balance instead of balance. * `MerkleProofKZGCommitments`: Add tests * Remove peer sampling. * `DataColumnSidecars`: Add missing tests. * Fix Jame's comment. * Fix James' comment. * Fix James' comment. * Fix James' coment. * Fix James' comment. --------- Co-authored-by: terence <terence@prysmaticlabs.com>
58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
package peerdas_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/peerdas"
|
|
"github.com/OffchainLabs/prysm/v6/config/params"
|
|
"github.com/OffchainLabs/prysm/v6/testing/require"
|
|
)
|
|
|
|
func TestCanSelfReconstruct(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
totalNumberOfCustodyGroups uint64
|
|
custodyNumberOfGroups uint64
|
|
expected bool
|
|
}{
|
|
{
|
|
name: "totalNumberOfCustodyGroups=64, custodyNumberOfGroups=31",
|
|
totalNumberOfCustodyGroups: 64,
|
|
custodyNumberOfGroups: 31,
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "totalNumberOfCustodyGroups=64, custodyNumberOfGroups=32",
|
|
totalNumberOfCustodyGroups: 64,
|
|
custodyNumberOfGroups: 32,
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "totalNumberOfCustodyGroups=65, custodyNumberOfGroups=32",
|
|
totalNumberOfCustodyGroups: 65,
|
|
custodyNumberOfGroups: 32,
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "totalNumberOfCustodyGroups=63, custodyNumberOfGroups=33",
|
|
totalNumberOfCustodyGroups: 65,
|
|
custodyNumberOfGroups: 33,
|
|
expected: true,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
// Set the total number of columns.
|
|
params.SetupTestConfigCleanup(t)
|
|
cfg := params.BeaconConfig().Copy()
|
|
cfg.NumberOfCustodyGroups = tc.totalNumberOfCustodyGroups
|
|
params.OverrideBeaconConfig(cfg)
|
|
|
|
// Check if reconstuction is possible.
|
|
actual := peerdas.CanSelfReconstruct(tc.custodyNumberOfGroups)
|
|
require.Equal(t, tc.expected, actual)
|
|
})
|
|
}
|
|
}
|