Skip to content

Commit

Permalink
Update Config To Latest Value (#14352)
Browse files Browse the repository at this point in the history
* Update values

* Update Spec To v1.5.0-alpha.5

* Fix Discovery Tests

* Hardcode Subnet Count For Tests

* Fix All Initial Sync Tests

* Gazelle

* Less Chaotic Service Initialization

* Gazelle
  • Loading branch information
nisdas authored and nalepae committed Nov 25, 2024
1 parent 326a6c2 commit ad4f801
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 125 deletions.
4 changes: 2 additions & 2 deletions beacon-chain/p2p/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func TestCreateLocalNode(t *testing.T) {
// Check custody_subnet_count config.
custodySubnetCount := new(uint64)
require.NoError(t, localNode.Node().Record().Load(enr.WithEntry(peerdas.CustodySubnetCountEnrKey, custodySubnetCount)))
require.Equal(t, uint64(1), *custodySubnetCount)
require.Equal(t, params.BeaconConfig().CustodyRequirement, *custodySubnetCount)
})
}
}
Expand Down Expand Up @@ -629,7 +629,7 @@ func TestRefreshPersistentSubnets(t *testing.T) {
eip7594ForkEpoch = 10
)

custodySubnetCount := uint64(1)
custodySubnetCount := params.BeaconConfig().CustodyRequirement

