Skip to content

fix: Do not use nHeight when trying to identify the very first/initial snapshot - #5538

Merged
UdjinM6 merged 1 commit into
dashpay:developfrom
UdjinM6:5493_followup
Aug 21, 2023
Merged

UdjinM6 merged 1 commit into
dashpay:developfrom
UdjinM6:5493_followup

Conversation

@UdjinM6

@UdjinM6 UdjinM6 commented Aug 17, 2023 •

Copy link
Copy Markdown

Issue being fixed or feature implemented

-1 will only mean not initialized from now

Should fix crashes like https://gitlab.com/dashpay/dash/-/jobs/4893359925
This fix applied on top of #5525 https://gitlab.com/UdjinM6/dash/-/pipelines/972154075

What was done?

Introduce and use m_initial_snapshot_index instead of re-using nHeight. Added a couple of asserts to make sure:

  1. we never create mn lists with nHeight set to -1 explicitly (but it's ok for ctor with no params to do so)
  2. we never set nHeight to -1 for an existing mn list
  3. we never try to get a height for a non-initialized list
  4. GetListForBlockInternal never returns non-initialized mn lists

How Has This Been Tested?

Run tests, run regtest/testnet wallets.

Breaking Changes

We never stored snapshots with nHeight == -1, should be no breaking changes I think.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@UdjinM6 UdjinM6 added this to the 20 milestone Aug 17, 2023
Comment thread src/evo/deterministicmns.cpp Resolved
@knst

knst commented Aug 17, 2023

Copy link
Copy Markdown
Collaborator

concept ACK.
It seems as QT's callback from Timer indeed can be called before blockchain's data fully initialized.

@UdjinM6
UdjinM6 marked this pull request as draft August 17, 2023 17:02
@UdjinM6

UdjinM6 commented Aug 17, 2023

Copy link
Copy Markdown
Author

That's what I thought initially too but looking at logs a bit more - node1 was at height=14 already when it crashed, it must be some deeper issue.

ogabrielides
ogabrielides previously approved these changes Aug 18, 2023

@ogabrielides ogabrielides left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ACK

…l snapshot

`-1` will only mean `not initialized` from now
@UdjinM6 UdjinM6 changed the title fix: fix crashes introduced in 5493 fix: Do not use nHeight when trying to identify the very first/initial snapshot Aug 18, 2023
@UdjinM6

UdjinM6 commented Aug 18, 2023

Copy link
Copy Markdown
Author

I think I found the root of it (pls check PR description).

@UdjinM6
UdjinM6 marked this pull request as ready for review August 18, 2023 15:18

@ogabrielides ogabrielides left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK for squash merge

@knst knst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@UdjinM6
UdjinM6 merged commit 4896809 into dashpay:develop Aug 21, 2023
@UdjinM6
UdjinM6 deleted the 5493_followup branch August 21, 2023 21:47
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.

4 participants