Skip to content

Commit 76dd754

Browse files
Fix store height update in manager (cosmos#1142)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview Closes: cosmos#884 Applies the fix described in rollkit/rollkit#884 (comment) - update the store height before pushing the block to DA so that the store height accessed in `trySyncNextBlock` is updated. <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. --> ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [x] New and updated code has appropriate documentation - [ ] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [ ] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords
1 parent 1acf092 commit 76dd754

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

block/manager.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (m *Manager) SyncLoop(ctx context.Context, cancel context.CancelFunc) {
313313
daHeight := blockEvent.daHeight
314314
blockHash := block.Hash().String()
315315
blockHeight := uint64(block.Height())
316-
m.logger.Debug("block body retrieved from DALC",
316+
m.logger.Debug("block body retrieved",
317317
"height", blockHeight,
318318
"daHeight", daHeight,
319319
"hash", blockHash,
@@ -437,6 +437,8 @@ func (m *Manager) BlockStoreRetrieveLoop(ctx context.Context) {
437437
daHeight := atomic.LoadUint64(&m.daHeight)
438438
for _, block := range blocks {
439439
m.blockInCh <- newBlockEvent{block, daHeight}
440+
m.logger.Debug("block retrieved from p2p block sync", "blockHeight", block.Height(), "daHeight", daHeight)
441+
440442
}
441443
}
442444
lastBlockStoreHeight = blockStoreHeight
@@ -648,6 +650,11 @@ func (m *Manager) publishBlock(ctx context.Context) error {
648650
if err != nil {
649651
return err
650652
}
653+
654+
blockHeight := uint64(block.Height())
655+
// Update the stored height before submitting to the DA layer and committing to the DB
656+
m.store.SetHeight(blockHeight)
657+
651658
blockHash := block.Hash().String()
652659
m.blockCache.setSeen(blockHash)
653660

@@ -669,8 +676,6 @@ func (m *Manager) publishBlock(ctx context.Context) error {
669676
m.pendingBlocks = append(m.pendingBlocks, block)
670677
m.pendingBlocksMtx.Unlock()
671678

672-
blockHeight := uint64(block.SignedHeader.Header.Height())
673-
674679
// Commit the new state and block which writes to disk on the proxy app
675680
_, _, err = m.executor.Commit(ctx, newState, block, responses)
676681
if err != nil {
@@ -689,9 +694,6 @@ func (m *Manager) publishBlock(ctx context.Context) error {
689694
return err
690695
}
691696

692-
// Only update the stored height after successfully submitting to DA layer and committing to the DB
693-
m.store.SetHeight(blockHeight)
694-
695697
newState.DAHeight = atomic.LoadUint64(&m.daHeight)
696698
// After this call m.lastState is the NEW state returned from ApplyBlock
697699
// updateState also commits the DB tx

0 commit comments

Comments
 (0)