From a65486ed28121907acfc913678eaac8665143ac8 Mon Sep 17 00:00:00 2001 From: Nick Vincent Date: Wed, 27 Nov 2024 03:38:46 -0500 Subject: [PATCH] =?UTF-8?q?hotfix=20=F0=9F=9A=91:=20Temporary=20fix=20for?= =?UTF-8?q?=20#47?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ISSUE: #47 --- app/src/app.rs | 16 +++++++++++----- app/src/aura.rs | 10 ++++++---- crates/federation/src/lib.rs | 21 ++++++++++++++++----- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/app/src/app.rs b/app/src/app.rs index 704a49a..84f8826 100644 --- a/app/src/app.rs +++ b/app/src/app.rs @@ -176,7 +176,13 @@ impl App { .unwrap() .unwrap_or(chain_spec.bitcoin_start_height); + let og_threshold = ((3 * 2) + 2) / 3; let threshold = ((chain_spec.federation_bitcoin_pubkeys.len() * 2) + 2) / 3; // 2rds majority, rounded up + let og_bitcoin_federation = Federation::new( + chain_spec.federation_bitcoin_pubkeys[0..3].to_vec(), + og_threshold, + self.bitcoin_network, + ); let bitcoin_federation = Federation::new( chain_spec.federation_bitcoin_pubkeys.clone(), threshold, @@ -240,6 +246,7 @@ impl App { self.bitcoin_rpc_user.expect("RPC user is configured"), self.bitcoin_rpc_pass.expect("RPC password is configured"), ), + og_bitcoin_federation.taproot_address.clone(), bitcoin_federation.taproot_address.clone(), ), bitcoin_wallet, @@ -272,11 +279,10 @@ impl App { chain.clone().listen_for_peer_discovery().await; chain.clone().listen_for_rpc_requests().await; - chain - .clone() - .monitor_bitcoin_blocks(bitcoin_start_height) - .await; - + if chain_spec.is_validator { + chain.clone().monitor_bitcoin_blocks(bitcoin_start_height).await; + } + AuraSlotWorker::new( Duration::from_millis(slot_duration), authorities, diff --git a/app/src/aura.rs b/app/src/aura.rs index 559eae5..bb6bbc7 100644 --- a/app/src/aura.rs +++ b/app/src/aura.rs @@ -98,9 +98,10 @@ impl Aura { .then_some(()) .ok_or(AuraError::BadSignature)?; - if !block.is_signed_by(expected_authority_index) { - return Err(AuraError::InvalidAuthor); - } + // TODO: Replace with dynamic sourcing for authorities at a given timespan + // if !block.is_signed_by(expected_authority_index) { + // return Err(AuraError::InvalidAuthor); + // } Ok(()) } @@ -114,7 +115,8 @@ impl Aura { // + 2 makes this equal to `ceil((len*2) / 3.0)` let required_signatures = if self.authorities.len() > 3 { - ((self.authorities.len() * 2) + 2) / 3 + // ((self.authorities.len() * 2) + 2) / 3 + 1 } else { 1 }; diff --git a/crates/federation/src/lib.rs b/crates/federation/src/lib.rs index ee87333..7514c7f 100644 --- a/crates/federation/src/lib.rs +++ b/crates/federation/src/lib.rs @@ -80,6 +80,7 @@ pub struct PegInInfo { } pub struct Bridge { + og_pegin_address: BitcoinAddress, pegin_address: BitcoinAddress, bitcoin_core: BitcoinCore, } @@ -87,8 +88,9 @@ pub struct Bridge { impl Bridge { const BRIDGE_CONTRACT_ADDRESS: &'static str = "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"; - pub fn new(bitcoin_core: BitcoinCore, pegin_address: BitcoinAddress) -> Self { + pub fn new(bitcoin_core: BitcoinCore, og_pegin_address: BitcoinAddress, pegin_address: BitcoinAddress) -> Self { Self { + og_pegin_address, pegin_address, bitcoin_core, } @@ -135,8 +137,16 @@ impl Bridge { .rpc .get_raw_transaction(txid, Some(block_hash))?; - self.pegin_info(&tx, *block_hash, block_info.height as u32) - .ok_or(Error::NotAPegin) + let pegin_info = self.pegin_info(&tx, *block_hash, block_info.height as u32); + + match pegin_info { + None => { + Err(Error::NotAPegin) + } + Some(info) => { + Ok(info) + } + } } pub fn fetch_transaction(&self, txid: &Txid, block_hash: &BlockHash) -> Option { @@ -199,8 +209,9 @@ impl Bridge { .output .iter() .find(|output| { - self.pegin_address - .matches_script_pubkey(&output.script_pubkey) + self.og_pegin_address + .matches_script_pubkey(&output.script_pubkey) || self.pegin_address + .matches_script_pubkey(&output.script_pubkey) }) .map(|x| x.value)?;