Currently, to get the ancestor of a block in the StoreVmDatabase we crawl the ancestors one by one until we reach the desired block number. For the regular non-import case, the state on top of which the VM is executing is canonical. And to get the ancestor of a canonical block we just need to get the canonical hash for a certain block number, which is information we have available on the store and doesn't require iterating through ancestors.
However, this might require an API change, as getting the canonical block for a certain block number is an async function and the StoreVMDatabase is a sync trait.
Currently, to get the ancestor of a block in the StoreVmDatabase we crawl the ancestors one by one until we reach the desired block number. For the regular non-import case, the state on top of which the VM is executing is canonical. And to get the ancestor of a canonical block we just need to get the canonical hash for a certain block number, which is information we have available on the store and doesn't require iterating through ancestors.
However, this might require an API change, as getting the canonical block for a certain block number is an async function and the StoreVMDatabase is a sync trait.