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

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

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Aug 17, 2023

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
src/evo/deterministicmns.cpp Outdated Show resolved Hide resolved
@knst
Copy link
Collaborator

knst commented Aug 17, 2023

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
Copy link
Author

UdjinM6 commented Aug 17, 2023

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
Copy link
Collaborator

@ogabrielides ogabrielides left a comment

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
Copy link
Author

UdjinM6 commented Aug 18, 2023

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
Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK for squash merge

Copy link
Collaborator

@knst knst left a comment

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
13 checks passed
@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