|
@ -94,6 +94,22 @@ func (s *lightClientStateProvider) AppHash(ctx context.Context, height uint64) ( |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
// We also try to fetch the blocks at height H and H+2, since we need these
|
|
|
|
|
|
// when building the state while restoring the snapshot. This avoids the race
|
|
|
|
|
|
// condition where we try to restore a snapshot before H+2 exists.
|
|
|
|
|
|
//
|
|
|
|
|
|
// FIXME This is a hack, since we can't add new methods to the interface without
|
|
|
|
|
|
// breaking it. We should instead have a Has(ctx, height) method which checks
|
|
|
|
|
|
// that the state provider has access to the necessary data for the height.
|
|
|
|
|
|
// We piggyback on AppHash() since it's called when adding snapshots to the pool.
|
|
|
|
|
|
_, err = s.lc.VerifyLightBlockAtHeight(ctx, int64(height+2), time.Now()) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
_, err = s.lc.VerifyLightBlockAtHeight(ctx, int64(height), time.Now()) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
return header.AppHash, nil |
|
|
return header.AppHash, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|