Compare commits

...

1 Commits

Author SHA1 Message Date
Manu NALEPA
491a173678 Request block by root: Return early and improve logging. 2025-02-03 16:21:32 +01:00
4 changed files with 36 additions and 3 deletions

View File

@@ -53,7 +53,7 @@ func TestProcessPendingAtts_NoBlockRequestBlock(t *testing.T) {
a := &ethpb.AggregateAttestationAndProof{Aggregate: &ethpb.Attestation{Data: &ethpb.AttestationData{Target: &ethpb.Checkpoint{Root: make([]byte, 32)}}}}
r.blkRootToPendingAtts[[32]byte{'A'}] = []ethpb.SignedAggregateAttAndProof{&ethpb.SignedAggregateAttestationAndProof{Message: a}}
require.NoError(t, r.processPendingAtts(context.Background()))
require.LogsContain(t, hook, "Requesting block by root")
require.LogsContain(t, hook, "Requesting block by root: Not found")
}
func TestProcessPendingAtts_HasBlockSaveUnAggregatedAtt(t *testing.T) {

View File

@@ -292,8 +292,6 @@ func (s *Service) sendBatchRootRequest(ctx context.Context, roots [][32]byte, ra
r := roots[i]
if s.seenPendingBlocks[r] || s.cfg.chain.BlockBeingSynced(r) {
roots = append(roots[:i], roots[i+1:]...)
} else {
log.WithField("blockRoot", fmt.Sprintf("%#x", r)).Debug("Requesting block by root")
}
}
s.pendingQueueLock.RUnlock()

View File

@@ -11,6 +11,7 @@ import (
"github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/types"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/sync/verify"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/verification"
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
"github.com/prysmaticlabs/prysm/v5/config/params"
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
@@ -46,11 +47,40 @@ func (s *Service) sendBeaconBlocksRequest(ctx context.Context, requests *types.B
}
return nil
})
log := log.WithField("peer", id)
blkByRoot := make(map[[fieldparams.RootLength]byte]interfaces.ReadOnlySignedBeaconBlock)
for _, blk := range blks {
blkRoot, err := blk.Block().HashTreeRoot()
if err != nil {
return errors.Wrap(err, "block hash tree root")
}
blkByRoot[blkRoot] = blk
}
if err != nil {
log = log.WithError(err)
}
for requestedRoot := range requestedRoots {
log := log.WithField("root", fmt.Sprintf("%#x", requestedRoot))
if _, ok := blkByRoot[requestedRoot]; ok {
log.Debug("Requesting block by root: Success")
continue
}
log.Debug("Requesting block by root: Not found")
}
// The following part deals with blobs (if any).
for _, blk := range blkByRoot {
// Skip blocks before deneb because they have no blob.
if blk.Version() < version.Deneb {
continue
}
blkRoot, err := blk.Block().HashTreeRoot()
if err != nil {
return err
@@ -66,6 +96,7 @@ func (s *Service) sendBeaconBlocksRequest(ctx context.Context, requests *types.B
return err
}
}
return err
}

View File

@@ -0,0 +1,4 @@
### Changed
- `sendBatchRootRequest`: Remove `Requesting block by root` log.
- `sendBeaconBlocksRequest`: Add `Requesting block by root: {Success,Not found}` log with peer ID.