Skip to content

Commit

Permalink
sync, blocks: request blocks when tortoise crossed local threshold (s…
Browse files Browse the repository at this point in the history
…pacemeshos#4826)

closes: spacemeshos#4824

- first improvement is to register peers that supported blocks, otherwise we will be guessing from whom to request the block
- and when mesh is called by sync or block builder it may send request to fetch blocks from registered peers. previously it would do so only in sync code path, which is less robust and might be delayed by fork finder
  • Loading branch information
dshulyak authored and brunovale91 committed Aug 21, 2023
1 parent cd076d5 commit 52cffb8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 2 additions & 5 deletions mesh/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,12 @@ func (msh *Mesh) ProcessLayer(ctx context.Context, lid types.LayerID) error {
})),
)
}
applicable, missing := filterMissing(results, next)
if len(missing) > 0 {
if missing := missingBlocks(results); len(missing) > 0 {
select {
case <-ctx.Done():
case msh.missingBlocks <- missing:
}
if len(applicable) == 0 {
return fmt.Errorf("%w: request missing blocks %v", ErrMissingBlock, missing)
}
return fmt.Errorf("request missing blocks %v", missing)
}

if err := msh.ensureStateConsistent(ctx, applicable); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions syncer/state_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ func (s *Syncer) processLayers(ctx context.Context) error {
// even if it fails to fetch opinions, we still go ahead to ProcessLayer so that the tortoise
// has a chance to count ballots and form its own opinions
if err := s.mesh.ProcessLayer(ctx, lid); err != nil {
if !errors.Is(err, mesh.ErrMissingBlock) {
s.logger.WithContext(ctx).With().Warning("mesh failed to process layer from sync", lid, log.Err(err))
}
s.logger.WithContext(ctx).With().Warning("mesh failed to process layer from sync", lid, log.Err(err))
}
}
s.logger.WithContext(ctx).With().Debug("end of state sync",
Expand Down

0 comments on commit 52cffb8

Please sign in to comment.