8000 chain: handle accumulator reorg by Davidson-Souza · Pull Request #498 · vinteumorg/Floresta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chain: handle accumulator reorg #498

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

Merged
merged 2 commits into from
Jun 16, 2025

Conversation

Davidson-Souza
Copy link
Collaborator

What is the purpose of this pull request?

  • Bug fix
  • Documentation update
  • New feature
  • Test
  • Other:

Which crates are being modified?

  • floresta-chain
  • floresta-cli
  • floresta-common
  • floresta-compact-filters
  • floresta-electrum
  • floresta-watch-only
  • floresta-wire
  • floresta
  • florestad
  • Other:

Description

Right now, if we ever encounter ourselves in a reorg of the chain, we will get into a corrupted state, because we won't update our accumulator for the no most-work-chain. Therefore, causing us to get stuck.

This commit adds logic to save an retrieve accumulators from different heights, allowing a full reorg of our chain.

@Davidson-Souza Davidson-Souza added bug Something isn't working consensus This changes something inside our consensus implementation labels May 26, 2025
@Davidson-Souza Davidson-Souza force-pushed the reorg branch 2 times, most recently from 98940bc to 633775f Compare May 30, 2025 20:31
@Davidson-Souza Davidson-Souza marked this pull request as ready for review May 30, 2025 20:32
@Davidson-Souza Davidson-Souza force-pushed the reorg branch 2 times, most recently from a25ce25 to 95045a7 Compare May 30, 2025 20:47
Copy link
Contributor
@jaoleal jaoleal left a comment

Choose a reason for hiding this comment

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

LGTM

@Davidson-Souza Davidson-Souza force-pushed the reorg branch 2 times, most recently from 13e5167 to c5bb5c1 Compare June 2, 2025 20:31
@Davidson-Souza
Copy link
Collaborator Author

rebased and updated with @jaoleal's comments.

@jaoleal
Copy link
Contributor
jaoleal commented Jun 3, 2025

ACK 9754a71

8000
@Davidson-Souza
Copy link
Collaborator Author

Updated with @JoseSK999's comments. Also fixed the numbers under Calculations on flat_chain_store

@Davidson-Souza
Copy link
Collaborator Author

@JoseSK999 fixed!

@Davidson-Souza Davidson-Souza force-pushed the reorg branch 2 times, most recently from bf77cd3 to fecf9f2 Compare June 11, 2025 23:32
@Davidson-Souza
Copy link
Collaborator Author

Rebased and addressed @JoseSK999's comments.

@Davidson-Souza
Copy link
Collaborator Author

Fixed a problem with --assume-utreexo where, if we kill the node right after we called mark_chain_as_assumed, we wouldn't save any root. So, in the next start-up, our node would get stuck since it didn't have roots to work with.

@Davidson-Souza
Copy link
Collaborator Author

Wtf? Can anyone reproduce this error?

I not only can't reproduce it, the line where it claims to panic doesn't have any unwrap (⊙_☉)

@JoseSK999
Copy link
Contributor
JoseSK999 commented Jun 16, 2025

Wtf? Can anyone reproduce this error?

I not only can't reproduce it, the line where it claims to panic doesn't have any unwrap (⊙_☉)

@Davidson-Souza I reproduced this! GitHub Actions will not run on your version of the code but on the merged version with master. You can reproduce this by rebasing locally (and running just test-features).

After rebasing the unwrap line is correct.

@Davidson-Souza
Copy link
Collaborator Author

Wtf? Can anyone reproduce this error?
I not only can't reproduce it, the line where it claims to panic doesn't have any unwrap (⊙_☉)

@Davidson-Souza I reproduced this! GitHub Actions will not run on your version of the code but on the merged version with master. You can reproduce this by rebasing locally (and running just test-features).

After rebasing the unwrap line is correct.

Wtf? Can anyone reproduce this error?
I not only can't reproduce it, the line where it claims to panic doesn't have any unwrap (⊙_☉)

@Davidson-Souza I reproduced this! GitHub Actions will not run on your version of the code but on the merged version with master. You can reproduce this by rebasing locally (and running just test-features).

After rebasing the unwrap line is correct.

Ohhh it's a silent merge conflict! Thanks @JoseSK999

@JoseSK999
Copy link
Contributor

The NotFound error variants are terrible for debugging :/ we should return what was looked for

@Davidson-Souza
Copy link
Collaborator Author

The NotFound error variants are terrible for debugging :/ we should return what was looked for

In this case it's a block. But yeah, terrible naming

Right now, if we ever encounter ourselves in a reorg of the chain, we
will get into a corrupted state, because we won't update our accumulator
for the no most-work-chain. Therefore, causing us to get stuck.

This commit adds logic to save an retrieve accumulators from different
heights, allowing a full reorg of our chain.
This commit adds a functional test for reorg, where we:
 - Create an utreexod and florestad instance
 - Connect them
 - Mine 10 blocks using utreexod
 - Wait for florestad to catch up
 - Use `invalidateblock` on utreexod to cause a fork on block 5
 - Mine 20 more blocks on top of the tip
 - Check if both have the same tip and accumulator at the end
@JoseSK999
Copy link
Contributor

More than just the name I meant making the variant wrap a string or something that provides context about where this error originates. Good for another PR.

Copy link
Contributor
@JoseSK999 JoseSK999 left a comment

Choose a reason for hiding this comment

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

ACK 48290f3

@Davidson-Souza Davidson-Souza merged commit 6012b55 into vinteumorg:master Jun 16, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working consensus This changes something inside our consensus implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0