mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
b7175b3482
* Revert "Revert "Update fastssz" (#7100)"
This reverts commit b954db9704
.
* Preston's patch
* Merge branch 'master' of github.com:prysmaticlabs/prysm into revert-7100-revert-6760-update-fssz
* Update fssz, add regression test case
* more HTR with fssz
* fix some tests
* only one test left
* Make it so that HTR will work
* gofmt, imports
* gofmt, imports
* fix
* Merge branch 'master' of github.com:prysmaticlabs/prysm into revert-7100-revert-6760-update-fssz
* fix
* Merge branch 'master' into revert-7100-revert-6760-update-fssz
* Merge refs/heads/master into revert-7100-revert-6760-update-fssz
* gaz
* Merge branch 'revert-7100-revert-6760-update-fssz' of github.com:prysmaticlabs/prysm into revert-7100-revert-6760-update-fssz
* Merge refs/heads/master into revert-7100-revert-6760-update-fssz
* fix test
* Merge branch 'revert-7100-revert-6760-update-fssz' of github.com:prysmaticlabs/prysm into revert-7100-revert-6760-update-fssz
* Merge refs/heads/master into revert-7100-revert-6760-update-fssz
64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package sync
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop"
|
|
)
|
|
|
|
func (s *Service) beaconBlockSubscriber(ctx context.Context, msg proto.Message) error {
|
|
signed, ok := msg.(*ethpb.SignedBeaconBlock)
|
|
if !ok {
|
|
return errors.New("message is not type *ethpb.SignedBeaconBlock")
|
|
}
|
|
|
|
if signed == nil || signed.Block == nil {
|
|
return errors.New("nil block")
|
|
}
|
|
|
|
s.setSeenBlockIndexSlot(signed.Block.Slot, signed.Block.ProposerIndex)
|
|
|
|
block := signed.Block
|
|
|
|
root, err := block.HashTreeRoot()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := s.chain.ReceiveBlock(ctx, signed, root); err != nil {
|
|
interop.WriteBlockToDisk(signed, true /*failed*/)
|
|
s.setBadBlock(ctx, root)
|
|
return err
|
|
}
|
|
|
|
// Delete attestations from the block in the pool to avoid inclusion in future block.
|
|
if err := s.deleteAttsInPool(block.Body.Attestations); err != nil {
|
|
log.Errorf("Could not delete attestations in pool: %v", err)
|
|
return nil
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// The input attestations are seen by the network, this deletes them from pool
|
|
// so proposers don't include them in a block for the future.
|
|
func (s *Service) deleteAttsInPool(atts []*ethpb.Attestation) error {
|
|
for _, att := range atts {
|
|
if helpers.IsAggregated(att) {
|
|
if err := s.attPool.DeleteAggregatedAttestation(att); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
// Ideally there's shouldn't be any unaggregated attestation in the block.
|
|
if err := s.attPool.DeleteUnaggregatedAttestation(att); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|