Skip to content

Commit

Permalink
Merge pull request onflow#5151 from onflow/leo/enable-unfinalized-loader
Browse files Browse the repository at this point in the history
[Storehouse] Use unfinalized loader when storehouse is enabled
  • Loading branch information
zhangchiqing authored Dec 18, 2023
2 parents bc1e678 + ed6d74c commit 9296205
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
9 changes: 7 additions & 2 deletions cmd/execution_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,12 @@ func (exeNode *ExecutionNode) LoadIngestionEngine(
}

fetcher := fetcher.NewCollectionFetcher(node.Logger, exeNode.collectionRequester, node.State, exeNode.exeConf.onflowOnlyLNs)
loader := loader.NewUnexecutedLoader(node.Logger, node.State, node.Storage.Headers, exeNode.executionState)
var blockLoader ingestion.BlockLoader
if exeNode.exeConf.enableStorehouse {
blockLoader = loader.NewUnfinalizedLoader(node.Logger, node.State, node.Storage.Headers, exeNode.executionState)
} else {
blockLoader = loader.NewUnexecutedLoader(node.Logger, node.State, node.Storage.Headers, exeNode.executionState)
}

exeNode.ingestionEng, err = ingestion.New(
exeNode.ingestionUnit,
Expand All @@ -978,7 +983,7 @@ func (exeNode *ExecutionNode) LoadIngestionEngine(
exeNode.executionDataPruner,
exeNode.blockDataUploader,
exeNode.stopControl,
loader,
blockLoader,
)

// TODO: we should solve these mutual dependencies better
Expand Down
4 changes: 3 additions & 1 deletion engine/execution/ingestion/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (e *Engine) reloadUnexecutedBlocks() error {
e.log.Debug().Hex("block_id", blockID[:]).Msg("reloaded block")
}

log.Info().Msg("all unexecuted have been successfully reloaded")
e.log.Info().Int("count", len(unexecuted)).Msg("all unexecuted have been successfully reloaded")

return nil
})
Expand Down Expand Up @@ -396,6 +396,8 @@ func (e *Engine) enqueueBlockAndCheckExecutable(
Uint64("first_unexecuted_in_queue", firstUnexecutedHeight).
Bool("complete", complete).
Bool("head_of_queue", head).
Int("cols", len(executableBlock.Block.Payload.Guarantees)).
Int("missing_cols", len(missingCollections)).
Msg("block is enqueued")

return missingCollections, nil
Expand Down
11 changes: 8 additions & 3 deletions engine/execution/ingestion/loader/unfinalized_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ func (e *UnfinalizedLoader) LoadUnexecuted(ctx context.Context) ([]flow.Identifi
return nil, fmt.Errorf("could not get finalized block: %w", err)
}

lg := e.log.With().
Uint64("last_finalized", final.Height).
Uint64("last_finalized_executed", lastExecuted).
Logger()

lg.Info().Msgf("start loading unfinalized blocks")

// TODO: dynamically bootstrapped execution node will reload blocks from
unexecutedFinalized := make([]flow.Identifier, 0)

Expand All @@ -69,9 +76,7 @@ func (e *UnfinalizedLoader) LoadUnexecuted(ctx context.Context) ([]flow.Identifi

unexecuted := append(unexecutedFinalized, pendings...)

e.log.Info().
Uint64("last_finalized", final.Height).
Uint64("last_finalized_executed", lastExecuted).
lg.Info().
// Uint64("sealed_root_height", rootBlock.Height).
// Hex("sealed_root_id", logging.Entity(rootBlock)).
Int("total_finalized_unexecuted", len(unexecutedFinalized)).
Expand Down
14 changes: 14 additions & 0 deletions engine/execution/state/mock/execution_state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions engine/execution/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ type ExecutionState interface {
ctx context.Context,
result *execution.ComputationResult,
) error

// only available with storehouse enabled
// panic when called with storehouse disabled (which should be a bug)
GetHighestFinalizedExecuted() uint64
}

type state struct {
Expand Down

0 comments on commit 9296205

Please sign in to comment.