Skip to content

Commit f01e54d

Browse files
committed
FIX
1 parent 3ac52fe commit f01e54d

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

coprocessor/fhevm-engine/host-listener/src/cmd/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ impl InfiniteLogIter {
460460
logs: std::mem::take(&mut current_logs),
461461
summary,
462462
catchup: true,
463-
finalized: self.catchup_finalization_in_blocks > MINIMUM_DELAY_FOR_FINALIZATION_IN_BLOCKS,
463+
finalized: self.catchup_finalization_in_blocks
464+
> MINIMUM_DELAY_FOR_FINALIZATION_IN_BLOCKS,
464465
};
465466
blocks_logs.push(block_logs);
466467
}

coprocessor/fhevm-engine/host-listener/src/database/ingest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ pub async fn ingest_block_logs(
310310
info!(block_number, catchup_insertion, "Catchup inserted events");
311311
}
312312
}
313-
db.mark_block_as_valid(&mut tx, &block_logs.summary, block_logs.finalized).await?;
313+
db.mark_block_as_valid(&mut tx, &block_logs.summary, block_logs.finalized)
314+
.await?;
314315
if at_least_one_insertion {
315316
db.update_dependence_chain(
316317
&mut tx,

coprocessor/fhevm-engine/host-listener/tests/host_listener_integration_tests.rs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -945,14 +945,12 @@ async fn test_listener_restart_and_chain_reorg() -> Result<(), anyhow::Error> {
945945
test_listener_no_event_loss(true, true).await
946946
}
947947

948-
async fn check_finalization_status(
949-
setup: Setup
950-
) {
948+
async fn check_finalization_status(setup: Setup) {
951949
let provider = ProviderBuilder::new()
952-
.wallet(setup.wallets[0].clone())
953-
.connect_ws(WsConnect::new(setup.args.url.to_string()))
954-
.await
955-
.unwrap();
950+
.wallet(setup.wallets[0].clone())
951+
.connect_ws(WsConnect::new(setup.args.url.to_string()))
952+
.await
953+
.unwrap();
956954
// Verify block finalization status: for each block number, one should be finalized and others orphaned
957955
let blocks = sqlx::query!(
958956
"SELECT block_number, block_hash, block_status FROM host_chain_blocks_valid"
@@ -962,7 +960,10 @@ async fn check_finalization_status(
962960

963961
let blocks = blocks.expect("Failed to fetch blocks from database");
964962

965-
let mut blocks_by_number: std::collections::HashMap<i64, Vec<(Vec<u8>, String)>> = std::collections::HashMap::new();
963+
let mut blocks_by_number: std::collections::HashMap<
964+
i64,
965+
Vec<(Vec<u8>, String)>,
966+
> = std::collections::HashMap::new();
966967
for block in blocks {
967968
blocks_by_number
968969
.entry(block.block_number)
@@ -971,21 +972,37 @@ async fn check_finalization_status(
971972
}
972973

973974
for (block_number, block_variants) in blocks_by_number.iter() {
974-
let finalized_count = block_variants.iter().filter(|(_, status)| status == "finalized").count();
975-
let orphan_count = block_variants.iter().filter(|(_, status)| status == "orphaned").count();
975+
let finalized_count = block_variants
976+
.iter()
977+
.filter(|(_, status)| status == "finalized")
978+
.count();
979+
let orphan_count = block_variants
980+
.iter()
981+
.filter(|(_, status)| status == "orphaned")
982+
.count();
976983
assert_eq!(
977984
finalized_count, 1,
978985
"Block {} should have exactly one finalized variant, found {}",
979986
block_number, finalized_count
980987
);
981-
let finalized_hash = block_variants.iter().find(|(_, status)| status == "finalized").map(|(hash, _)| hash).unwrap();
988+
let finalized_hash = block_variants
989+
.iter()
990+
.find(|(_, status)| status == "finalized")
991+
.map(|(hash, _)| hash)
992+
.unwrap();
982993
assert_eq!(
983994
orphan_count,
984995
block_variants.len() - 1,
985996
"Block {} should have remaining variants as orphan",
986997
block_number
987998
);
988-
let expected_hash= provider.get_block_by_number((*block_number as u64).into()).await.unwrap().unwrap().header.hash;
999+
let expected_hash = provider
1000+
.get_block_by_number((*block_number as u64).into())
1001+
.await
1002+
.unwrap()
1003+
.unwrap()
1004+
.header
1005+
.hash;
9891006
assert_eq!(
9901007
&expected_hash.0,
9911008
finalized_hash.as_slice(),

coprocessor/fhevm-engine/transaction-sender/src/ops/delegate_user_decrypt.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ use crate::metrics::{
99
use crate::nonce_managed_provider::NonceManagedProvider;
1010
use crate::ops::common::{try_extract_non_retryable_config_error, CoprocessorConfigError};
1111

12+
use alloy::network::{Ethereum, TransactionBuilder};
1213
use alloy::primitives::Address;
1314
use alloy::providers::Provider;
1415
use alloy::rpc::types::TransactionRequest;
1516
use alloy::transports::{RpcError, TransportErrorKind};
16-
use alloy::{
17-
network::{Ethereum, TransactionBuilder},
18-
};
1917

2018
use anyhow::Result;
2119
use async_trait::async_trait;
@@ -310,7 +308,8 @@ impl<P: Provider<Ethereum> + Clone + 'static> DelegateUserDecryptOperation<P> {
310308
}
311309

312310
async fn get_block_status(&self, delegation: &DelegationRow) -> BlockStatus {
313-
let status = sqlx::query!(r#"
311+
let status = sqlx::query!(
312+
r#"
314313
SELECT block_status
315314
FROM host_chain_blocks_valid
316315
WHERE block_hash = $2 AND chain_id = $1

0 commit comments

Comments
 (0)