mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-20 17:54:38 +00:00
Improve log statements in processor
This commit is contained in:
parent
7538c10159
commit
caa695511b
5 changed files with 37 additions and 13 deletions
|
@ -533,7 +533,7 @@ impl Coin for Bitcoin {
|
||||||
Err(RpcError::ConnectionError) => Err(CoinError::ConnectionError)?,
|
Err(RpcError::ConnectionError) => Err(CoinError::ConnectionError)?,
|
||||||
// TODO: Distinguish already in pool vs double spend (other signing attempt succeeded) vs
|
// TODO: Distinguish already in pool vs double spend (other signing attempt succeeded) vs
|
||||||
// invalid transaction
|
// invalid transaction
|
||||||
Err(e) => panic!("failed to publish TX {:?}: {e}", tx.txid()),
|
Err(e) => panic!("failed to publish TX {}: {e}", tx.txid()),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,7 +517,7 @@ impl Coin for Monero {
|
||||||
Err(RpcError::ConnectionError) => Err(CoinError::ConnectionError)?,
|
Err(RpcError::ConnectionError) => Err(CoinError::ConnectionError)?,
|
||||||
// TODO: Distinguish already in pool vs double spend (other signing attempt succeeded) vs
|
// TODO: Distinguish already in pool vs double spend (other signing attempt succeeded) vs
|
||||||
// invalid transaction
|
// invalid transaction
|
||||||
Err(e) => panic!("failed to publish TX {:?}: {e}", tx.hash()),
|
Err(e) => panic!("failed to publish TX {}: {e}", hex::encode(tx.hash())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,10 @@ impl<C: Coin, D: Db> ScannerDb<C, D> {
|
||||||
|
|
||||||
let key_bytes = key.to_bytes();
|
let key_bytes = key.to_bytes();
|
||||||
|
|
||||||
// Don't add this key if it's already present
|
|
||||||
let key_len = key_bytes.as_ref().len();
|
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;
|
let mut i = 0;
|
||||||
while i < keys.len() {
|
while i < keys.len() {
|
||||||
if keys[i .. (i + key_len)].as_ref() == key_bytes.as_ref() {
|
if keys[i .. (i + key_len)].as_ref() == key_bytes.as_ref() {
|
||||||
|
@ -330,7 +332,7 @@ impl<C: Coin, D: Db> Scanner<C, D> {
|
||||||
// CONFIRMATIONS - 1 as whatever's in the latest block already has 1 confirm
|
// CONFIRMATIONS - 1 as whatever's in the latest block already has 1 confirm
|
||||||
Ok(latest) => latest.saturating_sub(C::CONFIRMATIONS.saturating_sub(1)),
|
Ok(latest) => latest.saturating_sub(C::CONFIRMATIONS.saturating_sub(1)),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
warn!("Couldn't get {}'s latest block number", C::ID);
|
warn!("couldn't get latest block number");
|
||||||
sleep(Duration::from_secs(60)).await;
|
sleep(Duration::from_secs(60)).await;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +362,7 @@ impl<C: Coin, D: Db> Scanner<C, D> {
|
||||||
let block = match scanner.coin.get_block(i).await {
|
let block = match scanner.coin.get_block(i).await {
|
||||||
Ok(block) => block,
|
Ok(block) => block,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
warn!("Couldn't get {} block {i}", C::ID);
|
warn!("couldn't get block {i}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -369,7 +371,7 @@ impl<C: Coin, D: Db> Scanner<C, D> {
|
||||||
if let Some(id) = scanner.db.block(i) {
|
if let Some(id) = scanner.db.block(i) {
|
||||||
// TODO2: Also check this block builds off the previous block
|
// TODO2: Also check this block builds off the previous block
|
||||||
if id != block_id {
|
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 {
|
} else {
|
||||||
info!("Found new block: {}", hex::encode(&block_id));
|
info!("Found new block: {}", hex::encode(&block_id));
|
||||||
|
@ -400,7 +402,7 @@ impl<C: Coin, D: Db> Scanner<C, D> {
|
||||||
let outputs = match scanner.coin.get_outputs(&block, key).await {
|
let outputs = match scanner.coin.get_outputs(&block, key).await {
|
||||||
Ok(outputs) => outputs,
|
Ok(outputs) => outputs,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
warn!("Couldn't scan {} block {i:?}", C::ID);
|
warn!("Couldn't scan block {i}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,19 @@ impl<C: Coin, D: Db> SignerDb<C, D> {
|
||||||
// Transactions can be completed by multiple signatures
|
// Transactions can be completed by multiple signatures
|
||||||
// Save every solution in order to be robust
|
// Save every solution in order to be robust
|
||||||
let mut existing = txn.get(Self::completed_key(id)).unwrap_or(vec![]);
|
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());
|
existing.extend(tx.as_ref());
|
||||||
txn.put(Self::completed_key(id), existing);
|
txn.put(Self::completed_key(id), existing);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ impl<D: Db> SubstrateSigner<D> {
|
||||||
// If we don't have an attempt logged, it's because the coordinator is faulty OR
|
// If we don't have an attempt logged, it's because the coordinator is faulty OR
|
||||||
// because we rebooted
|
// because we rebooted
|
||||||
None => {
|
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
|
// Don't panic on the assumption we rebooted
|
||||||
Err(())?;
|
Err(())?;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,10 @@ impl<D: Db> SubstrateSigner<D> {
|
||||||
let machine = match self.preprocessing.remove(&id.id) {
|
let machine = match self.preprocessing.remove(&id.id) {
|
||||||
// Either rebooted or RPC error, or some invariant
|
// Either rebooted or RPC error, or some invariant
|
||||||
None => {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Some(machine) => machine,
|
Some(machine) => machine,
|
||||||
|
@ -219,7 +222,10 @@ impl<D: Db> SubstrateSigner<D> {
|
||||||
panic!("never preprocessed yet signing?");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
Some(machine) => machine,
|
Some(machine) => machine,
|
||||||
|
@ -347,7 +353,7 @@ impl<D: Db> SubstrateSigner<D> {
|
||||||
if !id.signing_set(&signer.keys.params()).contains(&signer.keys.params().i()) {
|
if !id.signing_set(&signer.keys.params()).contains(&signer.keys.params().i()) {
|
||||||
continue;
|
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
|
// If we reboot mid-sign, the current design has us abort all signs and wait for latter
|
||||||
// attempts/new signing protocols
|
// attempts/new signing protocols
|
||||||
|
@ -362,7 +368,11 @@ impl<D: Db> SubstrateSigner<D> {
|
||||||
//
|
//
|
||||||
// Only run if this hasn't already been attempted
|
// Only run if this hasn't already been attempted
|
||||||
if signer.db.has_attempt(&id) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue