|
6 | 6 | "time"
|
7 | 7 |
|
8 | 8 | "github.com/pkg/errors"
|
| 9 | + "github.com/prysmaticlabs/go-bitfield" |
9 | 10 | "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/blocks"
|
10 | 11 | "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
11 | 12 | coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time"
|
@@ -420,21 +421,58 @@ func (s *Service) savePostStateInfo(ctx context.Context, r [32]byte, b interface
|
420 | 421 | }
|
421 | 422 |
|
422 | 423 | // This removes the attestations in block `b` from the attestation mem pool.
|
423 |
| -func (s *Service) pruneAttsFromPool(headBlock interfaces.ReadOnlySignedBeaconBlock) error { |
| 424 | +func (s *Service) pruneAttsFromPool(ctx context.Context, headState state.BeaconState, headBlock interfaces.ReadOnlySignedBeaconBlock) error { |
424 | 425 | atts := headBlock.Block().Body().Attestations()
|
425 | 426 | for _, att := range atts {
|
426 |
| - if features.Get().EnableExperimentalAttestationPool { |
427 |
| - if err := s.cfg.AttestationCache.DeleteCovered(att); err != nil { |
428 |
| - return errors.Wrap(err, "could not delete attestation") |
| 427 | + if !att.IsAggregated() { |
| 428 | + if err := s.cfg.AttPool.DeleteUnaggregatedAttestation(att); err != nil { |
| 429 | + return err |
429 | 430 | }
|
430 |
| - } else if att.IsAggregated() { |
431 |
| - if err := s.cfg.AttPool.DeleteAggregatedAttestation(att); err != nil { |
| 431 | + continue |
| 432 | + } |
| 433 | + |
| 434 | + if att.Version() == version.Phase0 { |
| 435 | + if features.Get().EnableExperimentalAttestationPool { |
| 436 | + if err := s.cfg.AttestationCache.DeleteCovered(att); err != nil { |
| 437 | + return err |
| 438 | + } |
| 439 | + } else if err := s.cfg.AttPool.DeleteAggregatedAttestation(att); err != nil { |
432 | 440 | return err
|
433 | 441 | }
|
434 |
| - } else { |
435 |
| - if err := s.cfg.AttPool.DeleteUnaggregatedAttestation(att); err != nil { |
| 442 | + continue |
| 443 | + } |
| 444 | + |
| 445 | + offset := uint64(0) |
| 446 | + |
| 447 | + committeeIndices := att.CommitteeBitsVal().BitIndices() |
| 448 | + committees, err := helpers.AttestationCommittees(ctx, headState, att) |
| 449 | + if err != nil { |
| 450 | + return err |
| 451 | + } |
| 452 | + for i, c := range committees { |
| 453 | + ab := bitfield.NewBitlist(uint64(len(c))) |
| 454 | + for j := uint64(0); j < uint64(len(c)); j++ { |
| 455 | + ab.SetBitAt(j, att.GetAggregationBits().BitAt(j+offset) == true) |
| 456 | + } |
| 457 | + |
| 458 | + cb := primitives.NewAttestationCommitteeBits() |
| 459 | + cb.SetBitAt(uint64(committeeIndices[i]), true) |
| 460 | + |
| 461 | + a := ðpb.AttestationElectra{ |
| 462 | + AggregationBits: ab, |
| 463 | + Data: att.GetData(), |
| 464 | + CommitteeBits: cb, |
| 465 | + } |
| 466 | + |
| 467 | + if features.Get().EnableExperimentalAttestationPool { |
| 468 | + if err := s.cfg.AttestationCache.DeleteCovered(a); err != nil { |
| 469 | + return err |
| 470 | + } |
| 471 | + } else if err := s.cfg.AttPool.DeleteAggregatedAttestation(a); err != nil { |
436 | 472 | return err
|
437 | 473 | }
|
| 474 | + |
| 475 | + offset += uint64(len(c)) |
438 | 476 | }
|
439 | 477 | }
|
440 | 478 | return nil
|
|
0 commit comments