Compare commits

...

4 Commits

Author SHA1 Message Date
Joel Liu
ede6385cfa
Merge 14edeca41b into a4dd88f2b8 2024-09-11 18:00:11 +08:00
peilun-conflux
a4dd88f2b8
Change submit receipt to info. (#195)
Some checks failed
abi-consistent-check / build-and-compare (push) Has been cancelled
code-coverage / unittest-cov (push) Has been cancelled
rust / check (push) Has been cancelled
rust / test (push) Has been cancelled
rust / lints (push) Has been cancelled
functional-test / test (push) Has been cancelled
2024-09-11 17:59:43 +08:00
peilun-conflux
3dc3d0574f
Fix typos. (#193) 2024-09-11 17:57:41 +08:00
Joel
14edeca41b use get_block to fetch latest block 2024-09-10 13:44:56 +08:00
3 changed files with 27 additions and 8 deletions

View File

@ -362,7 +362,13 @@ impl LogEntryFetcher {
block_hash_cache: &Arc<RwLock<BTreeMap<u64, Option<BlockHashAndSubmissionIndex>>>>,
log_page_size: u64,
) -> Result<Option<(u64, H256, Option<Option<u64>>)>> {
let latest_block_number = provider.get_block_number().await?.as_u64();
let latest_block_number = provider
.get_block(BlockNumber::Latest)
.await?
.ok_or(anyhow!("failed to get latest block"))?
.number
.ok_or(anyhow!("latest block number is none"))?
.as_u64();
debug!(
"from block number {}, latest block number {}, confirmation delay {}",
from_block_number, latest_block_number, confirmation_delay
@ -383,6 +389,9 @@ impl LogEntryFetcher {
block.number
);
}
if block.logs_bloom.is_none() {
bail!("block {:?} logs bloom is none", block.number);
}
if from_block_number > 0 && block.parent_hash != parent_block_hash {
// reorg happened
@ -412,13 +421,22 @@ impl LogEntryFetcher {
block.number
);
}
if Some(block.parent_hash) != parent_block_hash {
if parent_block_hash.is_none() || Some(block.parent_hash) != parent_block_hash {
bail!(
"parent block hash mismatch, expected {:?}, actual {}",
parent_block_hash,
block.parent_hash
);
}
if block_number == to_block_number && block.hash.is_none() {
bail!("block {:?} hash is none", block.number);
}
if block.logs_bloom.is_none() {
bail!("block {:?} logs bloom is none", block.number);
}
parent_block_hash = block.hash;
blocks.insert(block_number, block);
}
@ -470,7 +488,7 @@ impl LogEntryFetcher {
}
let tx = txs_hm[&log.transaction_index];
if log.transaction_hash != Some(tx.hash) {
if log.transaction_hash.is_none() || log.transaction_hash != Some(tx.hash) {
warn!(
"log tx hash mismatch, log transaction {:?}, block transaction {:?}",
log.transaction_hash,
@ -478,7 +496,9 @@ impl LogEntryFetcher {
);
return Ok(progress);
}
if log.transaction_index != tx.transaction_index {
if log.transaction_index.is_none()
|| log.transaction_index != tx.transaction_index
{
warn!(
"log tx index mismatch, log tx index {:?}, block transaction index {:?}",
log.transaction_index,

View File

@ -100,7 +100,7 @@ async fn request_miner_id(
.retries(3)
.await
.map_err(|e| format!("Fail to execute mine answer transaction: {:?}", e))?
.ok_or("Request miner id transaction dropped after 3 retires")?;
.ok_or("Request miner id transaction dropped after 3 retries")?;
let first_log = receipt
.logs

View File

@ -167,12 +167,11 @@ impl Submitter {
.await
.map_err(|e| format!("Fail to execute mine answer transaction: {:?}", e))?
.ok_or(format!(
"Mine answer transaction dropped after {} retires",
"Mine answer transaction dropped after {} retries",
SUBMISSION_RETIES
))?;
info!("Submit PoRA success");
debug!("Receipt: {:?}", receipt);
info!("Submit PoRA success, receipt: {:?}", receipt);
Ok(())
}