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: deserialize BlockTree iteratively #258

Merged
merged 6 commits into from
Oct 11, 2023
Merged

Conversation

ielashi
Copy link
Collaborator

@ielashi ielashi commented Oct 6, 2023

Problem

We're now running into a situation where the Bitcoin testnet has ~125k unstable blocks due to a difficulty reset.
Recursively deserializing these blocks, which we do in post_upgrade, causes a stack overflow.

Solution

Rewrite the BlockTree deserialization to be iterative rather than recursive. Running a test with the current production state confirms that it fixes that stack overflow issue.

@ielashi ielashi marked this pull request as ready for review October 6, 2023 09:29
@ielashi ielashi requested a review from a team as a code owner October 6, 2023 09:29
@ielashi
Copy link
Collaborator Author

ielashi commented Oct 6, 2023

Marking this as a draft while I explore a safe alternative in Rust.

@ielashi ielashi marked this pull request as draft October 6, 2023 12:50
@ielashi ielashi marked this pull request as ready for review October 10, 2023 13:10
@ielashi
Copy link
Collaborator Author

ielashi commented Oct 10, 2023

I updated the PR with an alternative implementation that doesn't use unsafe. cc @dsarlis

canister/src/blocktree/serde.rs Outdated Show resolved Hide resolved
canister/src/blocktree/serde.rs Outdated Show resolved Hide resolved
@ielashi ielashi enabled auto-merge (squash) October 11, 2023 07:34
@ielashi ielashi merged commit 6ee5447 into master Oct 11, 2023
21 checks passed
@ielashi ielashi deleted the ielashi/iterative_serde branch October 11, 2023 07:54
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.

3 participants