Skip to content

STR-1331 Optimistic Fulfiller Duties Execution #137

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
merged 77 commits into from
May 12, 2025

Conversation

Rajil1213
Copy link
Collaborator

@Rajil1213 Rajil1213 commented May 8, 2025

Description

This PR adds the ability for operator nodes to fulfill withdrawal requests and to get reimbursed provided that they are not challenged.

In so doing, it also makes the following additional changes:

  • updates the strata dependency to use the updated checkpoint/chain-state structure.
  • updates the bitvm dependency to use the optimized graph generation.
  • updates most of the STFs to handle cases where a contract may receive txs belonging to other graphs tied to the same deposit.
  • updates the transaction APIs in the tx-graph crate to not require connectors when finalizing.
  • updates the dockerfile for bitcoind to automine blocks given a certain env variable.
  • handles an edge case where we proceed to the next step before all nonces are received for all graphs (previously, we only used to check the number of nonces per graph and not the number of graphs themselves).
  • updates the stake chain API to compute sighashes just-in-time with the supplied prevouts

TODO

  • rebase with main.
  • update the prover test files to fix failing tests.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/Enhancement (non-breaking change which adds functionality or enhances an existing one)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor
  • New or updated tests
  • Dependency Update

Notes to Reviewers

Good luck. 👀

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added (where necessary) tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.

Related Issues

Closes STR-1331

@Rajil1213
Copy link
Collaborator Author

I've rebased this with main and also updated the proof test-data. So this is actually ready for review now.

Copy link

codecov bot commented May 8, 2025

Codecov Report

Attention: Patch coverage is 21.64682% with 1513 lines in your changes missing coverage. Please review.

Project coverage is 51.87%. Comparing base (01a19e6) to head (e0e3c9f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/duty-tracker/src/executors/deposit.rs 0.00% 399 Missing ⚠️
crates/duty-tracker/src/contract_state_machine.rs 0.00% 387 Missing ⚠️
...uty-tracker/src/executors/optimistic_withdrawal.rs 0.00% 330 Missing ⚠️
crates/duty-tracker/src/contract_manager.rs 0.00% 143 Missing ⚠️
crates/duty-tracker/src/contract_persister.rs 0.00% 75 Missing ⚠️
crates/agent/src/operator.rs 0.00% 42 Missing ⚠️
...ates/duty-tracker/src/stake_chain_state_machine.rs 0.00% 30 Missing ⚠️
crates/stake-chain/src/transactions/stake.rs 86.69% 29 Missing ⚠️
crates/bridge-proof/protocol/src/tx_info.rs 44.73% 21 Missing ⚠️
crates/stake-chain/src/stake_chain.rs 88.15% 9 Missing ⚠️
... and 13 more
@@            Coverage Diff             @@
##             main     #137      +/-   ##
==========================================
- Coverage   53.43%   51.87%   -1.57%     
==========================================
  Files         145      147       +2     
  Lines       24153    24650     +497     
==========================================
- Hits        12905    12786     -119     
- Misses      11248    11864     +616     
Files with missing lines Coverage Δ
bin/dev-cli/src/constants.rs 0.00% <ø> (ø)
crates/agent/src/base.rs 0.00% <ø> (ø)
crates/agent/src/strata_rpc.rs 0.00% <ø> (ø)
crates/bridge-proof/test-utils/src/lib.rs 90.38% <100.00%> (ø)
crates/connectors/src/connector_a3.rs 93.27% <100.00%> (+0.10%) ⬆️
crates/connectors/src/connector_k.rs 100.00% <100.00%> (ø)
crates/db/src/persistent/sqlite.rs 94.84% <100.00%> (ø)
crates/duty-tracker/src/predicates.rs 64.40% <100.00%> (+0.45%) ⬆️
crates/secret-service-proto/src/v1/traits.rs 0.00% <ø> (ø)
crates/secret-service-proto/src/v1/wire.rs 45.45% <ø> (ø)
... and 29 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@ProofOfKeags ProofOfKeags left a comment

Choose a reason for hiding this comment

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

Beautifully organized PR. Content wise I have a lot to say, though. I'll leave the details to the individual comments. Any 🫡 emojis should be understood as explicit acks. This helps as we iterate on this PR to know what we've already looked at.

Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

minor nits and agree with Keagan's review

Comment on lines 336 to 339
/// # CAUTION
///
/// This should only be invoked for stake_index >= 1, i.e. from at least second stake
/// transaction.
Copy link
Member

Choose a reason for hiding this comment

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

What if we added an idx field to StakeTx and then did an assert! here (or even a debug_assert!)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could but I don't know if that is any better -- we'd have panics either way. The only difference will be when we invoke this function rather than when we broadcast the transaction, and both those things happen at about the same time.

Copy link
Member

Choose a reason for hiding this comment

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

Cc @ProofOfKeags who might have a good argument here with enforcing invariants instead of warning about them in docstrings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's the thing -- adding a runtime assertion does not enforce the invariant any more than the docstring.

The only way to really enforce it is to have separate types for the first and subsequent stake txs.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, agreed. Maybe add a TODO then or a ticket?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I'm cooking up something.

Copy link
Collaborator Author

@Rajil1213 Rajil1213 May 9, 2025

Choose a reason for hiding this comment

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

Okay check this out: f3ffd2a.

I've completely overhauled the stake tx API so that it distinguishes between the first one and the rest. It'll be easier to review in the following order:

  1. crates/stake-chain/src/transactions/stake_tx.rs
  2. crates/stake-chain/src/stake_chain.rs
  3. duty-tracker/src/contract_state_machine.rs
  4. duty-tracker/src/contract-manager.rs
  5. duty-tracker/src/executors/optimistic_withdrawal.rs

Copy link
Contributor

Choose a reason for hiding this comment

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

This commit is amazing.

storopoli
storopoli previously approved these changes May 9, 2025
Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK 6f45030

@Rajil1213 Rajil1213 force-pushed the feature/fulfiller-duties branch 3 times, most recently from 24cdf0a to 244ccdf Compare May 9, 2025 22:56
@Rajil1213 Rajil1213 force-pushed the feature/fulfiller-duties branch 2 times, most recently from 2f05f4d to 8e1deca Compare May 11, 2025 17:26
@Rajil1213 Rajil1213 force-pushed the feature/fulfiller-duties branch from 8e1deca to e0e3c9f Compare May 11, 2025 19:25
Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK e0e3c9f

Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK e0e3c9f

@Rajil1213 Rajil1213 added this pull request to the merge queue May 12, 2025
Merged via the queue into main with commit ca7379d May 12, 2025
13 checks passed
@Rajil1213 Rajil1213 deleted the feature/fulfiller-duties branch May 12, 2025 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants