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

Bug: not updating view of peer burnchain state appropriately #2960

Open
pavitthrap opened this issue Dec 2, 2021 · 6 comments
Open

Bug: not updating view of peer burnchain state appropriately #2960

pavitthrap opened this issue Dec 2, 2021 · 6 comments
Assignees
Labels
icebox Issues that are not being worked on

Comments

@pavitthrap
Copy link
Contributor

The following logic in chat.rs updates the stored stats we have for our view of a peer's burnchain state:

                // update chain view from preamble
                if msg.preamble.burn_block_height > self.burnchain_tip_height {
                    self.burnchain_tip_height = msg.preamble.burn_block_height;
                    self.burnchain_tip_burn_header_hash = msg.preamble.burn_block_hash.clone();
                }

                if msg.preamble.burn_stable_block_height > self.burnchain_stable_tip_height {
                    self.burnchain_stable_tip_height = msg.preamble.burn_stable_block_height;
                    self.burnchain_stable_tip_burn_header_hash =
                        msg.preamble.burn_stable_block_hash.clone();
                }

We only update our view if the sent burn heights are strictly greater than the ones we have stored for that peer. Doing so fails to account for re-orgs in the underlying chain (bitcoin).

I plan to make the height vars of type Option<u64>, so that we can properly distinguish between the var being unset and the var being equal to 0.

@jcnelson @kantai thoughts?

@pavitthrap pavitthrap self-assigned this Dec 2, 2021
@pavitthrap pavitthrap added the bug Unwanted or unintended property causing functional harm label Dec 2, 2021
@jcnelson jcnelson removed the bug Unwanted or unintended property causing functional harm label Dec 2, 2021
@jcnelson
Copy link
Member

jcnelson commented Dec 2, 2021

It's not a bug. Two burnchain blocks with the same height are concurrent -- neither one is definitively the chain tip, so it doesn't matter which one gets reported as the remote chaintip view. If you want, you can update the code to check both burn_block_height and burn_block_hash (and burn_stable_block_height and burn_stable_block_hash), but it won't meaningfully change the way the code behaves.

@kantai
Copy link
Member

kantai commented Dec 2, 2021

It's not a bug. Two burnchain blocks with the same height are concurrent -- neither one is definitively the chain tip, so it doesn't matter which one gets reported as the remote chaintip view. If you want, you can update the code to check both burn_block_height and burn_block_hash (and burn_stable_block_height and burn_stable_block_hash), but it won't meaningfully change the way the code behaves.

But a peer's burn tip can regress -- in the event of PoX re-orgs.

@jcnelson
Copy link
Member

jcnelson commented Dec 2, 2021

So, the only code that cares about the burn block height and burn stable block height is the inventory state machine, which uses them as a hint to determine which block inventories it can ask for. If the the remote peer undergoes a PoX reorg, but the local peer asks for a block inventory for a now-invalid list of sortitions, the local peer will just get a NACK, which it interprets as the remote peer being on a different PoX fork. This is acceptable, because it causes the local peer to stop asking for later block inventories and to try again later.

We could update this code path to simply reset the burn block heights to whatever is in the preamble, and it probably won't change anything, but we'd want to test it live first.

@stale
Copy link

stale bot commented Dec 24, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 24, 2022
@jcnelson
Copy link
Member

Circling back to this, I think it might be sufficient to just remove the conditional check. The remote peer's burnchain view is just whatever it claims it is.

@stale stale bot removed the stale label Feb 22, 2023
@kantai
Copy link
Member

kantai commented Feb 22, 2023

It seems like you probably have the most context for this, so I'm adding you to the assignees, @jcnelson

@jcnelson jcnelson added the icebox Issues that are not being worked on label Mar 7, 2023
@pavitthrap pavitthrap removed their assignment Jul 14, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New in Stacks Core Eng Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
icebox Issues that are not being worked on
Projects
Status: Status: 🆕 New
Development

No branches or pull requests

3 participants