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: never consider Stacks chain tips that are not on the canonical burn chain #4886

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

jcnelson
Copy link
Member

This PR fixes an incident from earlier this morning whereby miners consistently failed to mine blocks because their preferred chain tip was no longer on the canonical Bitcoin fork. This was due to (1) an omitted check when searching for ancestral Stacks tips to consider, and (2) an off-by-one error which meant that the highest considered ancestor had the same height as the already-filtered Stacks tips (instead of an earlier height).

You can see the difference as follows:

With the fix:

$ stacks-node pick-best-tip --config ~/mainnet-2.5.toml --at-stacks-height 153917
INFO [1718387049.331670] [testnet/stacks-node/src/main.rs:293] [main] stacks-node 0.1.0 (:, debug build, linux [x86_64])
INFO [1718387049.331731] [testnet/stacks-node/src/main.rs:66] [main] Loading config at path /home/jude/mainnet-2.5.toml
INFO [1718387049.500576] [testnet/stacks-node/src/neon_node.rs:1493] [main] Tip #0 ea37553db307bca3a2dc0413dd7eb943f4fbfecc/3a852c6ea871ea45528e9cd4800349e8685a46d9470e2c53b45b30fe15c18234 at 847851:153917 has score 1 (1 (non-ancestor) + 0 (earlier sibs) + 0 (earlier sibs) + 0 (earlier sibs))
INFO [1718387049.500607] [testnet/stacks-node/src/neon_node.rs:1493] [main] Tip #1 6a7f03e8da186957d979b0d3ec7330478f8ab600/36a21c1b248d205136378fc1409aa7d7727b61571bc3bea5c63da65c97e25817 at 847852:153917 has score 2 (1 (uncles) + 1 (non-ancestor) + 0 (earlier sibs) + 0 (earlier sibs) + 0 (earlier sibs))
INFO [1718387049.500619] [testnet/stacks-node/src/neon_node.rs:1524] [main] Best tip is #0 ea37553db307bca3a2dc0413dd7eb943f4fbfecc/3a852c6ea871ea45528e9cd4800349e8685a46d9470e2c53b45b30fe15c18234
Best tip is TipCandidate { stacks_height: 153917, consensus_hash: ea37553db307bca3a2dc0413dd7eb943f4fbfecc, anchored_block_hash: 3a852c6ea871ea45528e9cd4800349e8685a46d9470e2c53b45b30fe15c18234, parent_consensus_hash: ef78a4c1acf7a004d9ef170bee78245527cb5dcb, parent_anchored_block_hash: 678d064fbb1c9abc1a69c333ce2977535ef69791d846ed88917acefcf930dde7, burn_height: 847851, num_earlier_siblings: 0 }

Without the fix:

$ stacks-node pick-best-tip --config ~/mainnet-2.5.toml --at-stacks-height 153917
INFO [1718387084.670752] [testnet/stacks-node/src/main.rs:293] [main] stacks-node 0.1.0 (:, release build, linux [x86_64])
INFO [1718387084.670805] [testnet/stacks-node/src/main.rs:66] [main] Loading config at path /home/jude/mainnet-2.5.toml
INFO [1718387084.823874] [testnet/stacks-node/src/neon_node.rs:1472] [main] Tip #0 1b2ef7d48334989af51335211c218a5164f57ba5/7a08061efeb9516be3835e8478e15872d247be9fb2c42e690ba0af43fc494073 at 847849:153917 has score 2 (1 (non-ancestor) + 1 (non-ancestor) + 0 (earlier sibs) + 0 (earlier sibs) + 0 (earlier sibs))
INFO [1718387084.823901] [testnet/stacks-node/src/neon_node.rs:1472] [main] Tip #1 ea37553db307bca3a2dc0413dd7eb943f4fbfecc/3a852c6ea871ea45528e9cd4800349e8685a46d9470e2c53b45b30fe15c18234 at 847851:153917 has score 3 (1 (non-ancestor) + 1 (uncles) + 1 (non-ancestor) + 0 (earlier sibs) + 0 (earlier sibs) + 0 (earlier sibs))
INFO [1718387084.823918] [testnet/stacks-node/src/neon_node.rs:1472] [main] Tip #2 6a7f03e8da186957d979b0d3ec7330478f8ab600/36a21c1b248d205136378fc1409aa7d7727b61571bc3bea5c63da65c97e25817 at 847852:153917 has score 5 (2 (uncles) + 1 (non-ancestor) + 1 (uncles) + 1 (non-ancestor) + 0 (earlier sibs) + 0 (earlier sibs) + 0 (earlier sibs))
INFO [1718387084.823925] [testnet/stacks-node/src/neon_node.rs:1503] [main] Best tip is #0 1b2ef7d48334989af51335211c218a5164f57ba5/7a08061efeb9516be3835e8478e15872d247be9fb2c42e690ba0af43fc494073
Best tip is TipCandidate { stacks_height: 153917, consensus_hash: 1b2ef7d48334989af51335211c218a5164f57ba5, anchored_block_hash: 7a08061efeb9516be3835e8478e15872d247be9fb2c42e690ba0af43fc494073, parent_consensus_hash: ef78a4c1acf7a004d9ef170bee78245527cb5dcb, parent_anchored_block_hash: 678d064fbb1c9abc1a69c333ce2977535ef69791d846ed88917acefcf930dde7, burn_height: 847849, num_earlier_siblings: 0 }

@jcnelson jcnelson requested a review from a team as a code owner June 14, 2024 17:45
@jcnelson jcnelson requested review from kantai and obycode June 14, 2024 17:45
Copy link
Contributor

@obycode obycode 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

@smcclellan smcclellan left a comment

Choose a reason for hiding this comment

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

The 4 mutant failures on this PR are about under-tested functions:

  • 2 are for this is_on_canonical_burnchain_fork function returning true or false & not failing a test.
  • The other 2 are for load_candidate_tips returning empty/default & not failing a test.

The quickest workaround is to skip, but the best approach is to add the tests. I included as suggestions what is needed to skip the tests in case you prefer that route.

testnet/stacks-node/src/neon_node.rs Show resolved Hide resolved
testnet/stacks-node/src/neon_node.rs Show resolved Hide resolved
kantai added a commit that referenced this pull request Jun 18, 2024
…onical-2.5.0.0.4

Fix: never consider Stacks chain tips that are not on the canonical burn chain #4886
@jcnelson jcnelson enabled auto-merge June 20, 2024 15:42
@jcnelson jcnelson added this pull request to the merge queue Jun 21, 2024
Merged via the queue into develop with commit 04cc312 Jun 21, 2024
1 check passed
@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 Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants