Skip to content

Commit

Permalink
PeerDAS: Withhold data on purpose. (#14076)
Browse files Browse the repository at this point in the history
* Introduce hidden flag `data-columns-withhold-count`.

* Address Nishant's comment.
  • Loading branch information
nalepae committed Oct 8, 2024
1 parent 53d43f5 commit 7147136
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
22 changes: 18 additions & 4 deletions beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,28 @@ func (vs *Server) broadcastAndReceiveBlobs(ctx context.Context, sidecars []*ethp
// broadcastAndReceiveDataColumns handles the broadcasting and reception of data columns sidecars.
func (vs *Server) broadcastAndReceiveDataColumns(ctx context.Context, sidecars []*ethpb.DataColumnSidecar, root [fieldparams.RootLength]byte) error {
eg, _ := errgroup.WithContext(ctx)

dataColumnsWithholdCount := features.Get().DataColumnsWithholdCount

for i, sd := range sidecars {
// Copy the iteration instance to a local variable to give each go-routine its own copy to play with.
// See https://golang.org/doc/faq#closures_and_goroutines for more details.
colIdx := i
sidecar := sd
colIdx, sidecar := i, sd

eg.Go(func() error {
if err := vs.P2P.BroadcastDataColumn(ctx, uint64(colIdx)%params.BeaconConfig().DataColumnSidecarSubnetCount, sidecar); err != nil {
return errors.Wrap(err, "broadcast data column")
// Compute the subnet index based on the column index.
subnet := uint64(colIdx) % params.BeaconConfig().DataColumnSidecarSubnetCount

if colIdx < dataColumnsWithholdCount {
log.WithFields(logrus.Fields{
"root": fmt.Sprintf("%#x", root),
"subnet": subnet,
"dataColumnIndex": colIdx,
}).Warning("Withholding data column")
} else {
if err := vs.P2P.BroadcastDataColumn(ctx, subnet, sidecar); err != nil {
return errors.Wrap(err, "broadcast data column")
}
}

roDataColumn, err := blocks.NewRODataColumnWithRoot(sidecar, root)
Expand Down
8 changes: 8 additions & 0 deletions config/features/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ type Flags struct {
// changed on disk. This feature is for advanced use cases only.
KeystoreImportDebounceInterval time.Duration

// DataColumnsWithholdCount specifies the likelihood of withholding a data column sidecar when proposing a block (percentage)
DataColumnsWithholdCount int

// AggregateIntervals specifies the time durations at which we aggregate attestations preparing for forkchoice.
AggregateIntervals [3]time.Duration
}
Expand Down Expand Up @@ -269,6 +272,11 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
cfg.EnablePeerDAS = true
}

if ctx.IsSet(DataColumnsWithholdCount.Name) {
logEnabled(DataColumnsWithholdCount)
cfg.DataColumnsWithholdCount = ctx.Int(DataColumnsWithholdCount.Name)
}

cfg.AggregateIntervals = [3]time.Duration{aggregateFirstInterval.Value, aggregateSecondInterval.Value, aggregateThirdInterval.Value}
Init(cfg)
return nil
Expand Down
8 changes: 8 additions & 0 deletions config/features/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ var (
Name: "peer-das",
Usage: "Enables Prysm to run with the experimental peer data availability sampling scheme.",
}
// DataColumnsWithholdCount is a flag for withholding data columns when proposing a block.
DataColumnsWithholdCount = &cli.IntFlag{
Name: "data-columns-withhold-count",
Usage: "Number of columns to withhold when proposing a block. DO NOT USE IN PRODUCTION.",
Value: 0,
Hidden: true,
}
)

// devModeFlags holds list of flags that are set when development mode is on.
Expand Down Expand Up @@ -232,6 +239,7 @@ var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []c
EnableQUIC,
DisableCommitteeAwarePacking,
EnablePeerDAS,
DataColumnsWithholdCount,
}...)...)

// E2EBeaconChainFlags contains a list of the beacon chain feature flags to be tested in E2E.
Expand Down

0 comments on commit 7147136

Please sign in to comment.