Skip to content

Commit

Permalink
Merge pull request #677 from oasisprotocol/mitjat/skip-nonexistent-block
Browse files Browse the repository at this point in the history
analyzer/consensus: Skip nonexistent mainnet block 8048955
  • Loading branch information
Andrew7234 authored May 3, 2024
2 parents 2ba4737 + 1d833f8 commit c37d7a0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .changelog/677.bugfix.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
analyzer/consensus: Skip nonexistent mainnet block 8048955

Nexus can now reindex the whole range of blocks without getting stuck on this
block.
34 changes: 18 additions & 16 deletions analyzer/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,25 +305,27 @@ func (m *processor) ProcessBlock(ctx context.Context, uheight uint64) error {
return fmt.Errorf("height %d is too large", uheight)
}
height := int64(uheight)
batch := &storage.QueryBatch{}

// Fetch all data.
fetchTimer := m.metrics.BlockFetchLatencies()
data, err := fetchAllData(ctx, m.source, m.network, height, m.mode == analyzer.FastSyncMode)
fetchTimer.ObserveDuration()
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf("%d must be less than or equal to the current blockchain height", height)) {
return analyzer.ErrOutOfRange
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)
fetchTimer.ObserveDuration()
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf("%d must be less than or equal to the current blockchain height", height)) {
return analyzer.ErrOutOfRange
}
return err
}
return err
}

// Process data, prepare updates.
analysisTimer := m.metrics.BlockAnalysisLatencies()
batch := &storage.QueryBatch{}
err = m.queueDbUpdates(batch, *data)
analysisTimer.ObserveDuration()
if err != nil {
return err
// Process data, prepare updates.
analysisTimer := m.metrics.BlockAnalysisLatencies()
err = m.queueDbUpdates(batch, *data)
analysisTimer.ObserveDuration()
if err != nil {
return err
}
}

// Update indexing progress.
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{} `koanf:"missing_blocks"`
}

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 c37d7a0

Please sign in to comment.