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!(strata-cli): X-Only PK of recovery address instead of take back leaf hash #735

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

storopoli
Copy link
Member

Description

Deposit Request Transactions (DRT) now need X-Only PK of recovery address instead of take back leaf hash.
This fixes the strata-cli DRT metadata OP_RETURN construction.

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

The new OP_RETURN now is:

  1. magic bytes
  2. 32-byte X-only PK for the recovery P2TR address
  3. 20-byte EL address

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

STR-1176

@storopoli storopoli requested review from Rajil1213 and Zk2u March 13, 2025 17:15
@storopoli storopoli requested a review from a team as a code owner March 13, 2025 17:15
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

Attention: Patch coverage is 78.12500% with 7 lines in your changes missing coverage. Please review.

Project coverage is 54.91%. Comparing base (0e1171e) to head (cf5eb8c).

Files with missing lines Patch % Lines
bin/strata-cli/src/cmd/deposit.rs 78.12% 7 Missing ⚠️
@@            Coverage Diff             @@
##             main     #735      +/-   ##
==========================================
+ Coverage   54.80%   54.91%   +0.10%     
==========================================
  Files         322      322              
  Lines       36107    36125      +18     
==========================================
+ Hits        19788    19837      +49     
+ Misses      16319    16288      -31     
Files with missing lines Coverage Δ
crates/primitives/src/constants.rs 100.00% <ø> (ø)
crates/util/python-utils/src/constants.rs 100.00% <ø> (ø)
crates/util/python-utils/src/drt.rs 87.26% <ø> (ø)
bin/strata-cli/src/cmd/deposit.rs 28.57% <78.12%> (+28.57%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

github-actions bot commented Mar 13, 2025

Commit: 0cf2ea9

SP1 Execution Results

program cycles success
Bitcoin Blockspace 70,991
EVM EE STF 302,087
CL STF 166,600
Checkpoint 4,252

Copy link
Contributor

@Rajil1213 Rajil1213 left a comment

Choose a reason for hiding this comment

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

Would it be possible to squeeze in this change as well?
https://alpenlabs.atlassian.net/browse/STR-970

Instead of two scripts: N/N and take back, this would mean there is a single script and the taproot internal key will be N/N. I'm guessing this should be straightforward to implement but let me know if it isn't, in which case we can defer it to later. This will also require a tiny change on the strata-bridge since we no longer need the control block to spend the taproot and only need to tweak the internal key with the script.

@storopoli storopoli requested review from a team as code owners March 13, 2025 18:35
@storopoli storopoli requested a review from a team as a code owner March 13, 2025 18:48
@storopoli
Copy link
Member Author

Would it be possible to squeeze in this change as well? https://alpenlabs.atlassian.net/browse/STR-970

Instead of two scripts: N/N and take back, this would mean there is a single script and the taproot internal key will be N/N. I'm guessing this should be straightforward to implement but let me know if it isn't, in which case we can defer it to later. This will also require a tiny change on the strata-bridge since we no longer need the control block to spend the taproot and only need to tweak the internal key with the script.

Like this in 4a0d3f1 ?

@storopoli storopoli requested review from Rajil1213 and Zk2u March 13, 2025 18:50
@Rajil1213
Copy link
Contributor

Rajil1213 commented Mar 13, 2025

Like this in 4a0d3f1 ?

Yes, I think so. Is there a way to test it though? The output descriptor should be the same as if you constructed the taproot address manually via:

let take_back_script = construct_takeback_script(); // <pk>OP_CHECKSIGVERIFY<D>OP_CSV
let taproot_addr = create_taproot_addr(network::Regtest, SpendPath::Both { internal_key: bridge_key, scripts: &[take_back_script] }).unwrap();

@storopoli
Copy link
Member Author

Like this in 4a0d3f1 ?

Yes, I think so. Is there a way to test it though? The output descriptor should be the same as if you constructed the taproot address manually via:

let take_back_script = construct_takeback_script(); // <pk>OP_CHECKSIGVERIFY<D>OP_CSV
let taproot_addr = create_taproot_addr(network::Regtest, SpendPath::Both { internal_key: bridge_key, scripts: &[take_back_script] }).unwrap();

Vacuum sealed in cf5eb8c

Copy link
Contributor

@delbonis delbonis left a comment

Choose a reason for hiding this comment

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

Approving this tentatively, but the deposit subcommand is being removed in the other PR, so some of this could be removed.

Comment on lines +204 to +208
use crate::constants::BRIDGE_MUSIG2_PUBKEY;

#[test]
fn bridge_in_descriptor_script() {
let bridge_musig2_pubkey = BRIDGE_MUSIG2_PUBKEY.parse::<XOnlyPublicKey>().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hold on, what is this pubkey for?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the musig2 aggregated key. Arguably, we should construct this ourselves by reading off of the params (not for this PR though).

@Rajil1213
Copy link
Contributor

Approving this tentatively, but the deposit subcommand is being removed in the other PR, so some of this could be removed.

@delbonis how are we planning to do deposits for Testnet I if not via the strata-cli?

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.

4 participants