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

Only consider target_block_height when relevant #2780

Merged
merged 8 commits into from
Jul 29, 2021
Merged

Conversation

lgalabru
Copy link
Contributor

@lgalabru lgalabru commented Jul 26, 2021

With this fix, we're only considering the target_block_height if this value is relevant.
The sync_with_indexer function is reading the burnchain state from the bitcoin-node and should be considered as the source of truth, and should ignore / correct the hint when it's determined as off.
Address #2783.

@lgalabru lgalabru changed the title Fix edge case preventing boot from disk Only consider target_block_height when relevant Jul 27, 2021
@lgalabru lgalabru marked this pull request as ready for review July 27, 2021 17:16
@lgalabru lgalabru self-assigned this Jul 27, 2021
Copy link
Contributor

@gregorycoppola gregorycoppola left a comment

Choose a reason for hiding this comment

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

Hey Ludo.. just a few comments about the comments.. and some questions about clarifying how this was tested.

src/burnchains/burnchain.rs Outdated Show resolved Hide resolved
@@ -1213,12 +1213,21 @@ impl Burnchain {
);

if let Some(target_block_height) = target_block_height_opt {
Copy link
Contributor

Choose a reason for hiding this comment

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

So, there's no test? How was this change tested and why do we know it is an improvement?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, no, unfortunately there's no test.
This change was tested locally with a copy the chainstate of a miner that was stuck because of this bug, and this branch was then directly deployed by @CharlieC3 to the miner on the same chainstate, and that helped us unblocking the miner - looks like an improvement.

The code coverage for this routine is pretty bad because this function is doing way too many things.
I think we could rewrite this routine, extract the logic dealing with the boundaries and target block (there are a lot of if in there that would deserve some testing), and unit test that logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. Can you just summarize this in the PR description?

src/burnchains/burnchain.rs Outdated Show resolved Hide resolved
// target_block_height is used as a hint, but could also be completely off
// in certain situations. The current function is directly reading the
// headers and syncing with the bitcoin-node, and the interval of blocks
// to download computed here should be considered as our source of truth.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the comment on line 1144 need to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. This function is still returning a burnchain tip, at least as high as target_block_height_opt if given.

@gregorycoppola
Copy link
Contributor

Also.. is there an Issue for this?

@@ -1213,12 +1213,21 @@ impl Burnchain {
);
Copy link
Contributor

@pavitthrap pavitthrap Jul 27, 2021

Choose a reason for hiding this comment

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

I think the debug statement above should be

 debug!(
            "Sync'ed headers from {} to {}. DB at {}",
            sync_height, end_block, db_height
         );

Could you fix this as part of this pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with latest

@lgalabru
Copy link
Contributor Author

@gregorycoppola yes there's an issue - #2783

Copy link
Contributor

@gregorycoppola gregorycoppola left a comment

Choose a reason for hiding this comment

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

Can you link the issue in the description?

@@ -1213,12 +1213,21 @@ impl Burnchain {
);

if let Some(target_block_height) = target_block_height_opt {
Copy link
Contributor

Choose a reason for hiding this comment

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

OK. Can you just summarize this in the PR description?

@blockstack-devops
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants