reordered blob validation (#13347)

This commit is contained in:
David Theodore 2023-12-14 20:46:12 -06:00 committed by GitHub
parent 62ecc0d177
commit 0fde4a22e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,7 +56,7 @@ func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Mes
// [REJECT] The sidecar is for the correct subnet -- i.e. compute_subnet_for_blob_sidecar(sidecar.index) == subnet_id.
want := fmt.Sprintf("blob_sidecar_%d", computeSubnetForBlobSidecar(blob.Index))
if !strings.Contains(*msg.Topic, want) {
log.WithFields(blobFields(blob)).Debug("Sidecar index does not match topic")
log.WithFields(blobFields(blob)).Debug("Sidecar index does not match topic")
return pubsub.ValidationReject, fmt.Errorf("wrong topic name: %s", *msg.Topic)
}
@ -64,12 +64,18 @@ func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Mes
return pubsub.ValidationIgnore, err
}
if err := vf.SlotAboveFinalized(); err != nil {
startTime, err := slots.ToTime(uint64(s.cfg.chain.GenesisTime().Unix()), blob.Slot())
if err != nil {
return pubsub.ValidationIgnore, err
}
if err := vf.ValidProposerSignature(ctx); err != nil {
return pubsub.ValidationReject, err
// [IGNORE] The sidecar is the first sidecar for the tuple (block_header.slot, block_header.proposer_index, sidecar.index) with valid header signature and sidecar inclusion proof
if s.hasSeenBlobIndex(blob.Slot(), blob.ProposerIndex(), blob.Index) {
return pubsub.ValidationIgnore, nil
}
if err := vf.SlotAboveFinalized(); err != nil {
return pubsub.ValidationIgnore, err
}
if err := vf.SidecarParentSeen(s.hasBadBlock); err != nil {
@ -82,6 +88,10 @@ func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Mes
return pubsub.ValidationIgnore, err
}
if err := vf.ValidProposerSignature(ctx); err != nil {
return pubsub.ValidationReject, err
}
if err := vf.SidecarParentValid(s.hasBadBlock); err != nil {
return pubsub.ValidationReject, err
}
@ -102,19 +112,10 @@ func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Mes
return pubsub.ValidationReject, err
}
// [IGNORE] The sidecar is the first sidecar for the tuple (block_header.slot, block_header.proposer_index, sidecar.index) with valid header signature and sidecar inclusion proof
if s.hasSeenBlobIndex(blob.Slot(), blob.ProposerIndex(), blob.Index) {
return pubsub.ValidationIgnore, nil
}
if err := vf.SidecarProposerExpected(ctx); err != nil {
return pubsub.ValidationReject, err
}
startTime, err := slots.ToTime(uint64(s.cfg.chain.GenesisTime().Unix()), blob.Slot())
if err != nil {
return pubsub.ValidationIgnore, err
}
fields := blobFields(blob)
sinceSlotStartTime := receivedTime.Sub(startTime)
fields["sinceSlotStartTime"] = sinceSlotStartTime