Skip to content

DB get_compact_block_stream slow init time with very large block ranges. #912

@idky137

Description

@idky137

Currently the get_compact_block_stream in DbV1 uses validate_block_range, checking that all heights in the range hold valid data.

Currently DbV1 does run this check on startup, once heights marked as valid this is a very efficient check:

fn is_validated(&self, h: u32) -> bool {
        let tip = self.validated_tip.load(Ordering::Acquire);
        h <= tip || self.validated_set.contains(&h)
    }

However, if get_compact_block_stream is called before the initial block scan has completed, then validate_block_range will call validate_block_blocking for every height not yet in the DB's validated set or above validated tip. This can be very slow for large un-validated block ranges and currently stops get_compact_block_stream returning any blocks until complete.

This should be updated to call validate_block_blocking for each height separately, so that get_compact_block_stream does not stall for long periods, just has slightly slower performance when working with un-validated database heights.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions