diff --git a/processor/src/coins/bitcoin.rs b/processor/src/coins/bitcoin.rs index 994346ca..52c5da4f 100644 --- a/processor/src/coins/bitcoin.rs +++ b/processor/src/coins/bitcoin.rs @@ -533,7 +533,7 @@ impl Coin for Bitcoin { Err(RpcError::ConnectionError) => Err(CoinError::ConnectionError)?, // TODO: Distinguish already in pool vs double spend (other signing attempt succeeded) vs // invalid transaction - Err(e) => panic!("failed to publish TX {:?}: {e}", tx.txid()), + Err(e) => panic!("failed to publish TX {}: {e}", tx.txid()), } Ok(()) } diff --git a/processor/src/coins/monero.rs b/processor/src/coins/monero.rs index ec030e13..85374437 100644 --- a/processor/src/coins/monero.rs +++ b/processor/src/coins/monero.rs @@ -517,7 +517,7 @@ impl Coin for Monero { Err(RpcError::ConnectionError) => Err(CoinError::ConnectionError)?, // TODO: Distinguish already in pool vs double spend (other signing attempt succeeded) vs // invalid transaction - Err(e) => panic!("failed to publish TX {:?}: {e}", tx.hash()), + Err(e) => panic!("failed to publish TX {}: {e}", hex::encode(tx.hash())), } } diff --git a/processor/src/scanner.rs b/processor/src/scanner.rs index b2f2b4fb..4082b8d9 100644 --- a/processor/src/scanner.rs +++ b/processor/src/scanner.rs @@ -73,8 +73,10 @@ impl ScannerDb { let key_bytes = key.to_bytes(); - // Don't add this key if it's already present let key_len = key_bytes.as_ref().len(); + assert_eq!(keys.len() % key_len, 0); + + // Don't add this key if it's already present let mut i = 0; while i < keys.len() { if keys[i .. (i + key_len)].as_ref() == key_bytes.as_ref() { @@ -330,7 +332,7 @@ impl Scanner { // CONFIRMATIONS - 1 as whatever's in the latest block already has 1 confirm Ok(latest) => latest.saturating_sub(C::CONFIRMATIONS.saturating_sub(1)), Err(_) => { - warn!("Couldn't get {}'s latest block number", C::ID); + warn!("couldn't get latest block number"); sleep(Duration::from_secs(60)).await; continue; } @@ -360,7 +362,7 @@ impl Scanner { let block = match scanner.coin.get_block(i).await { Ok(block) => block, Err(_) => { - warn!("Couldn't get {} block {i}", C::ID); + warn!("couldn't get block {i}"); break; } }; @@ -369,7 +371,7 @@ impl Scanner { if let Some(id) = scanner.db.block(i) { // TODO2: Also check this block builds off the previous block if id != block_id { - panic!("{} reorg'd from {id:?} to {:?}", C::ID, hex::encode(block_id)); + panic!("reorg'd from finalized {} to {}", hex::encode(id), hex::encode(block_id)); } } else { info!("Found new block: {}", hex::encode(&block_id)); @@ -400,7 +402,7 @@ impl Scanner { let outputs = match scanner.coin.get_outputs(&block, key).await { Ok(outputs) => outputs, Err(_) => { - warn!("Couldn't scan {} block {i:?}", C::ID); + warn!("Couldn't scan block {i}"); break; } }; diff --git a/processor/src/signer.rs b/processor/src/signer.rs index beac611e..1887d9ad 100644 --- a/processor/src/signer.rs +++ b/processor/src/signer.rs @@ -54,7 +54,19 @@ impl SignerDb { // Transactions can be completed by multiple signatures // Save every solution in order to be robust let mut existing = txn.get(Self::completed_key(id)).unwrap_or(vec![]); - // TODO: Don't do this if this TX is already present + + // Don't add this TX if it's already present + let tx_len = tx.as_ref().len(); + assert_eq!(existing.len() % tx_len, 0); + + let mut i = 0; + while i < existing.len() { + if existing[i .. (i + tx_len)].as_ref() == tx.as_ref() { + return; + } + i += tx_len; + } + existing.extend(tx.as_ref()); txn.put(Self::completed_key(id), existing); } diff --git a/processor/src/substrate_signer.rs b/processor/src/substrate_signer.rs index 5f59a9d3..a281ef17 100644 --- a/processor/src/substrate_signer.rs +++ b/processor/src/substrate_signer.rs @@ -135,7 +135,7 @@ impl SubstrateSigner { // If we don't have an attempt logged, it's because the coordinator is faulty OR // because we rebooted None => { - warn!("not attempting {:?}. this is an error if we didn't reboot", id); + warn!("not attempting {}. this is an error if we didn't reboot", hex::encode(id.id)); // Don't panic on the assumption we rebooted Err(())?; } @@ -171,7 +171,10 @@ impl SubstrateSigner { let machine = match self.preprocessing.remove(&id.id) { // Either rebooted or RPC error, or some invariant None => { - warn!("not preprocessing for {:?}. this is an error if we didn't reboot", id); + warn!( + "not preprocessing for {}. this is an error if we didn't reboot", + hex::encode(id.id) + ); return; } Some(machine) => machine, @@ -219,7 +222,10 @@ impl SubstrateSigner { panic!("never preprocessed yet signing?"); } - warn!("not preprocessing for {:?}. this is an error if we didn't reboot", id); + warn!( + "not preprocessing for {}. this is an error if we didn't reboot", + hex::encode(id.id) + ); return; } Some(machine) => machine, @@ -347,7 +353,7 @@ impl SubstrateSigner { if !id.signing_set(&signer.keys.params()).contains(&signer.keys.params().i()) { continue; } - info!("selected to sign {:?}", id); + info!("selected to sign {} #{}", hex::encode(id.id), id.attempt); // If we reboot mid-sign, the current design has us abort all signs and wait for latter // attempts/new signing protocols @@ -362,7 +368,11 @@ impl SubstrateSigner { // // Only run if this hasn't already been attempted if signer.db.has_attempt(&id) { - warn!("already attempted {:?}. this is an error if we didn't reboot", id); + warn!( + "already attempted {} #{}. this is an error if we didn't reboot", + hex::encode(id.id), + id.attempt + ); continue; }