Skip to content

Commit

Permalink
add missingblocks field to history
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew7234 committed Apr 30, 2024
1 parent 2e931fd commit 2f7d9f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 2 additions & 6 deletions analyzer/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion config/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2f7d9f2

Please sign in to comment.