// Set up epochs.
defaultCfg := params.BeaconConfig()
Expand Down
5 changes: 3 additions & 2 deletions beacon-chain/p2p/testing/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
type TestP2P struct {
t *testing.T
BHost host.Host
EnodeID enode.ID
pubsub *pubsub.PubSub
joinedTopics map[string]*pubsub.Topic
BroadcastCalled atomic.Bool
Expand Down Expand Up @@ -292,8 +293,8 @@ func (*TestP2P) ENR() *enr.Record {
}

// NodeID returns the node id of the local peer.
func (*TestP2P) NodeID() enode.ID {
return [32]byte{}
func (p *TestP2P) NodeID() enode.ID {
return p.EnodeID
}

// DiscoveryAddresses --
Expand Down
35 changes: 30 additions & 5 deletions beacon-chain/sync/data_columns_sampling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"crypto/sha256"
"encoding/binary"
"fmt"
"testing"

"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
Expand Down Expand Up @@ -203,12 +204,14 @@ func TestDataColumnSampler1D_PeerManagement(t *testing.T) {
testCases := []struct {
numPeers int
custodyRequirement uint64
subnetCount uint64
expectedColumns [][]uint64
prunePeers map[int]bool // Peers to prune.
}{
{
numPeers: 3,
custodyRequirement: 1,
subnetCount: 32,
expectedColumns: [][]uint64{
{6, 38, 70, 102},
{3, 35, 67, 99},
Expand All @@ -221,6 +224,7 @@ func TestDataColumnSampler1D_PeerManagement(t *testing.T) {
{
numPeers: 3,
custodyRequirement: 2,
subnetCount: 32,
expectedColumns: [][]uint64{
{6, 16, 38, 48, 70, 80, 102, 112},
{3, 13, 35, 45, 67, 77, 99, 109},
Expand All @@ -232,7 +236,12 @@ func TestDataColumnSampler1D_PeerManagement(t *testing.T) {
},
}

params.SetupTestConfigCleanup(t)
for _, tc := range testCases {
cfg := params.BeaconConfig()
cfg.CustodyRequirement = tc.custodyRequirement
cfg.DataColumnSidecarSubnetCount = tc.subnetCount
params.OverrideBeaconConfig(cfg)
test, sampler := setupDataColumnSamplerTest(t, uint64(tc.numPeers))
for i := 0; i < tc.numPeers; i++ {
p := createAndConnectPeer(t, test.p2pSvc, test.chainSvc, test.dataColumnSidecars, tc.custodyRequirement, nil, i+1)
Expand Down Expand Up @@ -282,12 +291,14 @@ func TestDataColumnSampler1D_SampleDistribution(t *testing.T) {
testCases := []struct {
numPeers int
custodyRequirement uint64
subnetCount uint64
columnsToDistribute [][]uint64
expectedDistribution []map[int][]uint64
}{
{
numPeers: 3,
custodyRequirement: 1,
subnetCount: 32,
// peer custody maps
// p0: {6, 38, 70, 102},
// p1: {3, 35, 67, 99},
Expand Down Expand Up @@ -318,6 +329,7 @@ func TestDataColumnSampler1D_SampleDistribution(t *testing.T) {
{
numPeers: 3,
custodyRequirement: 2,
subnetCount: 32,
// peer custody maps
// p0: {6, 16, 38, 48, 70, 80, 102, 112},
// p1: {3, 13, 35, 45, 67, 77, 99, 109},
Expand All @@ -340,8 +352,12 @@ func TestDataColumnSampler1D_SampleDistribution(t *testing.T) {
},
},
}

params.SetupTestConfigCleanup(t)
for _, tc := range testCases {
cfg := params.BeaconConfig()
cfg.CustodyRequirement = tc.custodyRequirement
cfg.DataColumnSidecarSubnetCount = tc.subnetCount
params.OverrideBeaconConfig(cfg)
test, sampler := setupDataColumnSamplerTest(t, uint64(tc.numPeers))
for i := 0; i < tc.numPeers; i++ {
p := createAndConnectPeer(t, test.p2pSvc, test.chainSvc, test.dataColumnSidecars, tc.custodyRequirement, nil, i+1)
Expand All @@ -351,7 +367,7 @@ func TestDataColumnSampler1D_SampleDistribution(t *testing.T) {

for idx, columns := range tc.columnsToDistribute {
result := sampler.distributeSamplesToPeer(columns)
require.Equal(t, len(tc.expectedDistribution[idx]), len(result))
require.Equal(t, len(tc.expectedDistribution[idx]), len(result), fmt.Sprintf("%v - %v", tc.expectedDistribution[idx], result))

for peerIdx, dist := range tc.expectedDistribution[idx] {
for _, column := range dist {
Expand All @@ -364,6 +380,10 @@ func TestDataColumnSampler1D_SampleDistribution(t *testing.T) {
}

func TestDataColumnSampler1D_SampleDataColumns(t *testing.T) {
params.SetupTestConfigCleanup(t)
cfg := params.BeaconConfig()
cfg.DataColumnSidecarSubnetCount = 32
params.OverrideBeaconConfig(cfg)
test, sampler := setupDefaultDataColumnSamplerTest(t)
sampler.refreshPeerInfo()

Expand Down Expand Up @@ -391,6 +411,11 @@ func TestDataColumnSampler1D_SampleDataColumns(t *testing.T) {
}

func TestDataColumnSampler1D_IncrementalDAS(t *testing.T) {
params.SetupTestConfigCleanup(t)
cfg := params.BeaconConfig()
cfg.DataColumnSidecarSubnetCount = 32
params.OverrideBeaconConfig(cfg)

testCases := []struct {
name string
samplesCount uint64
Expand Down Expand Up @@ -450,9 +475,9 @@ func TestDataColumnSampler1D_IncrementalDAS(t *testing.T) {

for _, tc := range testCases {
test, sampler := setupDataColumnSamplerTest(t, 3)
p1 := createAndConnectPeer(t, test.p2pSvc, test.chainSvc, test.dataColumnSidecars, 1, tc.columnsNotToRespond, 1)
p2 := createAndConnectPeer(t, test.p2pSvc, test.chainSvc, test.dataColumnSidecars, 1, tc.columnsNotToRespond, 2)
p3 := createAndConnectPeer(t, test.p2pSvc, test.chainSvc, test.dataColumnSidecars, 1, tc.columnsNotToRespond, 3)
p1 := createAndConnectPeer(t, test.p2pSvc, test.chainSvc, test.dataColumnSidecars, params.BeaconConfig().CustodyRequirement, tc.columnsNotToRespond, 1)
p2 := createAndConnectPeer(t, test.p2pSvc, test.chainSvc, test.dataColumnSidecars, params.BeaconConfig().CustodyRequirement, tc.columnsNotToRespond, 2)
p3 := createAndConnectPeer(t, test.p2pSvc, test.chainSvc, test.dataColumnSidecars, params.BeaconConfig().CustodyRequirement, tc.columnsNotToRespond, 3)
test.peers = []*p2ptest.TestP2P{p1, p2, p3}

sampler.refreshPeerInfo()
Expand Down
Loading

0 comments on commit ad4f801

Please sign in to comment.