Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analyzer/consensus: Skip nonexistent mainnet block 8048955 #677

Merged
merged 2 commits into from
May 3, 2024

Conversation

mitjat
Copy link
Contributor

@mitjat mitjat commented Mar 27, 2024

On Oasis mainnet, consensus block 8048955 does not exist: 8048954 is the last block of Cobalt, and 8048956 is the first block of Damask. This was an unintended side effect of the dump-restore Damask upgrade.

Nexus was unaware of this, and would get stuck on that block when reindexing the entire history. The only way to "unstick" it was (small) manual DB surgery. This PR hardcodes the block as an exception, and makes Nexus skip it.

Testing:
One-off manual test. Ran mainnet analysis with the following config:

    consensus:
      from: 8_048_946  # Damask genesis was at 8_048_956; probe slightly into Cobalt
      to:   8_048_966

and verified that blocks are analyzed as expected.

@mitjat mitjat marked this pull request as draft March 27, 2024 01:28
@mitjat mitjat changed the title WIP: mitjat/skip-nonexistent-block analyzer/consensus: Skip nonexistent mainnet block 8048955 Mar 27, 2024
@mitjat mitjat force-pushed the mitjat/skip-nonexistent-block branch from bdd4537 to 5faadc5 Compare March 27, 2024 02:05
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
isBlockAbsent := m.chain == common.ChainNameMainnet && height == 8048955
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could go as some kind of addition to the History config. this is the height just below when mainnet damask started. maybe we could put something in the mainnet cobalt record to say height 8048955 was absent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first instinct too. But Jernej was saying how this was definitely a bug/mistake when doing the Damask dump-restore. In the future, a) dump-restores are unlikely, b) if they do happen, we're unlikely to make the same mistake twice. So it's IMO an overgeneralization to bloat the history config with this, and make the consuming code (= here) more complex and general and indirect. Let's expand History once we have more than one such block in the future.

I also thought about at least referencing the Damask genesis height from History config here. So instead of comparing to 8048955, I could compare to (genesis_height - 1). But then I decided that's no more informative, and just harder to grep for.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opposite opinion from the same principles:

  • it'll take at least a little code change no matter what
  • it happened once and we anticipate not again, so this only exists as a historical artifact
  • better to shove the details into the "history" data rather than bloat the code with special (name, height) coordinates

ok on not optimizing generality or auto computing the height though

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would prevent us from having to add this special purpose chain name arg throughout

Copy link
Collaborator

@pro-wh pro-wh Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra thing: I'm against doing special behavior for named default chains that a custom history config can't do. we've used custom history to work around things before, don't want to lose this fix if we need to do that later

@mitjat mitjat force-pushed the mitjat/skip-nonexistent-block branch from 5faadc5 to 20669d7 Compare March 28, 2024 05:24
@mitjat mitjat marked this pull request as ready for review March 28, 2024 05:25
@mitjat mitjat requested a review from pro-wh March 28, 2024 05:25
analyzer/consensus/consensus.go Outdated Show resolved Hide resolved
analyzer/consensus/consensus.go Outdated Show resolved Hide resolved
@Andrew7234 Andrew7234 force-pushed the mitjat/skip-nonexistent-block branch from 4152c29 to 823c2cd Compare April 30, 2024 19:39
@Andrew7234 Andrew7234 force-pushed the mitjat/skip-nonexistent-block branch from 823c2cd to 2f7d9f2 Compare April 30, 2024 20:03
@Andrew7234
Copy link
Collaborator

Ok updated to address comments. Tried testing on the same range as the PR description but it's having issues connecting to the production cobalt archive node.

config/history.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@pro-wh pro-wh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the changes, still looks very clean

@Andrew7234 Andrew7234 force-pushed the mitjat/skip-nonexistent-block branch from 2f7d9f2 to 1d833f8 Compare May 1, 2024 03:16
@Andrew7234 Andrew7234 merged commit c37d7a0 into main May 3, 2024
14 checks passed
@Andrew7234 Andrew7234 deleted the mitjat/skip-nonexistent-block branch May 3, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants