From 17ebf4be832b5f58c05a6e8bdd11b6dbb7d9b17d Mon Sep 17 00:00:00 2001 From: eigmax Date: Wed, 28 Jan 2026 14:54:43 +0000 Subject: [PATCH] chore: code style adjustment --- Cargo.lock | 38 +----- Cargo.toml | 4 +- .../bitcoin-light-client-circuit/src/lib.rs | 39 +++--- .../bitcoin-light-client-circuit/src/utils.rs | 114 +----------------- crates/commit-chain/Cargo.toml | 2 +- crates/commit-chain/src/commit_chain.rs | 26 +++- crates/commit-chain/src/publisher.rs | 99 ++++++++++++++- crates/state-chain/src/cbft.rs | 19 --- crates/state-chain/src/state_chain.rs | 3 - crates/store/Cargo.toml | 4 +- node/Cargo.toml | 6 +- node/src/bin/sequencer-set-publish.rs | 14 ++- proof-builder-rpc/Cargo.toml | 2 +- 13 files changed, 164 insertions(+), 206 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16730c74..74b0efa7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3177,7 +3177,6 @@ dependencies = [ "blake3", "borsh", "guest-executor", - "header-chain", "hex", "prost-build 0.13.5", "rand 0.8.5", @@ -5760,22 +5759,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper 1.8.1", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.19" @@ -5795,11 +5778,9 @@ dependencies = [ "percent-encoding", "pin-project-lite", "socket2 0.6.2", - "system-configuration 0.6.1", "tokio", "tower-service", "tracing", - "windows-registry", ] [[package]] @@ -9447,7 +9428,7 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.32", "hyper-rustls 0.24.2", - "hyper-tls 0.5.0", + "hyper-tls", "ipnet", "js-sys", "log", @@ -9487,22 +9468,17 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", - "encoding_rs", "futures-core", "futures-util", - "h2 0.4.13", "http 1.4.0", "http-body 1.0.1", "http-body-util", "hyper 1.8.1", "hyper-rustls 0.27.7", - "hyper-tls 0.6.0", "hyper-util", "js-sys", "log", - "mime", "mime_guess", - "native-tls", "percent-encoding", "pin-project-lite", "quinn", @@ -9513,7 +9489,6 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.2", "tokio", - "tokio-native-tls", "tokio-rustls 0.26.4", "tokio-util", "tower 0.5.3", @@ -13285,17 +13260,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" -dependencies = [ - "windows-link", - "windows-result 0.4.1", - "windows-strings", -] - [[package]] name = "windows-result" version = "0.1.2" diff --git a/Cargo.toml b/Cargo.toml index 0058578c..629e3ad2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ members = [ "crates/header-chain", "crates/commit-chain", "crates/state-chain", + #"crates/mara-slipstream-client", "crates/bitcoin-light-client-circuit", "circuits/header-chain-proof/host", "circuits/commit-chain-proof/host", @@ -70,7 +71,8 @@ secp256k1 = { version = "0.29.1", features = ["global-context"] } anyhow = "1.0.97" strum = { version = "0.26", features = ["derive"] } tempfile = "3.19.1" -reqwest = { version = "0.12.15", features = ["json"] } +reqwest = { version = "0.12.28", default-features = false, features = ["json"] } +http-body-util = "0.1" axum = "0.8.1" http = "1.3.1" diff --git a/crates/bitcoin-light-client-circuit/src/lib.rs b/crates/bitcoin-light-client-circuit/src/lib.rs index 9693310a..59b5f78a 100644 --- a/crates/bitcoin-light-client-circuit/src/lib.rs +++ b/crates/bitcoin-light-client-circuit/src/lib.rs @@ -516,7 +516,7 @@ pub fn verify_proof( #[cfg(test)] mod tests { use super::*; - use bitcoin::{Amount, Transaction}; + use bitcoin::Transaction; const PROOF: &[u8] = include_bytes!("../../../circuits/data/watchtower/output3.bin.proof.bin"); const PUBLIC_INPUTS: &[u8] = include_bytes!("../../../circuits/data/watchtower/output3.bin.public_inputs.bin"); @@ -561,22 +561,6 @@ mod tests { assert_eq!(words, recovered); } - #[test] - fn test_extract_op_return() { - // Example: construct a fake tx with OP_RETURN - let expected_op_data = [12, 3, 4, 45]; - let script = ScriptBuf::new_op_return(&expected_op_data); - let tx = Transaction { - version: bitcoin::transaction::Version::TWO, - lock_time: bitcoin::absolute::LockTime::ZERO, - input: vec![], - output: vec![bitcoin::TxOut { value: Amount::ZERO, script_pubkey: script }], - }; - - let op_return_data = commit_chain::extract_op_return_data(&tx.output); - assert_eq!(expected_op_data.to_vec(), op_return_data); - } - #[test] fn test_u256_to_le_bits() { use std::str::FromStr; @@ -595,4 +579,25 @@ mod tests { let reconstructed_str = reconstructed2.to_string(); assert_eq!(u_str, reconstructed_str); } + + #[test] + fn test_extract_data_from_commitment_outputs() { + use bitcoin::consensus::encode::deserialize; + // Testnet4 tx: 14b586e2e64e7b4b12aca96832d0703b9d218fa81e0ea84c1155a5749b28924b + let bytes = hex::decode( + "02000000000102c1eeed57e622af0fbb57e863a3b6284dc5ce6249804d0b6ce923bf81004188b00000000000fffffffff0679cdb8b16eebfbcd7fb4d582a20247857db4927f0f79388ba6735bdcd98f60b00000000ffffffff0c4a010000000000002200209bf28a9ccba44a0cbdd17ce6bb8262a136a08ac0088b0ec3f5ae484951f590dd4a01000000000000220020f65f87063cd8c00f539cb877d19a672b241066780a185357072e7da517286a1d4a0100000000000022002056dde473377f215234cf46258af2e2a5007a8e34206ecb438cef18906035c7384a01000000000000220020e77df8511565180c187f61ecdaf15fdc0bcd6076084a3a6823eb1e7fbb4e5af74a01000000000000220020ee98e7229e9a7ac2269cf2c493ff09f1c8b64f5116f5c3662be80640f8a11e144a01000000000000220020a2703885ba63f87d5bde5c3f085a7343e09eaef408074390d2081ff325cc6e894a0100000000000022002038e7a277db470a65c1075e58053075fe83944c621e43601f2b77e18e597c1cbe4a01000000000000220020ad89f2340414b9209003047abdf53716103ff6e71bd1f04c17055c33859124e84a010000000000002200207024bc980d3fa0d5715d859f2e036164414bbdcf0000000000000000000000004a01000000000000220020000000000000000000000938e7e6f31c23766897f6d40100307830306562643200000000000000003c6a3a353862363863396134373432343339653636393834306432306265626665346562643236393366636138323463386430623065346531366233368726980000000000220020082778653debae3a77067cc2c165ae2294c4c6984515aabe977dde1d8e39365103412853f869fd7d8a3e97fd095e6dce63be7e13b172f70e6c92b4ad968af671b3b1f72113b8d2a2a3749c02fc1241110081d8b8ba3686fc6e9b157530ba2fc41bef81222076c09522e2614dadf1471e456abf567b1756465a4133cedc7a0780b277f7e954ac41c076c09522e2614dadf1471e456abf567b1756465a4133cedc7a0780b277f7e954d391bf91c2d0eb83acda477b90f5efbfa4e4d1388e31690a6de57ff01c93f2e202473044022006feb2824f0d733e11c98ea52b0c2aaa1e6bc4c4223287959addbe2e33ebb71202203a1d4613db8eadf3e8d65e46b94e4027d3e6435a2abffd8aeefbc8bd4858f7a50123210376c09522e2614dadf1471e456abf567b1756465a4133cedc7a0780b277f7e954ac00000000" + ).unwrap(); + let tx: Transaction = deserialize(&bytes).unwrap(); + + let commitment = extract_data_from_commitment_outputs(&tx.output); + let ( + parsed_graph_id, + _proof, + _public_values, + _vk, + _watchtower_total_work, + _watchtower_consensus_block_height, + ) = parse_watchtower_commitment(&commitment).unwrap(); + assert_eq!(hex::encode(parsed_graph_id), "9bf28a9ccba44a0cbdd17ce6bb8262a1"); + } } diff --git a/crates/bitcoin-light-client-circuit/src/utils.rs b/crates/bitcoin-light-client-circuit/src/utils.rs index b3025b92..02ee439c 100644 --- a/crates/bitcoin-light-client-circuit/src/utils.rs +++ b/crates/bitcoin-light-client-circuit/src/utils.rs @@ -2,24 +2,7 @@ use bitcoin::absolute::LockTime; use bitcoin::blockdata::opcodes::all::*; use bitcoin::blockdata::script::Builder; use bitcoin::transaction::Version; -use bitcoin::{ - Address, Amount, CompressedPublicKey, Network, OutPoint, ScriptBuf, Sequence, Transaction, - TxIn, TxOut, Witness, -}; -use hex::FromHex; - -use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; - -pub fn decode_eth_address(addr: &str) -> Result<[u8; 20], hex::FromHexError> { - // Strip 0x if it exists - let addr = addr.strip_prefix("0x").unwrap_or(addr); - // Decode into Vec - let bytes = Vec::from_hex(addr)?; - - // Ensure it's 20 bytes - let arr: [u8; 20] = bytes.try_into().expect("Ethereum address must be 20 bytes"); - Ok(arr) -} +use bitcoin::{Address, Amount, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Witness}; /// Return script length L for a standard m-of-n multisig script with compressed pubkeys. pub fn multisig_script_len(n: u32) -> u32 { @@ -146,98 +129,3 @@ pub fn create_sequencer_update_partial_tx( }; Ok(tx) } - -pub fn create_dummy_publisher_keys(total: usize, network: Network) -> Vec<(SecretKey, PublicKey)> { - let secp = Secp256k1::new(); - - let mut keys = Vec::new(); - - for i in 0..total { - let sk = SecretKey::from_slice(&[i as u8 + 1; 32]).unwrap(); - let pk = PublicKey::from_secret_key(&secp, &sk); - keys.push((sk, pk)); - } - println!("Publisher private key:"); - keys.iter().for_each(|(sk, _)| { - let k = bitcoin::PrivateKey { compressed: true, network: network.into(), inner: *sk }; - println!("{:?}\n", k.to_wif()) - }); - println!("Publisher public key:"); - keys.iter().for_each(|(_, pk)| println!("{}\n", CompressedPublicKey(*pk))); - keys -} - -#[cfg(test)] -mod tests { - use super::*; - use bitcoin::{ - Address, EcdsaSighashType, Network, OutPoint, Sequence, TxIn, absolute::LockTime, - hashes::Hash, transaction::Version, - }; - use commit_chain::*; - - #[test] - fn test_verify_p2wsh_multisig_witness() { - // === Step 1: generate key pairs === - let keys = create_dummy_publisher_keys(3, bitcoin::Network::Regtest); - let pubkeys: Vec = keys.iter().map(|(_, pk)| *pk).collect(); - - let threshold = 2; - - // === Step 2: create redeem_script === - let redeem_script = create_sequencer_update_script(&pubkeys, threshold); - - // === Step 3: create prevout (P2WSH output) === - let script_pubkey = ScriptBuf::new_p2wsh(&redeem_script.wscript_hash()); - let prev_value = Amount::from_sat(100_000); - let prevout = TxOut { value: prev_value, script_pubkey }; - - // Fake OutPoint - let prev_outpoint = - OutPoint { txid: bitcoin::Txid::from_byte_array([0u8; 32].into()), vout: 0 }; - - // === Step 4: construct spending tx === - let mut tx = Transaction { - version: Version::TWO, - lock_time: LockTime::ZERO, - input: vec![TxIn { - previous_output: prev_outpoint, - script_sig: ScriptBuf::new(), - sequence: Sequence::MAX, - witness: Witness::default(), - }], - output: vec![TxOut { - value: Amount::from_sat(99_000), - script_pubkey: { - let btc_pk0 = bitcoin::PublicKey::from(pubkeys[0]); - Address::p2pkh(&btc_pk0, Network::Testnet).script_pubkey() - }, - }], - }; - - // === Step 5: sign by 2 private keys === - let (sig1, _) = - sign_partial(&mut tx, &keys[0].0, &redeem_script, prev_value, EcdsaSighashType::All) - .unwrap(); - - let (sig2, _) = - sign_partial(&mut tx, &keys[1].0, &redeem_script, prev_value, EcdsaSighashType::All) - .unwrap(); - - // === Step 6: finalize witness === - finalize(&mut tx, vec![sig1, sig2], &redeem_script).unwrap(); - - // === Step 7: verify === - let ok = verify_p2wsh_multisig_witness( - &tx, - 0, - &prevout, - &redeem_script, - &pubkeys, - threshold as usize, - ) - .unwrap(); - - assert!(ok, "2-of-3 multisig witness should verify"); - } -} diff --git a/crates/commit-chain/Cargo.toml b/crates/commit-chain/Cargo.toml index e7c6f7f8..a0afcbd6 100644 --- a/crates/commit-chain/Cargo.toml +++ b/crates/commit-chain/Cargo.toml @@ -10,7 +10,7 @@ bitcoin = { workspace = true, features = ["serde", "rand", "secp-recovery"] } bincode = "1.3.3" # workspace guest-executor = { workspace = true } -header-chain = { path = "../header-chain" } +#header-chain = { path = "../header-chain" } # Ziren zkm-verifier = { git = "https://github.com/ProjectZKM/Ziren", package = "zkm-verifier" } diff --git a/crates/commit-chain/src/commit_chain.rs b/crates/commit-chain/src/commit_chain.rs index fa388c61..eb246bde 100644 --- a/crates/commit-chain/src/commit_chain.rs +++ b/crates/commit-chain/src/commit_chain.rs @@ -134,7 +134,6 @@ impl CommitChainState { let mut commit_block_height: u32 = self.block_height; for commit in &commits { let latest_commit_txn_with_wtns = &commit.commit_txn; - println!("commit tx: {:?}", latest_commit_txn_with_wtns.compute_txid()); let latest_sequencers = &commit.sequencers; let publisher_public_keys = &commit.publisher_public_keys; let threshold = commit.threshold; @@ -142,14 +141,10 @@ impl CommitChainState { assert_eq!(commit.genesis_txid, self.genesis_txid); let prev_commit_txid = prev_commit_txn.compute_txid(); - println!("prev commit txid: {prev_commit_txid}, {prev_commit_txn:?}"); // calculate the commitment of prev sequencer set and check the equivalent if !prev_sequencers.is_empty() { let expected_prev_commit = extract_op_return_data(&prev_commit_txn.output); if let Hash::Sha256(prev_sequencer_set_hash) = sequencer_hash(prev_sequencers) { - println!( - "expected prev commit: {expected_prev_commit:?}, {prev_sequencer_set_hash:?}" - ); assert_eq!(prev_sequencer_set_hash[..], expected_prev_commit[0..32]); } else { panic!("Invalid prev sequencer set hash"); @@ -244,3 +239,24 @@ pub fn extract_op_return_data(tx_output: &[TxOut]) -> Vec { } results } + +#[cfg(test)] +mod tests { + use super::*; + use bitcoin::{Amount, ScriptBuf}; + #[test] + fn test_extract_op_return() { + // Example: construct a fake tx with OP_RETURN + let expected_op_data = [12, 3, 4, 45]; + let script = ScriptBuf::new_op_return(&expected_op_data); + let tx = Transaction { + version: bitcoin::transaction::Version::TWO, + lock_time: bitcoin::absolute::LockTime::ZERO, + input: vec![], + output: vec![bitcoin::TxOut { value: Amount::ZERO, script_pubkey: script }], + }; + + let op_return_data = extract_op_return_data(&tx.output); + assert_eq!(expected_op_data.to_vec(), op_return_data); + } +} diff --git a/crates/commit-chain/src/publisher.rs b/crates/commit-chain/src/publisher.rs index cb5c1e2b..d69239f5 100644 --- a/crates/commit-chain/src/publisher.rs +++ b/crates/commit-chain/src/publisher.rs @@ -1,8 +1,7 @@ use std::error::Error; -use bitcoin::blockdata::opcodes::all::*; -use bitcoin::blockdata::script::Builder; -use bitcoin::{Amount, ScriptBuf, Transaction, TxOut, Witness}; +use bitcoin::blockdata::{opcodes::all::*, script::Builder}; +use bitcoin::{Amount, CompressedPublicKey, Network, ScriptBuf, Transaction, TxOut, Witness}; use bitcoin::secp256k1::{ Message, PublicKey, Secp256k1, SecretKey, ecdsa::Signature as EcdsaSignature, @@ -169,3 +168,97 @@ pub fn verify_p2wsh_multisig_witness( Ok(matched >= threshold) } + +pub fn create_dummy_publisher_keys(total: usize, network: Network) -> Vec<(SecretKey, PublicKey)> { + let secp = Secp256k1::new(); + + let mut keys = Vec::new(); + + for i in 0..total { + let sk = SecretKey::from_slice(&[i as u8 + 1; 32]).unwrap(); + let pk = PublicKey::from_secret_key(&secp, &sk); + keys.push((sk, pk)); + } + println!("Publisher private key:"); + keys.iter().for_each(|(sk, _)| { + let k = bitcoin::PrivateKey { compressed: true, network: network.into(), inner: *sk }; + println!("{:?}\n", k.to_wif()) + }); + println!("Publisher public key:"); + keys.iter().for_each(|(_, pk)| println!("{}\n", CompressedPublicKey(*pk))); + keys +} + +#[cfg(test)] +mod tests { + use super::*; + use bitcoin::{ + Address, EcdsaSighashType, Network, OutPoint, Sequence, TxIn, absolute::LockTime, + hashes::Hash, transaction::Version, + }; + + #[test] + fn test_verify_p2wsh_multisig_witness() { + // === Step 1: generate key pairs === + let keys = create_dummy_publisher_keys(3, bitcoin::Network::Regtest); + let pubkeys: Vec = keys.iter().map(|(_, pk)| *pk).collect(); + + let threshold = 2; + + // === Step 2: create redeem_script === + let redeem_script = create_sequencer_update_script(&pubkeys, threshold); + + // === Step 3: create prevout (P2WSH output) === + let script_pubkey = ScriptBuf::new_p2wsh(&redeem_script.wscript_hash()); + let prev_value = Amount::from_sat(100_000); + let prevout = TxOut { value: prev_value, script_pubkey }; + + // Fake OutPoint + let prev_outpoint = + OutPoint { txid: bitcoin::Txid::from_byte_array([0u8; 32].into()), vout: 0 }; + + // === Step 4: construct spending tx === + let mut tx = Transaction { + version: Version::TWO, + lock_time: LockTime::ZERO, + input: vec![TxIn { + previous_output: prev_outpoint, + script_sig: ScriptBuf::new(), + sequence: Sequence::MAX, + witness: Witness::default(), + }], + output: vec![TxOut { + value: Amount::from_sat(99_000), + script_pubkey: { + let btc_pk0 = bitcoin::PublicKey::from(pubkeys[0]); + Address::p2pkh(&btc_pk0, Network::Testnet).script_pubkey() + }, + }], + }; + + // === Step 5: sign by 2 private keys === + let (sig1, _) = + sign_partial(&mut tx, &keys[0].0, &redeem_script, prev_value, EcdsaSighashType::All) + .unwrap(); + + let (sig2, _) = + sign_partial(&mut tx, &keys[1].0, &redeem_script, prev_value, EcdsaSighashType::All) + .unwrap(); + + // === Step 6: finalize witness === + finalize(&mut tx, vec![sig1, sig2], &redeem_script).unwrap(); + + // === Step 7: verify === + let ok = verify_p2wsh_multisig_witness( + &tx, + 0, + &prevout, + &redeem_script, + &pubkeys, + threshold as usize, + ) + .unwrap(); + + assert!(ok, "2-of-3 multisig witness should verify"); + } +} diff --git a/crates/state-chain/src/cbft.rs b/crates/state-chain/src/cbft.rs index e213e0f6..7f2291e8 100644 --- a/crates/state-chain/src/cbft.rs +++ b/crates/state-chain/src/cbft.rs @@ -70,32 +70,13 @@ pub fn verify_sequencer_commit(light_block: &LightBlock) { /// Verify pub fn verify_sequencer_set(light_block_1: LightBlock, light_block_2: LightBlock) { - // Normally we could just do this to read in the LightBlocks, but bincode doesn't work with - // LightBlock. This is likely a bug in tendermint-rs. - // let light_block_1 = zkm_zkvm::io::read::(); - // let light_block_2 = zkm_zkvm::io::read::(); - println!("LightBlock1 number of validators: {}", light_block_1.validators.validators().len()); println!("LightBlock2 number of validators: {}", light_block_2.validators.validators().len()); - // println!("cycle-tracker-start: header hash"); - // let header_hash_1 = light_block_1.signed_header.header.hash(); - // let header_hash_2 = light_block_2.signed_header.header.hash(); - // println!("cycle-tracker-end: header hash"); - - // println!("cycle-tracker-start: public input headers"); - // zkm_zkvm::io::commit_slice(header_hash_1.as_bytes()); - // zkm_zkvm::io::commit_slice(header_hash_2.as_bytes()); - // println!("cycle-tracker-end: public input headers"); - - println!("cycle-tracker-start: hash committee"); assert_eq!( light_block_1.next_validators.hash(), light_block_1.as_trusted_state().next_validators_hash ); - println!("cycle-tracker-end: hash committee"); - - println!("cycle-tracker-start: verify"); let vp = ProdVerifier::default(); let opt = Options { trust_threshold: Default::default(), diff --git a/crates/state-chain/src/state_chain.rs b/crates/state-chain/src/state_chain.rs index 6d0ae0b2..d5f84288 100644 --- a/crates/state-chain/src/state_chain.rs +++ b/crates/state-chain/src/state_chain.rs @@ -131,8 +131,5 @@ pub fn execute_el_block_and_check_withdraw_tx( }); let (header, _) = executor.execute(input, storage_info).expect("failed to execute client"); - //let block_hash = header.hash_slow(); - //println!("block_hash: {block_hash:?}"); header - // assert_eq!(block_hash, next_block_hash); } diff --git a/crates/store/Cargo.toml b/crates/store/Cargo.toml index 9b44dadc..40374484 100644 --- a/crates/store/Cargo.toml +++ b/crates/store/Cargo.toml @@ -16,10 +16,10 @@ tracing = { workspace = true } futures = { workspace = true } strum = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["full"] } -reqwest = { version = "0.12.15", features = ["multipart", "json", "stream"]} +reqwest = { workspace = true, features = ["multipart", "json", "stream"]} serde_json = { workspace = true } walkdir = "2" -tokio-util = "0.7.14" +tokio-util.workspace = true [dev-dependencies] tempfile = "3.19.1" \ No newline at end of file diff --git a/node/Cargo.toml b/node/Cargo.toml index d0003e2e..e7fdbc85 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -67,11 +67,11 @@ hex = { workspace = true } anyhow = { workspace = true } tempfile = { workspace = true } tokio = { workspace = true, features = ["full"] } -tokio-util = "0.7.15" +tokio-util.workspace = true -http-body-util = "0.1" +http-body-util.workspace = true axum = { workspace = true, features = ["macros", "json"] } -reqwest = { version = "0.12.15", features = ["json"] } +reqwest = { workspace = true, features = ["json"] } tower-http = { version = "0.6.2", features = ["cors", "trace"] } http = { workspace = true } stun-client = "0.1.4" diff --git a/node/src/bin/sequencer-set-publish.rs b/node/src/bin/sequencer-set-publish.rs index 4e082299..7a3941b6 100644 --- a/node/src/bin/sequencer-set-publish.rs +++ b/node/src/bin/sequencer-set-publish.rs @@ -24,6 +24,7 @@ use client::goat_chain::GOATClient; use client::goat_chain::GoatInitConfig; use client::goat_chain::SequencerSetUpdateWitness; use dotenv::dotenv; +use hex::FromHex; use tracing_subscriber::EnvFilter; use cbft_rpc::{fetch_cbft_validator_info, fetch_validators}; @@ -33,7 +34,7 @@ use bitcoin::secp256k1::{Message, Secp256k1}; use bitcoin::sighash::{EcdsaSighashType, SighashCache}; use bitcoin_light_client_circuit::{ /*create_dummy_publisher_keys,*/ create_fee_tx, create_sequencer_update_partial_tx, - decode_eth_address, estimate_tx_vbytes, + estimate_tx_vbytes, }; use commit_chain::{CommitInfo, create_sequencer_update_script, finalize, sign_raw}; use tendermint::validator::Info; @@ -50,6 +51,17 @@ pub fn decode_btc_public_keys(pubkey: &str) -> Result Result<[u8; 20], hex::FromHexError> { + // Strip 0x if it exists + let addr = addr.strip_prefix("0x").unwrap_or(addr); + // Decode into Vec + let bytes = Vec::from_hex(addr)?; + + // Ensure it's 20 bytes + let arr: [u8; 20] = bytes.try_into().expect("Ethereum address must be 20 bytes"); + Ok(arr) +} + #[derive(Parser, Debug)] #[command(name = "sequencer-set-publisher", version, about)] struct Args { diff --git a/proof-builder-rpc/Cargo.toml b/proof-builder-rpc/Cargo.toml index d967aaf5..bec395f7 100644 --- a/proof-builder-rpc/Cargo.toml +++ b/proof-builder-rpc/Cargo.toml @@ -19,7 +19,7 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } serde = { workspace = true, default-features = false, features = ["derive"] } axum = { workspace = true, features = ["macros", "json"] } -http-body-util = "0.1" +http-body-util.workspace = true prometheus-client = { workspace = true } uuid = { workspace = true } bitcoin = { workspace = true }