diff --git a/internal/blocksync/reactor.go b/internal/blocksync/reactor.go index 49192b11a..1228dffe7 100644 --- a/internal/blocksync/reactor.go +++ b/internal/blocksync/reactor.go @@ -577,7 +577,14 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh // TODO(sergio, jmalicevic): Should we also validate against the extended commit? if r.lastTrustedBlock.block == nil { if state.LastBlockHeight != 0 { - r.lastTrustedBlock = &TrustedBlockData{r.store.LoadBlock(state.LastBlockHeight), r.store.LoadSeenCommit()} + seenCommit := r.store.LoadSeenCommit() + + if seenCommit.Height != state.LastBlockHeight || !seenCommit.BlockID.Equals(state.LastBlockID) { + panic(" The last commit is not corresponding to the last existing height") + } + + r.lastTrustedBlock = &TrustedBlockData{r.store.LoadBlock(state.LastBlockHeight), seenCommit} + if r.lastTrustedBlock.block == nil { panic("Failed to load last trusted block") } diff --git a/internal/blocksync/reactor_test.go b/internal/blocksync/reactor_test.go index 22c26d692..b4dcddd0d 100644 --- a/internal/blocksync/reactor_test.go +++ b/internal/blocksync/reactor_test.go @@ -481,7 +481,7 @@ func TestReactor_NonGenesisSync(t *testing.T) { } return matching }, - 30*time.Second, + 10*time.Second, 10*time.Millisecond, "expected node to be partially synced", )