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

Feat: sortition state tracking in signer #4801

Merged
merged 14 commits into from
Jun 5, 2024
Merged

Conversation

kantai
Copy link
Member

@kantai kantai commented May 16, 2024

Description

This PR adds a new module chainstate to the signer binary. This module contains a struct SortitionsView which tracks information about the most recent sortitions from the stacks-node. It obtains this information from a new RPC endpoint in the stacks-node. The struct caches this information (controlled via the fresh flag). To integrate it with the signer binary, on burnchain events, this flag should be flipped.

This sortitions view applies a bunch of "good behavior" checks on submitted NakamotoBlocks. It checks:

  1. If there is a tenure change, whether or not the new tenure confirms the expected number of blocks.
  2. If there is a tenure change, whether or not the new tenure's parent_tenure_id is a valid choice (it should not reorg another tenure, but if it does, it should be because the prior tenure was empty).
  3. If there is not a tenure change, whether or not the new block confirms the expected number of blocks in the ongoing tenure.

There are some TODOs left in the PR. These mostly will require additional state tracking in the signer binary:

  1. This isn't integrated into the signer binary yet. This integration should be very straight-forward: the check should be applied before submitting the block for validation, and the fresh flag should be flipped on burn events. This isn't done yet because I don't want to step on the other signer work at the moment.
  2. Checking if a non-empty forked tenure had a "poorly timed" first block. Reorging such a tenure should be allowed.
  3. Checking if a tenure extend should be expected for a late arriving bitcoin block.

On top of this, there's I think another TODO. This PR uses signed_off as the indicator of whether or not a block should be considered "must confirm". This is a local-only policy, which is great, but it's not the one this should eventually ship with. Instead, signers should track the threshold of signatures (gathering them just like the miner does). This will allow signers to broadcast the block if the miner fails to do so, but it will also allow signers to mark blocks as signed_off and threshold_reached. This should be follow-on work from this PR (will open an issue).

Note: the checks in this struct depend on the stacks-node's block validation endpoint to do a bunch of other checks. The reason that things like checking the parent_tenure_id as it does are sufficient is that the stacks-node itself enforces the match between the sortition's parent_tenure_id and the tenure change payload in the block.

@hstove hstove force-pushed the feat/header-signer-signatures branch from 0025174 to da6dad1 Compare May 16, 2024 20:49
@hstove hstove requested review from a team as code owners May 16, 2024 20:49
@saralab saralab requested a review from jcnelson May 20, 2024 14:37
@kantai
Copy link
Member Author

kantai commented May 20, 2024

Thanks for the comments @jferrant -- I will work through them and also rebase with the latest from the parent branch.

@kantai kantai dismissed stale reviews from jcnelson and jferrant June 4, 2024 20:21

The base branch was changed.

@kantai kantai requested review from jcnelson and jferrant June 4, 2024 20:22
@kantai kantai enabled auto-merge June 4, 2024 20:23
jcnelson
jcnelson previously approved these changes Jun 5, 2024
@kantai kantai requested a review from a team June 5, 2024 13:58
jferrant
jferrant previously approved these changes Jun 5, 2024
@kantai kantai dismissed stale reviews from jferrant and jcnelson via 5370a1c June 5, 2024 17:06
@kantai kantai requested review from jcnelson and jferrant June 5, 2024 17:06
@kantai
Copy link
Member Author

kantai commented Jun 5, 2024

Hopefully the last round of re-reviews, here!

@kantai kantai disabled auto-merge June 5, 2024 18:25
@kantai kantai enabled auto-merge June 5, 2024 18:25
@kantai kantai added this pull request to the merge queue Jun 5, 2024
Merged via the queue into develop with commit 3d96d53 Jun 5, 2024
1 check passed
@kantai kantai deleted the feat/signer-stacks-state branch June 5, 2024 21:39
@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 31, 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.

4 participants