stacks-network / stacks-core

The Stacks blockchain implementation
https://docs.stacks.co
GNU General Public License v3.0
3.01k stars 671 forks source link

fix: disregard tx count if the stacks tip has changed #5158

Closed obycode closed 2 months ago

obycode commented 2 months ago

When mining, if the Stacks tip changes, then we no longer want to compare the transaction count of a newly mined block with that of the previously mined block, since the previous block is now a reorg.

Fixes #5157.

obycode commented 2 months ago

This still needs an integration test.

hstove commented 2 months ago

Plan for integration test:

obycode commented 2 months ago

Plan for integration test:

  • Two miners
  • Miner A finishes a tenure and miner B submits a block commit before seeing the last block of A's tenure
  • B's commit is committing to a block (of A's) that has something like 4 tx's
  • Then, B gets the new block from A and builds off of it
  • When B tries to make a block, it only has two tx's available, because 2 of them were in A's last block
  • Without this PR's change, the miner would get stuck. The test should verify that B can make the new block just fine

This sounds good, except in the last bullet, it's not that the miner would get stuck, but it would mine a sibling block, instead of building off of the latest tip, so we would not see the chain length increase and we would see two blocks at the same height.

blockstack-devops commented 3 weeks ago

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.