diff --git a/analyzer/consensus/consensus.go b/analyzer/consensus/consensus.go index 1e3ebbb4a..1e54f4806 100644 --- a/analyzer/consensus/consensus.go +++ b/analyzer/consensus/consensus.go @@ -66,7 +66,6 @@ func OpenSignedTxNoVerify(signedTx *transaction.SignedTransaction) (*transaction // processor is the block processor for the consensus layer. type processor struct { - chain common.ChainName mode analyzer.BlockAnalysisMode history config.History source nodeapi.ConsensusApiLite @@ -79,9 +78,8 @@ type processor struct { var _ block.BlockProcessor = (*processor)(nil) // NewAnalyzer returns a new analyzer for the consensus layer. -func NewAnalyzer(chain common.ChainName, blockRange config.BlockRange, batchSize uint64, mode analyzer.BlockAnalysisMode, history config.History, source nodeapi.ConsensusApiLite, network sdkConfig.Network, target storage.TargetStorage, logger *log.Logger) (analyzer.Analyzer, error) { +func NewAnalyzer(blockRange config.BlockRange, batchSize uint64, mode analyzer.BlockAnalysisMode, history config.History, source nodeapi.ConsensusApiLite, network sdkConfig.Network, target storage.TargetStorage, logger *log.Logger) (analyzer.Analyzer, error) { processor := &processor{ - chain: chain, mode: mode, history: history, source: source, @@ -309,9 +307,7 @@ func (m *processor) ProcessBlock(ctx context.Context, uheight uint64) error { height := int64(uheight) batch := &storage.QueryBatch{} - isBlockAbsent := m.chain == common.ChainNameMainnet && height == 8048955 // Block does not exist due to mishap during upgrade to Damask. - - if !isBlockAbsent { + if _, isBlockAbsent := m.history.MissingBlocks[uheight]; !isBlockAbsent { // Fetch all data. fetchTimer := m.metrics.BlockFetchLatencies() data, err := fetchAllData(ctx, m.source, m.network, height, m.mode == analyzer.FastSyncMode) diff --git a/cmd/analyzer/analyzer.go b/cmd/analyzer/analyzer.go index 9e877ab4e..e9fe13f96 100644 --- a/cmd/analyzer/analyzer.go +++ b/cmd/analyzer/analyzer.go @@ -303,7 +303,7 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo if err1 != nil { return nil, err1 } - return consensus.NewAnalyzer(cfg.Source.ChainName, *fastRange, cfg.Analyzers.Consensus.BatchSize, analyzer.FastSyncMode, *cfg.Source.History(), sourceClient, *cfg.Source.SDKNetwork(), dbClient, logger) + return consensus.NewAnalyzer(*fastRange, cfg.Analyzers.Consensus.BatchSize, analyzer.FastSyncMode, *cfg.Source.History(), sourceClient, *cfg.Source.SDKNetwork(), dbClient, logger) }) } } @@ -340,7 +340,7 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo if err1 != nil { return nil, err1 } - return consensus.NewAnalyzer(cfg.Source.ChainName, cfg.Analyzers.Consensus.SlowSyncRange(), cfg.Analyzers.Consensus.BatchSize, analyzer.SlowSyncMode, *cfg.Source.History(), sourceClient, *cfg.Source.SDKNetwork(), dbClient, logger) + return consensus.NewAnalyzer(cfg.Analyzers.Consensus.SlowSyncRange(), cfg.Analyzers.Consensus.BatchSize, analyzer.SlowSyncMode, *cfg.Source.History(), sourceClient, *cfg.Source.SDKNetwork(), dbClient, logger) }) } if cfg.Analyzers.Emerald != nil { diff --git a/config/history.go b/config/history.go index 94b281637..52bbba796 100644 --- a/config/history.go +++ b/config/history.go @@ -23,7 +23,8 @@ type Record struct { } type History struct { - Records []*Record `koanf:"records"` + Records []*Record `koanf:"records"` + MissingBlocks map[uint64]struct{} } func (h *History) CurrentRecord() *Record { @@ -82,6 +83,8 @@ func (h *History) RecordForRuntimeRound(runtime common.Runtime, round uint64) (* var DefaultChains = map[common.ChainName]*History{ common.ChainNameMainnet: { + // Block does not exist due to mishap during upgrade to Damask. + MissingBlocks: map[uint64]struct{}{8048955: {}}, Records: []*Record{ { // https://github.com/oasisprotocol/mainnet-artifacts/releases/tag/2023-11-29 @@ -135,6 +138,7 @@ var DefaultChains = map[common.ChainName]*History{ }, }, common.ChainNameTestnet: { + MissingBlocks: map[uint64]struct{}{}, Records: []*Record{ { // https://github.com/oasisprotocol/testnet-artifacts/releases/tag/2023-10-12