Skip to content

state machine updates for tx replay #6020

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

Merged

Conversation

hstove
Copy link
Contributor

@hstove hstove commented Apr 16, 2025

This PR implements:

  • Detecting forks in the signer state machine
  • Updating the tenure fork info API to include dropped blocks, which can be used to construct the tx replay set
  • Include a Vec<StacksTransaction> in state machine updates
    • For now, this vec is cleared as soon as a new Stacks block comes in (regardless of that block's contents). This allows us to monitor state machine updates

This builds on top of #6048 (which we should merge first)

@hstove
Copy link
Contributor Author

hstove commented Apr 23, 2025

Current state of this PR:

  • tx_replay_set, an Option<Vec<StacksTransaction>>, is added the SignerStateMachine
  • signer_state detects a bitcoin fork in bitcoin_block_arrival and fetches dropped blocks
  • The "fork info" API is updated to included dropped Nakamoto blocks
  • The signer updates their local signer state machine with the dropped tx's from this API
  • A new integration test triggers a Bitcoin fork and asserts that the state machine has the right tx replay set

@hstove hstove requested review from jferrant, kantai and obycode May 1, 2025 14:41
@hstove hstove marked this pull request as ready for review May 1, 2025 14:42
@hstove hstove requested a review from a team as a code owner May 1, 2025 14:42
@hstove hstove changed the title wip: state machine updates for tx replay state machine updates for tx replay May 1, 2025
Copy link
Contributor

@kantai kantai left a comment

Choose a reason for hiding this comment

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

This LGTM, just a few comments

@hstove hstove requested a review from a team as a code owner May 9, 2025 00:02
@hstove hstove requested review from obycode and kantai May 9, 2025 00:03
@hstove
Copy link
Contributor Author

hstove commented May 9, 2025

All comments addressed, plz re-review!

kantai
kantai previously approved these changes May 9, 2025
obycode
obycode previously approved these changes May 9, 2025
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!

@hstove hstove dismissed stale reviews from obycode and kantai via 745ce55 May 9, 2025 19:03
@hstove hstove requested review from obycode and kantai May 9, 2025 19:03
@hstove
Copy link
Contributor Author

hstove commented May 9, 2025

Fixed a conflict, re-requesting reviews 🙏

@wileyj wileyj self-requested a review May 9, 2025 20:09
@hstove hstove added this pull request to the merge queue May 12, 2025
Merged via the queue into stacks-network:develop with commit 0022c19 May 12, 2025
206 of 209 checks passed
@hstove hstove deleted the feat/fork-detection-state-machine branch May 12, 2025 13:25
Copy link

codecov bot commented May 12, 2025

Codecov Report

Attention: Patch coverage is 46.37437% with 318 lines in your changes missing coverage. Please review.

Project coverage is 83.33%. Comparing base (0ca28a0) to head (745ce55).
Report is 28 commits behind head on develop.

Files with missing lines Patch % Lines
testnet/stacks-node/src/tests/signer/v0.rs 0.00% 276 Missing ⚠️
stacks-signer/src/client/stacks_client.rs 0.00% 21 Missing ⚠️
stacks-signer/src/v0/signer_state.rs 93.54% 6 Missing ⚠️
stacks-signer/src/signerdb.rs 90.56% 5 Missing ⚠️
stackslib/src/net/api/mod.rs 86.20% 4 Missing ⚠️
stackslib/src/chainstate/stacks/transaction.rs 0.00% 3 Missing ⚠️
...tackslib/src/chainstate/nakamoto/staging_blocks.rs 92.30% 2 Missing ⚠️
stackslib/src/net/api/get_tenures_fork_info.rs 95.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6020      +/-   ##
===========================================
+ Coverage    73.43%   83.33%   +9.89%     
===========================================
  Files          538      538              
  Lines       388534   389065     +531     
  Branches       323      323              
===========================================
+ Hits        285306   324210   +38904     
+ Misses      103220    64847   -38373     
  Partials         8        8              
Files with missing lines Coverage Δ
libsigner/src/events.rs 89.21% <100.00%> (+3.19%) ⬆️
stacks-signer/src/tests/chainstate.rs 100.00% <100.00%> (+16.00%) ⬆️
stacks-signer/src/v0/signer.rs 85.09% <100.00%> (+1.10%) ⬆️
stackslib/src/chainstate/stacks/mod.rs 78.96% <ø> (+0.23%) ⬆️
testnet/stacks-node/src/tests/signer/mod.rs 87.09% <100.00%> (-4.23%) ⬇️
stackslib/src/net/api/get_tenures_fork_info.rs 74.75% <95.00%> (+0.90%) ⬆️
...tackslib/src/chainstate/nakamoto/staging_blocks.rs 90.74% <92.30%> (+0.08%) ⬆️
stackslib/src/chainstate/stacks/transaction.rs 97.21% <0.00%> (+19.69%) ⬆️
stackslib/src/net/api/mod.rs 89.69% <86.20%> (-0.75%) ⬇️
stacks-signer/src/signerdb.rs 94.07% <90.56%> (+10.84%) ⬆️
... and 3 more

... and 261 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ca28a0...745ce55. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Tx Replay: Signer detects forks and updates state machine with replay transactions
5 participants