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

Deposit sighash collection #381

Open
wants to merge 36 commits into
base: dev
Choose a base branch
from
Open

Deposit sighash collection #381

wants to merge 36 commits into from

Conversation

ceyhunsen
Copy link
Member

@ceyhunsen ceyhunsen commented Dec 17, 2024

Description

Adds sighash collection for deposit steps.

@ceyhunsen ceyhunsen changed the base branch from ceyhun/operator_winternitz to dev December 19, 2024 13:16
@ceyhunsen ceyhunsen changed the base branch from dev to ceyhun/operator_winternitz December 19, 2024 13:18
@ceyhunsen ceyhunsen changed the title Presign collection Deposit sighash collection Dec 20, 2024
Base automatically changed from ceyhun/operator_winternitz to dev December 22, 2024 18:32
@ekrembal ekrembal marked this pull request as ready for review January 2, 2025 08:40
@ekrembal ekrembal requested a review from atacann January 2, 2025 11:13
Replace arbitrary sleep delays with proper server readiness detection using
oneshot channels. This change:

- Removes unreliable fixed delays
- Adds proper server readiness detection
- Enables future shutdown handling capabilities
- Makes server startup more deterministic

The implementation now uses tokio::sync::oneshot channels to signal when
each gRPC server is bound and ready to accept connections.
let leaf_hash = TapLeafHash::from_script(
&tx_handler
.scripts
.get(txin_index)
Copy link
Member Author

@ceyhunsen ceyhunsen Jan 2, 2025

Choose a reason for hiding this comment

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

Do we need bound checks for this? Indexing with [idx] is dangerous if the array is smaller than the index but in this case, is there a possibility that this would happen? If not, we can revert this for simpler code and better performance.

PS: I added this.

@@ -357,7 +373,7 @@ mod tests {
let mut tx_handler = create_invalid_mock_tx_handler(actor);

let prev_tx: Transaction = Transaction {
version: Version::TWO,
version: Version(3),
Copy link
Member Author

Choose a reason for hiding this comment

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

Latest rust-bitcoin does not have support for this. That's why we did it like this.

use futures_core::stream::Stream;

pub fn create_nofn_sighash_stream(
_db: Database,
pub async fn dummy(
Copy link
Member Author

Choose a reason for hiding this comment

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

This function can be deleted: It's here because rust-analyzer won't give hints about code if it is in a macro (in this case try_stream).

@@ -149,6 +149,7 @@ async fn key_spend() {
&musig_agg_xonly_pubkey_wrapped,
)
.unwrap();
rpc.mine_blocks(1).await.unwrap();
Copy link
Member Author

@ceyhunsen ceyhunsen Jan 2, 2025

Choose a reason for hiding this comment

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

This and other unrelated mine_blocks() calls are added because current rust-bitcoin library version creates V2 transactions and Bitcoin Core will deny to use these UTXOs in V3 transactions, before getting them mined. These can be deleted after rust-bitcoin library supports V3 transactions.

OutPoint {
txid: wcp_txid,
vout: watchtower_idx as u32,
},
Copy link

Choose a reason for hiding this comment

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

I think first input should be vout 0 of watchtower challenge tx, instead of the watchtower challenge page tx


let mut operator_challenge_nack_txhandler =
builder::transaction::create_operator_challenge_nack_txhandler(
wcp_txid,
Copy link

Choose a reason for hiding this comment

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

Should be watchtower challenge txid, not page

// Check for missing indices
let indices: Vec<i32> = operators.iter().map(|(idx, _, _, _)| *idx).collect();
let expected_indices: Vec<i32> = (0..indices.len() as i32).collect();

Copy link

Choose a reason for hiding this comment

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

Is operator_idx consecutive starting from 0 or some random unique identifier for each operator?

let winternitz_pubkeys = winternitz_pubkeys
.into_iter()
.map(WinternitzPubkey::from_bitvm)
.collect::<Vec<_>>();
Copy link

Choose a reason for hiding this comment

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

duplicate

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 0f4b154.

@ceyhunsen
Copy link
Member Author

I suggest holding merge for this PR until we find the reason why grpc_flow test takes too much time. I think test is passing but it is very slow. On Github, it seems to be even more slower and Github marks this test failed because of this.

If this is not the case, there could be some race conditions.

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.

3 participants