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

Nakamoto Miner[3.0] - Finish signing in-progress block at the end of a tenure or reward cycle #4532

Closed
obycode opened this issue Mar 13, 2024 · 7 comments

Comments

@obycode
Copy link
Contributor

obycode commented Mar 13, 2024

Currently, when a new burn block arrives that kicks off a new reward cycle, both the miner and the signers will cancel the in-progress block. From the miner's perspective this looks like:

  • Miner mines block B
  • Miner proposes block B
  • Miner sees new burn block
  • Miner cancels B

From the signer's perspective this looks like:

  • Signer sees block B proposal and initiates block validation
  • Signer sees new burn block which activates cycle N
  • Signer for N-1 is killed
  • Block validation response is ignored by signer for cycle N

There are other timing variations of the above scenario (e.g. burn block arrives after signing is initiated, but before signing completes) . I believe with the Nakamoto design, we no longer need to have this race against the burn blocks. Instead, we should allow block B to complete, then the next miner should start its tenure building off of B.

At the end of a tenure which is not the end of a cycle, the miner will cancel block B, but the signer is not killed as it is in the above scenario, so they may complete the signing of the block. I'm not entirely sure exactly what happens in this case at the moment.

@obycode
Copy link
Contributor Author

obycode commented Mar 13, 2024

I saw this scenario happen in the nakamoto-1 testnet, and it caused a delay in block production:

  • 09:10:00.860 - miner assembled block 6028
  • 09:10:00.892 - miner proposed block 6028 to signers
  • 09:10:02.112 - miner sees new burn block 1236, cancels block assembly
  • 09:10:02.455 - miner' (next tenure) assembles block 6028'
  • 09:10:02.550 - miner' proposes block 6028' to signers
  • 09:10:03.186 - signers complete signing for block 6028
  • 09:10:03.365 - miner' receives signature for 6028, ignores it.

@saralab saralab added 2.5 3.0 and removed 2.5 labels Mar 15, 2024
@saralab saralab moved this from Status: 🆕 New to Status: 📋 Backlog in Stacks Core Eng Apr 24, 2024
@saralab saralab changed the title Finish signing in-progress block at the end of a tenure or reward cycle Nakamoto Miner[3.0] - Finish signing in-progress block at the end of a tenure or reward cycle Apr 30, 2024
@jferrant
Copy link
Collaborator

jferrant commented May 1, 2024

This will require changes on the signer's end to not abort signing blocks if their tenure is expired (i.e. a to be signed stacks block could arrive after the burn block that indicates a new reward cycle has started)

@saralab saralab moved this from Status: 📋 Backlog to Status: 💻 In Progress in Stacks Core Eng May 14, 2024
@obycode obycode moved this from Status: 💻 In Progress to Status: 📋 Backlog in Stacks Core Eng May 16, 2024
@saralab saralab moved this from Status: 📋 Backlog to Status: 💻 In Progress in Stacks Core Eng Jun 13, 2024
@obycode
Copy link
Contributor Author

obycode commented Jun 17, 2024

I think the simplest policy for this situation would be Option A:

From the miner's perspective:

  • If I see a burn block before proposing my block to the signers, don't bother sending it
  • If the signers approve a block I proposed before seeing the next burn block, broadcast it

From the signers' perspective:

  • If I receive a block proposal after seeing the new burn block, ignore it
  • If I am in the middle of signing a proposed block when I see the new burn block, finish signing it

An alternative, Option B, would be to allow the miner to finish building the block it is currently building when it sees the new burn block. This would require the signers to have some grace period where they allow one new block proposal after they have seen the new burn block.

From the miner's perspective:

  • If I see a burn block before proposing my block to the signers, immediately finish building the block and send it to the signers
  • Wait for the final block to be approved and then broadcast it (or upon rejection, just end)

From the signers' perspective:

  • Wait for one final block from the miner for X seconds after seeing the burn block
  • If a block arrives before the grace period ends, sign it
  • Do not sign blocks from the next miner until after the grace period has ended
  • If a block arrives after the grace period ends, ignore it

I have a strong preference for Option A since it is significantly simpler and also potentially helps to encourage the miner to send blocks at a regular pace (i.e. the amount of work thrown away at the end of the tenure is small, since smaller blocks have been regularly built and proposed throughout the tenure).

@kantai
Copy link
Member

kantai commented Jun 17, 2024

Yes -- I agree with Option A.

@obycode
Copy link
Contributor Author

obycode commented Jun 26, 2024

Ok, it seems like Option A is already what is happening on both the miner and signer sides. I don't think we need any changes for that basic case. I have an integration test to verify this in #4919.

@saralab saralab moved this from Status: 💻 In Progress to Status: In Review in Stacks Core Eng Jun 27, 2024
@obycode
Copy link
Contributor Author

obycode commented Jun 28, 2024

The case I was primarily concerned about is no longer an issue. I think we can close this issue, though it's possible other cases are found with further testing.

@obycode obycode closed this as completed Jun 28, 2024
@github-project-automation github-project-automation bot moved this from Status: In Review to Status: ✅ Done in Stacks Core Eng Jun 28, 2024
@blockstack-devops
Copy link
Contributor

This issue 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 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

6 participants